-->
Hi friends,
This is the vhdl code for LED
blinking at 1 sec exactly.
I have a Papilio one which is
running at 32MHz.
So all I had to do is count 32million
(1111010000100100000000000 in binary) clock pulses to get one second.
Then I toggled the LED pin.
------------------------------------------------
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity main is
port
(
clk:in std_logic;
led1:out std_logic;
led2:out std_logic
);
end main;
architecture Behavioral of main
is
signal
counter: std_logic_vector(26 downto 0) := (others =>'0');
signal
bit1:std_logic :='0';
signal
bit2:std_logic :='0';
begin
timer_process:process(clk)
begin
if
rising_edge(clk)
then
if (counter(24 downto 0) =
"1111010000100100000000000") then --count upto 32M
led1 <=
bit1;
led2 <=
bit2;
counter <= (others =>'0') ;
bit1 <=
not bit1;
bit2 <=
not bit2;
else
counter <= counter+1;
end if;
end
if;
end
process;
end Behavioral;
------------------------------------------------
0 comments:
Post a Comment