YouTube2Text

[CS61C FA20] Lecture 20.4 - Single-Cycle CPU Control: Control Logic Design — Transcript

by CS 61C Departmental · 1,960 words · 359 segments · language en · Watch on YouTube

Full transcript

  1. 0:01[Music]
  2. 0:08hello
  3. 0:08and welcome back to our s5 cpu design
  4. 0:11module
  5. 0:12in the past few segments we walked
  6. 0:15through the execution
  7. 0:16of several instructions and at moments
  8. 0:19that
  9. 0:19might have felt repetitive and perhaps
  10. 0:22boring
  11. 0:23but we wanted to accomplish two purposes
  12. 0:26by doing that the first one was to get a
  13. 0:30good sense
  14. 0:31of how long does it take us to execute
  15. 0:34an instruction
  16. 0:36and we actually ended up measuring that
  17. 0:38that will help us
  18. 0:39in the next module but the second
  19. 0:42purpose was to get a really
  20. 0:44good handle on what is the control logic
  21. 0:47supposed to do
  22. 0:49that's going to make this segment
  23. 0:52much easier to understand and make it
  24. 0:55look
  25. 0:55fairly straightforward
  26. 0:58so let's get into that first let's recap
  27. 1:02what do we expect control logic to do
  28. 1:04control logic can be viewed essentially
  29. 1:06as a lookup table this is a lookup table
  30. 1:10with a bunch of rows
  31. 1:13and columns rows are the inputs which
  32. 1:17would be
  33. 1:17the instructions that we would like to
  34. 1:19execute
  35. 1:21the columns would be the control bits
  36. 1:24so each row input is
  37. 1:28an instruction that we are running along
  38. 1:30with the two more inputs these are the
  39. 1:32branch
  40. 1:33compare comparison outcomes whether the
  41. 1:36operands are equal
  42. 1:37or less than remember those are the two
  43. 1:39arrows that were also pointing down into
  44. 1:40the control logic as the inputs
  45. 1:42we need those to figure out how to
  46. 1:44select some of the control signals
  47. 1:47and then each row has a particular set
  48. 1:50of control signals that are set
  49. 1:53that it needs to correctly execute so
  50. 1:56um our well uh familiar
  51. 1:59uh the instructions we are well familiar
  52. 2:01with is our ad
  53. 2:03the ad has its control word
  54. 2:07encoded in the first row so we can view
  55. 2:10this
  56. 2:10as a word it has a number of bits
  57. 2:15about 15 of them
  58. 2:19so it simply says what is the control
  59. 2:21what are the control bits supposed to be
  60. 2:23so we know that pc cell is supposed to
  61. 2:26be pointing to the input that will take
  62. 2:28the next instruction plus four
  63. 2:30immediate select is don't care whether
  64. 2:31it's a zero or one
  65. 2:33or uh actually this is a a three bit
  66. 2:36value for the immediate select so
  67. 2:38they can be anything zero zero zero zero
  68. 2:40zero one
  69. 2:41uh zero one zero and so on and it
  70. 2:43doesn't matter to us
  71. 2:46um also branch sinus
  72. 2:50does not matter either because we are
  73. 2:51not executing a branch
  74. 2:54but a cell and b cell signals
  75. 2:57do matter and they should be taking the
  76. 3:00inputs from the registers alu is
  77. 3:04a 4-bit control signal because
  78. 3:07you can do quite a bit of stuff in this
  79. 3:10case we're going to encode it to do the
  80. 3:12addition
  81. 3:13we're going to set its control bits to
  82. 3:16do the
  83. 3:17addition and then the memory read write
  84. 3:20is going to be set to read
  85. 3:21register write enable is going to be one
  86. 3:24and finally right back select is a two
  87. 3:26bit
  88. 3:26control signal that will be set to right
  89. 3:30back from the alu
  90. 3:33so how do we implement this control
  91. 3:35logic this essentially
  92. 3:36through table there are two options to
  93. 3:38do that one of them is to use a
  94. 3:40read-only memory
  95. 3:41the other option is to use the control
  96. 3:44combinational logic a bunch of
  97. 3:46hands and words read-only memory is
  98. 3:50like a standard memory that we have seen
  99. 3:52before
  100. 3:54except that we don't write into it
  101. 3:57we just read from it so that's why it's
  102. 3:58called red only
  103. 4:01we actually write to it at the design
  104. 4:03time when we are designing this control
  105. 4:06logic we populated with ones and zeros
  106. 4:09whatever we
  107. 4:10whatever we would like to see in
  108. 4:11particular control words
  109. 4:14so it's relatively easy to do that and
  110. 4:17then we will just
  111. 4:18read it by pointing to a particular
  112. 4:21control word that you would like to get
  113. 4:24out of this
  114. 4:25read-only memory
  115. 4:29so a designer can keep reprogramming it
  116. 4:32while designing it and then we can test
  117. 4:34it out by executing a whole bunch of
  118. 4:36instructions
  119. 4:37it's really really easy it's popular
  120. 4:40during prototyping
  121. 4:42it is also popular popular when we are
  122. 4:44trying to perhaps add an
  123. 4:46extension so for example we would like
  124. 4:48to add
  125. 4:49a compressed part of the instruction set
  126. 4:53risk 5 instruction set we have heard
  127. 4:54about compressed instructions before
  128. 4:56so you would just add that part of the
  129. 4:58table
  130. 4:59to our rom and then try it out in
  131. 5:02practice
  132. 5:03when we design real chips
  133. 5:07control will be designed as a bunch of
  134. 5:09end and ors because that's more compact
  135. 5:12and it is faster
  136. 5:16but let's actually see what do we need
  137. 5:18in order to implement
  138. 5:19control logic what kind of inputs do we
  139. 5:22need well we need to to have a unique
  140. 5:24representation for every single one of
  141. 5:26these instructions
  142. 5:27and we need those two bits for the
  143. 5:30branch outcomes
  144. 5:33instructions are 32 bits wide but
  145. 5:36the relevant information is stored in
  146. 5:38only nine bits so somebody can say that
  147. 5:40risk 5i arbitrary to i is
  148. 5:43just a 9-bit isa
  149. 5:47where are the relevant bits the relevant
  150. 5:50bits are
  151. 5:51the upper five bits of the opcode
  152. 5:54the entire function three field
  153. 5:57and that one bit from for
  154. 6:01from the function seven field the third
  155. 6:03bit of the instruction
  156. 6:04that is be used for encoding some of the
  157. 6:07add subs
  158. 6:08and shifts
  159. 6:11so there is just a total of nine of them
  160. 6:15five plus three plus one if we are going
  161. 6:17to add some instructions like a
  162. 6:18compressed instruction we would need to
  163. 6:20take
  164. 6:20a look also at the last two bits or the
  165. 6:23least significant
  166. 6:24two bits which one
  167. 6:27which are set to be one and one for
  168. 6:32rb32i
  169. 6:34but for now since we're only dealing
  170. 6:37with
  171. 6:37arbitrary 2i instructions in order to
  172. 6:40decode them
  173. 6:41we just need those nine bits from the
  174. 6:44instruction
  175. 6:46and two additional bits which are the
  176. 6:49branch outcomes
  177. 6:50so we would point to the rom
  178. 6:53with an address that is 18 bits wide
  179. 6:57and we are going to read out of that rom
  180. 7:00a 15 bit
  181. 7:01control word this control world word
  182. 7:04will
  183. 7:04contain one bit for a pc select three
  184. 7:06bits for the immediate select
  185. 7:08uh a bit for sineness of a branch a bit
  186. 7:12for
  187. 7:12a select and b select each alu select
  188. 7:16will be
  189. 7:16a 4-bit control signal memory read write
  190. 7:20is a single
  191. 7:21control bit register write enable
  192. 7:25is also a single control bit and finally
  193. 7:27right-back select
  194. 7:28is a 2-bit output how does the
  195. 7:31rom actually work inside
  196. 7:36it's it looks like a lookup table table
  197. 7:38literally
  198. 7:40we are going to address this lookup
  199. 7:42table
  200. 7:43with the same stuff that we have had in
  201. 7:45the initial
  202. 7:46original initial lookup table um we are
  203. 7:49going to have
  204. 7:51instructions represented by
  205. 7:54their nine bit values plus two
  206. 7:58bits that represent the branch outcomes
  207. 8:01and then in
  208. 8:04each row here will be a corresponding
  209. 8:07control word
  210. 8:08for those instructions first what we do
  211. 8:12we decode the address
  212. 8:17um these inputs the the the
  213. 8:23the the instruction types are binary
  214. 8:26encoded
  215. 8:28the output of the address decoded is so
  216. 8:30called one hot
  217. 8:32only one of these lines is going to
  218. 8:35light up we are going to address only
  219. 8:37one control word
  220. 8:39because that's what makes sense we don't
  221. 8:40want to have to control two different
  222. 8:42control words that would confuse the
  223. 8:44data path
  224. 8:44we only produce one control word
  225. 8:48for each instruction or in instruction
  226. 8:51branch combination
  227. 8:53so for example our ad would
  228. 8:56point to the first line in this
  229. 8:58read-only memory
  230. 9:00and
  231. 9:04if we are executing an ad this is the
  232. 9:07only wire that is going to light up that
  233. 9:09is this is the only wire that is going
  234. 9:10to be true
  235. 9:11all the other ones are going to be zeros
  236. 9:14so
  237. 9:14the output of this
  238. 9:18controller we are going to get a control
  239. 9:20word
  240. 9:22that only corresponds to an add
  241. 9:26all the other ones are zeros
  242. 9:32in a way you can view this
  243. 9:35as an and or structure
  244. 9:38in order to only have one of these
  245. 9:41lines enabled this address decoder has
  246. 9:44to be
  247. 9:45a fairly wide end and then in order to
  248. 9:48form the output controller word
  249. 9:51it can be just an or that's the simplest
  250. 9:53way to implement it
  251. 9:54so this is an and or structure
  252. 9:58in general there is a lot of redundancy
  253. 10:01here with
  254. 10:02you know many of these entries are going
  255. 10:04to be zeros
  256. 10:05so that's the idea of trying to simplify
  257. 10:09the the entire control logic into
  258. 10:12a smaller numbers number of ands and ors
  259. 10:15so in this case let's take an example
  260. 10:18what is perhaps the simplest
  261. 10:20encoding example that we have in our
  262. 10:23instruction set
  263. 10:24and that would be whether the branch is
  264. 10:27assigned
  265. 10:27or not so let's take a look at what
  266. 10:30encodes
  267. 10:32that we are dealing with a branch these
  268. 10:34are the instruction bits
  269. 10:35six to two these five instruction bits
  270. 10:37are telling us
  271. 10:38that it's a branch if the values are one
  272. 10:41one one
  273. 10:42and one one zero zero zero
  274. 10:46and then we need to find out in
  275. 10:50the funct 3 field function 3 field what
  276. 10:53kind of a branch
  277. 10:54it is so
  278. 10:59when looking at these the bottom two the
  279. 11:01last two
  280. 11:02are the unsigned branches vltu
  281. 11:06and bgeu what is common for them
  282. 11:09the and different for the other
  283. 11:12instructions
  284. 11:13well you can take a look at this middle
  285. 11:14bit instruction three bit
  286. 11:17it is true only for those two
  287. 11:20so that sets the sinus of a branch
  288. 11:23in order to decode this branch we just
  289. 11:25need to look at that
  290. 11:28middle bit instruction three bit and it
  291. 11:30tells us
  292. 11:31whether the branch is signed or not so
  293. 11:34that control signal
  294. 11:35is essentially equal to instruction 13
  295. 11:38and the branch because you know this bit
  296. 11:40will be true for
  297. 11:42other types of instructions in order to
  298. 11:48decode the branch right i mean the
  299. 11:50branch is encoded
  300. 11:52with the
  301. 11:57lower bits
  302. 12:00so it is i
  303. 12:04six and
  304. 12:09i5 and
  305. 12:13not i4
  306. 12:16and not i 3
  307. 12:21and not i 2
  308. 12:25that is our branch
  309. 12:31that tells us that the codes all the
  310. 12:33branch instructions
  311. 12:35and then to just select
  312. 12:38that we are looking for an unsigned
  313. 12:40branch we add
  314. 12:41that with the instruction bit 13. fairly
  315. 12:44simple isn't it
  316. 12:46this is a wide
  317. 12:506 bit wide and gate
  318. 12:54keep in mind that sometimes six bit wide
  319. 12:57end gates may not be the most practical
  320. 12:59thing to implement
  321. 13:00so we'll try to break this down
  322. 13:01typically into
  323. 13:03a couple of gates that's what
  324. 13:06our boolean manipulation is for isn't it
  325. 13:11let's design the decode logic for add
  326. 13:15so add is just one line
  327. 13:18in this in this through table
  328. 13:22that has our nine bits you know here is
  329. 13:25our add
  330. 13:27so what we will do to decode that we are
  331. 13:32executing an add well he would just
  332. 13:34write down the expression
  333. 13:35that it is equal to i3
  334. 13:40instruction bit being false
  335. 13:43i14 is false i13
  336. 13:46is false i12 is false all of them are
  337. 13:48zeros
  338. 13:49and then we need to end this with an r
  339. 13:51type instruction
  340. 13:53our type is encoded as
  341. 14:00i6 being false i5 being true i4 being
  342. 14:04through
  343. 14:05i3 being false i2 being
  344. 14:10false and that's it we can if we are
  345. 14:13adding other
  346. 14:14extensions we would have to end this
  347. 14:17with
  348. 14:17one one in the last bit positions but we
  349. 14:20don't have to
  350. 14:21for the purpose of our project because
  351. 14:24we don't have any other instructions
  352. 14:27and that's it we've just finished
  353. 14:30all what we need to know about
  354. 14:31instruction decoding
  355. 14:33and we've done more than that we
  356. 14:34actually built
  357. 14:37a complete risc-v processor we should
  358. 14:39celebrate that
  359. 14:40which we'll do after a bit of a break

About this transcript

This page contains the full transcript of [CS61C FA20] Lecture 20.4 - Single-Cycle CPU Control: Control Logic Design by CS 61C Departmental, generated from the public captions YouTube serves with the video. The transcript has 1,960 words across 359 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.