[CS61C FA20] Lecture 07.2 - RISC-V Intro: Elements of Architecture: Registers — Transcript
Full transcript
- 0:00[Music]
- 0:08welcome back to the risk 5
- 0:10assembly language module
- 0:13we are going to talk a little bit more
- 0:15about the elements
- 0:16of the architecture so
- 0:20just to recap instruction set for a
- 0:23particular architecture
- 0:24is a set of instructions that that
- 0:26architecture can execute
- 0:29it is represented by
- 0:32its assembly language instruction set
- 0:34architecture is an old concept
- 0:35it dates back to the first electronic
- 0:38computers
- 0:39discussed in this paper by berks
- 0:41goldstein and von neumann
- 0:44dated 1947 roughly
- 0:49the key thing here is that each line of
- 0:51assembly code represents one
- 0:53instruction for the computer and
- 0:56computer
- 0:56is going to execute that
- 1:02the first element of the architecture
- 1:04are
- 1:05its registers
- 1:09unlike higher level languages like c or
- 1:12java
- 1:13there are no variables in assembly um
- 1:17they will be really complicated to
- 1:18implement in software so
- 1:21assembly operands those that follow the
- 1:24verb are generally registers
- 1:29what are registers well those are harder
- 1:31objects
- 1:32that sit inside of a processor core and
- 1:35there is a limited number of them
- 1:37operations are performed on the data
- 1:40that is sitting
- 1:41inside the registers the benefit
- 1:45is since they're really local to the
- 1:47processor core
- 1:48and to the units that are doing the
- 1:50calculations inside the course
- 1:52they're really fast they're lightning
- 1:53fast um what do i what does that
- 1:56mean if a processor
- 1:59runs at four gigahertz that means
- 2:03every quarter of a nanosecond it can
- 2:05access
- 2:07its registers once per cycle one cycle
- 2:11in a four gigahertz processor
- 2:12is quarter of a nanosecond
- 2:16how fast is one through a nanosecond
- 2:17well it's very fast
- 2:19if you recall the speed of light is
- 2:21three times the
- 2:23try three times ten to the eight meters
- 2:24per second that means the light
- 2:26travels about thirty thirty centimeters
- 2:29in a nanosecond
- 2:30or about ten centimeters this much is
- 2:33ten centimeters
- 2:34in point three nanoseconds that also
- 2:37tells us that
- 2:38if we put objects farther away
- 2:41than this far
- 2:45there is no hope that we can access them
- 2:46as fast as we can access the registers
- 2:50we can't beat the speed of light so
- 2:53let's
- 2:54see a model of how does a computer look
- 2:56like
- 2:58this is a picture that shows a level of
- 3:02abstraction
- 3:03of the operation of a compute system
- 3:07generally a processor
- 3:10is connected to the memory and in this
- 3:13case
- 3:14it is connected to the input and output
- 3:16devices
- 3:18in this model it looks like the input
- 3:20and output devices are connected to the
- 3:22memory
- 3:23in real life processor is the one that
- 3:24orchestrates loading
- 3:26uh memory from uh the io devices and
- 3:30you know sending the data from the
- 3:31memory to the outputs
- 3:33inside the processor there is generally
- 3:36a control unit
- 3:38and a data plot inside the data path the
- 3:41main elements are those registers
- 3:43and the execution unit typically called
- 3:45the arithmetic logic unit
- 3:48the processor communicates to the memory
- 3:51by
- 3:52issuing addresses and reading
- 3:56data from the memory or writing the data
- 3:58to the memory
- 4:00there is another important concept here
- 4:02we don't
- 4:03want to accidentally write into the
- 4:06memory we can read without any harm to
- 4:09the memory will not alter the values
- 4:10when we read from the memory
- 4:12but when we want to write to the memory
- 4:15we need to
- 4:15say that we are sure when we really want
- 4:17to write to the memory
- 4:19and we do that by you know asserting
- 4:22this
- 4:22enabled signal and that is it
- 4:25will really be working on this
- 4:28conceptual view
- 4:29of a computing system of a processor
- 4:31memory and io
- 4:32and we'll add a few elements through
- 4:34this class but this is
- 4:35pretty good to start with
- 4:39remember you know another view of why
- 4:42registers are important
- 4:44remember our other view of the
- 4:46abstraction the abstraction
- 4:47of a memory system and principle
- 4:50locality and
- 4:51memory hierarchy the goal of
- 4:54all these memory systems is to make
- 4:58memory appear infinitely fast
- 5:01and infinitely large well not that
- 5:04infinitely fast
- 5:05extremely fast like registers but
- 5:08since we have a very long very small
- 5:10number of of registers we would like to
- 5:12make
- 5:13a lot of the bulk memory look to be as
- 5:16fast as the registers
- 5:18how fast are the registers well they're
- 5:21essentially
- 5:22um in this jim gray's analogy
- 5:27as the data that we can keep in our head
- 5:30so how many numbers can
- 5:32you keep in your brain i mean for me
- 5:34that's kind of a
- 5:37a limited number maybe a dozen
- 5:40or two and i can retrieve them uh in
- 5:43about a minute
- 5:45we'll see we'll recall these
- 5:47equivalences of how long does it take us
- 5:49to retrieve the data
- 5:51for other types of of systems
- 5:58important thing about the registers
- 6:00since they are
- 6:01really deep in the hardware right next
- 6:04to the execution course
- 6:07there has to be a limited number of them
- 6:09we cannot have an infinite number of
- 6:10registers
- 6:11because they need to be close to the
- 6:13core
- 6:18so all our assembly code
- 6:21needs to be carefully crafted to utilize
- 6:24these registers for fast execution
- 6:27the number of registers is limited and
- 6:30it is one of the main features of the
- 6:31instruction set architecture
- 6:33some instructions at architectures like
- 6:36x86 have a very
- 6:38small number of registers there are only
- 6:41eight general purpose registers and then
- 6:42some
- 6:43specialized registers inside x86
- 6:47risk 5 has 32 registers how did
- 6:50we determine how did we come up with 32
- 6:53well um
- 6:54it is based based on a goldilocks
- 6:56principle
- 6:57smaller is faster but too small is bad
- 7:00um
- 7:01if you have too many of them it's going
- 7:02to slow down the machine gold deluxe
- 7:04principle says
- 7:05this porridge is too hot this forage is
- 7:07too cold this porridge is just
- 7:09right
- 7:13in rb variant of risk five
- 7:17each register is 32 bits wide
- 7:20these groups of 32 bits as we mentioned
- 7:22are
- 7:23called words in arbitrary two each word
- 7:26is four bytes 32 bits
- 7:30the textbook uses 64 bit wide
- 7:34words it is also word but it's a 64
- 7:38bit word so the width of a word is
- 7:42associated with the with the variant of
- 7:45the architecture
- 7:50let's dive a little bit more into the
- 7:53concept of registers
- 7:55so there are 32 registers in risk 5 and
- 7:58they're numbered
- 7:59by number numbered from 0 to 31.
- 8:03you usually refer to them as physical
- 8:06registers
- 8:07x0 to x31 x0
- 8:11we'll talk about that one uh later is
- 8:14very special
- 8:15because it is hardwired to zero you
- 8:18cannot change its value
- 8:19it always stores a zero because we like
- 8:22to have a zero
- 8:23handy um always around a representation
- 8:26of a zero
- 8:26always near the processor
- 8:30now registers will have their logical
- 8:33names
- 8:34we're gonna have to add them a bit later
- 8:40few other differences between the
- 8:41variables and the registers
- 8:44in c and other higher level programming
- 8:47languages
- 8:49variables need to be declared first and
- 8:51given a type
- 8:53so we would like to distinguish integers
- 8:55from characters
- 8:57um because it's kind of important
- 9:00to know that you know somebody should
- 9:02warn us
- 9:03if we try to add integers and characters
- 9:06we
- 9:06should make sure that that's actually
- 9:08what we want to do
- 9:09more importantly in in
- 9:13c we need to know how much memory is
- 9:16going to be
- 9:17taken by a particular data structure and
- 9:19that very much depends
- 9:20on the type data type that that uses
- 9:26so each variable can only represent that
- 9:29data type otherwise we would have
- 9:31all kinds of memory errors registers
- 9:34in assembly have no type um and
- 9:38it's the operation that operates on them
- 9:40that verb that operates on you know that
- 9:43is inside the instruction um determines
- 9:46what we actually do with the contents of
- 9:48the registers
- 9:51hope this makes sense will make a much
- 9:53more sense when we see
- 9:54particular examples of that
- 10:01one important note here
- 10:04is um it's always good to have comments
- 10:07in your code
- 10:08um so use comments to make your code
- 10:11more readable
- 10:12hash is used for this five comments
- 10:15anything to the
- 10:18to the left of the hash mark is your
- 10:21code
- 10:21anything to the right is ignored by the
- 10:23compiler and
- 10:25by the assembler and is not
- 10:28sent down to the processor
- 10:32there is difference from c that you
- 10:34cannot have multi-line comments like we
- 10:36had in the c
- 10:37star start the comment star slash ends
- 10:41the comment that does not exist in the
- 10:42assembly
- 10:43this style of commenting has been around
- 10:45for a long time here's a good
- 10:47chunk of history this is apollo's
- 10:50guidance computer and you can find all
- 10:52of
- 10:52its code on the github it has been
- 10:55recently about two years ago has been
- 10:56put on the github
- 10:58um the lead programmer was margaret
- 11:01hamilton um and you can see the printout
- 11:04of the code
- 11:05that i believe is for the lunar lander
- 11:07that is taller than her
- 11:09done i bet on a line printer
- 11:13and you will find hash marks
- 11:17and silico comments behind that
- 11:20uh like temporary i hope i hope hope
- 11:24all right back to the assembly
- 11:26instructions
- 11:28to try to wrap it up for this short
- 11:31segment
- 11:33in assembly language each statement is
- 11:36called an instruction it executes one
- 11:39of a short list or about four dish or so
- 11:43risk five instructions
- 11:46each line of assembly language contains
- 11:49at most one instruction
- 11:51and these instructions can be viewed as
- 11:53you know
- 11:54additions or subtractions or logical
- 11:56operations
- 11:59but let's pause here jump
- 12:02to the next video in a few minutes to
- 12:05see
- 12:06practical examples of how do they look
- 12:08like
- 12:10see you there
About this transcript
This page contains the full transcript of [CS61C FA20] Lecture 07.2 - RISC-V Intro: Elements of Architecture: Registers by CS 61C Departmental, generated from the public captions YouTube serves with the video. The transcript has 1,600 words across 305 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.