YouTube2Text

[CS61C FA20] Lecture 20.3 - Single-Cycle CPU Control: Instruction Timing — Transcript

by CS 61C Departmental · 3,009 words · 545 segments · language en · Watch on YouTube

Full transcript

  1. 0:01[Music]
  2. 0:09hello
  3. 0:10and welcome back to the rest 5 cpu
  4. 0:12design module
  5. 0:13we have designed a configurable data
  6. 0:15path and
  7. 0:16we have outlined the logic control logic
  8. 0:20that sets up the data path to execute
  9. 0:22pretty much every instruction that we
  10. 0:24have in the rp32i
  11. 0:26base instruction set in that process we
  12. 0:29have
  13. 0:29figured out that there is a lot of stuff
  14. 0:32that happens concurrently
  15. 0:33in both data path and the logic for
  16. 0:37example
  17. 0:37while we are retrieving an operand from
  18. 0:40the register file
  19. 0:42we are generating the immediate as well
  20. 0:46concurrently we've also
  21. 0:49gotten some sense for the timing timing
  22. 0:52is
  23. 0:53very important um obviously these
  24. 0:57this logic that implements the data path
  25. 0:59and the control
  26. 1:00takes some time to complete
  27. 1:04and that critical path the longest time
  28. 1:08that it takes us to execute
  29. 1:09an instruction in a data path sets how
  30. 1:12frequently we can
  31. 1:16operate around the clock on this
  32. 1:18processor and sets how many instructions
  33. 1:20we can
  34. 1:20run per second we have gotten
  35. 1:24only qualitative sense for timing so far
  36. 1:28so we're going to try to make it a bit
  37. 1:31more quantitative
  38. 1:33in this section so to do that
  39. 1:36let's examine our well-known data path
  40. 1:38that we've had before so this is the
  41. 1:40same pictures
  42. 1:41as we have had before along with the
  43. 1:44control
  44. 1:44module below it and we'll execute
  45. 1:48a very familiar instruction which is a
  46. 1:51register based ad
  47. 1:54this instruction runs like every single
  48. 1:56one every
  49. 1:57single one that we have already seen
  50. 2:00running on this data path
  51. 2:02it starts the execution on the rising
  52. 2:04edge of a clock
  53. 2:06that's when we update the program
  54. 2:07counter the new value of the program
  55. 2:09counter appears
  56. 2:10at its output and there are two things
  57. 2:13that happen concurrently
  58. 2:15we add four to it and we fetch
  59. 2:18the instruction from the instruction
  60. 2:20memory those two processes
  61. 2:22are will take about a comparable amount
  62. 2:26of time i wouldn't say
  63. 2:27the same amount of time which one is
  64. 2:30going to be longer
  65. 2:31it really depends on the technology that
  66. 2:33we implement
  67. 2:34this in
  68. 2:38so we are going to have
  69. 2:41a new value of pc plus 4 ready
  70. 2:44at the input of this multiplexer but the
  71. 2:47correct value is not going to be
  72. 2:49present in front of the pc until we have
  73. 2:52the value
  74. 2:53of pc cell settled
  75. 2:56so concurrently with that we will fetch
  76. 2:58the instruction from the instruction
  77. 3:00memory and when that signal
  78. 3:02appears we have completed the phase
  79. 3:04first phase of this
  80. 3:05execution which is the instruction fetch
  81. 3:08now at that moment two other things are
  82. 3:12going to happen concurrently
  83. 3:14we will start the process of
  84. 3:17retrieving the values of the source
  85. 3:19registers rs1 and rs2 from the register
  86. 3:21file
  87. 3:22and we will start decoding the
  88. 3:26instruction
  89. 3:26as we decode the instruction we'll
  90. 3:28figure out that it's an add
  91. 3:30that add will tell us that
  92. 3:33we should set the pc cell to pick the
  93. 3:36top
  94. 3:37input from this multiplexer right there
  95. 3:40that the immediate select
  96. 3:44control should be a donk here because we
  97. 3:47don't have an immediate in this
  98. 3:48instruction register write enable
  99. 3:51should be set to one because we do have
  100. 3:52to write the value
  101. 3:54of the addition back into the
  102. 3:56destination register of a register file
  103. 3:59all branch signals are donkeyers a
  104. 4:02select and b select are both zeros
  105. 4:03because we are selecting the outputs of
  106. 4:06the outputs of the register file
  107. 4:10alu select is set to add memory read
  108. 4:12write is set
  109. 4:13to read because we are not writing to
  110. 4:15the memory and right back select is set
  111. 4:17to one such that we will be writing back
  112. 4:19the alu value
  113. 4:20as soon as the signal pc cell settles
  114. 4:24we will have a valid output
  115. 4:28of that multiplexer set at the input of
  116. 4:31the program counter but the new value
  117. 4:32into a program counter is not going to
  118. 4:34be written
  119. 4:35until we
  120. 4:39complete the cycle and set up the next
  121. 4:44rising edge of the clock
  122. 4:47what you see here is that this path is
  123. 4:50shorter than the one that is going to
  124. 4:54happen concurrently there is way more
  125. 4:56blocks
  126. 4:57downstream let's see what is happening
  127. 4:58downstream
  128. 5:00so we are still in the instruction
  129. 5:02decode phase it will complete at the
  130. 5:04moment when we get the valid outputs
  131. 5:07of the register file from the register
  132. 5:09file
  133. 5:10so the register file read completes the
  134. 5:14instruction decode
  135. 5:16phase of execution then we proceed with
  136. 5:19the execute phase during that we will
  137. 5:22go through these two multiplexers there
  138. 5:25are two multiplexers but
  139. 5:27both propagation delays are happening
  140. 5:29concurrently
  141. 5:30so we only count for one propagation
  142. 5:32delay they there
  143. 5:33and then we go through the alu delay
  144. 5:36and we have completed the execute phase
  145. 5:40so three phases are done there is no
  146. 5:42memory access phase
  147. 5:43when we are doing register based ad so
  148. 5:45we are proceeding to complete
  149. 5:47the write back right back doesn't have
  150. 5:49much here
  151. 5:51there is only one multiplexer in the
  152. 5:53path and
  153. 5:55we have data ready to be written back
  154. 5:58into the destination register
  155. 6:01it will be written on the next rising
  156. 6:04edge of a clock
  157. 6:05but keep in mind that this input
  158. 6:08into the register rd has to be stable
  159. 6:12setup time before the rising edge of the
  160. 6:14clock
  161. 6:15so that has to be accounted for into the
  162. 6:17delay
  163. 6:19so on the next rising edge of a clock
  164. 6:21we'll update both the destination
  165. 6:22register and the program counter let's
  166. 6:24take a look at the timing diagrams
  167. 6:26that describe this in a bit more detail
  168. 6:28and describe more of this concurrency
  169. 6:30of operations that are happening during
  170. 6:32the execution of the instruction
  171. 6:34so this is the same data path that we
  172. 6:36have seen before we are just
  173. 6:37annotating signals and the timing
  174. 6:41clock signal has its high and low values
  175. 6:45each one clock cycle corresponds to
  176. 6:48the time from one rising edge of a clock
  177. 6:50to the next rising edge of a clock so we
  178. 6:52have
  179. 6:53a total of two clock cycles in
  180. 6:56this diagram two complete clock cycles
  181. 6:58in this diagram
  182. 7:00um we are going to show what we have
  183. 7:04at the output of a program counter at
  184. 7:06the output of a program counter
  185. 7:08we have a bundle of 32 wires we are not
  186. 7:11going to show these
  187. 7:1232 wires individually like we haven't
  188. 7:16we're going to use a shorthand notation
  189. 7:17that we've introduced before
  190. 7:19we're going to show them as a bundle and
  191. 7:22we are going to associate a hexadecimal
  192. 7:24value with that bundle
  193. 7:26in this case let's say the program
  194. 7:27counter has a value
  195. 7:29of one zero zero zero hex
  196. 7:33the value
  197. 7:37at
  198. 7:40the output of the program counter
  199. 7:45is valid after the propagation delay
  200. 7:48that is equal to t
  201. 7:50clock to q
  202. 7:54and all 32 outputs of that
  203. 7:57program counter are valid at the same
  204. 7:59time
  205. 8:00now two things are happening
  206. 8:02concurrently we're
  207. 8:04fetching an instruction from the memory
  208. 8:06and the
  209. 8:08we're updating the program counter
  210. 8:12incrementing the program counter the
  211. 8:14value of pc plus 4
  212. 8:16gets stable gets updated after
  213. 8:19a propagation delay through that adder
  214. 8:22but there is one important difference
  215. 8:24here while
  216. 8:26when we are updating pc on the rising
  217. 8:29edge of a clock
  218. 8:30all of those outputs
  219. 8:33changed at the same time after clock to
  220. 8:35output delay
  221. 8:36because all of them go through the same
  222. 8:39type of
  223. 8:39flip-flops or the same flavor of a
  224. 8:42flip-flop
  225. 8:44these pc plus four outputs are
  226. 8:47not going to show up all at the same
  227. 8:50time
  228. 8:51the least significant bits of addition
  229. 8:54become
  230. 8:55stable sooner than the more significant
  231. 8:59bits
  232. 8:59so we're going to have multiple of these
  233. 9:01crosses in these diagrams we're always
  234. 9:03showing the last transition
  235. 9:05which is the one that is going to be in
  236. 9:07the critical path
  237. 9:09so after the propagation delay of the
  238. 9:13most significant bit the pc plus 4
  239. 9:16is the new value and at the same time
  240. 9:19we are proceeding with fetching the
  241. 9:21instruction
  242. 9:23the instruction is going to show up at
  243. 9:26the output of the instruction memory
  244. 9:28and it's also going to have 32 bits here
  245. 9:31we are using annotation where we
  246. 9:34this uh assemble that instruction and
  247. 9:37find out that it is an ad instead of
  248. 9:39showing 32 bits here we show it's an ad
  249. 9:41that adds extra contents of x2 and x3
  250. 9:44and stores it in x1
  251. 9:46propagation delays are comparable to
  252. 9:50the other delays now control logic
  253. 9:54is going to follow that at this moment
  254. 9:57when the
  255. 9:57instruction has been read from the
  256. 10:00memory we have finished the instruction
  257. 10:02fetch
  258. 10:04phase of execution so this is our
  259. 10:08instruction fetch we are proceeding with
  260. 10:12the next phase
  261. 10:13which is instruction decode control
  262. 10:16logic
  263. 10:17does a part of that and sets the
  264. 10:20control bits you know reading
  265. 10:23the registers register values takes
  266. 10:27usually
  267. 10:27longer time than that and when they
  268. 10:31those outputs are stable
  269. 10:33we have completed the sixth second phase
  270. 10:37of execution which is
  271. 10:40instruction decode
  272. 10:43then we perform the alu operation
  273. 10:48and at that point we have completed
  274. 10:51the execute phase finally
  275. 10:55we are ready to write
  276. 10:59the result back into the register file
  277. 11:05there is a short delay between the alu
  278. 11:07and
  279. 11:09and the point when the write back signal
  280. 11:11is stable that corresponds to
  281. 11:13this final multiplexer delay but one
  282. 11:16thing
  283. 11:16that we have to keep in mind we cannot
  284. 11:20have the next rising edge of a clock too
  285. 11:23early otherwise we will be violating the
  286. 11:25setup time
  287. 11:25so we have to respect the setup time
  288. 11:28before this
  289. 11:29rising edge of our clock tsu
  290. 11:33so this last transition
  291. 11:36out of the from the right back signal
  292. 11:41cannot come after the setup time of
  293. 11:45the register in the register file so
  294. 11:51we are going to write the correct value
  295. 11:53into the register so register one
  296. 11:55gets a new value that is the sum of the
  297. 11:58contents of register two
  298. 11:59and register three and notice that both
  299. 12:04program counter and the register file
  300. 12:08are updated at the same time
  301. 12:11clock to queue delay after the rising
  302. 12:14edge of a clock
  303. 12:16hopefully this was clear
  304. 12:19let's take a look at you know if we can
  305. 12:21quantify this
  306. 12:23timing what we said there are
  307. 12:26two things that are happening
  308. 12:28concurrently and
  309. 12:29we are assuming here that the control
  310. 12:32logic definitely takes
  311. 12:34shorter time than the time that it takes
  312. 12:37us
  313. 12:38to retrieve the data from the register
  314. 12:40file
  315. 12:41so there are two loops that set the
  316. 12:43timing
  317. 12:44one that involves the propagation delay
  318. 12:47from the program counter
  319. 12:48through the other and the multiplexer
  320. 12:50and comes back to that program counter
  321. 12:53that that delay path equals to clock to
  322. 12:55output delay of the program counter
  323. 12:58plus time to add time to propagate
  324. 13:01through the multiplexer and then has to
  325. 13:02meet the setup time
  326. 13:04of that program counter
  327. 13:08the other path is clearly longer it's
  328. 13:10the yellow one
  329. 13:11in the yellow path we go through the
  330. 13:14clocked output delay of the program
  331. 13:15counter
  332. 13:17access time for the instruction memory
  333. 13:19access time for the register file
  334. 13:23multiplexer alu delay another
  335. 13:26multiplexer and then we again have to
  336. 13:28meet the setup time but
  337. 13:29not of the program counter the setup
  338. 13:31time of the
  339. 13:33register file so we can write correctly
  340. 13:36the value into the
  341. 13:40rd so those two if you just
  342. 13:44compare these two terms these two
  343. 13:46equations
  344. 13:47it turns out that the max of these two
  345. 13:50is always going to be um i
  346. 13:54i t i mem t reg t max t
  347. 13:58l u plus another t max so
  348. 14:01the critical path here is the pathways
  349. 14:05execution
  350. 14:06not update of the program counter
  351. 14:12okay this instruction had only four
  352. 14:15phases of execution let's take
  353. 14:17a look at an instruction that has five
  354. 14:19phases of
  355. 14:20five phases of execution which is load
  356. 14:23word
  357. 14:23or lw so in that case it works
  358. 14:28exactly the same way that the extraction
  359. 14:31is executed as all the others
  360. 14:33on the rising edge of a clock we update
  361. 14:34the program counter
  362. 14:38and the new value appears at the output
  363. 14:40of a program counter
  364. 14:41then we have two simultaneous
  365. 14:44paths that get exercised we go through
  366. 14:47the other
  367. 14:48and update the value of a program
  368. 14:50counter and fetch a new instruction
  369. 14:52then we start decoding that instruction
  370. 14:55we set the control bits appropriately
  371. 14:57pc plus 4 is
  372. 15:00what is bc cell set to immediate select
  373. 15:05is set to
  374. 15:08be of a type of i immediate because
  375. 15:12loads are of immediate of uh i types
  376. 15:16register write enable is set to one
  377. 15:18because we're going to write
  378. 15:19back the result um from the that we
  379. 15:23retrieve from the memory uh all branches
  380. 15:25are set
  381. 15:26to don't cares a select is zero
  382. 15:29to take rs1 and b select the set
  383. 15:32to one to take the immediate alu adds
  384. 15:35those two together
  385. 15:37memory read write is set to read because
  386. 15:39we're actually this time reading
  387. 15:40the memory and right back select is set
  388. 15:43to zero
  389. 15:44such that we send the memory
  390. 15:47output to be written back into the
  391. 15:49destination register
  392. 15:51we proceed with executing this
  393. 15:53instruction so since
  394. 15:56the pc 4 is ready
  395. 15:59early on as soon as pc cell signal is
  396. 16:03ready
  397. 16:04we'll write a new value into the program
  398. 16:06counter
  399. 16:09now two other things happen concurrently
  400. 16:12and they start while we are decoding the
  401. 16:15instruction
  402. 16:16first the output
  403. 16:19we read we access the register file
  404. 16:23and we get the rs2 rs1 at its output
  405. 16:27simultaneously we also generate the
  406. 16:30immediate
  407. 16:31it is not clear which one of these two
  408. 16:33is going to take longer time
  409. 16:35because if you remember the immediate
  410. 16:37generation depends
  411. 16:38on the coding of the instructions so we
  412. 16:40need to know that this is an i type of
  413. 16:42intermediate in order to
  414. 16:43generate the correct correct immediate
  415. 16:46so that delay tends to be
  416. 16:48comparable to the delay of retrieving
  417. 16:50the data
  418. 16:51from the register so then the rest is
  419. 16:55similar to what we have seen before this
  420. 16:58completes the instruction fetch
  421. 17:02instruction decode phase instruction
  422. 17:04fetch was completed with the
  423. 17:05access of to the instruction memory this
  424. 17:08completes the
  425. 17:09instruction the code phase
  426. 17:12then we go into the execute phase that
  427. 17:15one is completed
  428. 17:16when the output of the alu is valid with
  429. 17:19the address that points to the memory
  430. 17:21we go through the memory access phase
  431. 17:24and
  432. 17:24finally we write back the result of that
  433. 17:28into the destination register
  434. 17:31now we have three possible parts that
  435. 17:34uh could be critical one is this one
  436. 17:36that we have already figured out that
  437. 17:38this short
  438. 17:38this uh um founders
  439. 17:41rock is the name of this color it's a
  440. 17:43berkeley color
  441. 17:46is definitely a shorter path than either
  442. 17:48one of these two and these two other
  443. 17:50parts
  444. 17:51are almost the same they just differ in
  445. 17:54the delay
  446. 17:55of the register file axis versus the
  447. 17:57immediate generation
  448. 17:58delay so in both of those cases
  449. 18:02we go through the instruction memory
  450. 18:07then either the immediate generation
  451. 18:12or the register file followed by a mux
  452. 18:15alu data memory and another multiplexer
  453. 18:19we have to add clock to queue delay of
  454. 18:22the program counter that launched the
  455. 18:23instruction
  456. 18:24and the setup time of the register file
  457. 18:28that needs to be met in order to
  458. 18:29correctly write back the result
  459. 18:33when that is done we can write back
  460. 18:36right complete this instruction right
  461. 18:38back into the
  462. 18:39register and update the program counter
  463. 18:43a little bit more conceptual timing
  464. 18:45shows what we have seen
  465. 18:47already in the previous few slides here
  466. 18:50is
  467. 18:51showing what is happening during one
  468. 18:53clock cycle
  469. 18:54pc gets updated and
  470. 18:58instruction fetch completes
  471. 19:01the first phase of execution the time
  472. 19:04that it takes here
  473. 19:05is some time that corresponds to
  474. 19:07instruction fetch
  475. 19:09then valid outputs
  476. 19:13at the output of the register file
  477. 19:15complete the instruction decode phase
  478. 19:17of execution then alu stabili output
  479. 19:22finishes the execute phase
  480. 19:25stable memory
  481. 19:28output completes the memory access phase
  482. 19:34there is very little logic that is
  483. 19:37in the right back phase so we have to go
  484. 19:40through that
  485. 19:42by piece of logic and make sure that we
  486. 19:46meet the setup time of whatever we are
  487. 19:49writing back into
  488. 19:51before the next rising edge of the clock
  489. 19:55if we put some numbers to it instruction
  490. 19:58fetch say takes
  491. 20:00200 picoseconds until we get
  492. 20:03the results out of the instruction
  493. 20:04memory and that then
  494. 20:06takes another 100 picoseconds to read
  495. 20:08the registers
  496. 20:09to complete the instruction decode alu
  497. 20:12say takes 200 picoseconds and completes
  498. 20:14the execute phase
  499. 20:16data memory say takes 200 picoseconds to
  500. 20:19get the data and complete the memory
  501. 20:21access phase
  502. 20:22and finally write back says takes a 100
  503. 20:25picoseconds that includes that setup
  504. 20:27time
  505. 20:28the total time is 800 picoseconds
  506. 20:32to execute this instruction
  507. 20:36one thing that is worth noting
  508. 20:40is that not all the instructions go
  509. 20:42through every single phase so some of
  510. 20:43them are going to be done sooner some of
  511. 20:45them are going to be done later
  512. 20:46we always have to take the worst case in
  513. 20:48this case the worst case is
  514. 20:51load word add only goes through four
  515. 20:54phases as we have seen before
  516. 20:56instruction fetch instruction decode alu
  517. 20:59or
  518. 21:00execute and write back so that takes
  519. 21:03only 600 picoseconds
  520. 21:04branch of equal goes only through three
  521. 21:06phases
  522. 21:08and so on um load word is the longest
  523. 21:11one takes 800 picoseconds
  524. 21:13how fast we can clock that well we can
  525. 21:16clock it
  526. 21:17at maximum clock frequency
  527. 21:21that is 1.25 gigahertz
  528. 21:27should be noted that we were if we're
  529. 21:31somehow able to clock this data path so
  530. 21:35we can execute
  531. 21:36just one piece of it we
  532. 21:40would have been able to run this at
  533. 21:44the frequency that corresponds to the
  534. 21:48longest delay of each execution units
  535. 21:51of each of the units that are in the
  536. 21:53data path so perhaps we could run this
  537. 21:55at five gigahertz we can't do that
  538. 22:00because we can't just execute some
  539. 22:02instructions and not the others
  540. 22:04or just perform the addition and neglect
  541. 22:06everything else
  542. 22:07but we are going to see how we can
  543. 22:08benefit from that a bit later i'll
  544. 22:12take a quick break now and be back in a
  545. 22:15second

About this transcript

This page contains the full transcript of [CS61C FA20] Lecture 20.3 - Single-Cycle CPU Control: Instruction Timing by CS 61C Departmental, generated from the public captions YouTube serves with the video. The transcript has 3,009 words across 545 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.