Lab 4: Implementation of combinational circuit and sequential circuit on FF > Students write the SystemVerilog code to perform the function's circuit as instructed from Prelab with the p
Trang 1VIET NAM NATIONAL UNIVERSITY HO CHI MINH CITY - UNIVERSITY OF TECHNOLOGY
FACULTY OF ELECTRICAL AND ELECTRONICS ENGINEERING
DEPARTMENT OF ELECTRONICS
0o00—
ạ c›
INTRODUCTION TO COMPUTING LABORATORY MANUAL
Trang 2gà Lab 4: Implementation of combinational circuit and sequential circuit on FF
<3
LAB 4: IMPLEMENTATION OF BASIC
COMBINATIONAL AND SEQUENTIAL
LOGIC CIRCUITS ON FPGA
Ho va tộn: Nguyộn Thai Binh Duong Lớp TN: TT05
MSSV: 2051103 Ngay: 15/11/2022
Work: 100%
A LAB MANUAL
OBJECTIVES
- Understand how to use FPGA kits, programming software
- Understand how to design a basic combinational and sequential logic circuits on FPGA
- Understand the process of describing hardware on FPGAs
Il PREPARATION:
- Toprepare well forthe test, students MUST read Appendix 1 first and complete the steps
of Sample lab in Appendix 2, and submit it with Prelab 4 before entering class
- Students must complete and submit Prelab 4 before entering class
- Students read the appendix and the Kit DE2 Manual to understand how to use the DE2 Kit, wiring, peripherals, and how to use Q uartus software to simulate and synthesize circuits Students refer to the documentation to understand how to write hardware designs in the SystemVerilog language
lII LAB INSTRUCTIONS
EXPERIMENT 1
Objective: Design the combinational circuit that calculates the absolute value of a 4-bit number (the input is A; the output is S)
đằ Students draw the logic gate diagram of the circuit to be designed
@ Electronics Department
72
Ho Chi Minh City University of Technology, Vietne
Trang 3Lab 4: Implementation of combinational circuit and sequential circuit on FF
> Students write the SystemVerilog code to perform the function's circuit as instructed
from Prelab with the pin assignment as follows:
o Pins A[3:0] assigned to SW [3:0]
o Pins S$ [8:0] assigned to LEDR [8:0]
Tee er 0|
@ Electronics Department
Ho Chi Minh City University of Technology, Vietne 73
Trang 4@
gà Lab 4: Implementation of combinational circuit and sequential circuit on FF
c›
> Students compile the above program Then, students simulate the output waveform in all cases of the input Capture the output waveform
(Insert a photo demonstrating that the student has simulated the circuit)
Electronics Department
Ho Chi Minh City University of Technology, Vietne 74
Trang 5gà Lab 4: Implementation of combinational circuit and sequential circuit on FF
c›
> Students view the results (To@l Netlist Viewer@ RTL Viewer) of the circuit
Decoder1
Als (3 0]
DECODER
DecoderO 15 0
DECODER
>» Students download the code to the DE2 Kit
(Insert a photo proving that the student has uploaded the Kit)
=
terre
me DET - 06
` _ mm
II đo | |
@ Electronics Department
Ho Chi Minh City University of Technology, Vietne 75
Trang 6Lab 4: Implementation of combinational circuit and sequential circuit on FF
EXPERIMENT 2
Objective: Design the combinational circuit that implements the ALU
The ALU calculates two 4-bit numbers (the two inputs are A and B respectively, the output is
S, the flags are Ci and Co) through the 2-bit input: Sel
- If Sel=00: S=A+B
- If Sel=01: S=A-B
- lf Sel=10: S=A AND B
- lf Sel=11: S=AOR B
Students write the SystemVerilog code to perform the function's circuit as instructed from Prelab with the pin assignment as follows:
©
©
øi@DESKTOP-BVE3LRI: ~ /lab04/ex02
Pins A [3:0] assigned to SW [3:0]
Pins B [3:0] assigned to SW [7:4]
Pins Ci assigned to SW [8]
Pins S [3:0] assigned to LEDR [3:0]
Pins Go assigned to LEDR [4]
Electronics Department
Ho Chi Minh City University of Technology, Vietne 76
Trang 7@
Lab 4: Implementation of combinational circuit and sequential circuit on FF
gà
> Students compile the above program Then, students simulate the output waveform in all cases of the input Capture the output waveform
(Insert a photo demonstrating that the student has simulated the circuit)
G Sirmstaton Yrave torn Echt - [end 2 se aooat.imas]
> Students view the results (Togl Netlist Viewer@ RTL Viewer) of the circuit
ex02:ex02_wrapper_dut
¬L_@œEDr‹(4 0)
Electronics Department
Ho Chi Minh City University of Technology, Vietne 77
Trang 8Lab 4: Implementation of combinational circuit and sequential circuit on FF
gà
Mux3
#‡ñ9 —IECc[!.r]
Electronics Department
Ho Chi Minh City University of Technology, Vietne 78
Trang 9Lab 4: Implementation of combinational circuit and sequential circuit on FF
c2
» Students download the code to the DE2 Kit
(Insert a photo proving that the student has uploaded the Kit)
@ Electronics Department
Ho Chi Minh City University of Technology, Vietne 79
Trang 10Lab 4: Implementation of combinational circuit and sequential circuit on FF
EXPERIMENT 3
Objective: Design a 3-bit down counter circuit
The count value changes every 1s The output is connected to a common anode 7-segment LED
In addition, the counter has an RST pin (active high) used to reset the counter state to 0 Hint:
- The clock signal is generated from the frequency divider from 50MHz to 1Hz
- Students use the 7-segment LED decoder module in PRELAB, connecting the output of the counter to the input of the module
ằ Students draw the logic gate diagram of the circuit to be designed
đằ Students write the SystemVerilog code to perform the function's circuit as instructed from Prelab with the pin assignment as follows:
o 7-segment LED ouput assigned to HEX [0]
o Pins RST assigned to SW [0]
> Students compile the above program Then, students simulate the output waveform in all cases of the input Capture the output waveform
(Insert a photo demonstrating that the student has simulated the circuit)
[ops s200re znnm oan 12s 16us 192us 2246 25203 209us 322.8 35203 38403 4dộu3 448u9 481s 512M S4gus 5766 683 64us 672L 7.0418 73905 7680u5 80,3
> Students view the results (To@l Netlist Viewer@ RTL Viewer) of the circuit
—E=>LEDR[0 0]
GS Electronics Department
Ho Chi Minh City University of Technology, Vietne 80
Trang 11Lab 4: Implementation of combinational circuit and sequential circuit on FF
Electronics Department
Ho Chi Minh City University of Technology, Vietne 81
Trang 12Lab 4: Implementation of combinational circuit and sequential circuit on FF
Electronics Department
Ho Chi Minh City University of Technology, Vietne 82
Trang 13Lab 4: Implementation of combinational circuit and sequential circuit on FF
» Students download the code to the DE2 Kit
(Insert a photo proving that the student has uploaded the Kit)
EXPERIMENT 4
Objective: Design a 4-bit up counter circuit from 5 to 14
The count value changes every 1s The output is connected to a common anode 7-segment LED
In addition, the counter has an RST pin (active high) used to reset the counter state to 0 Hint:
- The clock signal is generated from the frequency divider from 50MHz to 1Hz
- Students use the 7-segment LED decoder module in PRELAB, connecting the output
of the counter to the input of the module
Electronics Department
Ho Chi Minh City University of Technology, Vietne 83
Trang 14Lab 4: Implementation of combinational circuit and sequential circuit on FF
- Students need to write a 4-bit binary to BCD converter module
» Students draw the logic gate diagram of the circuit to be designed
» Students write the SystemVerilog code to perform the function's circuit as instructed from Prelab with the pin assignment as follows:
o Two7-segment LED outputs assigned to HEX [1], HEX [0]
o Pins RST assigned to SW [0]
Electronics Department
Ho Chi Minh City University of Technology, Vietne 84
Trang 15Lab 4: Implementation of combinational circuit and sequential circuit on FF
Electronics Department
Ho Chi Minh City University of Technology, Vietne 85
Trang 16Lab 4: Implementation of combinational circuit and sequential circuit on FF
Electronics Department
Ho Chi Minh City University of Technology, Vietne 86
Trang 17Lab 4: Implementation of combinational circuit and sequential circuit on FF
Electronics Department
Ho Chi Minh City University of Technology, Vietne 87
Trang 18Appendix 2: Sample la
> Students compile the above program Then, students simulate the output waveform in all cases of the input Capture the output waveform
(Insert a photo demonstrating that the student has simulated the circuit)
> Students view the results (To@l Netlist Viewer@ RTL Viewer) of the circuit
Electronics Department
Ho Chi Minh City University of Technology, Vietne 88
Trang 19Appendix 2: Sample la
>» Students download the code to the DE2 Kit
(Insert a photo proving that the student has uploaded the Kit)
Electronics Department
Ho Chi Minh City University of Technology, Vietne 89