E15A Laboratory 2

Combinational Logic in Verilog


Useful references for E15 labs

You might want to print out the Synthesizable Verilog Quick Reference (pdf
(originally at http://www.cl.cam.ac.uk/teaching/0910/ECAD+Arch/files/verilogcheatsheet.pdf)


In this lab you will be doing some basic programming in Verilog, and then implementing your design in hardware on an FPGA (Field Programmable Gate Array).

Quartus for Verilog tutorial

Go through the tutorial describing the writing, compiling, simulating and running of Verilog code using Quartus and the DE0 board.

Working with 7 segment displays.

A BCD to 7 segmant decoder takes in a 4 bit BCD (Binary Coded Decimal) number and lights the digits of a seven segment display to represent a number from 0 to 9..

Number (decimal) 0 1 2 3 4 5 6 7 8 9
Number (binary) 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001
Display

 

The DE0 has several seven segment digits, HEX0 is the rightmost one. It is controlled by 7 bits.

 
image adapted from Quartus documention.

So, for example, to display the number one, you want the LED's labelled b and c ( HEX0[1] and HEX0[2]) to be on, and all others off.

Create a BCD to seven segment decoder

Write a verilog module that performs this conversion. It has a 4 bit (binary coded decimal) input called "i":and a 7 bit (for seven segment display) output called "o". Use Quartus and create a project called "lab2" with a file called "bcd2seven.v." This follows closely the section labelled "The Basics" in the tutorial. Use the following as a template.

module bcd2seven(i, o);

    // Input Port(s)
    input [3:0]i;

    // Output Port(s)
    output [6:0]o;
    
    // you fill in logical expressions here.

endmodule

Note that the individual segments on the HEX0 display are lit when you apply a low signal, and are off when you apply a high signal. You need to account for this in your design somehow.

Simulation

Simulate the code to verify that it works as expected (i.e., generate a timing diagram).  Present these results neatly.  You don't need to show that each digit is represented correctly, but pick two or three numbers and show that the simulated result is as expected. Follow the section labelled "Simulation" in the tutorial. Note in the simulator you can select all the bits of the input (the "i" vector) and set the variable to count (click on icon), instead of setting i[3], i[2], i[1] and i[0] separately. Remember when you are only simulating that you can just do an "Analysis and Synthesis" and needn't do a full compilation (Go to Processing→Start→Analysis and Synthesis, or type ctrl-k)

Run on hardware with switches

Connect inputs of the bcd2seven module to the switches SW[3:0], and the outputs to HEX0[6:0].Call the top level entity file "bcdSwitch.v." Follow the section labelled "Running on Hardware" in the tutorial. You'll need "E15DE0.qsf". You will need to do a full compilation. Verify that it works as expected.

Run on hardware with counter

Connect a counter (0 to 9) to the inputs of the bcd2seven module and LEDR[3:0], and the display HEX0[6:0] to the outputs of your module. Call the top level entity file "bcdCount.v." Follow the section labelled "Using a counter" in the tutorial. You'll need "E15Counter1HzB.v". Verify that it works as expected.

Extra (not required)

Build a "cylon" display with 6 eyes. Demonstrate your circuit for me (or send me a video, along with the names of the people in your group).


To Turn in:

Each part of each task should be well labeled and in order. Each group should turn in one report as a single pdf on moodle.


Please contact me if you find any errors or other problems (e.g., something is unclearly stated) in this web page