M
Max
Guest
the following source has a strange behaviour
-----------8<-----------------
entity main is
Port ( clk : in std_logic;
cnt : inout std_logic_vector(2 downto 0);
o: out std_logic;
en : in std_logic);
end main;
architecture Behavioral of main is
begin
process (clk, en)
begin
if en = '0' then
cnt <= (others => '0');
o <= '0';
elsif rising_edge(clk) then
cnt <= cnt + 1;
if cnt = 1 then
o <= '1';
end if;
end if;
end process;
end Behavioral;
------8<---------------
I'm expecting that o goes high at first rising edge of clk, after en
goes high.
Instead this happens after another clock cycle.
Debugging this code I found that cnt is not updated immediatly, is it
right?
thanks
-----------8<-----------------
entity main is
Port ( clk : in std_logic;
cnt : inout std_logic_vector(2 downto 0);
o: out std_logic;
en : in std_logic);
end main;
architecture Behavioral of main is
begin
process (clk, en)
begin
if en = '0' then
cnt <= (others => '0');
o <= '0';
elsif rising_edge(clk) then
cnt <= cnt + 1;
if cnt = 1 then
o <= '1';
end if;
end if;
end process;
end Behavioral;
------8<---------------
I'm expecting that o goes high at first rising edge of clk, after en
goes high.
Instead this happens after another clock cycle.
Debugging this code I found that cnt is not updated immediatly, is it
right?
thanks