YouTube2Text

[CS61C FA20] Lecture 18.5 - Single-Cycle CPU Datapath I: Datapath with Immediates — Transcript

by CS 61C Departmental · 1,140 words · 203 segments · language en · Watch on YouTube

Full transcript

  1. 0:01[Music]
  2. 0:11hi
  3. 0:12welcome back let's continue with our
  4. 0:13risk 5 cpu design
  5. 0:15we have designed a data path and a
  6. 0:17control that supports
  7. 0:18all r types we have seen how
  8. 0:21we support the execution of the register
  9. 0:24based edition
  10. 0:25and then extended it extended it to
  11. 0:28support subtraction
  12. 0:29and then all the other r types let's see
  13. 0:32what do we need
  14. 0:32in order to support operations with
  15. 0:35immediates
  16. 0:38first let's recap what is uh what are
  17. 0:41how do our
  18. 0:42immediate instructions look like in this
  19. 0:45example add immediate
  20. 0:47takes an immediate value of -50
  21. 0:51adds it to the contents of a register x1
  22. 0:55and stores the result in x15
  23. 0:59it has similar but slightly different
  24. 1:01format from r types
  25. 1:03it has a different op code but the
  26. 1:06fields for
  27. 1:06our d and rs1 are the same
  28. 1:10as what we have had in our types um
  29. 1:12funct
  30. 1:133 function 3 encoding is the same as
  31. 1:15what we have seen before
  32. 1:17but instead of rs2
  33. 1:20field it was 5 bits wide and the
  34. 1:23function 7 field
  35. 1:24that was seven bits wide it has one
  36. 1:2712-bit field
  37. 1:28that stores the immediate value
  38. 1:32so let's take a look at how do we plug
  39. 1:34that into a data path
  40. 1:36let's start with our add sub data path
  41. 1:40or actually a general data path that
  42. 1:42supports r types
  43. 1:44and see how we can modify it to
  44. 1:47add support for the immediates remember
  45. 1:50we had our program counter
  46. 1:52our fixed adder that would increment
  47. 1:55that program counter
  48. 1:58by four on every clock tick
  49. 2:02instruction memory register file and the
  50. 2:04alu
  51. 2:05and the appropriate control
  52. 2:10now instead of
  53. 2:13adding two
  54. 2:16register values rs1 and rs2 we would
  55. 2:18like to change that
  56. 2:20and add the contents of rs1
  57. 2:23to an immediate or any media to a
  58. 2:25contents of registrar s1
  59. 2:26and store it in rd we got
  60. 2:32two thirds of what we need here we got
  61. 2:35the value from
  62. 2:36rs1 in the right place in the alu
  63. 2:40and we are writing it into a correct
  64. 2:42place in the register file
  65. 2:44except that the second input of the alu
  66. 2:47or what we would call a b
  67. 2:49input b input of the alu we have
  68. 2:52rs2 connected instead of the immediate
  69. 2:56so we could build another data path that
  70. 2:57would be supporting immediates we will
  71. 2:59drip out everything instead
  72. 3:01of this input being connected to rs2 we
  73. 3:05can connect it
  74. 3:06to connect an immediate to it
  75. 3:09but let's not do that let's just build
  76. 3:12one data pad it
  77. 3:13supports both our types and i types and
  78. 3:15how would you do that
  79. 3:16well we would just put a multiplexer so
  80. 3:19this multiplexer selects between
  81. 3:22rs2 value and the immediate
  82. 3:26based on some select signal which is b
  83. 3:29cell and b cell stands for b select
  84. 3:33b operand for the alu so if it is equal
  85. 3:36to zero
  86. 3:38we will pick rs2 if it is equal to one
  87. 3:41we'll pick the immediate
  88. 3:42keep in mind that both of these inputs
  89. 3:44are 32-bit
  90. 3:46values meaning there are 32-bit
  91. 3:50wires you know 32 different wires coming
  92. 3:53in
  93. 3:53the input 0 and the input 1 and 32 wires
  94. 3:57are coming out
  95. 3:59based on one select signal
  96. 4:02now we got pretty much everything we
  97. 4:05needed here
  98. 4:06and we do need to get this immediate
  99. 4:09from somewhere
  100. 4:10immediate is in the upper part of the
  101. 4:12instruction and it is only 12 bits
  102. 4:15wide so we need to take that 12 bit
  103. 4:18wide value and make 32 bits out of that
  104. 4:22so we need a little block here that will
  105. 4:25do that immediate generation
  106. 4:28so you'll be controlled by this
  107. 4:30immediate select
  108. 4:34what we'll find out a little bit later
  109. 4:35on
  110. 4:37is that we will
  111. 4:40see different types of immediates
  112. 4:42remember different instruction types
  113. 4:44have different
  114. 4:45encodings for the immediates so we'd
  115. 4:48like to reuse that block so we'll say
  116. 4:50make us an immediate of an i type
  117. 4:53this time but we'll see that a bit later
  118. 4:59so let's see what happens when we light
  119. 5:02up this data path and
  120. 5:03this is a fun example here so when we
  121. 5:06light up the data path we first read the
  122. 5:10program counter program counter points
  123. 5:12to the instruction memory
  124. 5:13reads out the the the contents of the
  125. 5:16instruction memory
  126. 5:17and reads out the instruction that it
  127. 5:19that it
  128. 5:21addresses and updates the program
  129. 5:24counter
  130. 5:25now we got all of this instruction so
  131. 5:28we will point to the register file
  132. 5:32to the three parts of a register file
  133. 5:34all three parts of the register file
  134. 5:37and simultaneously start generating the
  135. 5:40immediate
  136. 5:40now you may wonder over here oh don't
  137. 5:44can do don't we need to disconnect this
  138. 5:46input
  139. 5:48b we really don't want that
  140. 5:51rs2 value well we are going to
  141. 5:55generate both rs1 and rs2 at the output
  142. 5:58of the
  143. 5:58register file and we are going to well
  144. 6:01use the rs1
  145. 6:02value but rs2 simply will be ignored
  146. 6:06remember our register file always reads
  147. 6:09we just give it an address it produces
  148. 6:11an output
  149. 6:12we don't need a clock or anything to
  150. 6:14make that happen
  151. 6:15so produce that value but our
  152. 6:18multiplexer will be set
  153. 6:20to take the value of the immediate and
  154. 6:23forward it to the alu so alu will
  155. 6:26calculate
  156. 6:27the new value the contents of
  157. 6:30rs1 plus the immediate and put it back
  158. 6:34at the input of the register file on the
  159. 6:37next clock tick
  160. 6:38we are going to write that new value new
  161. 6:41state
  162. 6:41into the the destination register rd
  163. 6:45together with updating the
  164. 6:48the program counter and that's it this
  165. 6:50is a support for the immediates
  166. 6:53let's take a little bit um
  167. 6:56just one more thing here the key thing
  168. 6:59here is
  169. 7:00we have to have b select set to one
  170. 7:03so one more thing uh here is um
  171. 7:07how do we generate the immediate here so
  172. 7:10if we were just
  173. 7:11to take a look uh if we just needed to
  174. 7:14support i type immediates
  175. 7:16that would have been very simple
  176. 7:19our i type immediates are in the upper
  177. 7:2212
  178. 7:22bits of the instruction so what you
  179. 7:25would do you would just
  180. 7:26take 12 wires and
  181. 7:30move them down to the lowest 12 bits of
  182. 7:33the immediate
  183. 7:35so we'll take 12 wires and wire them
  184. 7:38down
  185. 7:39to to the immediate what do we do
  186. 7:42with the upper 20 bits well all what we
  187. 7:45need to do is to copy
  188. 7:48the most significant bit of the
  189. 7:50instruction field
  190. 7:52um to perform sign extension so we will
  191. 7:54just make
  192. 7:5520 copies of that most significant bit
  193. 7:59of the immediate value
  194. 8:06in general we are going to be using a
  195. 8:07few multiplexers to support
  196. 8:09different types of immediates when we
  197. 8:11introduced
  198. 8:12introduce the other formats support for
  199. 8:16the other formats
  200. 8:17a bit later we'll break now and we're
  201. 8:20going to
  202. 8:21take a look at more instructions see you
  203. 8:24then

About this transcript

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