Forum Discussion
Altera_Forum
Honored Contributor
9 years agoLED lights, SWITCHES and between :)
Hi all, I would like to greet and thank for beeing here and answering i'm kind of new to VHDL and trying to perfrom a project with my new DE2-115 and i hope that you guys can help me figure out...
Altera_Forum
Honored Contributor
9 years agoHi alex,
i really having har time to understand what i'm doing wrong and why it's not working as i want it... all i want is that GRID1 & GRID2 (LED's) will be turned on after 5 seconds from the moment LED1 is turned on. i am turning one of the switches on and than a LED light is on, and than, delay of 5 seconds i want that two other leds will be lighetned up. what am i missing?
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
USE IEEE.STD_LOGIC_ARITH.ALL;
entity mode_one IS --Simulating mode_one:free mode
generic (width5s : integer := 5); --Pulse width of 1 seconds
port( clk_in: IN STD_LOGIC; --50Mhz DE2 input.
reset : IN std_logic;
IF1: IN STD_LOGIC; --InfraRed 1
IF2: IN STD_LOGIC; --InfraRed 2
LED1:buffer STD_LOGIC; --LED1
GRID1:buffer STD_LOGIC; --GRID1
GRID2:buffer STD_LOGIC); --GRID1
END mode_one;
architecture behave OF mode_one IS
signal counter: integer range 25000000 downto 0; --1st process -divider- internal memories
signal clk_out: std_logic; --1st process -divider- internal memories
signal cnt: integer range 0 to width5s; --2nd process -oneshot- internal memories
BEGIN
LED1 <= IF1 AND IF2;
divider: process(clk_in) --process frequency divider
BEGIN
IF clk_in'EVENT AND clk_in = '1' THEN --Calculating untill counter =25M
if counter = 25000000 then --If counter reached 50mhz
clk_out <= NOT clk_out; --switching the output pulse. only when counter =25M
counter <= 0;
ELSE counter <= counter+1;
end if;
end if;
--counter <=0; --Reset counter
--cnt <= cnt+1;
-- ELSE counter <= counter+1;
-- end if;
-- end if;
end process;
oneshot: process (clk_out,cnt,reset) --Process actions with delay
BEGIN
if reset ='0' then
clk_out <= '0';
cnt <= 0;
else
--if clk_out'EVENT AND clk_out = '1' then
if led1 ='1' then
if counter = 0 then
if cnt < width5s then
clk_out <= '1';
cnt <= cnt+1;
GRiD1 <= led1;
GRID2 <= led1;
else
cnt <= 0;
clk_out <= '0';
--if counter <= 0 then --If X has been counted perform the following
--if cnt = 5 then
-- GRID1 <= LED1;
--GRID2 <= LED1;
end if;
end if;
end if;
end if;
end process oneshot;
end behave;
Cheers, Alex --- Quote End ---