YouTube2Text

[CS61C FA20] Lecture 07.2 - RISC-V Intro: Elements of Architecture: Registers — Transcript

by CS 61C Departmental · 1,600 words · 305 segments · language en · Watch on YouTube

Full transcript

  1. 0:00[Music]
  2. 0:08welcome back to the risk 5
  3. 0:10assembly language module
  4. 0:13we are going to talk a little bit more
  5. 0:15about the elements
  6. 0:16of the architecture so
  7. 0:20just to recap instruction set for a
  8. 0:23particular architecture
  9. 0:24is a set of instructions that that
  10. 0:26architecture can execute
  11. 0:29it is represented by
  12. 0:32its assembly language instruction set
  13. 0:34architecture is an old concept
  14. 0:35it dates back to the first electronic
  15. 0:38computers
  16. 0:39discussed in this paper by berks
  17. 0:41goldstein and von neumann
  18. 0:44dated 1947 roughly
  19. 0:49the key thing here is that each line of
  20. 0:51assembly code represents one
  21. 0:53instruction for the computer and
  22. 0:56computer
  23. 0:56is going to execute that
  24. 1:02the first element of the architecture
  25. 1:04are
  26. 1:05its registers
  27. 1:09unlike higher level languages like c or
  28. 1:12java
  29. 1:13there are no variables in assembly um
  30. 1:17they will be really complicated to
  31. 1:18implement in software so
  32. 1:21assembly operands those that follow the
  33. 1:24verb are generally registers
  34. 1:29what are registers well those are harder
  35. 1:31objects
  36. 1:32that sit inside of a processor core and
  37. 1:35there is a limited number of them
  38. 1:37operations are performed on the data
  39. 1:40that is sitting
  40. 1:41inside the registers the benefit
  41. 1:45is since they're really local to the
  42. 1:47processor core
  43. 1:48and to the units that are doing the
  44. 1:50calculations inside the course
  45. 1:52they're really fast they're lightning
  46. 1:53fast um what do i what does that
  47. 1:56mean if a processor
  48. 1:59runs at four gigahertz that means
  49. 2:03every quarter of a nanosecond it can
  50. 2:05access
  51. 2:07its registers once per cycle one cycle
  52. 2:11in a four gigahertz processor
  53. 2:12is quarter of a nanosecond
  54. 2:16how fast is one through a nanosecond
  55. 2:17well it's very fast
  56. 2:19if you recall the speed of light is
  57. 2:21three times the
  58. 2:23try three times ten to the eight meters
  59. 2:24per second that means the light
  60. 2:26travels about thirty thirty centimeters
  61. 2:29in a nanosecond
  62. 2:30or about ten centimeters this much is
  63. 2:33ten centimeters
  64. 2:34in point three nanoseconds that also
  65. 2:37tells us that
  66. 2:38if we put objects farther away
  67. 2:41than this far
  68. 2:45there is no hope that we can access them
  69. 2:46as fast as we can access the registers
  70. 2:50we can't beat the speed of light so
  71. 2:53let's
  72. 2:54see a model of how does a computer look
  73. 2:56like
  74. 2:58this is a picture that shows a level of
  75. 3:02abstraction
  76. 3:03of the operation of a compute system
  77. 3:07generally a processor
  78. 3:10is connected to the memory and in this
  79. 3:13case
  80. 3:14it is connected to the input and output
  81. 3:16devices
  82. 3:18in this model it looks like the input
  83. 3:20and output devices are connected to the
  84. 3:22memory
  85. 3:23in real life processor is the one that
  86. 3:24orchestrates loading
  87. 3:26uh memory from uh the io devices and
  88. 3:30you know sending the data from the
  89. 3:31memory to the outputs
  90. 3:33inside the processor there is generally
  91. 3:36a control unit
  92. 3:38and a data plot inside the data path the
  93. 3:41main elements are those registers
  94. 3:43and the execution unit typically called
  95. 3:45the arithmetic logic unit
  96. 3:48the processor communicates to the memory
  97. 3:51by
  98. 3:52issuing addresses and reading
  99. 3:56data from the memory or writing the data
  100. 3:58to the memory
  101. 4:00there is another important concept here
  102. 4:02we don't
  103. 4:03want to accidentally write into the
  104. 4:06memory we can read without any harm to
  105. 4:09the memory will not alter the values
  106. 4:10when we read from the memory
  107. 4:12but when we want to write to the memory
  108. 4:15we need to
  109. 4:15say that we are sure when we really want
  110. 4:17to write to the memory
  111. 4:19and we do that by you know asserting
  112. 4:22this
  113. 4:22enabled signal and that is it
  114. 4:25will really be working on this
  115. 4:28conceptual view
  116. 4:29of a computing system of a processor
  117. 4:31memory and io
  118. 4:32and we'll add a few elements through
  119. 4:34this class but this is
  120. 4:35pretty good to start with
  121. 4:39remember you know another view of why
  122. 4:42registers are important
  123. 4:44remember our other view of the
  124. 4:46abstraction the abstraction
  125. 4:47of a memory system and principle
  126. 4:50locality and
  127. 4:51memory hierarchy the goal of
  128. 4:54all these memory systems is to make
  129. 4:58memory appear infinitely fast
  130. 5:01and infinitely large well not that
  131. 5:04infinitely fast
  132. 5:05extremely fast like registers but
  133. 5:08since we have a very long very small
  134. 5:10number of of registers we would like to
  135. 5:12make
  136. 5:13a lot of the bulk memory look to be as
  137. 5:16fast as the registers
  138. 5:18how fast are the registers well they're
  139. 5:21essentially
  140. 5:22um in this jim gray's analogy
  141. 5:27as the data that we can keep in our head
  142. 5:30so how many numbers can
  143. 5:32you keep in your brain i mean for me
  144. 5:34that's kind of a
  145. 5:37a limited number maybe a dozen
  146. 5:40or two and i can retrieve them uh in
  147. 5:43about a minute
  148. 5:45we'll see we'll recall these
  149. 5:47equivalences of how long does it take us
  150. 5:49to retrieve the data
  151. 5:51for other types of of systems
  152. 5:58important thing about the registers
  153. 6:00since they are
  154. 6:01really deep in the hardware right next
  155. 6:04to the execution course
  156. 6:07there has to be a limited number of them
  157. 6:09we cannot have an infinite number of
  158. 6:10registers
  159. 6:11because they need to be close to the
  160. 6:13core
  161. 6:18so all our assembly code
  162. 6:21needs to be carefully crafted to utilize
  163. 6:24these registers for fast execution
  164. 6:27the number of registers is limited and
  165. 6:30it is one of the main features of the
  166. 6:31instruction set architecture
  167. 6:33some instructions at architectures like
  168. 6:36x86 have a very
  169. 6:38small number of registers there are only
  170. 6:41eight general purpose registers and then
  171. 6:42some
  172. 6:43specialized registers inside x86
  173. 6:47risk 5 has 32 registers how did
  174. 6:50we determine how did we come up with 32
  175. 6:53well um
  176. 6:54it is based based on a goldilocks
  177. 6:56principle
  178. 6:57smaller is faster but too small is bad
  179. 7:00um
  180. 7:01if you have too many of them it's going
  181. 7:02to slow down the machine gold deluxe
  182. 7:04principle says
  183. 7:05this porridge is too hot this forage is
  184. 7:07too cold this porridge is just
  185. 7:09right
  186. 7:13in rb variant of risk five
  187. 7:17each register is 32 bits wide
  188. 7:20these groups of 32 bits as we mentioned
  189. 7:22are
  190. 7:23called words in arbitrary two each word
  191. 7:26is four bytes 32 bits
  192. 7:30the textbook uses 64 bit wide
  193. 7:34words it is also word but it's a 64
  194. 7:38bit word so the width of a word is
  195. 7:42associated with the with the variant of
  196. 7:45the architecture
  197. 7:50let's dive a little bit more into the
  198. 7:53concept of registers
  199. 7:55so there are 32 registers in risk 5 and
  200. 7:58they're numbered
  201. 7:59by number numbered from 0 to 31.
  202. 8:03you usually refer to them as physical
  203. 8:06registers
  204. 8:07x0 to x31 x0
  205. 8:11we'll talk about that one uh later is
  206. 8:14very special
  207. 8:15because it is hardwired to zero you
  208. 8:18cannot change its value
  209. 8:19it always stores a zero because we like
  210. 8:22to have a zero
  211. 8:23handy um always around a representation
  212. 8:26of a zero
  213. 8:26always near the processor
  214. 8:30now registers will have their logical
  215. 8:33names
  216. 8:34we're gonna have to add them a bit later
  217. 8:40few other differences between the
  218. 8:41variables and the registers
  219. 8:44in c and other higher level programming
  220. 8:47languages
  221. 8:49variables need to be declared first and
  222. 8:51given a type
  223. 8:53so we would like to distinguish integers
  224. 8:55from characters
  225. 8:57um because it's kind of important
  226. 9:00to know that you know somebody should
  227. 9:02warn us
  228. 9:03if we try to add integers and characters
  229. 9:06we
  230. 9:06should make sure that that's actually
  231. 9:08what we want to do
  232. 9:09more importantly in in
  233. 9:13c we need to know how much memory is
  234. 9:16going to be
  235. 9:17taken by a particular data structure and
  236. 9:19that very much depends
  237. 9:20on the type data type that that uses
  238. 9:26so each variable can only represent that
  239. 9:29data type otherwise we would have
  240. 9:31all kinds of memory errors registers
  241. 9:34in assembly have no type um and
  242. 9:38it's the operation that operates on them
  243. 9:40that verb that operates on you know that
  244. 9:43is inside the instruction um determines
  245. 9:46what we actually do with the contents of
  246. 9:48the registers
  247. 9:51hope this makes sense will make a much
  248. 9:53more sense when we see
  249. 9:54particular examples of that
  250. 10:01one important note here
  251. 10:04is um it's always good to have comments
  252. 10:07in your code
  253. 10:08um so use comments to make your code
  254. 10:11more readable
  255. 10:12hash is used for this five comments
  256. 10:15anything to the
  257. 10:18to the left of the hash mark is your
  258. 10:21code
  259. 10:21anything to the right is ignored by the
  260. 10:23compiler and
  261. 10:25by the assembler and is not
  262. 10:28sent down to the processor
  263. 10:32there is difference from c that you
  264. 10:34cannot have multi-line comments like we
  265. 10:36had in the c
  266. 10:37star start the comment star slash ends
  267. 10:41the comment that does not exist in the
  268. 10:42assembly
  269. 10:43this style of commenting has been around
  270. 10:45for a long time here's a good
  271. 10:47chunk of history this is apollo's
  272. 10:50guidance computer and you can find all
  273. 10:52of
  274. 10:52its code on the github it has been
  275. 10:55recently about two years ago has been
  276. 10:56put on the github
  277. 10:58um the lead programmer was margaret
  278. 11:01hamilton um and you can see the printout
  279. 11:04of the code
  280. 11:05that i believe is for the lunar lander
  281. 11:07that is taller than her
  282. 11:09done i bet on a line printer
  283. 11:13and you will find hash marks
  284. 11:17and silico comments behind that
  285. 11:20uh like temporary i hope i hope hope
  286. 11:24all right back to the assembly
  287. 11:26instructions
  288. 11:28to try to wrap it up for this short
  289. 11:31segment
  290. 11:33in assembly language each statement is
  291. 11:36called an instruction it executes one
  292. 11:39of a short list or about four dish or so
  293. 11:43risk five instructions
  294. 11:46each line of assembly language contains
  295. 11:49at most one instruction
  296. 11:51and these instructions can be viewed as
  297. 11:53you know
  298. 11:54additions or subtractions or logical
  299. 11:56operations
  300. 11:59but let's pause here jump
  301. 12:02to the next video in a few minutes to
  302. 12:05see
  303. 12:06practical examples of how do they look
  304. 12:08like
  305. 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.