Lab 4: TinyRV1 Processor
Part E: Assembly Programming
Lab 4 will give you experience designing, implementing, testing, and prototyping a single-cycle processor microarchitecture. The processor will implement the TinyRV1 instruction set. The instruction set manual is located here:
The lab will continue to leverage concepts from Topic 2: Combinational Logic, Topic 3: Boolean Algebra, Topic 4: Combinational Building Blocks, Topic 6: Sequential Logic, Topic 7: Finite-State Machines, and Topic 8: Sequential Building Blocks. The lab will also leverage concepts from Topic 9: Instruction Set Architecture and Topic 10: Single-Cycle Processors The lab will continue to provide opportunities to leverage the three key abstraction principles: modularity, hierarchy, and regularity.
The lab includes six parts:
See canvas calendar or course schedule for all due dates.
-
Part A: Processor Components
- Submit via GitHub by 11:59 PM
- Students should work on Part A before, during, and after your assigned lab section during the week of the Part A simulation week of Lab 4
- Pre-lab survey on Canvas is (roughly) due by end of lab section during the Part A simulation week of Lab 4
-
Part B: TinyRV1 Processor
- Submit via GitHub by 11:59 PM
- Students should work on Part B before, during, and after your assigned lab section during the Part B simulation week of Lab 4
-
Part C: FPGA Prototype v1
- Due the 1st FPGA week of Lab 4 during assigned lab section
- This part will focus on prototyping the code developed in Part A+B
- Even though completed with a partner, every student must turn in their own paper check-off sheet in their lab section!
-
Part D: FPGA Prototype v2
- Due the 2nd FPGA week of Lab 4 during assigned lab section
- This part will focus on prototyping the code developed in Part A+B
- Even though completed with a partner, every student must turn in their own paper check-off sheet in their lab section!
-
Part E: TinyRV1 Assembly
- Submit via GitHub by 11:59 PM
- This part will include an accumulate assembly program, plus all of the assembly developed during Part C+D
-
Part F: Report
- Due on the last day of classes at 11:59pm for all groups!
- Post-lab survey on Canvas is due at the same time as the report
This handout assumes that you have read and understand the course tutorials and that you have attended the discussion sections. This handout assumes you have successfully completed Parts A, B, C, and D.
All parts of Lab 4 must be done with a partner. You can confirm your partner on Canvas (Click on People, then Groups, then search for your name to find your lab group).
You should have already cloned your group remote repository, so use git pull to ensure you have any recent updates before working on your lab assignment.
where XX should be replaced with your group number. Start by making
sure you are passing all of your hardware tests.
1. TinyRV1 Accumulate Assembly Program
We will start by implementing a simple accumulate assembly program. We
have provided you a template in lab4/asm/accumulate.asm. Take a look at
this template.
start:
# wait for button to be pressed
addi x1, x0, 1
wait_posedge:
lw x2, 0x208(x0)
bne x2, x1, wait_posedge
# wait for button to be unpressed
wait_negedge:
lw x2, 0x208(x0)
bne x2, x0, wait_negedge
# read and display size
lw x1, 0x200(x0)
sw x1, 0x210(x0)
# set breadboard pin high for timing
addi x3, x0, 1
sw x3, 0x21c(x0)
#''' LAB ASSIGNMENT ''''''''''''''''''''''''''''''''''''''''''''''''''''
# Write your accumulate loop
#'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
# Be sure to understand the code above and below so you know what
# register stores the size and what register stores the result.
# set breadboard pin low for timing
sw x0, 0x21c(x0)
# done
sw x4, 0x214(x0)
jal x0, start
.data
# result result seven
# size (dec) (hex) segment
# ----------------------------
.word 36 # 1 36 0x024 4
.word 26 # 2 62 0x03e 30
.word 69 # 3 131 0x083 3
.word 57 # 4 188 0x0bc 28
...
We have provided you assembly code to wait for a button to be pressed. Note that we cannot simply wait for in2 to be one because then we might end up triggering multiple accumulations. So we must first wait for the button to go from zero to one, and then wait for the button to go from one to zero. You can assume the behavior of your assembly program is undefined when size is zero.
The input data is specified usint the .data and .word assembler
directives. This means the input data will loaded in the data section of
physical memory, and recall from the TinyRV1 ISA that the data section
starts at address 0x100.
Once the button has been pressed then we read in0 and display the size on the seven-segment displays. We then write one to out3 before we start executing the accumulate loop and then write zero to out3 after we have finished executing the accumulate loop. Out3 will be connected to a pin on the breadboard; our plan is probe this pin on the breadboard with the oscilloscope so we can precisely measure the time to accumulate an array of numbers and then compare this to specialized hardware.
After the accumulate loop, we again set the breadboard pin to be low, before writing the result to out1 to be displayed on a seven-segment display. The very last step is to unconditionally jump back to the start of the program.
After implementing the accumulate loop, you can test it using the ISA simulator. You will need to use the TUI because you need to set in2 to one and then set it back to zero to start the accumulate loop. Try accumulating running the accumulate loop multiple times within the same execution with different size values to ensure your assembly program is working correctly.
% cd ${HOME}/ece2300/groupXX/build
% make proc-isa-sim
% make accumulate.bin
% ./proc-isa-sim +bin=accumulate.bin +tui
You can also test it using the RTL single-cycle processor simulator.
% cd ${HOME}/ece2300/groupXX/build
% make proc-scycle-sim
% make accumulate.bin
% ./proc-scycle-sim +bin=accumulate.bin +tui
2. TinyRV1 Assembly Programs
We now ask that you collect together the various assembly programs you
developed for this lab. These assembly programs should all be located
in the lab4/asm subdirectory and include the three calculator
assembly programs from Part C, the door monitor assembly programs from
Part D, and the accumulate assembly program you just wrote. More
specifically, here is a list of the assembly programs we expect you to
submit:
calculator-step1.asmcalculator-step2.asmcalculator-step3.asmdoor-monitor-step1.asmdoor-monitor-step2.asmdoor-monitor-step3.asmdoor-monitor-step4.asmaccumulate.asm
It is ok if the assembly program for the final step of the calculator and door monitor includes code for the optional extensions as long as the submitted code is fully functional. You should spend a few minutes cleaning up your assembly code. Add a few comments and make sure the code is indented consistently and is easy to read and understand.
Use the ISA and single-cycle simulators in TUI mode to make sure all eight assembly programs are fully functional. For example, here is how to assemble step 1 of the calculator program and test it on both the ISA and single-cycle simulators using TUI mode.
% cd ${HOME}/ece2300/groupXX/build
% make calculator-step1.bin
% make proc-isa-sim
% ./proc-isa-sim +bin=calculator-step1.bin +tui
...
(tui) /in0=2
(tui) /in1=3
(tui) /20
(tui) /in0=4
(tui) /in1=5
(tui) /20
(tui) /quit
% make proc-scycle-sim
% ./proc-scycle-sim +bin=calculator-step1.bin +tui
...
(tui) /in0=2
(tui) /in1=3
(tui) /20
(tui) /in0=4
(tui) /in1=5
(tui) /20
(tui) /quit
Use a similar approach for testing all eight assembly programs. Keep in
mind you can also use +tui-tall for the larger programs to see more of
the assembly code. You will not really be able to fully test step 4 of
the door monitoring program in simulation since we have a 1000 cycle
timeout and your delay loop might run for hundreds of thousands of
cycles. Just verify it functions correctly for the first 1000 cycles.
3. Lab Code Submission
To submit your code you simply push your code to GitHub. You can push your code as many times as you like before the deadline. Students are responsible for going to the GitHub website for your repository, browsing the source code, and confirming the code on GitHub is the code they want to submit is on GitHub. Your assembly code will be assessed primarily in terms of code functionality.