R
Ramya Murali
Guest
I have a counter (positive edge triggered) whose enable (active high)
is generated by a two state FSM (positive edge state transition).
Counter_enable is set to '0' in State 1 and set to '1' in State 2.
signal count : std_logic_vector (3 downto 0) := "0000";
p1 : process (clk, counter_enable)
begin
if ((rising_edge (clk) and (counter_enable = '1')) then
count <= count +1;
end if;
end process p1;
p2 : process (current_state)
case current_state is
when '0' => next_state <= '1'; counter_enable <= '0';
when '1' => next_state <= '1'; counter_enable <= '1;
when OTHERS => next_state <= '0'; counter_enable <= '0';
end case;
end process;
While simulating using ModelSim, at the positive edge of the clock
( say edge1) when the state transitions from S1 to S2, the
counter_enable is set to '1' correctly. But the counter doesnot begin
to count at this positive edge (edge1) but begins to count at the next
positive edge of the clock (edge2).
My reasoning is as follows.
The assignment to counter_enable occurs at the end of process p2,
which is at delta time after edge1. At delta time, even though the
process p1 is activated as counter_enable is included in its
sensitivity list, the condition rising_edge(clk) is not true and the
count is not incremented.
Is this correct? Is the counter_enable asynchronous?
is generated by a two state FSM (positive edge state transition).
Counter_enable is set to '0' in State 1 and set to '1' in State 2.
signal count : std_logic_vector (3 downto 0) := "0000";
p1 : process (clk, counter_enable)
begin
if ((rising_edge (clk) and (counter_enable = '1')) then
count <= count +1;
end if;
end process p1;
p2 : process (current_state)
case current_state is
when '0' => next_state <= '1'; counter_enable <= '0';
when '1' => next_state <= '1'; counter_enable <= '1;
when OTHERS => next_state <= '0'; counter_enable <= '0';
end case;
end process;
While simulating using ModelSim, at the positive edge of the clock
( say edge1) when the state transitions from S1 to S2, the
counter_enable is set to '1' correctly. But the counter doesnot begin
to count at this positive edge (edge1) but begins to count at the next
positive edge of the clock (edge2).
My reasoning is as follows.
The assignment to counter_enable occurs at the end of process p2,
which is at delta time after edge1. At delta time, even though the
process p1 is activated as counter_enable is included in its
sensitivity list, the condition rising_edge(clk) is not true and the
count is not incremented.
Is this correct? Is the counter_enable asynchronous?