ETL614 - Lab 2 System Verilog
ETL614 - Lab 2 System Verilog
ENGINEERING STUDIES
LAB 2
1
TABLE OF CONTENT
No Contents Page
1 Table of Content 1
2 Objectives 2
6 Appendix 8
1
A.OBJECTIVES:
i. To compile, program and test the clock divider module in part 1 on FPGA board.
ii. To compile, program and test the decoder to 7 segment modules in part 2 on
FPGAboard.
iii. To integrate the modules above as top module in part 3 and implement on FPGA
board.
2
B.EXPERIMENTS:
module clkdiv(
input logic clk_in,
input logic reset,
output logic clk
);
endmodule
Figure 1
1) Based on the SystemVerilog code in Figure 1, draw the block diagram for the clock divider module.
2) Create a Quartus project file as clkdiv.qpf in part 1 folder. Compile the clkdiv.sv file.
Capturethe RTL schematic
3) Assign the pin connections for the input clock, reset and LED as below. Refer the attachment
for pin location on the DE2 115 FPGA board. Recompile the design.
Table 1
CLK50 CLOCK,clk_in
SW0 RESET,reset
LEDR0/LEDG0 OUTPUT,clk
3
4) Program the design on the FPGA board.
5) Observe the output at LED. Capture the results on the board and discuss the results. Show
that the reset button can force the LED to be OFF.
6) Change the counter value count to 25'd50000000. Capture the results on the board and
discuss the results. Compare with the previous results.
4
PART 2: 7 Segment Decoder.
if (!reset)
begin
if (!I1&&(I2)&&(I3))
begin HEX0 <= 7'b1111001;end //DISPLAY 1
else if ( ) //ADD THE CORRECT CONDITION HERE
begin HEX0 <= 7'b ;end //ADD THE CORRECT OUTPUT PATTERN FOR HEX0.DISPLAY 2
else if ( ) //ADD THE CORRECT CONDITION HERE
begin HEX0 <= 7'b ;end //ADD THE CORRECT OUTPUT PATTERN FOR HEX0.DISPLAY 3
end
endmodule
Figure 2
1. The module in Figure 3 will convert the inputs from push button KEY1, KEY2 and KEY3 into its
numerical representation on the HEX0 7 segment display. Press and Hold the respective KEY
button and toggle SW0 up and down to generate clock. Show that the output HEX0 reset to
zero when SW1 (reset) HIGH. Test for several inputs and capture the results. Discuss the
results
2. Determine the type of module and SystemVerilog format of the code above.
3. Complete the decoder7seg.sv file in figure 2 and compile the design. Determine whether the
7-segment display is common anode or common cathode. Capture the RTL schematic
4. Create a project for the module in ModelSim. Write a testbench for the module. Simulate
the module and observed the output waveform. Discuss the results.
5. Assign the pin connections for the inputs and output HEX0 7-segment display as below. Refer
the attachment for pin locations on the DE2 115 FPGA board.
5
Table 2
Figure 3
6
PART 3: Top Module
1. Combine the clock divider and 7-segment decoder modules as below. Create a new module,
top in Quartus. Compile the design and capture the RTL schematic.
2. Create a project for the top module in ModelSim. Write a testbench for the top module.
Simulate the top module and observed the output waveform. Discuss the results.
3. Assign the pin connections and program the design on FPGA. Test the inputs for several
patterns. Capture the results on the boards and discuss the results of the new module top.
Compare the results with the ModelSim simulation.
decoder7seg
I1
I2
I3
reset
TOP
Figure 4
7
Appendix:
8
PIN ASSIGNMENTS:
.-0
"'""
l£ O A 2
,..,,.,
lfOR14
lfOR\5
"'
lEOA.18
"""" •••
G22
Signal Name FPGAPin No. Description VO Standard Figure 4-8 Connections between the slide switches and Cyclone IV E FPGA
LEDR(OJ PIN _G19 LED Red(OJ 2.5V
LEDR(1] PIN_F19 LED Red[1] 2.5V T•b l• 4-1 Pin Assignmrnts (orSUdtS"'ilth s
1
=i
1 SW(10] PIN_AC24 Slldo Swftch(10] Depending on JP7
LEDR(11] PIN H16 LED Red(11) 2. sv PIN_A8"24 SlideSWitch(11J Oopendlng on JP7
SW(11J
LEDR(12) PIN_J16 LED Red(12] 2.SV SWl12) PIN_AB23 $fideSWl tch(12] Depending on JP7
LEDR(13) PIN_H17 LED Red(13) 2. 5V SW(13) PIN_AA.24 Slid e SWitch(13) Oopendlng on JP7
SW(14) PIN. AA2) Slide Switch(14] Depending on JP7
LEDR(14) PIN_F15 LEDRed() 4) 2.5V SW(15] PIN_AA22 SlideSwitch(15] Oependlng on JP7
LEDR(15) PIN _G15 LEDRed[15] 2. 5V SW(16) PIN_Y2.4 $UdeSwitch(16) Depending on JP7
LEDR(16) PIN_ G16 LEDRed(16) -ii . SW(17] PIN_Y23 Slide SWftch(17 ] Depending on JP7