Tác giả giữ toàn bộ bản quyền (All Rights Reserved) — không phải giấy phép mở. Bạn vẫn xem và học miễn phí trên OpenER; muốn tái sử dụng cần xin phép tác giả.
DAN GARCIA
This is it. Welcome back. We're here. This is the last lecture of this four-lecture series, module, of synchronous digital systems.
This is it. We're building the climax. [HUMMING FANFARE] Come on.
And [VIBRATING LIPS WHILE HUMMING ASCENDING PITCH] climax, crescendo, to the final piece, [HUMMING FANFARE] "Ode to Joy," [HUMMING FANFARE] where we're looking and we're trying to build a subtractor, the final design of the tractor.
And it is extremely clever. And you'll see why this is clever.
Just to step back, don't look at the screen, don't look over here. Look at me.
I don't want to have to build 32 bits of an adder which does its thing and 32 bits of a subtractor, and then choose in a mux between them.
I'd like to be able to reuse that machinery. So can I possibly reuse the machinery for my cascaded adder for my subtractor. Here's the big idea. I love this idea.
a minus b is the same as a plus negative b. Like duh, yeah, I get that. But how does that embody itself in the circuit?
I love this part. See this little graph over here, this little truth table? It has an XOR. Do you remember that slide I showed you before?
I actually probably showed you this truth table. When x is 0, the output is just y. It's just y.
When x is 1, it switches, it's not y. We call this a conditional inverter.
So a plus negative b, sometimes I want to add a plus b. Sometimes I want to add a plus negative b.
How do you negate — this is so fun — how do you negate a two's complement number?
You invert the bits and add 1. [HUMMING GLEEFULLY] Subtract goes high, when this line goes high — I'm just so pleased because I just love this slide.
This is the crescendo of all the fun. And it really is very clever. When this subtract line goes high, I feed that into here. That is shared from each line of b.
I need 32 of these guys and of these guys. Each of those bits — just watch this — each of those bits, independently, is going to be flipped.
Remember, a two's complement number, you flip the bits. This does that. Each one of these gets their bits flipped.
When this goes high, each of them, if it's a 1, becomes a 0, the output is 0. If the input for b, if the n minus 1 is 0, the output is a 1.
It flips the bits. And add 1. I had this port sitting over here — [EXCITED WORDLESS VOCALIZATION] I'm just too pleased with myself — that was like, is it wiggling?
Do I let it go? Do I not plug anything into it? I said, well, let's put a 0 there. And it's true, two unsigned numbers, I better put a zero there.
But I want to be able to flip the bits and add one. This is your add 1. Flip the bits and add 1.
And you are now calculating a plus negative b, which is the same as a minus b.
So I can reuse my entire subtractor, retire all the adders, the 1-bit adders from my adder, to be able to do a subtractor by just flipping b's bits and adding 1.
And now I've flipped b. Now it's negative b. Now the b representation is negative b.
A plus negative b, a minus b. This is my what? This is my signed overflow.
My signed overflew by itself is my unsigned overflow.
Okay, so remember, XOR of both of these channels, c of n minus 1 and n — we just talked about that — is my signed overflow. Just take this line straight.
That's my unsigned overflow. I should write this right. Unsigned overflow.
Okay, you can't read my handwriting, but I can't either. [LAUGHS] When you get to be a PhD, you can write scribble and people can't tell what's happening. This is it.
I'm so excited. So in summary, use muxes to be able to do a flag person on the line. I got two signals to come in, but I only have one output.
I use a mux to be able to drive who gets to drive the output, who gets to drive across the bridge.
If I have s input bits, I select from among 2 to the s inputs. We saw 1 bit chooses among 2, 2 bits chooses among 4.
So s bits chooses among 2 to the s inputs. Each input themselves independently can be n bits wide.
That could be four 1-bit lanes driving a 1-bit output or four n-bit input lanes all driving one n-bit bridge. Okay, that's pretty cool. I can implement those muxes hierarchically.
We saw that thinking in the NCAA tournament. My ALU can be implemented using a mux.
I do all these calculations, and then I just, at the end, use the muxes to figure out who drives the output line.
And to build an n-bit adder/subtractor, I can use n 1-bit adders, cascade them together, and use an XOR to determine the signed overflow.
That's pretty cool. This is really good stuff.
So if I go back four lectures ago — and several hours in one long recording day for me — I started by talking about a transistor and having voltage turning on, and a gate, to be able to have what a bit means.
How do you even go from current flowing or not flowing to a bit? How to wire them to get some basic low-level structure. How to make a NAND gate.
How to build up. How to look at signals and waveforms. How to then ignore those signals and waveforms and throw some timing in there.
How to think about how would you build combinational logic circuits. What's some Boolean algebra behind that? How do you massage it?
How do you get your hands all stuck with lotion to massage a Boolean expression down to its simplest form? Maybe fewest gates.
And then how to take some of those basic gates to build them to higher-level blocks we're going to use in our data path to be able to build, together, a working machine to process RISC-V machine code and actually get this working.
That's the next three lectures. I cannot wait to see you there. Awesome, folks. Thank you so much for coming to these STS lectures.
We'll see you at the next time.
Đăng nhập để đánh giá học liệu này.
Đăng nhập để bình luận — chưa ai bình luận về học liệu này.
Không có khóa học liên quan.