A stopwatch is a good FPGA project that covers many basic, yet interesting areas of FPGA design. We will need display multiplexing for the multi-digit display, synchronous cascaded counter circuits to increment time registers for seconds and minutes, and a finite state machine to give us start, stop, and reset functionality.
I recently acquired a Basys 2 FPGA development board, which has an on-board 4 digit seven-segment display that lends itself nicely to keeping track of time in MM.SS format. Let’s build a stopwatch.
Last time we outlined how to divide down an FPGAs clock frequency using a basic counter circuit. This allowed us to have varying blinking frequencies for our LEDs depending on which bits of the counter register we tied them to.
What if we needed to adjust for a specific frequency of blinking, of wanted to adjust the time the LED is on vs off? What we are looking for is a programmable square wave generator. I will show you how we can program an FPGA in Verilog to act as one that takes two 4-bit inputs to control the on/off periods of the square wave.
Once we have went through the process of adjusting the on/off timing of a square wave, creating an adjustable PWM output for an LED comes naturally. We will see how to program an FPGA to output a PWM signal that allows us to adjust the brightness of an LED based on a 4 bit input signal.
FPGA Development boards usually run on a high frequency oscillator in the tens or hundreds of Megahertz range. One way to toggle an IO line at a slower frequency is to use a counter circuit. I will show you how to write some Verilog code that divides down a high clock frequency to a more human friendly time scale, and blink some LEDs!
The 8×8 LED matrix is a fun place to begin learning about how to control LEDs in a way that expresses something meaningful. You can create static images such as smiley faces, sprites, characters, and with some coding magic even create scrolling text and animations.
In this posting I will detail how to control 8×8 LED matrices with the MAX7219 Driver chip to create a cascaded scrolling text display. I will be using an AVR ATmega328P Microcontroller programed in C with the avr-gcc compiler.