Note that there are some explanatory texts on larger screens.

plurals
  1. POstate transition falling edge
    primarykey
    data
    text
    <p>I am revisiting VHDL after many years. I am trying to setup a basic state machine with a counter trigger at some overflow period. </p> <p>For some reason I am getting state transitions on the falling edge of the m_tick clock. There should only be a transition on the rising edge based on the m_tick &lt;= '1' in the state process? I must be overlooking something. </p> <p>I am testing in isim. I am sure I'm probably doing some not very smart. </p> <p>Thanks.</p> <pre><code>entity nes_ctl is generic( N: integer := 3; --17 bit overflow 131k ); port( clk : in std_logic; n_reset : in std_logic ); end nes_ctl; architecture Behavioral of nes_ctl is signal count_reg, count_next: unsigned(N-1 downto 0); --counter to produce tick signal m_tick: std_logic; --state variable type state_type is (s0,s1,s2,s3,s4,s5); signal state_reg, state_next: state_type; signal reset: std_logic; --inverted reset signal begin reset &lt;= not(n_reset); --invert the reset signal --syncronos logic process(clk) begin if(reset= '1') then count_reg &lt;= (others=&gt;'0'); state_reg &lt;= s0; elsif (clk'event and clk = '1') then count_reg &lt;= count_next; state_reg &lt;= state_next; end if; end process; count_next &lt;= count_reg +1; --increment counter, will overflow m_tick &lt;= '1' when count_reg = 0 else '0'; -- tick on every overflow --STATE MACHINE process(m_tick) begin if(m_tick &lt;= '1') then --only when m_tick goes high case state_reg is when s0 =&gt; state_next &lt;= s1; when s1 =&gt; state_next &lt;= s2; when s2 =&gt; state_next &lt;= s3; when s3 =&gt; state_next&lt;= s4; when s4 =&gt; state_next&lt;= s5; when s5 =&gt; state_next &lt;= s0; end case; else state_next &lt;= state_reg; --keep same state. no latches. end if; end process; end Behavioral; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload