Lecture 7 Carry look ahead adders, Latches, Flip-flops, registers, multiplexors, decoders Digital Works intro PH 3 : Appendix B.6-9. Adders. Last time we developed a 32 bit ripple adder. It is not an efficient adder, although simple to understand, so how can we improve its performance.
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation
Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement.Téléchargez la présentation en cliquant sur ce lien.Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.
Adders • Last time we developed a 32 bit ripple adder. • It is not an efficient adder, although simple to understand, so how can we improve its performance. • We will try to see what can be done to speed it up. Chapter 1 — Computer Abstractions and Technology — 2
Problem: ripple carry adder is slow • Is a 32-bit ALU as fast as a 1-bit ALU? • Is there more than one way to do addition? • two extremes: ripple carry and sum-of-products Can you see the ripple? How could you get rid of it? c1 = b0c0 + a0c0 +a0b0 c1 = (b0 + a0)c0 +a0b0 c2 = b1c1 + a1c1 +a1b1 c2 = (b1 + a1)c1 +a1b1 c3 = b2c2 + a2c2 +a2b2 c3 = … c4 = b3c3 + a3c3 +a3b3 c4 = … — 3
Carry-lookahead adder • An approach in-between our two extremes • Motivation: • If we didn't know the value of carry-in, what could we do? • Let gi = ai bi , called generate, and , pi = ai + bi , called propagate. Now the equations can be written as below c1 = g0 + p0c0 c2 = g1 + p1c1 = g1 + p1(g0 + p0c0) c3 = g2 + p2c2 = g2 + p2(g1 + p1(g0 + p0c0)) c4 = g3 + p3c3 = ... So we see it is possible to generate however many carries we desire that are independent of all carries except c0. However it tends to become quite expensive in terms of numbers of gates. So what can we do? — 4
Cascade connection of 4-bit carry lookahead adders. Can’t build a 16 bit adder this way... (too big) Could use ripple carry of 4-bit CLA adders Better: use the CLA principle again! Chapter 1 — Computer Abstractions and Technology — 6
Positive-edge-triggered D flip-flop • NAND gates 5 and 6 serve as an latch. Thus as long as S = R = 0, i.e. S’ = R’ = 1, the state of the latch cannot change; while whenever S or R is 1, i.e. S’ or R’ is 0, but not both the latch sets or resets. • Now if C = 0 the outputs of gates 2 and 3 are 1, regardless of D, so the latch does not change. • Now assume D = 0. then the output at gate 4 is 1 and at gate 1 is 0 since the outputs at gates 4 and 2 are 1. • When C goes from 0 to 1, the positive edge, all inputs to gate 3 become 1 so R’ = 0. But S’ remains 1 since the input from gate 1 is still 0 so Q = 0 and Q’ = 1. In addition the ouput 0 from gate 3 feeds back to gate 4 to keep the output there at 1 regardless of changes to D so long as C stays equal 1. Chapter 1 — Computer Abstractions and Technology — 17
Positive-edge-triggered flip-flop continued • Now suppose C = 0 and D = 1. As before the ouputs from gates 2 and 3 are 1 causing the S’R’ latch to hold its current state. However D = 1 causes the output of gate 4 to be 0 which causes the output of gate 1 to be 1. • Now when C changes to 1 both inputs to gate 2 become 1 so S’ = 0. R’ remains 1 since the input from gate 4 to gate 3 is 0. Now S’ = 0 and R’ = 1 causes Q = 1 and Q’ = 0. • The 0 output from gate 2 causes the outputs at gates 1 and 3 to remain at 1. Thus if D changes as long as C = 1, there will be no change in the S’R’ latch. Chapter 1 — Computer Abstractions and Technology — 18
Logic Design Basics • Information encoded in binary • Low voltage = 0, High voltage = 1 • One wire per bit • Multi-bit data encoded on multi-wire buses • Combinational element • Operate on data • Output is a function of input • State (sequential) elements • Store information Chapter 1 — Computer Abstractions and Technology — 21
A Y B A A Mux I0 Y + Y Y I1 ALU B B S F Combinational Elements • AND-gate • Y = A & B • Adder • Y = A + B • Arithmetic/Logic Unit • Y = F(A, B) • Multiplexer • Y = S ? I1 : I0 Chapter 1 — Computer Abstractions and Technology — 22
Multiplexor • A multiplexor that chooses one of two words. Built by using 1 bit multiplexors and stringing them together as on the right. Chapter 1 — Computer Abstractions and Technology — 28
Creating and using Macros Converting the two-input multiplexer circuit into a black box Chapter 1 — Computer Abstractions and Technology — 37
Creating the black box • Left click on the arrow. • Right click on one of the macro tags. • Select Template Editor from the menu with a left click. • The Template Editor window appears. You can create a symbol for your circuit. There may already be a default black box and if there is you can use it if you like, or you can delete it and draw one that you like. Chapter 1 — Computer Abstractions and Technology — 38
Procedure for building the macro • Once you have drawn an object or decided to use the default one you select the Pin Icon by left clicking. • You then place the cursor where you want it to be in the diagram and left click to insert it. • Next select it and right click and select associate with tag from the menu. • Next close the template editor. You will notice a 1 next to the selected macro tag. • Now select another macro tag, right click and select template editor and repeat the above procedure except for drawing the template. Do this for the remaining macro tags and then save the file. You do not use a separate name for the macro. Chapter 1 — Computer Abstractions and Technology — 40
Using a Macro Embedding a macro in a circuit Chapter 1 — Computer Abstractions and Technology — 44
Using a Macro continued • You can use the push button interactive tool to insert inputs to the macro and the LED tool to insert outputs to the macro. You then wire the interactive buttons and LEDs to the appropriate macro icons. You can then run and test it. • Suppose you want to build a circuit having more than one macro (which may or may not be the same) • Select the embed macro button and position the cursor to where you want it in the workspace and left click. Chapter 1 — Computer Abstractions and Technology — 45