H
Hammer
Hi all
I'm new to VHDL and if someone can help me. I tried to design one
traffic light for cars and one for pedestrian.
I was using FPGA from my university and it has 50 MHz kvartz so I had to
count 50000000 low to high transitions to get one second
but I want that counter to start counting after the key is pressed and
that sec counts to 37! I tried to do it the way it writes down.
entity count1 is
Port ( clock : in STD_LOGIC;
key : in STD_LOGIC;
yellow : out STD_LOGIC :='0';
green : out STD_LOGIC :='1';
red : out STD_LOGIC :='0';
pred : out STD_LOGIC :='1';
pgreen : out STD_LOGIC :='0');
end count1;
architecture Behavioral of count1 is
signal sec : integer range 0 to 50 :=0;
signal nsec : integer range 0 to 50000000 :=1;
begin
process (clock,key)
begin
if rising_edge(key) then <---THIS IS WHAT I TRIED(DOESN'T WORK)
if rising_edge(clock) then
if nsec = 50000000 then
nsec <= 1;
sec <= sec+1;
else
nsec <= nsec + 1;
end if;
end if;
end if;
end process;
end Behavioral;
IF I REMOVE CODE *** if rising_edge(key) then *** COUNTER WILL COUNT AS
LONG AS THERE IS CLOCK!
Thanks in advance!
I'm new to VHDL and if someone can help me. I tried to design one
traffic light for cars and one for pedestrian.
I was using FPGA from my university and it has 50 MHz kvartz so I had to
count 50000000 low to high transitions to get one second
but I want that counter to start counting after the key is pressed and
that sec counts to 37! I tried to do it the way it writes down.
entity count1 is
Port ( clock : in STD_LOGIC;
key : in STD_LOGIC;
yellow : out STD_LOGIC :='0';
green : out STD_LOGIC :='1';
red : out STD_LOGIC :='0';
pred : out STD_LOGIC :='1';
pgreen : out STD_LOGIC :='0');
end count1;
architecture Behavioral of count1 is
signal sec : integer range 0 to 50 :=0;
signal nsec : integer range 0 to 50000000 :=1;
begin
process (clock,key)
begin
if rising_edge(key) then <---THIS IS WHAT I TRIED(DOESN'T WORK)
if rising_edge(clock) then
if nsec = 50000000 then
nsec <= 1;
sec <= sec+1;
else
nsec <= nsec + 1;
end if;
end if;
end if;
end process;
end Behavioral;
IF I REMOVE CODE *** if rising_edge(key) then *** COUNTER WILL COUNT AS
LONG AS THERE IS CLOCK!
Thanks in advance!