[CS61C FA20] Lecture 19.1 - Single-Cycle CPU Datapath II: Supporting Loads — Transcript
Full transcript
- 0:01[Music]
- 0:10hi
- 0:10welcome back to our design of risk 5
- 0:13processor
- 0:14we've designed a data path that can
- 0:17execute both r type and i type
- 0:20instructions
- 0:22so let's recap it before we
- 0:25figure out how what do we need to do to
- 0:27it to add loads
- 0:31in the data path that we had so far we
- 0:34had
- 0:35only four phases of execution remember
- 0:38we said
- 0:39typically instruction execution has five
- 0:42phases
- 0:42but neither are types or i types that we
- 0:46have seen so far
- 0:47did not need to access memory saw
- 0:51so that phase was dropped first we have
- 0:54our instruction address stored in the
- 0:57program counter primary counter points
- 0:59to the instruction memory and fetches
- 1:02the instruction that you would like to
- 1:03execute
- 1:05in the second phase we could decode that
- 1:07instruction
- 1:08and by using the information that we
- 1:11decoded from the instructions fields
- 1:13we set the control bits
- 1:17at the same time we fetch the datum from
- 1:20the registers
- 1:22data from the registers and prepare the
- 1:24immediate
- 1:26in the third phase we execute the
- 1:28instruction in the lu
- 1:30we perform addition subtraction or any
- 1:33of the logic
- 1:34operations that we would like to do
- 1:38based on the instruction fields there is
- 1:41no
- 1:42memory access phase in instructions that
- 1:45we have seen so far so we proceed
- 1:47straight to the
- 1:48fifth stage of execution that
- 1:52is writing back the output of the alu
- 1:56into the destination register
- 2:00now in order to support loads and stores
- 2:02will have to have the data memory
- 2:05and keep in mind that risk 5 is so
- 2:08called a load store
- 2:10type of an architecture where all
- 2:12operations
- 2:13with the memory are done just with loads
- 2:16and stores
- 2:17no other instruction type accesses
- 2:20memory
- 2:21so let's review first what is what do we
- 2:24need to do with our loads
- 2:26here is a load word memory that we have
- 2:28seen before
- 2:29it is of an i type as well because it
- 2:32has the same format of
- 2:34an immediate as the previous i type
- 2:37instructions that we have seen before
- 2:39so immediate is 12 bits wide
- 2:43and it should be signed extended before
- 2:45it contents
- 2:46is added to the value in the register
- 2:49rs1
- 2:50now that sum of the immediate
- 2:54and the value from rs1
- 2:57should not be written straight back into
- 3:00the destination
- 3:01register which is what we did in i types
- 3:05instead it is being used to point to the
- 3:08memory
- 3:08address where we would like to retrieve
- 3:11data from
- 3:12and then that data that we get from the
- 3:14memory will be written back
- 3:16into the destination register so what
- 3:19does our data path need to support
- 3:22the first part looks exactly the same as
- 3:24what we have seen
- 3:26already in i types shared with r types
- 3:30except that we need to have memory back
- 3:33in the picture so memory is right here
- 3:37and it shouldn't be a surprise we
- 3:40point to an address in the memory where
- 3:43we would like
- 3:44to read the data from and the data
- 3:47appears
- 3:48at data r port
- 3:51we'll take that value from the data our
- 3:54port
- 3:54and write it back into the destination
- 3:57register
- 3:58but keep in mind we are not building a
- 4:00separate data path
- 4:02for loads this is the shared data path
- 4:05that we had before
- 4:07so in order to support both arithmetic
- 4:10instructions
- 4:11and loads we use a multiplexer and we
- 4:13select
- 4:14where does our destination
- 4:17for right back where does our operand
- 4:20for
- 4:21right back come from whether it comes
- 4:24straight from the alu
- 4:26or comes from the memory so we have a
- 4:29new
- 4:30select signal right back select
- 4:34in this case memory is configured for
- 4:36reading so we
- 4:37you know we treat it essentially as a
- 4:40combinational block we
- 4:41don't really care about the clock and
- 4:44our memory read write is going to be set
- 4:47to read
- 4:49let's light up this data path to see
- 4:52what it actually does
- 4:55so remember first we have our
- 4:58next instruction or current instruction
- 5:00to be executed
- 5:02in the program counter the program
- 5:04counter points
- 5:06to the address in the
- 5:09instruction memory where the instruction
- 5:11is
- 5:12we retrieve that instruction and decode
- 5:15it
- 5:16in the second phase of execution when
- 5:18decoding
- 5:19that address we find out
- 5:23when decoding the instruction i'm sorry
- 5:26we find out what do we want to do
- 5:28and set the appropriate control to
- 5:31execute it
- 5:32so we in this case we'll set the
- 5:35immediate to be of an
- 5:37i type we'll see we have other
- 5:39immediates later on
- 5:41then we will say that we will write we
- 5:43would like to write back
- 5:45into the register file we
- 5:49pick the b operand in the alu to
- 5:52be the immediate not the output of the
- 5:56register rs2 we
- 5:59set the type of alu operation that we
- 6:02would like to do
- 6:03remember we are using alu here to add
- 6:06the immediate
- 6:07to the value in rs1 we set
- 6:10memory read write to read and we set the
- 6:14write back select
- 6:15to zero to write back from the memory
- 6:20in the same phase of execution we
- 6:23prepare the alu operands
- 6:26which will be rs1 by reading the
- 6:29accessing the date the registers in the
- 6:31register file
- 6:32and extending the immediate value
- 6:36in the third phase of execution we
- 6:38perform the addition
- 6:41and point to the address in the data
- 6:44memory
- 6:45in the fourth phase of execution we
- 6:47perform the memory access
- 6:49and finally in the fifth phase of
- 6:50execution we write
- 6:52back to the destination register
- 6:57and that's it this is our support for
- 7:00the loads
- 7:01one thing that just has to be kept in
- 7:03mind there are
- 7:05several different load instructions in
- 7:08the risc-5 base
- 7:11rb32
- 7:15instruction set um so we have narrower
- 7:18loads
- 7:19these narrower loads can load bytes or
- 7:21half words meaning
- 7:23they can load eight bit
- 7:26wide data or 16-bit y data and it can be
- 7:30of signed or unsigned type
- 7:33it is supported by the same data path
- 7:35except that we
- 7:36may have to add or we definitely have to
- 7:39add
- 7:40a few logic gates and a few multiplexers
- 7:43to support that this is a good exercise
- 7:46in
- 7:48logic design and i strongly encourage
- 7:50you to
- 7:51take a look at that
- 7:54you may actually need this for a project
- 7:56and you will find it in some of the
- 7:58previous
- 7:59exams we can break now
- 8:02before we get to the stores so see you
- 8:05when
- 8:05we get to this stores module
About this transcript
This page contains the full transcript of [CS61C FA20] Lecture 19.1 - Single-Cycle CPU Datapath II: Supporting Loads by CS 61C Departmental, generated from the public captions YouTube serves with the video. The transcript has 1,078 words across 204 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.