Vhdl Program For 8 Bit Up Down Counter Circuit

Posted on -

A clock divider, covered in the previous tutorial, has been used to provide a slower clock to the binary counter. This slow clock makes it possible to see the binary value counting up on the LEDs. Binary Counter. The binary counter is contained in a VHDL process with the input clock divided by 8 (CLKDIV(2)) in its sensitivity list.

Created on: 9 January 2013

This tutorial shows how to create a binary counter in VHDL. The counter is really only a modification of the clock divider from the previous tutorial.

The value of the eight-bit counter is shown on eight LEDs on the CPLD board.

This video shows the binary counter in operation.

CPLD Board Configuration

It is necessary to have a clock pulse supplied to the CPLD for this tutorial. This is supplied to pin P7 of the CPLD from the AVR on the home built CPLD board as described in tutorial 6.

Binary Counter VHDL Code

The VHDL code listing for the binary counter is shown below.

Source Code

The VHDL source code with UCF and JED files can be downloaded here: VHDL-binary-counter.zip (6.2kB).

Libraries

Again, note that the STD_LOGIC_UNSIGNED module of the IEEE library is necessary and is included with the use statement at the top of the file.

Clock Divider

A clock divider, covered in the previous tutorial, has been used to provide a slower clock to the binary counter. This slow clock makes it possible to see the binary value counting up on the LEDs.

Binary Counter

The binary counter is contained in a VHDL process with the input clock divided by 8 (CLK_DIV(2)) in its sensitivity list. This supplies a clock of about 16.25Hz when using an input clock of about 130Hz (as supplied by the AVR).

Vhdl Program For 8 Bit Up Down Counter Circuit Diagram

The binary counter works exactly the same way as the clock divider, but consists of eight bits.

The COUNT register contains the binary counter value and is incremented on every rising clock edge of the clock divider. The value of the COUNT register is displayed on the LEDs with the code LED <= not COUNT; which inverts the count value to compensate for the inverting LED outputs on the home built CPLD board.

The binary counter could also have been implemented using an 11-bit register and then connecting the top 8 bits of the register to the LEDs. This would then run the counter at the same speed as the above counter with clock divider.

Amazon.co.uk

Vhdl Program For 8 Bit Up Down Counter Circuit

8 Bit Music Maker

Please enable JavaScript to view the comments powered by Disqus.

8 Bit Art

VHDL CPLD Course