FPGA - LED Patterns
Lab #5 LED
Patterns
Due Date: 10/20/2020
For Lab #5, you will create a hardware component called LED_patterns that will create
light patterns using the LEDs on the DE10-Nano board. This component will run in the
FPGA fabric and you will create this component in VHDL. We will use this component
to control the LED patterns from software running on the ARM CPUs in a later lab, so
you can ignore the registers that are shown in the figure below for now. In the
upcoming lab you will instantiate the LED_patterns component in the
HPS_LED_patterns component where you will create the registers and control the LED
patterns from software. In this lab you will instantiate the component LED_patterns at
the top level in your Quartus project and the register related signals will be hardcoded
with appropriate values in the instantiation port map.
LED_patterns Entity
You will need to use the entity given below.
Entity Signals
Signal Description
clk System clock running at 50 MHz
reset System reset (typically tied to KEY 0)
PB Pushbutton signal that will be used to change state.
Tied to KEY 1.
SW The four switches that will be used to determine the next state.
HPS_LED_patterns Controls if the LED patterns are controlled from the hardware
state machine or from software via the LED_reg register. If set to
‘0’, which it will be for this lab, the hardware state machine
controls the LEDs. If set to ‘1’, The LED output signal is
connected directly to register signal LED_reg.
SYS_CLKs_sec Set to how many system clock periods are in one second.
Base_rate Set to control the base rate of LED transitions in seconds.
Note: This is an unsigned 8-bit fixed-point word with 4 fractional
bits. For example, if Base_rate = 1.0, then transitions occur
every 1 second.
LED_reg LED register signal for software control of LEDs
LED Output signal to drive the LEDs
Functional Description of LED_patterns
The overall function of the LED_patterns component is controlled by the
HPS_LED_control input signal. In pseudo code:
if (HPS_LED_control == 1) then
LED <= LED_reg (all 8 bits) // LEDs are controlled by software
else
LED <= controlled by hardware state machine.
LED Patterns State Machine
When in the hardware control mode (HPS_LED_control == 0), the following functionality
needs to be implemented:
1. LED7 always blinks at a 1 * Base_rate seconds regardless of what the state
machine is doing. This will allow you to verify that your base rate is set correctly.
2. The LED Patterns state machine has 5 states described in the table below. When
the state machine is in the noted state, you need to implement the following LED
patterns. Note that these run at different rates.
State Description
0 LEDs[6:0] show one lit LED shifting right at 1/2 * Base_rate seconds (circular
shifting) This is the default reset/powerup state.
1 LEDs[6:0] show two lit LEDs, side-by-side, shifting left at 1/4 * Base_rate
seconds (circular shifting)
2 LEDs[6:0] show the output of a 7-bit up counter running at 2 * Base_rate
seconds. (counter wraps)
3 LEDs[6:0] show the output of a 7-bit down counter running at 1/8 * Base_rate
seconds. (counter wraps)
4 User defined pattern. Implement your own pattern. It can’t be an up/down
counter or a right/left shifter or any pattern that you know of that any of your
classmates are implementing. Define your pattern and your pattern transition
rate, i.e. x * Base_rate seconds.
3. State Transitions. When the push button (PB) is pressed, the following sequence
needs to happen each time the push button is pressed:
3.1. The binary code of the switches is displayed on LEDs[6:0] for 1 second.
3.2. The next_state is determined by the binary code the switches represent. If the
switches specify a next_state of 5 or greater, the next_state is ignored and the
current state is kept (the switch code is display for 1 second though even if it is
5 or greater)
3.3. The next_state implements the functionality in the table above.
Conditioning the Pushbutton Signal
You need to create a component called PB_conditioner that does three things to the
input signal:
1. Synchronizes the signal (two D flip-flops)
2. Debounces the signal (ignore changes faster than 100 msec)
3. Creates a single pulse with a period of 1 system clock no matter how long the
pushbutton is pressed or how many times it bounces (small state machine).