[CS61C FA20] Lecture 15.3 - State, State Machines: Accumulator revisited — Transcript
Full transcript
- 0:00and welcome back now let's take a deeper
- 0:03look at the accumulator we tried to do a
- 0:04couple of lectures ago
- 0:06now that we know what a register is and
- 0:07a flip-flop is and actually how to
- 0:09think about some of the timing issues
- 0:10that are accompanying
- 0:12uh the registered details so there's
- 0:14only two slides in this this lecture
- 0:17but it's a complicated one so let's
- 0:18actually dig deeper on this make sure we
- 0:19make sure we're at the same with the
- 0:21understanding what's happening
- 0:24here's my clock my clock is going to
- 0:26have
- 0:27rising edges and things are going to
- 0:29happen as those rising edges hit
- 0:32i'm going to indicate the adder
- 0:34propagation delay with
- 0:35tau sub add there's another way we think
- 0:37about it and
- 0:39the clock to q delay half of that let's
- 0:42just think about that
- 0:44and you're going to see this is
- 0:46complicated we're kind of turning this
- 0:47on the side to kind of show it a little
- 0:48bit better
- 0:49so x of i is going to be changing here's
- 0:51my x of i having different values
- 0:53starts at 0 here's of x x 0 x 1 x 2 etc
- 0:57okay
- 0:59here's the hard part this register it's
- 1:01got a reset button the most important
- 1:03thing on this slide i think is that the
- 1:04reset
- 1:05if the register gets up you know
- 1:09clocks up so rising edge turns around
- 1:12and
- 1:12there's an input d but also the register
- 1:15line is
- 1:16asserted or high i'm going to ignore my
- 1:18d and reset myself
- 1:20so kind of the idea is the reset takes
- 1:22priority over the d
- 1:23so i can't i can't care what the d is
- 1:25for my job is to reset myself so that's
- 1:27really important
- 1:29here's another thing that's confusing to
- 1:30many students i've got an
- 1:32s of i here and i've got an s of i minus
- 1:351 here
- 1:36and you're going to say well shouldn't
- 1:38shouldn't s of i shouldn't this be
- 1:39survived
- 1:40plus one isn't that isn't that right
- 1:41does that make more sense well let's
- 1:42think about it
- 1:43let's say we're at the s of i minus
- 1:44first iteration i went back and grabbed
- 1:47it okay
- 1:48rising edge of the clock presets low d
- 1:50asserted
- 1:51and now uh i'm now going to
- 1:54grab s of i minus 1 and show s of i
- 1:56minus 1. so now i'm holding it stable
- 1:59so f of y minus 1 is being stable on the
- 2:01s of y minus first iteration
- 2:02it comes around instantaneously and then
- 2:05x of i
- 2:07changes to the next value of r the last
- 2:10value of i
- 2:11and so this is the final output
- 2:15whatever that is this is s minus this is
- 2:16like all but the last number let's say
- 2:18that's what i mean okay let's say that's
- 2:20the n
- 2:20minus one maybe maybe n minus two here
- 2:22but it's all but the last number
- 2:24this then can change to the last number
- 2:26and then this holds
- 2:28the sum so really you're right that this
- 2:30is s of i because as that last number
- 2:32comes in
- 2:33i'm holding all but the last number on
- 2:34my s of i minus 1
- 2:36x of i as the last number that would be
- 2:38x of n minus 1.
- 2:39and then boom this is now the final
- 2:42value so that makes sense that this is s
- 2:44of i
- 2:44and this is s of i minus 1.
- 2:47we want to think about the circuit
- 2:49timing if we could take a look at this
- 2:50you know as you see this
- 2:52watch what happens it takes a little bit
- 2:54of time this
- 2:55s of i to s of i minus 1 is always going
- 2:58to be
- 2:59s of r minus s of i is sampled s of i is
- 3:02sampled and that value
- 3:06is then shown there always sampled
- 3:10shown there sampled and shown there okay
- 3:13so that's
- 3:14that's pretty clear what that does then
- 3:17there's going to be an adder delay okay
- 3:20x is going to change we don't actually
- 3:21know
- 3:22whether x is synchronous or async x is
- 3:24like basically hopefully a rhythmic
- 3:26number but who knows where it is regard
- 3:28to
- 3:29the actual rising edges of the clock x
- 3:31could be shifted all around there
- 3:33so only after watch this x is going to
- 3:36change okay i happen to draw this really
- 3:38nicely let me clear this up
- 3:40that i've got a new value of x just as
- 3:43what's this
- 3:43what's this device this this has s of i
- 3:46minus 1 here
- 3:49and x of i so i'm looking at this is the
- 3:51adder between these two values
- 3:53s of y minus 1 and x of i so when this
- 3:57n and thankfully they both change at
- 3:59exactly the same time
- 4:00so now i have to wait t add before
- 4:03that is seen on the output get it
- 4:06x of i x of i as x is 0 x 1
- 4:09this is now x of 0 plus x of 1 okay
- 4:13and this is the output so that the
- 4:15output is stable here
- 4:16that's pretty cool now let's actually go
- 4:18one more level of detail into this
- 4:20let's actually really look at this and
- 4:22this is fun to to do so
- 4:23please feel free to do this on your own
- 4:25grab the slides mark them up i encourage
- 4:26you to do this you'll learn a lot
- 4:28by the process i'm now including the
- 4:30reset value
- 4:31i'm including that i have no idea what s
- 4:33of i minus one was
- 4:35before i don't know what this what was
- 4:36locked in hook i buy a register from
- 4:39you know from fry's electronics who
- 4:40knows what was stored into it i don't
- 4:42even know
- 4:42you know rented apartment who knows what
- 4:44the condition of your apartment is going
- 4:45to be when you before you open the first
- 4:46door then you clean it up you reset it
- 4:48now you've got a nice apartment it's
- 4:49yours but when you get some used thing
- 4:51who knows what was in there before
- 4:52so i'm going to draw that as i don't
- 4:54know what was here before okay
- 4:56all right again we're gonna do the same
- 4:58thing we did before but really slowly
- 5:00okay so first let's put some numbers in
- 5:02here here one two three four
- 5:04all right my reset signal is shown let's
- 5:07go
- 5:07really slowly make sure we understand
- 5:09what's happening okay
- 5:11in practice x may not arrive to the
- 5:14adder at the same time of s
- 5:15minus one before a slide before like ah
- 5:17let's make the ideal case they both
- 5:18arrive at the same time
- 5:20that adder may see it offset you don't
- 5:21know when x comes in x is an
- 5:23asynchronous
- 5:24number so now by drawing them different
- 5:26watch what happens this is the fun thing
- 5:28here we go first thing ready who knows
- 5:31what happened in the past who knows
- 5:33where the register who knows the
- 5:34condition i register
- 5:35but i do know that at that first clock
- 5:37what do i get
- 5:38reset is high i'm going to ignore the
- 5:40input s of i so i ignore that for that
- 5:42time
- 5:43and i reset it so boom i wait t clock to
- 5:47q
- 5:47and who is my output s of i minus 1
- 5:50therefore
- 5:51this reset controls that number and it's
- 5:54reset to zero
- 5:55okay so that's the first i got the first
- 5:56there now it's stable at zero
- 5:58so now what what's the next thing to
- 6:01happen
- 6:02well that's a zero and now
- 6:06x i what's the next device this adder
- 6:10has s of i minus one so s of r minus one
- 6:13and x of i and this is the adders the
- 6:14same place so these guys are going to
- 6:16control oops
- 6:18these guys are going to control what
- 6:21happens
- 6:21here so both of these control what
- 6:24happens
- 6:24there at the sovi output okay so
- 6:29here is my zero here is my
- 6:33this was a zero before okay so that i
- 6:35have to wait t
- 6:36add t add and i go and that value
- 6:40after t add is available here zero zero
- 6:43i'm going to right here but again i
- 6:47don't know what this is this is zero who
- 6:48knows
- 6:48and now here's the key only at the next
- 6:52time
- 6:53right here there's my line
- 6:57only at that time do i have a stable s
- 6:59of i at zero a stable
- 7:00new value of x of i and in a way i kind
- 7:03of didn't care what was here
- 7:05now i've got a stable x of 0 right there
- 7:09after t add that's the time i have that
- 7:11x of
- 7:120 set on s of i so now
- 7:15and by the way i hope that that has
- 7:18stable
- 7:19from t set up before the clock
- 7:22through t hold after that's the
- 7:24important thing and we're going to see
- 7:24that a little bit more detail
- 7:26and it happens to be in this picture why
- 7:29do i care about that being stable
- 7:30because this
- 7:32this is being sampled right there
- 7:36and that output is going right there
- 7:38when is it going after clock to queue
- 7:40okay so it's often useful to do this on
- 7:42a graph paper where you can
- 7:44and make it you know make like t clock
- 7:45to queue one box as it's done here
- 7:48t adders two boxes kind of play with it
- 7:50a little bit and maybe make the clock
- 7:52eight boxes or something so you can see
- 7:53that's
- 7:53really useful to draw this on a big
- 7:55white board or graph paper okay so now
- 7:58i've got a stable x zero now here's the
- 8:00front here's the part that's really
- 8:01interesting
- 8:03there's my first value of s of i minus
- 8:07one
- 8:08x of i happens to be not synchronized
- 8:11with
- 8:11s of i minus one so now watch this this
- 8:15is crazy
- 8:17right here at this time right oops i'll
- 8:20try to
- 8:21i'll try to zoom in here so right there
- 8:26i have what's on the input the input
- 8:28this is the outer
- 8:29the input of the adder folks is x is
- 8:31zero and x is zero
- 8:34i should never have two x's zeros in my
- 8:36output and so watch what happens
- 8:38after after right there
- 8:41t add in this window that value
- 8:45is x zero plus x zero a wrong value
- 8:49my accumulator should never have that
- 8:50should i have zero x is zero
- 8:52x is 0 plus x of 1 x 0 plus x of 2
- 8:54should never have x 0 plus x 0 but it
- 8:56does for that exact window of time
- 8:59okay because of this x
- 9:02s of i is temporarily wrong
- 9:05but because this circuit stabilizes
- 9:08before it gets
- 9:10sampled at the clock period it's on it's
- 9:12temporary wrong for this window of time
- 9:15those inputs are x zero plus x is zero
- 9:18but at this time
- 9:22now they're right now i've got an x 0
- 9:24plus x of 1. and so
- 9:26then that's the right value
- 9:29okay and now
- 9:32hopefully if the circuit is built right
- 9:34what happens
- 9:36that stable t set up before this
- 9:40and stable t hold after and now i've got
- 9:43x is zero plus x sub 1
- 9:44and the right thing happens
- 9:48so ask yourself what
- 9:51happens if you ever overclock a system
- 9:54overclocking system means you turn the
- 9:56clock frequency up turn the clock
- 9:58frequency up means you
- 9:59shrink the period what starts to fail
- 10:02well let's look at this circuit
- 10:03as this i turn my clock frequency up as
- 10:06my
- 10:07yellow lines might start to shrink what
- 10:10happens
- 10:11well all of a sudden i'm starting to
- 10:14violate something what's getting
- 10:15violated why
- 10:16why would this ever be in kind of a why
- 10:19would they have a break this is going to
- 10:20work perfectly as long as i have a nice
- 10:22slow clock
- 10:23clock frequency big all long period i'm
- 10:25fine
- 10:26this starts to fail when all of a sudden
- 10:31that delay where it's stable here look
- 10:34boom right here
- 10:35s of i is stable but what if
- 10:39this is the line for and it's a little
- 10:41wiggly
- 10:42for t setup well it's still good it's
- 10:45stable before t setup
- 10:47and all of a sudden as i'm making the
- 10:49clock
- 10:50period smaller and smaller now t setup
- 10:52is getting closer and closer to when it
- 10:54is stable
- 10:55and when it just crosses that that's at
- 10:58my problem point
- 10:59so it turns out that it's the set up and
- 11:01hold issue that causes
- 11:03circuits to be wonky the circuit's not
- 11:07to be stable um so that's the issue
- 11:10it is that you start to infringe on my
- 11:13setup to hold that was a rule we agreed
- 11:15that's the rule you bought it it said
- 11:16look
- 11:17if you don't have a stable value on the
- 11:19input of this flip flop
- 11:21between setup setup time before the
- 11:23clock rising edge of the clock
- 11:24and whole time after i can't guarantee
- 11:26what i'm going to do i may go into a
- 11:28wheat i may have a
- 11:29value of a half or whatever that means
- 11:30whatever that means for the voltage is
- 11:32there
- 11:32i made wobble i may go into you know
- 11:35defibrillated heart attack up and down
- 11:37who knows i may
- 11:38i may start ignoring my input and just
- 11:40be i'll just hold this forever
- 11:42who knows where the flip-flop is going
- 11:43to break that starts to happen if you
- 11:45ever have a changing value between
- 11:47setup and hold and that's what starts to
- 11:49happen as i turn this clock
- 11:51cycle up and these yellow lines get
- 11:52closer all of a sudden the delay before
- 11:55it's stable before
- 11:56i sample it now it's not stable anymore
- 11:58i'm sampling a change value all of a
- 11:59sudden flip-flop goes into a bad
- 12:01situation that's exactly what happens
- 12:03see so in good circuits
- 12:06instability never happens around the
- 12:08rising edge of clock time before
- 12:10time after in bad circuits it does so
- 12:12that's what starts to break as you
- 12:14overclock systems you have this and by
- 12:16the way it's okay
- 12:17and in real life it's okay to have you
- 12:19know the input to some
- 12:20his register the input is registered be
- 12:23some crazy
- 12:24value but i don't care as long as it's
- 12:26the right value
- 12:27between set up and hold i've said the
- 12:28same thing multiple times but i really
- 12:29want to make sure i emphasize that
- 12:30the critical thing is it's stable
- 12:32between set up and hold and then i'm
- 12:33good i don't care if it's actually
- 12:35bad between it's all right to have x be
- 12:36totally asynchronous in fact you can
- 12:38even play with this
- 12:39and how far can you move x to be
- 12:40asynchronous be changing
- 12:42until this stops working so all those
- 12:44things are interesting thing we have
- 12:45drawn in a way that it actually does
- 12:46work but if i slide it the wrong way so
- 12:47it
- 12:48just is changing exactly right at the
- 12:50wrong time if it's changing just so that
- 12:52the adder by the time the adder delay
- 12:54gets factored in all of a sudden it's
- 12:56changing in there or how about this
- 12:58then i would have trouble or if i turn
- 13:00up t add if i make t
- 13:01add bigger i turn it'll knob on t add i
- 13:03buy a cheaper ti was
- 13:05discount to the discount bin to get to
- 13:07get the adder well now t add is bigger
- 13:09because of that now that pushes in to
- 13:10start impinging on my setup and whole
- 13:11time so all those things affect this
- 13:13circuit
- 13:14but you could either turn this clock
- 13:15cycle 2 up up too high
- 13:17or have t add too high or even clock to
- 13:19queue
- 13:20clock to queue could have i mean
- 13:21collector queue affects it as well so if
- 13:22i make talk to q really big
- 13:24it can start to impinge on its own the
- 13:26clock to queue is part of the flip flop
- 13:28it could impinge on its own set up and
- 13:29hold as well as well depending how you
- 13:31built those circuits
- 13:32okay boy good stuff right good stuff all
- 13:35right
- 13:35that's the end of this lecture we'll see
- 13:37the next one
About this transcript
This page contains the full transcript of [CS61C FA20] Lecture 15.3 - State, State Machines: Accumulator revisited by CS 61C Departmental, generated from the public captions YouTube serves with the video. The transcript has 2,711 words across 419 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.