LEGLite Description:
Instruction Formats
1
Instructions
2
Below is a circuit diagram for the single cycle LEGLite.
branchUncond
branchCond
aluSrcSel
Controller aluSel[2:0]
memRead
Instr[15:12]
memWrite
writeRegDataSel
writeRegIndexSel
regWrite
branchUncond
PC Update branchCond
Logic
Reset memRead memWrite
regWrite
regReadIndex1 aluSel[2:0]
Instr[2:0] Read regReadData1 ALUZero 128 memory
Read Read cells, 16-bits
PC Instr Reg1 Data1
Address regReadIndex2 aluResult per cell
Instr[5:3] aluSrcSel Address Cell
Read Read regReadData2
Instruction ALU addreses,
Reg2 Data2
Memory 0, 2, 4, 6, ...
Mux Mux aluInput2
(IM) For LD
regWriteData
Write Read
Instr[8:6] Write Data Mux
Data
Reg
For ADD, regWriteIndexSel memReadData
ADDI, etc Write
Data
writeRegDataSel
writeRegData
Instr[11:6]
SignExt
Instr[11:0]
PC-offsets
3
The computer must run the following testbench code, each having its own instruction memory (IM)
tb0.sv: The instruction memory for this testbench has the following short program that checks if arithmetic-R-type,
arithmetic-immediate, and unconditional branch instructions work
ADD X1,XZR,XZR
Loop: ADDI X1,X1,#1
B Loop
tb1.sv: The instruction memory for this testbench has the following program that repeatedly multiplies 2 x 5 and stores
the product in X2. This tests the instructions in the testbench 0 and the conditional branch.
tb2.sv: The instruction memory for this testbench has the following program that repeatedly multiplies 2 x 5 and stores
the product in Memory [4] and X0. This tests the memory access instructions ST and LD.
tb3.sv: The instruction memory for this testbench is modified from tb2.sv with the subroutine Funct. You should
change the datapath.
Loop1: BL Funct
Loop2: LD X0,[XZR,#4]
CBZ X0,Loop1
SUBI X0,X0,#1
ST X0,[XZR,#2]
LD X0,[XZR,#4]
ADDI X0,X0,#5
ST X0,[XZR,#4]
B Loop1
Funct: ADDI X0,XZR,#2
ST X0,[XZR,#2]
ST XZR,[XZR,#4]
BR X6
4
Tasks:
Grading:
Complete Points
tb1.sv 15
tb2.sv 24
tb3.xv 30
Submission Instructions:
1. Your leglite.sv
2. The last testbench file that works, i.e., one of tb1.sv, tb2.sv, or tb3.sv. Do not include multiple testbench files.
Do not modify the testbench file unless instructed to do so.
3. README file which includes
a. Your name
b. Description of what you have completed (and not completed). For example “I have completed
testbench 2 but not testbench 3”.
Upload the files individually. Do not compress them (e.g., zip) or put them in folders.
Hints:
The code is not tiny but it’s not large either. The final version of systemverilog code should be around 300 lines without
the spaces, etc. So it’s very manageable. Start early and get tb1.sv done within the first week. It’s actually easy. Take
a look at the entire code. It follows the block diagram above.
Note that if-else and case statements are used to implement multiplexers. Also, the PC is updated with if-else
statements. This is a behavioral method of implementing multiplexing.
Don’t forget that you can use $display when debugging. You can also modify the $monitor statement to display values
including signals within submodules.
I used edaplayground. I lost my code at some point because the website was sensitive with touchscreens and the
mouse.