Professional Documents
Culture Documents
LAB 4
Introduction 2
Objectives 2
Notice 2
Feedback 2
Assembly 3
Single-Cycle Processor 4
Preliminary 4
Problem 5
Requirements 5
Hints 6
Modified Processor 7
Report 9
Appendix 10
1
Hai Cao Xuan EE3043 Computer Architecture 203B3 - DOE - HCMUT
1. Introduction
1.1. Objectives
a. Review your understanding of RV32I instructions by using RISC-V assembly to program.
b. Design a Control Unit to drive the Single-Cycle Processor.
c. Design a Single-Cycle RV32I Processor.
1.2. Notice
Your report has to be formatted in APA style, as an example in Appendix b. You should use Google Docs to
write and then export your report in PDF format. The title will be lab4_student’s ID_student’s name.pdf.
Include your group members' names in the report, each group submits only ONE report.
1.3. Feedback
In case you meet an error or a typo or have any improvement in this document, please email the author:
cxhai.sdh221@hcmut.edu.vn
2
Hai Cao Xuan EE3043 Computer Architecture 203B3 - DOE - HCMUT
2. Assembly
a. Convert this simple assembly code into hexadecimal.
b. Write a code to find the largest number of the Fibonacci sequence less than 32’d500. You will put the
ceiling number in register x10 and save the value you find in 0x400.
c. Write a code in which you read an 8-bit binary in the address 0x500, convert it into 3 decimal digits,
and then write them into 0x420, 0x410, and 0x400, respectively. For example, the value in 0x500 is
0xEE, which is 238, so “2” will be in 0x420, “3” in 0x410, and “8” in 0x400.
To verify the code, use a RISC-V simulator to check. Please visit this: https://venus.cs61c.org/
3
Hai Cao Xuan EE3043 Computer Architecture 203B3 - DOE - HCMUT
3. Single-Cycle Processor
3.1. Preliminary
The figure on the next page is the single-cycle processor, forming from almost all of the students’ designs in the previous labs.
4
Hai Cao Xuan EE3043 Computer Architecture 203B3 - DOE - HCMUT
3.2. Problem
Design a Single-Cycle Procesor.
In order to do that, you need to implement the rest of the diagram, which are muxes, PC, ImmGen,...
3.3. Requirements
a. The module name of Immediate Generator is immgen.sv. Its output is imm.
b. The register PC also has clk_i and rst_ni (positive clock and low negative reset).
i. Name: ctrl_unit.sv
1. bl_sel: the select signal to choose between PC+4 (0) or PC calculated by ALU (1).
4. op_a_sel: the select signal to choose between rs1_data (0) or pc (1) to wire into
operand_a of ALU.
5. op_b_sel: the select signal to choose between rs2_data (0) or imm (1) to wire into
operand_b of ALU.
8. wb_sel: the select signal to choose between alu_data (0), ld_data (1), or pc_four
(2) to write back into rd_data of RegFile.
5
Hai Cao Xuan EE3043 Computer Architecture 203B3 - DOE - HCMUT
h. To verify your processor, use the code you write in exercise b of section 2. Assembly.
3.4. Hints
There is no hint for today 🙂
6
Hai Cao Xuan EE3043 Computer Architecture 203B3 - DOE - HCMUT
4. Modified Processor
For those who find the previous diagram basic or want to modify the processor for your own interest, here is a modified processor.
If you want to implement this, I suggest that you should learn Labs 2, 3, and 4 thoroughly first, then try to analyze this design.
7
Hai Cao Xuan EE3043 Computer Architecture 203B3 - DOE - HCMUT
8
Hai Cao Xuan EE3043 Computer Architecture 203B3 - DOE - HCMUT
5. Report
Students must include those:
9
Hai Cao Xuan EE3043 Computer Architecture 203B3 - DOE - HCMUT
Appendix
a. Lab 0 SystemVerilog
b. Report Template
c. RISC-V Specification
https://github.com/riscv/riscv-isa-manual/releases/download/Ratified-IMAFDQC/riscv-spec-2019121
3.pdf
10