[CS61C FA20] Lecture 19.4 - Single-Cycle CPU Datapath II: Adding JALR to Datapath — Transcript
Full transcript
- 0:01[Music]
- 0:08hi
- 0:08welcome back to risk 5 cpu design so far
- 0:12we have built
- 0:13the data path and the associated control
- 0:15that
- 0:16supports r type i type as type and b
- 0:20type instructions in that process we
- 0:24have added
- 0:25pretty much all of the hardware that we
- 0:27need to support
- 0:29all of the remaining instructions in the
- 0:31instruction set
- 0:32the changes that we need to add that we
- 0:36need to make to support the remaining
- 0:37instructions are relatively small
- 0:39so let's see what do we need to add to
- 0:41support
- 0:42gel r instruction that's the instruction
- 0:44that stands for jump and link register
- 0:47which is the one that we frequently use
- 0:50for
- 0:50function calls
- 0:54so gel r is an instruction of an
- 0:57i format that's the same format as we
- 1:00have used for
- 1:02arithmetic with immediates and for loads
- 1:06in that format we have an immediate in
- 1:09the upper 12 bits and then fields for
- 1:12one source register
- 1:13and one destination register so the
- 1:15format of the instruction is
- 1:17gel r rd rs immediate the instruction
- 1:20does two changes to the state
- 1:23it runs pc plus 4
- 1:26to the destination register which we'll
- 1:28be using as the return
- 1:30address from our function call and then
- 1:34jumps to the function by
- 1:38writing the rs1 value
- 1:41plus the immediate to the program
- 1:43counter
- 1:45notice that the use of the immediate
- 1:49format for
- 1:52r presented a compromise
- 1:57we lost one bit of a range because
- 2:00always the last bit of the immediate is
- 2:01set to zero so
- 2:02so we lose one bit of how far we can go
- 2:05with the gel
- 2:06r but it simplified the data path we are
- 2:09essentially reusing the the immediate
- 2:13generation
- 2:14mechanism from the i types
- 2:18so here is the data path that we have
- 2:21built so far
- 2:23it has the instruction the program
- 2:25counter the instruction memory
- 2:28the register file a branch comparator
- 2:31that we don't need
- 2:32this time the alu the data memory which
- 2:36we don't need either
- 2:38and the control
- 2:42we need to do two things first we need
- 2:44to figure out how to
- 2:46write the value of pc plus 4
- 2:49into the destination register in the
- 2:52register file
- 2:53and there is no immediate path we'll
- 2:55need to somehow add a multiplexer
- 2:57for that to happen then for the second
- 3:00part where we are going to be adding rs1
- 3:02within with an immediate we already have
- 3:04the mechanism we'll be using the alu
- 3:07and we are going to write it through the
- 3:09same hardware that we've used for
- 3:11supporting taken branches
- 3:14so here is what is the modification that
- 3:17is needed
- 3:18to support child r it is just adding
- 3:21this path
- 3:24that enables us to write pc plus 4
- 3:28to the destination register we have done
- 3:29that by widening
- 3:32the right back select multiplexer to
- 3:34have three possible
- 3:36inputs one or the
- 3:39right back value may be coming from the
- 3:41destination memory
- 3:43one where the right back would be coming
- 3:46from the alu and the third one
- 3:48is the pc plus four value
- 3:51we could have done this differently we
- 3:52have added one more multiplexer in
- 3:54series
- 3:55and another control signal but this way
- 3:57it's simpler we just widen the
- 3:58multiplexer and we are using
- 4:00a three position switch here for right
- 4:03back select
- 4:04so right back select has three different
- 4:06values zero one and two
- 4:09the rest of the modification is simply
- 4:12done through the control so there are no
- 4:13modifications to the data path we just
- 4:15have to set the control bits the right
- 4:17way
- 4:19notable thing here is pc cell control
- 4:22signal is always set to taken
- 4:25which means we are behaving like
- 4:28we are always taking a branch because it
- 4:31is a jump
- 4:33um immediate select is of i type because
- 4:35we are sharing the format with i types
- 4:38we do enable writing to the register
- 4:41file
- 4:42because we do have to write the
- 4:44destination value
- 4:46to the destination but we need to write
- 4:48the return address to the destination
- 4:50register
- 4:50we ignore everything it is associated
- 4:52with the branches we set the
- 4:54a b multiplexers appropriately and
- 4:57alu is set for an addition we are not
- 5:00working with the memory so
- 5:01we set it to read which is the default
- 5:03state and right back select this two as
- 5:05we already mentioned let's light up the
- 5:08gel r data path we start with fetching
- 5:11the instruction
- 5:12and we can immediately proceed to the
- 5:15decode
- 5:16one notable thing here is we instead of
- 5:19lighting up this path of
- 5:22pc plus 4 value going back to the input
- 5:24of the program counter
- 5:26it that does happen but this is a path
- 5:28that is never going to be taken so we
- 5:30are just
- 5:30lighting up the path that takes it to
- 5:33the right back select
- 5:35after the control logic sets all these
- 5:38signals appropriately
- 5:40we can proceed with the rest so
- 5:44actually concurrently with setting up
- 5:46the control registers
- 5:47immediate generation is going to happen
- 5:49and rs1 value is going to be
- 5:52sent over to the alu rs2
- 5:55is being ignored because it is invalid
- 5:58we don't have rs2 in the field
- 6:01in the instruction field the output of
- 6:03an alu
- 6:05will be the sum of the rs1 value
- 6:08with the immediate and that is going to
- 6:11be
- 6:12sent back to the pc cell multiplexer
- 6:14that one is set
- 6:15always to take that value not the pc
- 6:18plus 4
- 6:19that's going to be put at the input
- 6:22of the program counter so
- 6:27that is going to happen simultaneously
- 6:29with the write back select multiplexer
- 6:31presenting the pc plus 4 at the input
- 6:35of the rd on the next clock tick
- 6:39those two states are going to be updated
- 6:42and that's it we'll see some other
- 6:44instructions after we come back
About this transcript
This page contains the full transcript of [CS61C FA20] Lecture 19.4 - Single-Cycle CPU Datapath II: Adding JALR to Datapath by CS 61C Departmental, generated from the public captions YouTube serves with the video. The transcript has 966 words across 170 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to translate the transcript into 100+ languages.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, translation to 100+ languages, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.