[CS61C FA20] Lecture 19.2 - Single-Cycle CPU Datapath II: Datapath for Stores — Transcript
Full transcript
- 0:01[Music]
- 0:09hello
- 0:10welcome back to this 5 cpu design we've
- 0:12designed a data pod that we can share
- 0:14between all r type and i type
- 0:18instructions
- 0:18including the loads to support the loads
- 0:22we have added the memory to our data
- 0:25path
- 0:25we access the memory by pointing the
- 0:30the address to it and then we read the
- 0:33value
- 0:34and store it into the destination
- 0:37register
- 0:38let's see what do we need to modify in
- 0:40order to support stores
- 0:42so here is a representative store
- 0:45instruction which is store
- 0:46word in risk five it
- 0:49reads two registers rs1 and rs2
- 0:53and the immediate from the
- 0:56instruction we take
- 0:59that immediate value we extend it
- 1:03and add it to the value that is stored
- 1:05in the registers
- 1:06register rs1 that is what forms the
- 1:09address
- 1:10that is used to access the memory now
- 1:13when we have that address
- 1:14we take the contents of a register rs2
- 1:17and write it to the memory so what we
- 1:20can see
- 1:21from this is that we can reuse
- 1:25much of the data path we are still going
- 1:27to use the alu
- 1:28to form the address to add the
- 1:31immediate value to
- 1:35the contents of a register rs1 we do
- 1:38need to
- 1:39provide an additional path that would
- 1:42put the contents of register rs2
- 1:47in the port of the memory that is going
- 1:50to be
- 1:50used for writing and we need to modify
- 1:53the memory to
- 1:54enable it for writing such that it will
- 1:56be updated on the next
- 1:58clock cycle another important thing here
- 2:01is we need a different
- 2:02immediate this time so our immediate
- 2:05generation unit will need to be updated
- 2:07to be able to support two types of
- 2:09immediates
- 2:11in the i type of intermediate our
- 2:12immediate was
- 2:14located in the the the top
- 2:1812 top 12 most significant bits of the
- 2:21instruction
- 2:22but in the s format
- 2:26the immediate is split into two parts we
- 2:28have still the top
- 2:30seven bits in the top
- 2:33twelve most significant top 7 most
- 2:36significant bits
- 2:37of the instruction but the lower
- 2:405 bits are now in locations
- 2:4511 to 7.
- 2:48remember this was done such that we keep
- 2:50the
- 2:52the the fields that store the addresses
- 2:54of the registers the same
- 2:56across all instruction formats because
- 2:58those are in the critical path
- 3:00um you would have you can just imagine
- 3:02now we know the result
- 3:03the reason for that it would be a mess
- 3:06to try to move these addresses all over
- 3:09the place
- 3:10before we start address accessing the
- 3:13register file
- 3:14and raise the file is often in the
- 3:16critical path
- 3:19so we'll need a modification to the
- 3:21immediate generation unit but let's see
- 3:23what we got so far so what we have so
- 3:26far
- 3:26is the data path that supports the
- 3:30loads and in the loads
- 3:33i'm just showing the data path with lw
- 3:37load bytes and load half words need an
- 3:39additional multiplexer
- 3:40over here and a few logic gates but i'm
- 3:43leaving them out
- 3:44to avoid too much complexity here
- 3:48so what we had is the data memory we
- 3:51have added the data memory
- 3:53that we're going to use to read
- 3:56the the value from and store it back
- 3:59into the
- 4:00register file our alu
- 4:03points to the address where we would
- 4:05like to read from
- 4:07and it is formed by adding the immediate
- 4:11to the source register rs1
- 4:14the things that we need we we added were
- 4:18these control signals at the end
- 4:21uh mem rw and right back select
- 4:26let's see what we need to do to support
- 4:29stores
- 4:30so in order to support source we need to
- 4:33modify
- 4:34our model of the memory such that we can
- 4:37write to it so two things will happen
- 4:40our control signal mem read write
- 4:44is going to be given a value right so we
- 4:47can write to the memory
- 4:48on the next clock tick
- 4:51and we are adding another port to the
- 4:55memory which is data w
- 4:57this is where we are going to place the
- 4:59data that you would like to write into
- 5:00the memory at
- 5:02and we are going to ignore
- 5:05whatever is being read
- 5:09out of the memory accidentally we don't
- 5:11care about
- 5:12anything that appears at the data read
- 5:14port
- 5:16so we are setting the right back so
- 5:18let's select signal to
- 5:20a star or a donkey we'll use it in logic
- 5:23optimization later
- 5:24to minimize the number of gates that we
- 5:26need in the control
- 5:29so our data path now is very similar to
- 5:32what we have seen
- 5:33in the loads with a few exceptions
- 5:37immediate select is going to select a
- 5:39new type of an immediate
- 5:40which is the s type we are not
- 5:44writing back to the register file so we
- 5:46are going to
- 5:48set the reg right enable signal to zero
- 5:53and then uh we are still going to select
- 5:55the b
- 5:56operand here which will pick the
- 6:00b operand to be the immediate alu is
- 6:03still going to
- 6:04add that immediate to the rs1
- 6:08and that's how we got our address
- 6:11let's light up this data path to see how
- 6:13things actually
- 6:14propagate through it we're going to cut
- 6:17through the chase
- 6:18and we are going to go through the
- 6:20instruction fetch and
- 6:21end up with a data with the the
- 6:24instruction that is going to be decoded
- 6:27our control logic is now going to
- 6:29process that instruction and set
- 6:31appropriate signals in the control such
- 6:33that we
- 6:34light up the the right par parts of the
- 6:37data path
- 6:38so immediate select is going to be set
- 6:40to s register
- 6:42file writing is going to be disabled
- 6:45b select is going to be set to pick the
- 6:48immediate
- 6:50alu is going to be set to execute an
- 6:52addition
- 6:54and memory is going to be enabled for
- 6:56writing the final select signal
- 6:58is right back is a donkey
- 7:02so while the control is being lit up
- 7:06simultaneously we are accessing the
- 7:08registers and
- 7:09generating the immediate and what we see
- 7:11here we got
- 7:13our rs1 contents in rs2 contents
- 7:16and the important thing that we see here
- 7:19is that rs2 although it shows up at this
- 7:22multiplexer multiplexer is not selected
- 7:24to take it
- 7:25rs2 goes around it and goes to the
- 7:29data port of the memory at the same time
- 7:32our immediate is formed and goes to the
- 7:35alu output of that alu
- 7:37points to the address where we are going
- 7:39to write
- 7:40this data and that is it that completes
- 7:45the store cycle on the next clock tick
- 7:49the new datum is going to be written
- 7:51into the data memory
- 7:52and the program counter is going to be
- 7:56updated
- 7:59let's see a little bit about what do we
- 8:01need to do
- 8:02to our immediate generation unit our
- 8:04immediate generation unit
- 8:06so far was very simple it was designed
- 8:10to take 12 bits
- 8:11of the i type from the i type
- 8:13instruction
- 8:14and sign extend it to 32 bits
- 8:19now we have to support both i and s-type
- 8:22immediates
- 8:24these immediates
- 8:27are similar they have the top seven bits
- 8:31being the same so whatever we have in
- 8:34the top seven bits in both of
- 8:36i type ns type instructions is going to
- 8:38go into the same spot
- 8:40bits 7 to 12 or
- 8:436 to 11
- 8:46of the new immediate with 11th
- 8:50bit extended all the way to
- 8:5331st bit for sign extension
- 8:56but the lower five bits in case of
- 9:00i type are going to come from the
- 9:02instruction bits 24 to 20
- 9:04in in case of s type are going to come
- 9:07from
- 9:08instruction bits 11 to 7. so all what we
- 9:11need to do is to implement one
- 9:13multiplexer that is going to be working
- 9:15two way in case of an
- 9:17i type of an instruction is going to
- 9:18take bits 24 to 20
- 9:21in case of s type instruction is going
- 9:23to take bits 11 to 7
- 9:25and that's it that logic design is
- 9:28fairly simple
- 9:29all what we have is the same logic that
- 9:31we have had for
- 9:32i immediate creation and we are just
- 9:35adding
- 9:36one multiplexer in front of it
- 9:39that's most of it that we need to
- 9:41implement source
- 9:42there are two other store instructions
- 9:44in rs5 isa
- 9:46store bytes and store half words
- 9:49are um relatively
- 9:52straightforward to implement we use
- 9:54exactly the same data path
- 9:56the only modification that we need to do
- 9:58with just the gate or two is to make
- 10:00sure that we don't accidentally override
- 10:02something in the memory that we should
- 10:04not
- 10:05write into that completes the story
- 10:07about the stores
- 10:08where when we come back we're going to
- 10:11add
- 10:12a few major magnifications to the data
- 10:14path but that will be it
- 10:17pretty much everything we need to know
- 10:20about the
- 10:20data path see you then
About this transcript
This page contains the full transcript of [CS61C FA20] Lecture 19.2 - Single-Cycle CPU Datapath II: Datapath for Stores by CS 61C Departmental, generated from the public captions YouTube serves with the video. The transcript has 1,478 words across 260 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.