YouTube2Text

[CS61C FA20] Lecture 18.3 - Single-Cycle CPU Datapath I: R-Type Add Datapath — Transcript

by CS 61C Departmental · 1,715 words · 299 segments · language en · Watch on YouTube

Full transcript

  1. 0:01[Music]
  2. 0:11hi
  3. 0:12welcome back to design number x5 cpu
  4. 0:16we said that the cpu can be viewed as a
  5. 0:19complex state machine that consists of a
  6. 0:21data path and the control
  7. 0:22that are shared among all instructions
  8. 0:26but we're not going to go and go ahead
  9. 0:29and
  10. 0:29design the entire data path that is
  11. 0:31shared
  12. 0:32across all instructions um we
  13. 0:35let's try to start with something
  14. 0:37smaller so let's design a data path
  15. 0:39support one instruction type and in
  16. 0:41order to start fairly simple
  17. 0:43let's just pick one instruction let that
  18. 0:45be the r
  19. 0:47type add instruction remember our r
  20. 0:50type instructions those were all they
  21. 0:52all look similar and those were
  22. 0:54registered to register arithmetic and
  23. 0:56logic instructions
  24. 0:58they would operate on the contents of
  25. 1:00two source registers
  26. 1:02and store the result of that operation
  27. 1:05in the destination register rd
  28. 1:07they look similar they had the same
  29. 1:09opcode
  30. 1:100 1 1 0 0 1 1
  31. 1:14and same fields for the destination
  32. 1:16register
  33. 1:18first source register and the second
  34. 1:19source register and they differ by the
  35. 1:21encoding of the funct 3 field
  36. 1:23and this slight difference in the
  37. 1:2630th bit of instruction some of those
  38. 1:30were zero some of those
  39. 1:31were once so add rd
  40. 1:34rs1 rs2 instruction will take the values
  41. 1:36in the register rs1 and rs2
  42. 1:39and store the result in the register rd
  43. 1:43sub rd rs1 rs2 instruction
  44. 1:48would subtract the value of register rs2
  45. 1:52from the
  46. 1:52value of the register rs1 and store the
  47. 1:54result in the destination register
  48. 1:57rd to take a look a bit in more detail
  49. 2:00here is there is no new information at
  50. 2:03the top of the slide it
  51. 2:04just repeats the encoding for
  52. 2:06convenience
  53. 2:08but it helps us here illustrate what is
  54. 2:10the
  55. 2:12change in state of this state machine
  56. 2:16that executes instructions so
  57. 2:18instruction makes two changes to the
  58. 2:20machine state
  59. 2:22it updates the content of contents of a
  60. 2:26register rd
  61. 2:27with the sum of the values of rs1 and
  62. 2:30rs2
  63. 2:30without changing rs1 and rs2 and it
  64. 2:33updates the program counter to a new
  65. 2:35value
  66. 2:36that is four bytes larger so
  67. 2:39we need to build a data path that is
  68. 2:41going to do these two state updates
  69. 2:44so what we will see first we have a
  70. 2:46program counter
  71. 2:47that has its own state at the output of
  72. 2:51that program counter
  73. 2:52there is a current value of pc
  74. 2:58that points to the address in the
  75. 3:01instruction memory
  76. 3:03by pointing to a particular instruction
  77. 3:06in the
  78. 3:06instruction memory we'll read its
  79. 3:08contents
  80. 3:10and that will be an instruction that we
  81. 3:12would like to execute remember
  82. 3:14our model for the instruction memory is
  83. 3:15fairly simple we just need to point
  84. 3:18and the instruction is going to show up
  85. 3:20at the output we don't need the clock
  86. 3:22simultaneously we need this piece of a
  87. 3:25hardware we need this fixed function
  88. 3:27adder that will be always adding a value
  89. 3:294 to the current value of the pc and
  90. 3:33putting will be put pc plus 4 value at
  91. 3:37the input of the program counter
  92. 3:39now remember the contents of the
  93. 3:43program counter will not change until
  94. 3:45the next
  95. 3:46clock tick on the next rising edge of a
  96. 3:50clock
  97. 3:51program counter will take a new value of
  98. 3:54bc plus 4.
  99. 3:55but let's see what else do we need to do
  100. 3:58with this instruction
  101. 3:59so decoding instructions is
  102. 4:02fairly straightforward because we are
  103. 4:05going to always find
  104. 4:07things in the same place so our
  105. 4:09instruction
  106. 4:10here needs to point
  107. 4:14to the register file and conveniently
  108. 4:17we always are pointing to the same
  109. 4:19places in the register file we know that
  110. 4:21if we take
  111. 4:22a part of that instruction that
  112. 4:26contains bits 19 to 15
  113. 4:30will point to the address of rs1 so all
  114. 4:34what we need to do
  115. 4:35take those five bits from the
  116. 4:37instruction and connect them to the
  117. 4:39address port
  118. 4:40the first address port of the register
  119. 4:42file remember we are using
  120. 4:45a register file that simultaneously can
  121. 4:47read two
  122. 4:48registers so we're going to take the
  123. 4:50second
  124. 4:52collection of bits 24 to 20 and
  125. 4:55hook them up to the address of the
  126. 4:57second port
  127. 4:58as a result this register file
  128. 5:01will produce the outputs that correspond
  129. 5:06to the contents of a register rs 1 and
  130. 5:09rs2
  131. 5:10then all what we need to do is to add
  132. 5:11them together by using our alu
  133. 5:14alu is configured to be very simple here
  134. 5:16to just do addition so this is just an
  135. 5:18adder
  136. 5:19we'll get the new value at the output of
  137. 5:21an aldu
  138. 5:22that needs to be written into the
  139. 5:24register file to where does it should
  140. 5:26be written to the register rd where it's
  141. 5:29register rd we know from the instruction
  142. 5:31it is
  143. 5:33at the address that instruction bits 11
  144. 5:36to 7.2
  145. 5:37so on the next clock tick we are going
  146. 5:40to write that
  147. 5:41in to our destination register rd
  148. 5:46what else do we need to complete this
  149. 5:49well
  150. 5:49let's recap first what what we need to
  151. 5:52to do to
  152. 5:53to execute the whole instruction first
  153. 5:56we
  154. 5:59have the the current value of the
  155. 6:03program counter
  156. 6:04points to the address in the instruction
  157. 6:07memory
  158. 6:08that is going to after and the access
  159. 6:10delay
  160. 6:11produce the instruction its output
  161. 6:13simultaneously we are going to get a new
  162. 6:15value of the program counter pc plus 4
  163. 6:17but we are not going to write it in
  164. 6:19until the next
  165. 6:20clock tick now let's take a look at what
  166. 6:23is happening with the instruction itself
  167. 6:26decoding is straightforward we just
  168. 6:28pluck the parts of that instruction
  169. 6:30point
  170. 6:31to the register file notice that we
  171. 6:34already have the
  172. 6:35the address of the destination register
  173. 6:37so it will just show up at the input
  174. 6:40of the register file although it we are
  175. 6:42not going to do anything with it
  176. 6:44our results are going to show up at the
  177. 6:46output of the register file
  178. 6:48after the alu delay we are going to get
  179. 6:51the new value that should be written in
  180. 6:53the rd and it is just
  181. 6:54going to be sitting at the input of the
  182. 6:57register file until the
  183. 6:58next clock tick then two new values pc
  184. 7:02equals to pc plus four and rd equals to
  185. 7:05are the values of of rs1 and rs2
  186. 7:09is going to be updated on the next clock
  187. 7:12tick
  188. 7:13what do we need to complete this we need
  189. 7:15control and in this case control is
  190. 7:17fairly simple because
  191. 7:18we have a fixed function value that just
  192. 7:20does the addition so all what we need
  193. 7:22to do is to enable register file for
  194. 7:25writing to so we need to have this
  195. 7:29control register that enables
  196. 7:32writing into into the register file
  197. 7:36asserted the signal regret enable
  198. 7:39has to be equal to one let's take a look
  199. 7:41a bit at the timing
  200. 7:42of addition so here is the repeated data
  201. 7:46path it's exactly the same as what we
  202. 7:48have had in the previous
  203. 7:50slide we just added explicitly clock
  204. 7:53to see how does it orchestrates the
  205. 7:55operation of the cpu
  206. 7:59let's see what is happening as time goes
  207. 8:01by and time is going to move here
  208. 8:03from left to right
  209. 8:07we are going to look at what happens at
  210. 8:10roughly three clock
  211. 8:11cycles during three rising edges of a
  212. 8:14clock and we're actually going to focus
  213. 8:16only on two of them
  214. 8:17first on the first clock tick we update
  215. 8:20the value of the program counter and we
  216. 8:22write a new address into the program
  217. 8:24counter
  218. 8:25in this case it is one zero zero zero
  219. 8:28okay uh we're using some short kind of a
  220. 8:31short handle notation here yes because
  221. 8:33the program counter
  222. 8:34has 32 wires coming out of it
  223. 8:38so the single pc will have 32 binary
  224. 8:41values
  225. 8:42we are using bundle representation
  226. 8:44because it is really inconvenient to
  227. 8:46stare
  228. 8:46at 32 wires containing zeros and ones
  229. 8:50for a while we would not handle it well
  230. 8:52after about five minutes
  231. 8:54so we'll see this is a bundle that
  232. 8:55represents a hexadecimal value
  233. 8:57one zero zero zero corresponding to 32
  234. 9:01bits
  235. 9:02okay our current address is one zero
  236. 9:05zero zero
  237. 9:06and the value that we are going to get
  238. 9:09at the output of this adder is one
  239. 9:12zero zero four okay
  240. 9:16that is going to happen after the other
  241. 9:18delay so this
  242. 9:19adder has a little bit of a delay
  243. 9:26the next thing that is going to happen
  244. 9:27at about the same time
  245. 9:30after the access time
  246. 9:33of the memory we are going to get
  247. 9:37a value at the output of the memory that
  248. 9:40value
  249. 9:43here is the new instruction
  250. 9:47that instruction is another 32-bit
  251. 9:51binary number
  252. 9:52but that binary number instead of
  253. 9:54writing it a hexadecimal value we did
  254. 9:56another shorthand notation
  255. 9:57that shorthand notation basically says
  256. 10:01that we disassembled it and we got
  257. 10:03add x1 x2 x3
  258. 10:06as the value on our wires so that's a
  259. 10:09fairly straightforward thing
  260. 10:10to decode what we need to do is to point
  261. 10:13to
  262. 10:14parts of that instruction to the
  263. 10:16addresses of the register file that
  264. 10:18contain rs1 and rs2 and we get the
  265. 10:22values
  266. 10:23x2 and x3 as the contents of the
  267. 10:26registers
  268. 10:26x2 and x3 very good
  269. 10:30now in the next step we perform the alu
  270. 10:32we again have
  271. 10:33a bit of a delay there that corresponds
  272. 10:35to the addition delay
  273. 10:37and at the output of that register
  274. 10:41that alu we get the new value
  275. 10:44after a propagation delay so some of the
  276. 10:47values of register
  277. 10:492 and register 3 is sitting on these
  278. 10:52wires
  279. 10:53but it is not getting written into the
  280. 10:57register file for a while it'll get
  281. 10:59written on the next
  282. 11:01clock tick on the next rising edge of a
  283. 11:03clock so the next rising edge of a clock
  284. 11:08we store the values of ridge two and
  285. 11:10range three
  286. 11:12into the register file
  287. 11:16so simultaneously as we are updating
  288. 11:19that value in the register file that's
  289. 11:23when we are writing
  290. 11:24the new address into the program counter
  291. 11:28one zero zero four and we are continuing
  292. 11:30to execute the next instruction
  293. 11:32in the same order
  294. 11:37well the next that next instruction
  295. 11:39better be an ad because we don't know
  296. 11:40how to execute anything
  297. 11:42else we're going to see how we execute
  298. 11:44other things
  299. 11:45after a bit of a break see you then

About this transcript

This page contains the full transcript of [CS61C FA20] Lecture 18.3 - Single-Cycle CPU Datapath I: R-Type Add Datapath by CS 61C Departmental, generated from the public captions YouTube serves with the video. The transcript has 1,715 words across 299 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.