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 how to : i want to use these ports:port( IF1: IN STD_LOGIC; --InfraRed 1
IF2: IN STD_LOGIC; --InfraRed 2
LED2: OUT STD_LOGIC); --LED 2
LED1: OUT STD_LOGIC); --LED 1
when i'm switching IF1 on, and then IF2 ON - LED1 will turn on. that was accomplish by - LED1 <= IF1 AND IF2;
my question is - how to make LED2 turned ON 1 sec after LED1 ? i know that is need to use the 50MHz clk_out of the DE2, but can't implement it.. i have this code so far:
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
USE IEEE.STD_LOGIC_ARITH.ALL;
--entity mode_one IS
--
--generic (width1s : integer := 1); --pulse width1s 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
-- LED2:OUT STD_LOGIC; --LED 2
-- LED1: OUT STD_LOGIC; --LED 1
-- switch_in: in std_logic); --test switch to delay 1 sec'
--
--END mode_one;
--
--architecture behave OF mode_one IS
----1st process -divider- internal memories
--signal counter: integer range 50000000 downto 0;
--signal clk_out: std_logic;
----2nd process -oneshot- internal memories
signal cnt: integer range 0 to width1s;
BEGIN
divider: process(clk_in)
BEGIN
LED1 <= IF1 AND IF2;
IF clk_in'EVENT AND clk_in = '1' THEN --calculating untill counter =25M
if counter = 50000000 then
clk_out <= NOT clk_out; --switching the output pulse. only when counter =25M
counter <= 0;
ELSE counter <= counter+1;
end if;
end if;
end process;
oneshot: process (cnt,clk_out,switch_in,reset)
BEGIN
if reset ='0' then
clk_out <= '0';
cnt <= 0;
else if switch_in = '1' then
if clk_out'EVENT and clk_out = '1' then
if cnt < width1s then
clk_out <= '1';
cnt <= cnt+1;
else
cnt <= 0;
clk_out <= '0';
end if;
end if;
end if;
end if;
end process;
end behave;