ustinoff
Member level 2
In the picture, the countdown begins from the second tick of the CLK signal. It's very predicteble result if your desing works on "rising_edge" front:
But i want to start counting with the first tick of CLK. I know what i need - low front of CLK (CLK = '0') before EN = '1'. Is there another way?
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; entity p_test is port( en : in std_logic; arst : in std_logic; clk : in std_logic; dout : out std_logic_vector (3 downto 0) ); end p_test; architecture arch of p_test is signal counter : unsigned (3 downto 0); begin process(en,clk) begin if arst = '1' then counter <= (others=>'0'); elsif (rising_edge(clk)) then if en = '1' then counter <= counter + 1; end if; end if; end process; dout <= std_logic_vector(counter); end arch;
But i want to start counting with the first tick of CLK. I know what i need - low front of CLK (CLK = '0') before EN = '1'. Is there another way?