1Learning Outcomes¶
Implement a datapath that supports U-Type instructions (
luiandauipc).Explain why the ALU (in our course datapath) needs to support wiring the input
Bdirectly to its output.
🎥 Lecture Video
At this point, we have a datapath that can support R-, I-, S-, B-, and J-Type instructions. There is just one instruction format left: the U-Type (upper immediate) instruction. Review U-Type instructions before continuing.
2Updates needed for U-Type¶
To support U-Type:
RegFile: We read no registers but write one register
rd.PC: We read from and write to PC. The value to write is
pc + 4.
There are two updates we need to make:
The immediate generator must now support immediates in U-Type instructions.
The ALU must support passing the immediate through (i.e., select only ALU input
Band ignore inputA). This operation is needed for theluiinstruction.
3Tracing the lui Datapath¶
Figure 1:The lui datapath. Use the menu bar to trace through the animation or download a copy of the PDF/PPTX file.
Instruction Fetch: At the beginning of the clock cycle, read PC and fetch the current instruction from IMEM.
Before the next rising clock edge, set
pc + 4to the input of PC.Instruction Decode: Build the immediate
immfor U-Type instructions. Also configure control logic (see below).Execute: Get the value
immand set as the ALU output.Memory: (We don’t access DMEM, so skip this.)
Write Back: Write the ALU output to the destination register and connect output of the
WBSelmux to RegFile’swdatainput.Around the next rising clock edge,
wdata,RegWEn, andrdshould be held stable through setup and hold time of RegFile.
4Tracing the auipc Datapath¶
Figure 2:The auipc datapath. Use the menu bar to trace through the animation or download a copy of the PDF/PPTX file.
Instruction Fetch: At the beginning of the clock cycle, read PC and fetch the current instruction from IMEM. Feed
pctoEXphase.Before the next rising clock edge, set
pc + 4to the input of PC.Instruction Decode: Build the immediate
immfor U-Type instructions. Also configure control logic (see below).Execute: Compute
pc + immusing the ALU. Because control signals areASel=1andBSel=1, the two muxes before the ALU will selectpcandimm, respectively. BecauseALUSel=Add, the ALU will add these two values together.Memory: (We don’t access DMEM, so skip this.)
Write Back: Write the ALU output to the destination register and connect output of the
WBSelmux to RegFile’swdatainput.Around the next rising clock edge,
wdata,RegWEn, andrdshould be held stable through setup and hold time of RegFile.
Review Control Signals for Stores for an explanation of “don’t care.”