YouTube2Text

[CS61C FA20] Lecture 11.1 - RISC-V Instruction Formats I: Intro — Transcript

by CS 61C Departmental · 2,373 words · 452 segments · language en · Watch on YouTube

Full transcript

  1. 0:00[Music]
  2. 0:08it's 61c
  3. 0:10and we're getting into a new module in
  4. 0:1261c which is risk 5 instruction
  5. 0:15representation
  6. 0:18first we've learned high level language
  7. 0:20and we have by now mastered c
  8. 0:22after that we have mastered the assembly
  9. 0:25language
  10. 0:26a more basic language closer to the
  11. 0:28hardware that
  12. 0:29describes these elementary instructions
  13. 0:32that the processor
  14. 0:33is executing but processor is not able
  15. 0:36to understand these symbolic
  16. 0:37instructions that
  17. 0:38are load words and store words or ads
  18. 0:43what it understands are sequences of
  19. 0:45binary numbers
  20. 0:47zeros and ones to which the assembly
  21. 0:51language instructions that humans
  22. 0:52understand map to
  23. 0:56so we are going to see the translation
  24. 0:59of these
  25. 1:00symbolic instructions in assembly
  26. 1:03language ads and stores
  27. 1:06into sequences of binary numbers later
  28. 1:09on in the course we are going to see how
  29. 1:12does the hardware actually execute these
  30. 1:14sequences of binary numbers
  31. 1:16and what does it do with them and
  32. 1:18eventually we are going to build a
  33. 1:19computer
  34. 1:20and execute some of these programs so we
  35. 1:23are going to
  36. 1:25build go to introverse this whole stack
  37. 1:29but before we get into that let's
  38. 1:32take a look a bit about the computer
  39. 1:34history and how do we did we end up with
  40. 1:37some of the concepts and the terms that
  41. 1:39we are using here
  42. 1:41the first electronic computer general
  43. 1:44purpose electronic computer
  44. 1:46was the iniac iniak was built in 1946
  45. 1:49in at the university of pennsylvania
  46. 1:52under a contract
  47. 1:53from u.s army
  48. 1:56its purpose was not really to be a
  49. 1:58general purpose computer
  50. 2:00but to perform computations
  51. 2:04for the us army for the artillery
  52. 2:08in general in artillery one of the basic
  53. 2:11problems
  54. 2:12is that two sides of a triangle
  55. 2:15are known and one angle in that triangle
  56. 2:17unknown and somebody needs to calculate
  57. 2:19the third side side of a triangle
  58. 2:23and also to compensate for
  59. 2:26the ballistic trajectory and wind and
  60. 2:28stuff like that
  61. 2:32so army for that purpose used different
  62. 2:36computers
  63. 2:37they had human computers and that
  64. 2:39position in army was actually
  65. 2:41a human computer
  66. 2:45they would use slide rules and
  67. 2:48drawings and precomputed tables to
  68. 2:51quickly
  69. 2:52solve these triangles and i've read
  70. 2:55somewhere
  71. 2:56that some of them are very fast
  72. 2:59they were able to do that in just 12
  73. 3:02seconds so give that a try try to solve
  74. 3:04a triangle in 12 seconds
  75. 3:06um it was also interesting that these
  76. 3:08roles were often in second world war
  77. 3:10performed by females and one of them
  78. 3:14in the picture was a computer this is
  79. 3:17francine schneider who after being
  80. 3:20an army computer was transferred to be a
  81. 3:24programmer
  82. 3:25early programmer for the iniak
  83. 3:28iniak was blazingly fast
  84. 3:31it was able to do one multiply in 2.8
  85. 3:35milliseconds where
  86. 3:36each of these multiplies was would
  87. 3:38involve 10 decimal
  88. 3:40digits by 10 decimal digits
  89. 3:44and it was able to do other things than
  90. 3:46other than solving a triangle
  91. 3:48it was able to do integration that's
  92. 3:50what that i
  93. 3:51in anyak stands for
  94. 3:55but in order to perform a different
  95. 3:57function it had to be reprogrammed
  96. 4:00and the programming here was done or
  97. 4:02reprogramming was done
  98. 4:04by wires so somebody will have to go
  99. 4:07take all of those wires out and there
  100. 4:08are some switches
  101. 4:09and reprogram them to do a different
  102. 4:12function
  103. 4:13that's a procedure that would that would
  104. 4:16take
  105. 4:16two to three days typically and
  106. 4:20because it was just basically patch
  107. 4:22cords and patch cores didn't have
  108. 4:24as convenient connectors as we have them
  109. 4:27today like
  110. 4:28rj11s and rj45s you know so we can
  111. 4:32rewire our routers and so on this was
  112. 4:34just
  113. 4:35basically basic these are just basic
  114. 4:40cables
  115. 4:43the the idea of programming computers
  116. 4:46has been around and emerged
  117. 4:47at around the same time trying to figure
  118. 4:50out a better way to program computers
  119. 4:53so it was it
  120. 4:56became apparent that instructions can be
  121. 4:59represented as binary patterns
  122. 5:02and these bit patterns
  123. 5:06can be stored in a computer
  124. 5:09flipping switches up and down rather
  125. 5:12than
  126. 5:13moving the wires around so as a result
  127. 5:17if the program is stored in switches it
  128. 5:20can be reprogrammed in a matter of
  129. 5:21seconds or
  130. 5:22minutes as opposed to
  131. 5:26multiple days this is known
  132. 5:29as von neumann's concept of a stored
  133. 5:32program computer
  134. 5:33because of the report that von neumann
  135. 5:35wrote for the us army
  136. 5:37in 1945.
  137. 5:42it is interesting that this report was
  138. 5:44leaked
  139. 5:45they intended to patent that but they
  140. 5:47were not able because
  141. 5:48bonneyman's admin mailed it to everybody
  142. 5:52on his mailing list erroneously
  143. 5:56thinking that that's what he wanted
  144. 5:59the idea most likely originated from the
  145. 6:02others
  146. 6:04um neumann had
  147. 6:06um discussions with other members of a
  148. 6:10team
  149. 6:11and this was also anticipated earlier by
  150. 6:13uh turing and zeus
  151. 6:15but onneyman was the original author of
  152. 6:18the
  153. 6:19of the report that was sent to to the
  154. 6:21army
  155. 6:22so it is attributed to him
  156. 6:25the first actually general purpose
  157. 6:29store program electronic computer was
  158. 6:31edsack
  159. 6:32at cambridge at that time designed by
  160. 6:36the lee the design was led by morris
  161. 6:39walks one of the
  162. 6:40early computer pioneers um and all the
  163. 6:43programs were held
  164. 6:44as numbers in memory this dates um
  165. 6:49in 1949.
  166. 6:52it is interesting this was a what i
  167. 6:54believe that was the first
  168. 6:56computer that used two's
  169. 6:59complement but they didn't quite get the
  170. 7:02concept of
  171. 7:03bytes and constant words and so on back
  172. 7:06then so
  173. 7:07this used 35-bit binary two's complement
  174. 7:11numbers
  175. 7:11to represent the data
  176. 7:15then moving forward this concept has
  177. 7:18been adopted it has
  178. 7:20been seen as one of the main major
  179. 7:23advancements
  180. 7:24in designing computers as a
  181. 7:27so as a consequence of both data
  182. 7:31and the instructions being represented
  183. 7:34by binary sequences
  184. 7:36everything has a memory address in a
  185. 7:39computer
  186. 7:41so both instructions and the data are
  187. 7:44stored in memory and each one of them is
  188. 7:47addressable
  189. 7:48so we know that we can address our
  190. 7:51we can access our data by
  191. 7:56loads and stores but we can jump to
  192. 7:58different instructions by using branches
  193. 8:00and jumps
  194. 8:02in languages like c and assembly we can
  195. 8:04also do things that we shouldn't be
  196. 8:06doing for example right over our program
  197. 8:10because they live in the same same
  198. 8:13memory they are supposed to be in
  199. 8:15different parts of a memory
  200. 8:18but it is up to us um
  201. 8:21to keep them separate
  202. 8:26there is one register that is very
  203. 8:28important in here
  204. 8:30it is that we have encountered before
  205. 8:32that we call a program counter
  206. 8:35prior encounter it may not be the best
  207. 8:38name
  208. 8:39it is a pointer to the next instruction
  209. 8:42that is going to be executed in memory
  210. 8:45um different people call it differently
  211. 8:47um intel probably has a better name they
  212. 8:49call it instruction pointer
  213. 8:51makes sense why is it called a program
  214. 8:54counter
  215. 8:56most likely because of early ibm's
  216. 8:58computers
  217. 8:59and this is an example interesting
  218. 9:00example of ibm 701
  219. 9:03that was introduced in 1953.
  220. 9:07it has also interesting concepts that
  221. 9:09you can see on this front panel i mean
  222. 9:10this is a computer that looks like a
  223. 9:12refrigerator um
  224. 9:14a proper size of a computer of that time
  225. 9:18um and you can see these
  226. 9:22blinking lights and at its front panel
  227. 9:26what are these blinking lights when
  228. 9:27you're executing a program they're
  229. 9:29blinking fast so
  230. 9:30maybe they're good for animation but
  231. 9:32they are actually used for
  232. 9:34debugging programs because there is a
  233. 9:36switch here
  234. 9:37down there on the panel that enables
  235. 9:41single step execution so you can
  236. 9:43essentially
  237. 9:45flip that switch up and down and crank
  238. 9:47the program
  239. 9:48instruction by instruction through it
  240. 9:51and you'll find out that there are
  241. 9:52interesting
  242. 9:55registers over there there is a memory
  243. 9:57register on top
  244. 9:59that i believe contains the value
  245. 10:02of the operation of the of the data that
  246. 10:05was brought from memory
  247. 10:07um underneath is an accumulator that is
  248. 10:10about
  249. 10:10i think 38 bits wide they still didn't
  250. 10:13get
  251. 10:14the bytes and words by that then then
  252. 10:16there is a
  253. 10:17multiplier quotient register underneath
  254. 10:19and there are two registers on the
  255. 10:21bottom
  256. 10:22on the left we have an instruction
  257. 10:24counter
  258. 10:25essentially a program counter and the
  259. 10:27instruction register
  260. 10:29so as we are cranking to the program
  261. 10:32instruction by instruction
  262. 10:33we'll see side by side the count of an
  263. 10:36instruction
  264. 10:37and what is the binary instruction
  265. 10:39binary value of the instruction
  266. 10:41that is being executed along with the
  267. 10:43data that is in the accumulator
  268. 10:46and the you know data that came from the
  269. 10:48memory locations we care about
  270. 10:50interesting thing to see here
  271. 10:53instruction counter
  272. 10:54had 12 light bulbs meaning it was able
  273. 10:58to represent up to 12 bits so these
  274. 11:01this computer was able to to
  275. 11:04execute up to 2 to the 12 instructions
  276. 11:074096 instructions
  277. 11:09pretty big for that time
  278. 11:12all right there are quite a few
  279. 11:16consequences really important
  280. 11:18consequences
  281. 11:19um that are due to this representation
  282. 11:23of everything as binary numbers the
  283. 11:25first one is binary compatibility
  284. 11:28programs are now for convenience
  285. 11:30distributed in a binary form we don't
  286. 11:33distribute source program
  287. 11:34usually we don't the source code
  288. 11:38because it will be quite inconvenient to
  289. 11:41have
  290. 11:42everybody compile the source code
  291. 11:44meaning own a compiler
  292. 11:45compile the source code um
  293. 11:50supply libraries link it and
  294. 11:53load the the the executable in the end
  295. 11:57that would really limit proliferation of
  296. 12:01computing devices
  297. 12:04so these binaries are bound to specific
  298. 12:07instructions
  299. 12:08as you have seen before different isas
  300. 12:11are dominant in different domains for
  301. 12:14example pcs use
  302. 12:16intel x86 almost phones you use arms
  303. 12:19architecture and there is a lot of
  304. 12:22storage devices now that use risk five
  305. 12:24these are different isos and they have
  306. 12:27different
  307. 12:27binaries that work for them
  308. 12:31so the other concept that is very
  309. 12:34important is that
  310. 12:36we want machines to always run all
  311. 12:38programs
  312. 12:39for example when we upgrade an iphone
  313. 12:42from i don't know 10
  314. 12:43iphone 10 to iphone 11 we don't want to
  315. 12:47get all new applications and developers
  316. 12:49do not want to develop all
  317. 12:50new applications every time a new phone
  318. 12:52is issued we don't have to have all
  319. 12:54these
  320. 12:55different versions of binaries for
  321. 12:57different versions of the phones
  322. 13:00so we have to be backwards compatible
  323. 13:04and that also leads to a backward
  324. 13:06compatible instruction set
  325. 13:08evolving over time a notable example of
  326. 13:10that is x86 that was designed
  327. 13:13um in nine you know that was based it
  328. 13:16was
  329. 13:16designed in 1981 and adopted for ibm pc
  330. 13:20and ibm thought that
  331. 13:21you know they were thought they were
  332. 13:23optimistic that they were going to sell
  333. 13:2520 000 perhaps of these pcs
  334. 13:28but nowadays we still are able to
  335. 13:32execute
  336. 13:358088 code 8088 code
  337. 13:38which was the original processor in the
  338. 13:40ibm pc
  339. 13:42we can execute those binaries on a
  340. 13:44modern pc
  341. 13:45can you believe that there is quite a
  342. 13:48few
  343. 13:48consequences of that there is quite a
  344. 13:50bit of a baggage attached to that as
  345. 13:52well
  346. 13:56now a few important things
  347. 13:59when we view instructions as numbers
  348. 14:05most of the data that we work with are
  349. 14:0832
  350. 14:09commentary to be chunks so each register
  351. 14:12is a 32-bit word
  352. 14:14and our load worked and stored or store
  353. 14:16world operations that we have seen in
  354. 14:18assembly
  355. 14:19work with 32-bit words
  356. 14:22from the memory so how should our
  357. 14:25instructions look like
  358. 14:28so the computer works with ones and
  359. 14:31zeros
  360. 14:31and we have seen that the very base
  361. 14:34instruction set
  362. 14:36um has only
  363. 14:39about four-ish instructions maybe a
  364. 14:41little bit less
  365. 14:43but risk 5 isa gets extended
  366. 14:46to few hundreds of additional optional
  367. 14:49extensions
  368. 14:53each of these instructions should get
  369. 14:55its binary representation so we can
  370. 14:57number them perhaps means add can become
  371. 15:00instruction one
  372. 15:01sub maybe instruction two add immediate
  373. 15:05maybe an instruction three
  374. 15:07and so on but we usually will not
  375. 15:10do that we will for convenience
  376. 15:14such that it fits in the same memory as
  377. 15:16the data
  378. 15:17we are going to assign it 32-bit
  379. 15:20values it's also really important
  380. 15:24that these 32-bit instructions are used
  381. 15:26in
  382. 15:27all variants of risk 5 rb32
  383. 15:31rv64 and rb128
  384. 15:34so binaries stay tuned it has have to be
  385. 15:36compatible
  386. 15:39now important note is
  387. 15:43how do we use these 32 bits right i mean
  388. 15:45if we have
  389. 15:4632 bits for representing instructions
  390. 15:48that means that we can represent
  391. 15:50two to the 32 different instructions
  392. 15:53in our instructions so that's a lot and
  393. 15:55we're not going to do that
  394. 15:57we're going to design instruction set
  395. 16:00such that in its
  396. 16:01binary representation such that it is
  397. 16:03convenient for a microprocessor to
  398. 16:06interpret it we are essentially going to
  399. 16:08divide it into fields and these fields
  400. 16:10are going to give
  401. 16:11processor a clue what that instruction
  402. 16:15is so you can easily figure out what are
  403. 16:18we trying to do
  404. 16:20and execute it quickly
  405. 16:23so each field will tell processor
  406. 16:24something about the instruction
  407. 16:26what type of an instruction is it and
  408. 16:29which registers does it operate on
  409. 16:32one thing they will see that since we
  410. 16:34have 32
  411. 16:36registers in this five isa
  412. 16:40we'll need to reserve five bits for each
  413. 16:43of the operand registers out of these
  414. 16:4632.
  415. 16:48so but we also would like to have a
  416. 16:51field that is going to
  417. 16:53describe what kind of what type of
  418. 16:56instruction it is
  419. 16:57because it will lead to different
  420. 17:00sequences
  421. 17:01operations inside the processor for
  422. 17:03example we're going to use
  423. 17:05something that is called the r format
  424. 17:08for register to register arithmetic
  425. 17:10operations
  426. 17:10and logic operations as well we are
  427. 17:13going to use
  428. 17:14an i format for register immediate
  429. 17:17arithmetic and logical
  430. 17:19operations but also for loads that may
  431. 17:22be a bit of a surprise
  432. 17:23but load will have the same format as
  433. 17:27the immediates stores are different
  434. 17:30so they will be using an s format and
  435. 17:33then branches
  436. 17:34are going to be using yet a little
  437. 17:37different
  438. 17:38format than that although it will look
  439. 17:40similar to the s format
  440. 17:43now we'll need one very special format
  441. 17:45for very long immediates we haven't seen
  442. 17:47those instructions yet
  443. 17:48we're going to to introduce them and
  444. 17:50that is so called the u format
  445. 17:53and then there is a j format for jumps
  446. 17:55for the two jump instructions that we
  447. 17:57have already seen
  448. 17:58which is a variant of the u format
  449. 18:01so after this break we are going to take
  450. 18:04a look
  451. 18:05at the r format stay tuned
  452. 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.