I want a counter that the Most significant bit toggles every 2 seconds, and gets values 0 and 1.So for example it will have 0 for 2 seconds and after 1 for another 2 seconds etc.. I need it like that because I will connect the most significant bit to a decoder which will show results on FPGA 3starter (50MHZ/20ns) Does this will work?
library ieee ;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
----------------------------------------------------
entity counter is
generic(27: natural :=2);
port( clock: in std_logic;
rst: in std_logic;
count: in std_logic;
Q: out std_logic_vector(27-1 downto 0)
);
end counter;
----------------------------------------------------
architecture behv of counter is
signal Pre_Q: std_logic_vector(27-1 downto 0);
begin
-- behavior describe the counter
process(clock, count, clear)
begin
if clear = '1' then
Pre_Q <= Pre_Q - Pre_Q;
elsif (clock='1' and clock'event) then
if count = '1' then
Pre_Q <= Pre_Q + 1;
end if;
end if;
end process;
-- concurrent assignment statement
Q <= Pre_Q(27-1);
end behv;
max_count: natural := 100_000_000and in the othermax_count: natural := 400_000_000. However that alone doesn't seem enough difference to justify a new question. It might have been helpful to ask for a review of your VHDL, e.g. "Review VHDL for 2Hz counter", instead of ask a very similar question, and risking a 'close'. Just my $0.02 – gbulmer Aug 31 '14 at 17:53