5
points.A
Consider the G circuit, depicted on the following.
Since the G circuit is currently only combinational, we know exactly what to improve: Pipeline it.
- A01 = ?
- A02 = ?
- A03 = ?
- A04 = ?
- A05 = ?
- A06 = ?
B
Assume that we are trying to build a RISC-V processor. For the reference purpose, there are two 5-stage (IF
, DEC
, EXE
, MEM
, WB
) bypassing processors. However, they are a little broken. The processors are as follows:
Known properties:
PC + 4
).EXE
stage.We try this simple RISC-V looping code on both of these processors. Assume at the start of the code that x2
is set to some number greater than 0
and that all the other registers are set to 0
.
PC + 4
and annuls instructions following taken branches, how many cycles would it take for one iteration of the loop? Assume that the bnez
is taken. Provide the number of cycles per loop iteration.
- B01 = ?
0x10
into x2
, by the time the second iteration's addi
reaches EXE
, what value will be passed to x1
for each of the two defective processors? If the loop does not make it to a second iteration's addi
, write N/A
.
x1
: __ B02 __x1
: __ B03 __
- B02 = ?
- B03 = ?
C
Since having full bypassing can be very costly, we attempt to reorder the instructions in this loop so that we can minimize the total number of cycles per loop iteration while using a single bypass path.
We can change the order of the instructions in the program as long as it does not change the final result. In what order would you execute the 6 instructions in the loop so that you only need a single bypass path?
EXE
DEC
bypass path. Please list the opcodes in order of execution: __ C01 __ (split in comma)
- C01 = ?
400
ps (before) to 450
ps (with the branch calculated in decode).
EXE
and tCLK = 400ps, new: branch decision in DEC
and tCLK = 450ps)? __ C02 __
- C02 = ?
D
Consider the following C code:
Then, the translated RISC-V assembly:
Assume the registers are initialized to the values specified in the assembly code comments.
In the following five-stage pipelined RISC-V processor (IF
, DEC
, EXE
, MEM
, WB
):
PC + 4
).EXE
stage.How many cycles did it take to execute the first loop iteration on this processor? Make sure not to include the first two instructions at label start in your cycle count.
- D01 = ?
If you could modify your fetch stage to always fetch the correct next instruction instead of predicting all branches not taken, how many cycles will it now take to execute the first iteration of the loop on this modified processor? __ D02 __
- D02 = ?
Now, let's change this processor without bypassing. That is, all data hazards are resolved by stalling. How many cycles did it take to execute the first loop on this processor? __ D03 __
- D03 = ?
E
Given the standard RISC-V datapath, determine if the following is implementable or not without any additional functional units? Assume the instruction is not a pseudoinstruction encoding.
Consider the new instruction isnull rd, rs1
which check if an input given through rs1
is considered NULL
or not by C standard. The result is returned through rd
as a bit. Is it Implementable? __ E01 __ (Answer with Yes
or No
)
- E01 = ?
What changes would you need to make in order for the instruction to be able to execute correctly? Assume all modifications and additions are done on top of the existing single cycle datapath. Select all that apply. __ E02 __ (Anwser in the following items and use comma to split)
a
. Modify Branch Comparator logic.b
. Modify the control signals to the ALU
.c
. Modify the control logic for the Branch Comparator.d
. Modify ALU
buses.e
. Modify the control logic for WBSel
.f
. Add additional control signals for the writeback mux.g
. Modify control logic for ALU
/ALUSel
.h
. Modify the control logic for parsing instr[31:0]
.i
. Add an additional comparator.j
. None of the above.
- E02 = ?
isnull rd, rs1
is not in a standard RISC-V instruction format; as we are attempting to reduce the number of hardware changes in our datapath. We instead choose to implement our instruction as a pseudoinstruction in the following format. Which of the following statements is true? Assume earlier changes propagate. Select all that apply __ E03 __ (Anwser in the items and use comma to split)
a
. We need to provide a second argument x0
when calling the instruction and modify the control signals.b
. We need to provide a second argument x0
as a comparator for all branch comparisons.c
. It is impossible to represent as an R-Type instructiond
. We need to wire x0
as a comparator for all branch comparisons.e
. We need to wire x0
as rs2
and modify the control signals.
- E03 = ?
We plan to add a new R-Type signed compare instruction called comp
, into the RISC-V single-cycle datapath, to compare R[rs1]
and R[rs2]
and set R[rd]
appropriately. The RTL for it is shown below.
We want to change the datapath to make this work. We start by adding two more inputs (0x00000000
and 0x00000001
) to the rightmost WBSel
MUX. What else is required to make this instruction work? Select all that apply __ E04 __ (Anwser in the items and use comma to split)
a
. Modify Branch Compb
. Modify Imm. Gen.c
. Modify the ALU
and ALUSel
control signalsd
. Modify the control logic for RegWEn
e
. Modify the control logic for MemWEn
- E04 = ?
F
Much of the assembly code she writes involves iterating through arrays of integers. Instead of using several instructions to calculate the address of the next element, we propose a new instruction, iarrn rd, rs1, rs2
, which places into rd the address of the rs2
-th element of the array pointed to by rs1
. This instruction does not do bounds checking and it assumes the size of an integer is 4B (32 bits). Do not assume this instruction belongs to a specific type.
In verilog, the instruction is described as follows:
We are interested in modifying our RISC-V datapath to support this instruction. Assume we have introduced a new control bit IArrN
which is 1
when the current instruction is iarrn
and 0
otherwise. Using the datapath below, fill in the following table with the rest of the control bits for this instruction. If the control bit can be set to *
, please draw an X
in the table below.
IArrN | PCSel | RegWEn | MemRW | WBSel | BrUn | ALUSel |
---|---|---|---|---|---|---|
1 | F01 | F02 | F03 | F04 | F05 | ADD |
- F01 = ?
- F02 = ?
- F03 = ?
- F04 = ?
- F05 = ?
This instruction involves changing a few hardware pieces on the datapath in addition to changing control bits above. We propose modifying the ASel
and BSel
muxes, and their associated control bits (circled below).
How should we change BSel
to allow our new instruction, and all other RISC-V instructions, to execute correctly? Select one __ F06 __ Assume our ALU
, RegFile
, and memory units remain unchanged internally.
- F06 = ?
Following the previous quetion, how should we change ASel
to allow our new instruction, and all other RISC-V instructions, to execute correctly? Select one __ F07 __
- F07 = ?