Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting LEDs to blink in sequence

Status
Not open for further replies.

Flamefury

Programmer
Mar 10, 2010
1
CA
If I wanted to get LED lights blink one after another on an FPGA board, how would I go about doing this?

I first tried using a bunch of IF statements (if this light is on, turn it off and turn on the one next to it, if the next light is on, turn it off and turn on the light next to THAT one, etc.) but it's unsuccessful.

I also tried a case, but I attempted the same kind of logic and it also failed. Any advice?
 
Hello Flamefury,

I would just go for a shiftregister.
Lets say you have 8 LEDs then make a shiftregister of 8 bit.

signal LEDreg : std_logic_vector(7 downto 0) := (others => '0');

p_shiftreg : process (clk)
begin
if rising_edge(clk)then
Ledreg(0) <= input;
Ledreg(7 downto 1) <= Ledreg(6 downto 0);
end if;
end process p_shiftreg;

the input is a std_logic, it can be practically anything depending on how and what ou want to implement.
for example you could make a continuous binary counter and decode that input becomes one at one value. Then input will become 1 every X times and will shift trough the register.
for example:
signal count : std_logic_vector(7 downto 0) := (others => '0');

process(clk)
if rising_edge(clk)then
count <= count + '1';
end if;
end process;

input <= '1' when count = "00000000" else '0';

The LEDs you connect to every flip flop in the register.

e.g. LED(7 downto 0) <= Ledreg(7 downto 0);

Since you did not post your code it's hard to say ifit is correct or not. Pay attention that if you are using pure combinatorical logic this can go wrong because it will go so fast (determined by the FPGA fabric) that it will be invisible to you. Also make sure that the starting condition is guaranteed, aka th reset condition.

Wih the code above also note that if Clk is for example 10MHz, he LEDs will be continuosly on to the human eye.
You need to make sure that the clk frequency is 1HZ or lower to be able to see it clearly. Altough it is very logical, it is still often a common made mistake.

Regards,

jeandelfrigo

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top