Lab 8

There is no checkoff for lab this week. This is primarily review for the midterm, this will cover only a subset of the material in scope and is not a representation of what will appear on the exam.

Objectives

  • TSW gain insight on how to approach various topics that may be present for the midterm.

Exercise 1: RISC-V

Link to Green Sheet: https://cs61c.org/assets/resources/riscvcard_large.pdf

  • Understand the purpose of registers; why not just store everything in memory and then load a value when we need it?
  • Understand the purpose of caller/callee convention and how to write RISC-V code that obeys caller/callee convention. Remember that there is a table in the Green Sheet that says who is responsible for saving what registers.
  • Understand how iteration and recursion work in RISC-V. Some examples of recursion are Exercise 4 in Lab 04 and Exercise 1 in Lab 05. We highly encourage you to draw out the stack frames and what each one contains after executing the prologue; it will probably make it much easier to understand what’s going on.
  • Know the 6 instruction formats and how to encode any given instruction in binary using the 32 bit breakdown for its instruction type. Remember: your Green Sheet is your best friend in this class!
  • Remember that for jumps and branches, the least significant bit (LSB) is not encoded in the instruction. This is because instructions are either 2 or 4 bytes (2 byte instructions are an artifact from previous RISC versions), so the number of bytes you’ll be jumping will always be a multiple of 2.
  • Be comfortable with various pseudo-instructions such as j, ret, jr ra, li, la, bnez, and mv. Make sure you know what arguments they can take (if any) and what their “original” instructions are.

Exercise 2: Datapath Implementation (Structure/Control)

Recall that the critical path is the longest path(delay) from register to register, whether it be the same or different register. Setup time is the amount of time before the clock rise that the input signal must remain constant. Clk-to-Q time is the amount of time after the clock rise that the output signal takes to reflect the saved value. Hold time is the amount of time after the clock rise that the input signal must remain constant.

Some general formulas to note:

  • critical path = clk-to-q + LONGEST CL + setup
  • hold <= clk-to-q + SHORTEST CL

Make sure you know the different control signals, what they do, and how they affect our datapath!

  • PCSel - Selects between PC + 4 and ALU to update PC (Program Counter, which stores the address of the instruction we are executing)
  • RegWEn - Determines whether we allow the modification of registers in our register file
  • ImmSel - Selects which immediate type to generate (I, S, SB, U, UJ)
  • BrUn - Determines if we do unsigned or signed comparison
  • BrEq - On if rs1 == rs2
  • BrLt - On if rs1 < rs2 based off of BrUn
  • BSel - Selects between rs2 and the immediate
  • ASel - Selects between rs1 and PC
  • ALUSel - Selects the ALU operation to perform on the inputs
  • MemRW - Selects if we want to be able to write to memory
  • WBSel - Selects if we want to send either PC+4, ALU, or memory output to be written into the register file

No Checkoff