Milestone 2-Updated
Milestone 2-Updated
Milestone 2-Updated
Milestone 2 —
Design of a Single-Cycle Processor
Abstract
This document presents the second milestone in course EE3043. In case you
meet an error or have any improvement in this document, please email the TA:
[email protected] with the subject
“[COMPARCH203: FEEDBACK]”
1 Objectives
• Review understanding of SystemVerilog
2.1 Preliminary
The ALU in CPUs performs some sort of operation, depending on the ISA. Branch
Comparison, on the other hand, only compares two data. In this course, students will
use an RV32I ISA. However, first, there are some concepts to be reviewed.
1
Questions
Sign Extension
Logic Operation
Shift Operation
Comparison
• Given two 16-bit numbers, what operators could be used to know they’re
identical?
• Given two 16-bit numbers, how to determine which one is less than the
other?
Milestone 2 2
2.2 Requirements
2.2.1 ALU
Design an ALU to perform operations in an RV32I processor. The table below shows
its operations an RV32I ALU needs to be implemented.
1. Do NOT use -, >, < (SystemVerilog operations for subtraction and compari-
son)
3. Inputs:
4. Outputs
Design a Branch Comparison, which gathers two register values and compares.
1. Do NOT use -, >, < (SystemVerilog operations for subtraction and compari-
son)
3. Inputs:
Milestone 2 3
rs2_data the first operand — rs2 → B.
br_unsigned 1 if the two operands are unsigned.
4. Outputs
br_less 1 if A < B.
br_equal 1 if A = B.
3 Load-Store Unit
3.1 Regfile
In this lab, memory is understood as a storage to store instructions and store/load data.
As “packed array” gives designers a vector/scalar of bits, they could use packed arrays
to model a memory, yet “unpacked array” will also help designers in the simulation
phase. Unlike memory usually with one read port and one write port, the register file,
or RegFile, in RISC-V has a fixed number of registers, 32-bit data, and two read ports
and one write port. Another difference is that it has one constant register with the value
of 0.
Questions
• What are the differences between a packed array and an unpacked array?
3.1.1 Requirements
Design a register file according to the RISC-V specification: 32 32-bit registers, the
register 0 has the value of 0. Notice: the clock has to be named clk_i , and the low
active reset has to be named rst_ni . This convention has already been mentioned in
Milestone 1.
2. Inputs:
Milestone 2 4
rd_addr the address for rd.
rd_data the write data for rd.
rd_wren 1 if write to rd.
3. Outputs
5. In the memory and register file, the write data are available to read in the next
cycle, but the read data don’t need the clock.
Memory mapping is a technique to lay out the structure of memory. Different regions
in memory may serve different purposes. The figure below is the memory map of
MSP430.
Milestone 2 5
3.3 Requirements
Milestone 2 6
Notice: the clock has to be named clk_i , and the low active reset has to be named
rst_ni . This convention has already been mentioned in Milestone 1.
You will be given two memory models, which you will obtain in Section 4.
2. Inputs:
3. Outputs
4. There are some instructions that do NOT write or read 32-bit but less:
LB, LH, LBU, LHU, SB, SH. You may add signals to achieve desired opera-
tions. You must show your work in the report.
4 Single-Cycle Processor
To complete the processor, you must design Control Unit, Immediate Generator, and
then integrate the memory modules into your project. The standard processor in this
course is described in Figure 3.
Milestone 2 7
Figure 3: Standard Single-Cycle Processor
Milestone 2 8
4.1 Control Unit and Immediate Generator
Control Unit requires and produces the most number of signals in the processor. Hence,
you have two approaches:
• Using instr as the index to generate the data from ROM table.
2. Inputs:
3. Outputs
4. You may add signals for LB, LH, LBU, LHU, SB, SH.
Milestone 2 9
Figure 4: Modified Single-Cycle Processor
Milestone 2 10
4.3 Requirements
No matter what diagram you use to design your processor, your final design must satisfy
the naming below to ensure the testbench running properly.
2. Inputs:
3. Outputs
pc_debug_o PC.
io_lcd_o 32-bit data to drive LCD.
io_ledg_o 32-bit data to drive green LEDs.
io_ledr_o 32-bit data to drive red LEDs.
io_hex0..7_o 8 32-bit data to drive 7-segment LEDs.
4.4 Testbench
mem contains two memory models, you may read README.txt to grasp their specifi-
cation.
quartus contains DE2 pin assignment and a wrapper to implement your processor on DE2.
Please read README.txt to know how to set up Quartus.
src contains all your source code, so make sure all your code files are put into it.
tb contains test files. You must create “filelist” to list all files you use. Run make
to list all commands you can use. For example, I wanted to test my design, so I
typed make sim , and fortunately, it passed the test. This has to be included in the
report.
Milestone 2 11
1 ---------------------REPORT FILE---------------------
2
31 ---------------------END OF FILE---------------------
4.5 Conventions
In case you want to test for yourself, you could write your own assembly code, convert
it into binary code using this website. Below are the conventions for you to drive output
peripherals and read switches:
Milestone 2 12
Figure 5: Conventions
To drive LCD properly, you may visit this link to read the specification of LCD HD44780.
Milestone 2 13