You have no items in your shopping cart.

Subtotal:Rs.0.00
General

Lesson 2: Learn FPGA-Binary Counter using Spartan3an Stick Board

lesson-2-learn-fpga-binary-counter-using-spartan3an-stick-board

Lets quickly move on to lesson 2 with Binary Counter.  It’s always interesting to glow LED’s on any piece of hardware. What you can do with those LED’s? You can Blink them, you can Scroll from Left to Right and Right to Left, you can Count them , you can display any logic output which can be ‘0’ or ‘1’.

Spartan3an Stick Board got array of 8 LED’s to perform all the above mentioned operations. We are here to explore more on how to perform binary counter with those LED’s.

Now we are going to construct 8- bit Binary Counter. The 8-bit Synchronous Binary Counter counts sequentially on positive edge of every clock cycle.

binary counter in fpga

I write a VHDL Code for 8-Bit Binary Counter below.

library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_unsigned.all;

entity counter is

port(Clock, PRE : in  std_logic;

Q : out std_logic_vector(7 downto 0));

end counter;

architecture bhv of counter is

signal tmp: std_logic_vector(7 downto 0);

begin

process (Clock, PRE)

begin

if (PRE=’1′) then

tmp ‘0’);

elsif (Clock’event and Clock=’1′) then

tmp <= tmp + 1;

end if;

end process;

Q <= tmp;

end bhv;

 

 

From the above code, we will get counter running at 50MHz Speed which means it will count at the speed of 20 ns. You can’t visibly see the output of Counter with LED’s at 20 ns. Instead you can check them in simulation.

To make the count visible we are introducing 33 bit clock divider and assign the last 8 MSB bits to the output LED’s. Which gives the result of binary count at every 1s.

 

 

library ieee;

use ieee.std_logic_1164.all;

use ieee.std_logic_unsigned.all;

 

entity counter is

port(Clock, PRE : in  std_logic;

Q : out std_logic_vector(4 downto 0));

end counter;

 

architecture archi of counter is

signal tmp: std_logic_vector(32 downto 0);

begin

 

process (Clock, PRE)

begin

if (PRE='1') then

tmp ‘0’);

elsif (Clock’event and Clock=’1′) then

tmp <= tmp + 1;

end if;

end process;

Q <= tmp(32 downto 25);

end archi;

 

 

 

Pin Assignment for Spartan3an Stick Board.

 

NET “Q[7]” LOC = P69;

NET “Q[6]” LOC = P68;

NET “Q[5]” LOC = P67;

NET “Q[4]” LOC = P64;

NET “Q[3]” how to get cialis without a prescription LOC = P63;

NET “Q[2]” LOC = P62;

NET “Q[1]” LOC = P60;

NET “Q[0]” LOC = P59;

NET “Clock” LOC = P127;

NET “PRE” LOC = P33;

 

You can try more stuff with LED’s. Have fun !

https://www.pantechsolutions.net/cpld-fpga-boards/spartan3an-fpga-project-kit

Tags : Binary counter using FPGABinary Counter using Spartan3an Stick Board
jeevarajan

The author jeevarajan