lab work

profilegen_1
dsd_fall_2014_lab_5_1_1.docx

DSD F14

Lab 5

8 Bit UP/Dn Counter

In this lab you will design a Verilog Module for 7 segment display and then read in 4 bits in the slide switches SW0:SW3 and display it in the 7 segment displays. The 4 bits should display the digits 0-9 and A-F. The Displays should scroll the displayed digit across the eight 7 segment displays on the NEXYS-4 board using only 1 digit at a time, slowly moving across using the counted down slow clock. The configuration file will be provided and the shell for the .v file will be also. Write the rest of the code and then simulate it using a test bench. The shell for the TB will also be provided.

Example Code:

First we generate a slow clock to allow us to see the display move, much like we did using the counter. We use the clock input on the NEXYS-4 board which is running at 100MHz so we must divide it by about 100 x106.

// This code slows down the 100 Mhz clock to a 1 second period.

reg [31:0] counter_out;

reg Clk_Slow;

initial begin

counter_out<= 32'h00000000;

Clk_Slow <=0;

end

//this always block runs on the fast 100MHz clock

always @(posedge CLK) begin

counter_out<= counter_out + 32'h00000001;

if (counter_out > 32'h02F5E100) begin

counter_out<= 32'h00000000;

Clk_Slow <= !Clk_Slow;

end

end

Set up the 7 segment decoder using the following port list: The following code is for demonstration purposes only.

module Seven_Seg(

input [3:0] SW,

input CLK,

output reg [7:0] SSEG_CA,

output reg [7:0] SSEG_AN,

output [3:0] LED

);

// Note the segments areSSEG_CAthodes a,b,c,d,e,f,g,dp

// the SSEG_ANodes select which digit is selected

//SSEG_CA format {g, f, e, d, c, b, a}

DSD F14

Lab 5 UP Down Counter and Test Bench

Name_______________________ Lab Session M T W Date____________________

1. Explain why both the anode and the cathode need to be driven to a 0 to turn on a segment in a particular display?

2. What would you have to do to convert this code into a module that could display 8 different digits all at the same time using the 8 seven segment displays. Remember you do not have separate line connecting each display, but all the segments are connected to the line for “a” and all the “b” segments are connected together and so on for a, b ,c, d, e, f, and g. You do have a unique anode line for each of the 8 digits, but if you turn these all on at the same time then the same thing will be displayed in each digit. So, what technique must you use to display different information on each digit of the 8 digit display? Describe what you have to do.

3. How would you modify this code to only display the digits 0-9?

4. Paste in your code and test bench