[CS61C FA20] Lecture 11.1 - RISC-V Instruction Formats I: Intro — Transcript
Full transcript
- 0:00[Music]
- 0:08it's 61c
- 0:10and we're getting into a new module in
- 0:1261c which is risk 5 instruction
- 0:15representation
- 0:18first we've learned high level language
- 0:20and we have by now mastered c
- 0:22after that we have mastered the assembly
- 0:25language
- 0:26a more basic language closer to the
- 0:28hardware that
- 0:29describes these elementary instructions
- 0:32that the processor
- 0:33is executing but processor is not able
- 0:36to understand these symbolic
- 0:37instructions that
- 0:38are load words and store words or ads
- 0:43what it understands are sequences of
- 0:45binary numbers
- 0:47zeros and ones to which the assembly
- 0:51language instructions that humans
- 0:52understand map to
- 0:56so we are going to see the translation
- 0:59of these
- 1:00symbolic instructions in assembly
- 1:03language ads and stores
- 1:06into sequences of binary numbers later
- 1:09on in the course we are going to see how
- 1:12does the hardware actually execute these
- 1:14sequences of binary numbers
- 1:16and what does it do with them and
- 1:18eventually we are going to build a
- 1:19computer
- 1:20and execute some of these programs so we
- 1:23are going to
- 1:25build go to introverse this whole stack
- 1:29but before we get into that let's
- 1:32take a look a bit about the computer
- 1:34history and how do we did we end up with
- 1:37some of the concepts and the terms that
- 1:39we are using here
- 1:41the first electronic computer general
- 1:44purpose electronic computer
- 1:46was the iniac iniak was built in 1946
- 1:49in at the university of pennsylvania
- 1:52under a contract
- 1:53from u.s army
- 1:56its purpose was not really to be a
- 1:58general purpose computer
- 2:00but to perform computations
- 2:04for the us army for the artillery
- 2:08in general in artillery one of the basic
- 2:11problems
- 2:12is that two sides of a triangle
- 2:15are known and one angle in that triangle
- 2:17unknown and somebody needs to calculate
- 2:19the third side side of a triangle
- 2:23and also to compensate for
- 2:26the ballistic trajectory and wind and
- 2:28stuff like that
- 2:32so army for that purpose used different
- 2:36computers
- 2:37they had human computers and that
- 2:39position in army was actually
- 2:41a human computer
- 2:45they would use slide rules and
- 2:48drawings and precomputed tables to
- 2:51quickly
- 2:52solve these triangles and i've read
- 2:55somewhere
- 2:56that some of them are very fast
- 2:59they were able to do that in just 12
- 3:02seconds so give that a try try to solve
- 3:04a triangle in 12 seconds
- 3:06um it was also interesting that these
- 3:08roles were often in second world war
- 3:10performed by females and one of them
- 3:14in the picture was a computer this is
- 3:17francine schneider who after being
- 3:20an army computer was transferred to be a
- 3:24programmer
- 3:25early programmer for the iniak
- 3:28iniak was blazingly fast
- 3:31it was able to do one multiply in 2.8
- 3:35milliseconds where
- 3:36each of these multiplies was would
- 3:38involve 10 decimal
- 3:40digits by 10 decimal digits
- 3:44and it was able to do other things than
- 3:46other than solving a triangle
- 3:48it was able to do integration that's
- 3:50what that i
- 3:51in anyak stands for
- 3:55but in order to perform a different
- 3:57function it had to be reprogrammed
- 4:00and the programming here was done or
- 4:02reprogramming was done
- 4:04by wires so somebody will have to go
- 4:07take all of those wires out and there
- 4:08are some switches
- 4:09and reprogram them to do a different
- 4:12function
- 4:13that's a procedure that would that would
- 4:16take
- 4:16two to three days typically and
- 4:20because it was just basically patch
- 4:22cords and patch cores didn't have
- 4:24as convenient connectors as we have them
- 4:27today like
- 4:28rj11s and rj45s you know so we can
- 4:32rewire our routers and so on this was
- 4:34just
- 4:35basically basic these are just basic
- 4:40cables
- 4:43the the idea of programming computers
- 4:46has been around and emerged
- 4:47at around the same time trying to figure
- 4:50out a better way to program computers
- 4:53so it was it
- 4:56became apparent that instructions can be
- 4:59represented as binary patterns
- 5:02and these bit patterns
- 5:06can be stored in a computer
- 5:09flipping switches up and down rather
- 5:12than
- 5:13moving the wires around so as a result
- 5:17if the program is stored in switches it
- 5:20can be reprogrammed in a matter of
- 5:21seconds or
- 5:22minutes as opposed to
- 5:26multiple days this is known
- 5:29as von neumann's concept of a stored
- 5:32program computer
- 5:33because of the report that von neumann
- 5:35wrote for the us army
- 5:37in 1945.
- 5:42it is interesting that this report was
- 5:44leaked
- 5:45they intended to patent that but they
- 5:47were not able because
- 5:48bonneyman's admin mailed it to everybody
- 5:52on his mailing list erroneously
- 5:56thinking that that's what he wanted
- 5:59the idea most likely originated from the
- 6:02others
- 6:04um neumann had
- 6:06um discussions with other members of a
- 6:10team
- 6:11and this was also anticipated earlier by
- 6:13uh turing and zeus
- 6:15but onneyman was the original author of
- 6:18the
- 6:19of the report that was sent to to the
- 6:21army
- 6:22so it is attributed to him
- 6:25the first actually general purpose
- 6:29store program electronic computer was
- 6:31edsack
- 6:32at cambridge at that time designed by
- 6:36the lee the design was led by morris
- 6:39walks one of the
- 6:40early computer pioneers um and all the
- 6:43programs were held
- 6:44as numbers in memory this dates um
- 6:49in 1949.
- 6:52it is interesting this was a what i
- 6:54believe that was the first
- 6:56computer that used two's
- 6:59complement but they didn't quite get the
- 7:02concept of
- 7:03bytes and constant words and so on back
- 7:06then so
- 7:07this used 35-bit binary two's complement
- 7:11numbers
- 7:11to represent the data
- 7:15then moving forward this concept has
- 7:18been adopted it has
- 7:20been seen as one of the main major
- 7:23advancements
- 7:24in designing computers as a
- 7:27so as a consequence of both data
- 7:31and the instructions being represented
- 7:34by binary sequences
- 7:36everything has a memory address in a
- 7:39computer
- 7:41so both instructions and the data are
- 7:44stored in memory and each one of them is
- 7:47addressable
- 7:48so we know that we can address our
- 7:51we can access our data by
- 7:56loads and stores but we can jump to
- 7:58different instructions by using branches
- 8:00and jumps
- 8:02in languages like c and assembly we can
- 8:04also do things that we shouldn't be
- 8:06doing for example right over our program
- 8:10because they live in the same same
- 8:13memory they are supposed to be in
- 8:15different parts of a memory
- 8:18but it is up to us um
- 8:21to keep them separate
- 8:26there is one register that is very
- 8:28important in here
- 8:30it is that we have encountered before
- 8:32that we call a program counter
- 8:35prior encounter it may not be the best
- 8:38name
- 8:39it is a pointer to the next instruction
- 8:42that is going to be executed in memory
- 8:45um different people call it differently
- 8:47um intel probably has a better name they
- 8:49call it instruction pointer
- 8:51makes sense why is it called a program
- 8:54counter
- 8:56most likely because of early ibm's
- 8:58computers
- 8:59and this is an example interesting
- 9:00example of ibm 701
- 9:03that was introduced in 1953.
- 9:07it has also interesting concepts that
- 9:09you can see on this front panel i mean
- 9:10this is a computer that looks like a
- 9:12refrigerator um
- 9:14a proper size of a computer of that time
- 9:18um and you can see these
- 9:22blinking lights and at its front panel
- 9:26what are these blinking lights when
- 9:27you're executing a program they're
- 9:29blinking fast so
- 9:30maybe they're good for animation but
- 9:32they are actually used for
- 9:34debugging programs because there is a
- 9:36switch here
- 9:37down there on the panel that enables
- 9:41single step execution so you can
- 9:43essentially
- 9:45flip that switch up and down and crank
- 9:47the program
- 9:48instruction by instruction through it
- 9:51and you'll find out that there are
- 9:52interesting
- 9:55registers over there there is a memory
- 9:57register on top
- 9:59that i believe contains the value
- 10:02of the operation of the of the data that
- 10:05was brought from memory
- 10:07um underneath is an accumulator that is
- 10:10about
- 10:10i think 38 bits wide they still didn't
- 10:13get
- 10:14the bytes and words by that then then
- 10:16there is a
- 10:17multiplier quotient register underneath
- 10:19and there are two registers on the
- 10:21bottom
- 10:22on the left we have an instruction
- 10:24counter
- 10:25essentially a program counter and the
- 10:27instruction register
- 10:29so as we are cranking to the program
- 10:32instruction by instruction
- 10:33we'll see side by side the count of an
- 10:36instruction
- 10:37and what is the binary instruction
- 10:39binary value of the instruction
- 10:41that is being executed along with the
- 10:43data that is in the accumulator
- 10:46and the you know data that came from the
- 10:48memory locations we care about
- 10:50interesting thing to see here
- 10:53instruction counter
- 10:54had 12 light bulbs meaning it was able
- 10:58to represent up to 12 bits so these
- 11:01this computer was able to to
- 11:04execute up to 2 to the 12 instructions
- 11:074096 instructions
- 11:09pretty big for that time
- 11:12all right there are quite a few
- 11:16consequences really important
- 11:18consequences
- 11:19um that are due to this representation
- 11:23of everything as binary numbers the
- 11:25first one is binary compatibility
- 11:28programs are now for convenience
- 11:30distributed in a binary form we don't
- 11:33distribute source program
- 11:34usually we don't the source code
- 11:38because it will be quite inconvenient to
- 11:41have
- 11:42everybody compile the source code
- 11:44meaning own a compiler
- 11:45compile the source code um
- 11:50supply libraries link it and
- 11:53load the the the executable in the end
- 11:57that would really limit proliferation of
- 12:01computing devices
- 12:04so these binaries are bound to specific
- 12:07instructions
- 12:08as you have seen before different isas
- 12:11are dominant in different domains for
- 12:14example pcs use
- 12:16intel x86 almost phones you use arms
- 12:19architecture and there is a lot of
- 12:22storage devices now that use risk five
- 12:24these are different isos and they have
- 12:27different
- 12:27binaries that work for them
- 12:31so the other concept that is very
- 12:34important is that
- 12:36we want machines to always run all
- 12:38programs
- 12:39for example when we upgrade an iphone
- 12:42from i don't know 10
- 12:43iphone 10 to iphone 11 we don't want to
- 12:47get all new applications and developers
- 12:49do not want to develop all
- 12:50new applications every time a new phone
- 12:52is issued we don't have to have all
- 12:54these
- 12:55different versions of binaries for
- 12:57different versions of the phones
- 13:00so we have to be backwards compatible
- 13:04and that also leads to a backward
- 13:06compatible instruction set
- 13:08evolving over time a notable example of
- 13:10that is x86 that was designed
- 13:13um in nine you know that was based it
- 13:16was
- 13:16designed in 1981 and adopted for ibm pc
- 13:20and ibm thought that
- 13:21you know they were thought they were
- 13:23optimistic that they were going to sell
- 13:2520 000 perhaps of these pcs
- 13:28but nowadays we still are able to
- 13:32execute
- 13:358088 code 8088 code
- 13:38which was the original processor in the
- 13:40ibm pc
- 13:42we can execute those binaries on a
- 13:44modern pc
- 13:45can you believe that there is quite a
- 13:48few
- 13:48consequences of that there is quite a
- 13:50bit of a baggage attached to that as
- 13:52well
- 13:56now a few important things
- 13:59when we view instructions as numbers
- 14:05most of the data that we work with are
- 14:0832
- 14:09commentary to be chunks so each register
- 14:12is a 32-bit word
- 14:14and our load worked and stored or store
- 14:16world operations that we have seen in
- 14:18assembly
- 14:19work with 32-bit words
- 14:22from the memory so how should our
- 14:25instructions look like
- 14:28so the computer works with ones and
- 14:31zeros
- 14:31and we have seen that the very base
- 14:34instruction set
- 14:36um has only
- 14:39about four-ish instructions maybe a
- 14:41little bit less
- 14:43but risk 5 isa gets extended
- 14:46to few hundreds of additional optional
- 14:49extensions
- 14:53each of these instructions should get
- 14:55its binary representation so we can
- 14:57number them perhaps means add can become
- 15:00instruction one
- 15:01sub maybe instruction two add immediate
- 15:05maybe an instruction three
- 15:07and so on but we usually will not
- 15:10do that we will for convenience
- 15:14such that it fits in the same memory as
- 15:16the data
- 15:17we are going to assign it 32-bit
- 15:20values it's also really important
- 15:24that these 32-bit instructions are used
- 15:26in
- 15:27all variants of risk 5 rb32
- 15:31rv64 and rb128
- 15:34so binaries stay tuned it has have to be
- 15:36compatible
- 15:39now important note is
- 15:43how do we use these 32 bits right i mean
- 15:45if we have
- 15:4632 bits for representing instructions
- 15:48that means that we can represent
- 15:50two to the 32 different instructions
- 15:53in our instructions so that's a lot and
- 15:55we're not going to do that
- 15:57we're going to design instruction set
- 16:00such that in its
- 16:01binary representation such that it is
- 16:03convenient for a microprocessor to
- 16:06interpret it we are essentially going to
- 16:08divide it into fields and these fields
- 16:10are going to give
- 16:11processor a clue what that instruction
- 16:15is so you can easily figure out what are
- 16:18we trying to do
- 16:20and execute it quickly
- 16:23so each field will tell processor
- 16:24something about the instruction
- 16:26what type of an instruction is it and
- 16:29which registers does it operate on
- 16:32one thing they will see that since we
- 16:34have 32
- 16:36registers in this five isa
- 16:40we'll need to reserve five bits for each
- 16:43of the operand registers out of these
- 16:4632.
- 16:48so but we also would like to have a
- 16:51field that is going to
- 16:53describe what kind of what type of
- 16:56instruction it is
- 16:57because it will lead to different
- 17:00sequences
- 17:01operations inside the processor for
- 17:03example we're going to use
- 17:05something that is called the r format
- 17:08for register to register arithmetic
- 17:10operations
- 17:10and logic operations as well we are
- 17:13going to use
- 17:14an i format for register immediate
- 17:17arithmetic and logical
- 17:19operations but also for loads that may
- 17:22be a bit of a surprise
- 17:23but load will have the same format as
- 17:27the immediates stores are different
- 17:30so they will be using an s format and
- 17:33then branches
- 17:34are going to be using yet a little
- 17:37different
- 17:38format than that although it will look
- 17:40similar to the s format
- 17:43now we'll need one very special format
- 17:45for very long immediates we haven't seen
- 17:47those instructions yet
- 17:48we're going to to introduce them and
- 17:50that is so called the u format
- 17:53and then there is a j format for jumps
- 17:55for the two jump instructions that we
- 17:57have already seen
- 17:58which is a variant of the u format
- 18:01so after this break we are going to take
- 18:04a look
- 18:05at the r format stay tuned
- 18:08we'll be back
About this transcript
This page contains the full transcript of [CS61C FA20] Lecture 11.1 - RISC-V Instruction Formats I: Intro by CS 61C Departmental, generated from the public captions YouTube serves with the video. The transcript has 2,373 words across 452 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.