I have a ring counter which has an enable and a count enable. It so happens that in my larger design, the count enable is synchronous with the clock (and by that I mean the circuit which controls it pulls back to 0 on the rising edge).
Observe:
The F0 and F1 outputs should change at the rising edge happening at t = 130 ns. However, the count_en input gets pulled down at the same time that the ring counter is reading it.
How do I get the correct behaviour from VHDL? Here is my code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity ring_counter_top is
Port ( CLK : in STD_LOGIC;
RING_EN : in STD_LOGIC;
COUNT_EN : in STD_LOGIC;
F0 : out STD_LOGIC;
F1 : OUT STD_LOGIC
);
end ring_counter_top;
architecture Behavioral of ring_counter_top is
signal shift_reg : STD_LOGIC_VECTOR(1 downto 0) := "01";
signal F0_temp : STD_LOGIC := '1';
signal F1_temp : STD_LOGIC := '0';
signal count_tmp : std_logic;
begin
count_tmp <= COUNT_EN;
-- ring counter
process (CLK, RING_EN, COUNT_EN)
begin
if (RISING_EDGE(CLK)) then
if (count_tmp = '1') then
shift_reg(1) <= shift_reg(0);
shift_reg(0) <= shift_reg(1);
F0_temp <= shift_reg(0);
F1_temp <= shift_reg(1);
end if;
end if;
end process;
F0 <= F0_temp and RING_EN;
F1 <= F1_temp and RING_EN;
end Behavioral;


shift_regand then updating their values. Try including theshift_regsignal in simulation and check its status? If theshift_regcontents are"01"and"10"always, you could just do a negation instead of shifting them. And instead of assigning theshift_regtoF0_tempinside the process, you can assign it to the outputs concurrently.