[CS61C FA20] Lecture 18.5 - Single-Cycle CPU Datapath I: Datapath with Immediates — Transcript
Full transcript
- 0:01[Music]
- 0:11hi
- 0:12welcome back let's continue with our
- 0:13risk 5 cpu design
- 0:15we have designed a data path and a
- 0:17control that supports
- 0:18all r types we have seen how
- 0:21we support the execution of the register
- 0:24based edition
- 0:25and then extended it extended it to
- 0:28support subtraction
- 0:29and then all the other r types let's see
- 0:32what do we need
- 0:32in order to support operations with
- 0:35immediates
- 0:38first let's recap what is uh what are
- 0:41how do our
- 0:42immediate instructions look like in this
- 0:45example add immediate
- 0:47takes an immediate value of -50
- 0:51adds it to the contents of a register x1
- 0:55and stores the result in x15
- 0:59it has similar but slightly different
- 1:01format from r types
- 1:03it has a different op code but the
- 1:06fields for
- 1:06our d and rs1 are the same
- 1:10as what we have had in our types um
- 1:12funct
- 1:133 function 3 encoding is the same as
- 1:15what we have seen before
- 1:17but instead of rs2
- 1:20field it was 5 bits wide and the
- 1:23function 7 field
- 1:24that was seven bits wide it has one
- 1:2712-bit field
- 1:28that stores the immediate value
- 1:32so let's take a look at how do we plug
- 1:34that into a data path
- 1:36let's start with our add sub data path
- 1:40or actually a general data path that
- 1:42supports r types
- 1:44and see how we can modify it to
- 1:47add support for the immediates remember
- 1:50we had our program counter
- 1:52our fixed adder that would increment
- 1:55that program counter
- 1:58by four on every clock tick
- 2:02instruction memory register file and the
- 2:04alu
- 2:05and the appropriate control
- 2:10now instead of
- 2:13adding two
- 2:16register values rs1 and rs2 we would
- 2:18like to change that
- 2:20and add the contents of rs1
- 2:23to an immediate or any media to a
- 2:25contents of registrar s1
- 2:26and store it in rd we got
- 2:32two thirds of what we need here we got
- 2:35the value from
- 2:36rs1 in the right place in the alu
- 2:40and we are writing it into a correct
- 2:42place in the register file
- 2:44except that the second input of the alu
- 2:47or what we would call a b
- 2:49input b input of the alu we have
- 2:52rs2 connected instead of the immediate
- 2:56so we could build another data path that
- 2:57would be supporting immediates we will
- 2:59drip out everything instead
- 3:01of this input being connected to rs2 we
- 3:05can connect it
- 3:06to connect an immediate to it
- 3:09but let's not do that let's just build
- 3:12one data pad it
- 3:13supports both our types and i types and
- 3:15how would you do that
- 3:16well we would just put a multiplexer so
- 3:19this multiplexer selects between
- 3:22rs2 value and the immediate
- 3:26based on some select signal which is b
- 3:29cell and b cell stands for b select
- 3:33b operand for the alu so if it is equal
- 3:36to zero
- 3:38we will pick rs2 if it is equal to one
- 3:41we'll pick the immediate
- 3:42keep in mind that both of these inputs
- 3:44are 32-bit
- 3:46values meaning there are 32-bit
- 3:50wires you know 32 different wires coming
- 3:53in
- 3:53the input 0 and the input 1 and 32 wires
- 3:57are coming out
- 3:59based on one select signal
- 4:02now we got pretty much everything we
- 4:05needed here
- 4:06and we do need to get this immediate
- 4:09from somewhere
- 4:10immediate is in the upper part of the
- 4:12instruction and it is only 12 bits
- 4:15wide so we need to take that 12 bit
- 4:18wide value and make 32 bits out of that
- 4:22so we need a little block here that will
- 4:25do that immediate generation
- 4:28so you'll be controlled by this
- 4:30immediate select
- 4:34what we'll find out a little bit later
- 4:35on
- 4:37is that we will
- 4:40see different types of immediates
- 4:42remember different instruction types
- 4:44have different
- 4:45encodings for the immediates so we'd
- 4:48like to reuse that block so we'll say
- 4:50make us an immediate of an i type
- 4:53this time but we'll see that a bit later
- 4:59so let's see what happens when we light
- 5:02up this data path and
- 5:03this is a fun example here so when we
- 5:06light up the data path we first read the
- 5:10program counter program counter points
- 5:12to the instruction memory
- 5:13reads out the the the contents of the
- 5:16instruction memory
- 5:17and reads out the instruction that it
- 5:19that it
- 5:21addresses and updates the program
- 5:24counter
- 5:25now we got all of this instruction so
- 5:28we will point to the register file
- 5:32to the three parts of a register file
- 5:34all three parts of the register file
- 5:37and simultaneously start generating the
- 5:40immediate
- 5:40now you may wonder over here oh don't
- 5:44can do don't we need to disconnect this
- 5:46input
- 5:48b we really don't want that
- 5:51rs2 value well we are going to
- 5:55generate both rs1 and rs2 at the output
- 5:58of the
- 5:58register file and we are going to well
- 6:01use the rs1
- 6:02value but rs2 simply will be ignored
- 6:06remember our register file always reads
- 6:09we just give it an address it produces
- 6:11an output
- 6:12we don't need a clock or anything to
- 6:14make that happen
- 6:15so produce that value but our
- 6:18multiplexer will be set
- 6:20to take the value of the immediate and
- 6:23forward it to the alu so alu will
- 6:26calculate
- 6:27the new value the contents of
- 6:30rs1 plus the immediate and put it back
- 6:34at the input of the register file on the
- 6:37next clock tick
- 6:38we are going to write that new value new
- 6:41state
- 6:41into the the destination register rd
- 6:45together with updating the
- 6:48the program counter and that's it this
- 6:50is a support for the immediates
- 6:53let's take a little bit um
- 6:56just one more thing here the key thing
- 6:59here is
- 7:00we have to have b select set to one
- 7:03so one more thing uh here is um
- 7:07how do we generate the immediate here so
- 7:10if we were just
- 7:11to take a look uh if we just needed to
- 7:14support i type immediates
- 7:16that would have been very simple
- 7:19our i type immediates are in the upper
- 7:2212
- 7:22bits of the instruction so what you
- 7:25would do you would just
- 7:26take 12 wires and
- 7:30move them down to the lowest 12 bits of
- 7:33the immediate
- 7:35so we'll take 12 wires and wire them
- 7:38down
- 7:39to to the immediate what do we do
- 7:42with the upper 20 bits well all what we
- 7:45need to do is to copy
- 7:48the most significant bit of the
- 7:50instruction field
- 7:52um to perform sign extension so we will
- 7:54just make
- 7:5520 copies of that most significant bit
- 7:59of the immediate value
- 8:06in general we are going to be using a
- 8:07few multiplexers to support
- 8:09different types of immediates when we
- 8:11introduced
- 8:12introduce the other formats support for
- 8:16the other formats
- 8:17a bit later we'll break now and we're
- 8:20going to
- 8:21take a look at more instructions see you
- 8:24then
About this transcript
This page contains the full transcript of [CS61C FA20] Lecture 18.5 - Single-Cycle CPU Datapath I: Datapath with Immediates by CS 61C Departmental, generated from the public captions YouTube serves with the video. The transcript has 1,140 words across 203 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.