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