Physics 219 Fall, 1995academics.wellesley.edu/Physics/Rberg/logochip/docs/... · Web viewWith CMOS...

33
Physics 219, Fall, 2002 Combinational Logic Combinational Logic (Lab 11-1, parts a, b, and c and Lab 13 in The Student Manual) Table of Contents Digital Building Blocks..............................2 Combinational Logic.................................. 3 An example of combinational logic: A car’s warning buzzer..............................................3 Digital Logic Gates.................................. 4 Basic Examples......................................4 OR gate...........................................4 AND gate..........................................5 INVERTER gate.....................................5 NAND gate (NOT AND)...............................6 NOR gate (NOT OR).................................6 XOR gate (EXCLUSIVE OR)...........................7 Car warning buzzer implementation using logic gates. 7 DeMorgan's Theorem..................................8 Active High vs. Active Low Logic....................9 Field Effect Transistors.............................9 MOSFETs.............................................9 MOSFET Switches....................................12 Building Logic Gates Out of Transistors.............14 MOSFET Inverters...................................14 CMOS Inverter......................................16 MOSFET Body Connections............................17 CMOS NAND Gate.....................................17 Diode Gates........................................19 CMOS Three-State...................................20 page 1 out of 33 Last modified on 11/15/2002 05:35:00 PM

Transcript of Physics 219 Fall, 1995academics.wellesley.edu/Physics/Rberg/logochip/docs/... · Web viewWith CMOS...

Page 1: Physics 219 Fall, 1995academics.wellesley.edu/Physics/Rberg/logochip/docs/... · Web viewWith CMOS logic this asymmetry does not exist, but old habits are hard to break and active

Physics 219, Fall, 2002 Combinational Logic

Combinational Logic(Lab 11-1, parts a, b, and c and Lab 13 in The Student Manual)

Table of Contents

Digital Building Blocks..........................................................................................2Combinational Logic............................................................................................3

An example of combinational logic: A car’s warning buzzer.............................3Digital Logic Gates...............................................................................................4

Basic Examples....................................................................................................4OR gate............................................................................................................4AND gate........................................................................................................5INVERTER gate.............................................................................................5NAND gate (NOT AND)................................................................................6NOR gate (NOT OR)......................................................................................6XOR gate (EXCLUSIVE OR)........................................................................7

Car warning buzzer implementation using logic gates........................................7DeMorgan's Theorem..........................................................................................8Active High vs. Active Low Logic......................................................................9

Field Effect Transistors........................................................................................9MOSFETs............................................................................................................9MOSFET Switches............................................................................................12

Building Logic Gates Out of Transistors..........................................................14MOSFET Inverters............................................................................................14CMOS Inverter..................................................................................................16MOSFET Body Connections.............................................................................17CMOS NAND Gate...........................................................................................17Diode Gates.......................................................................................................19CMOS Three-State............................................................................................20

How do you get from logic gates to higher level computation?......................20Adder.................................................................................................................21Arithmetic Logic Unit (ALU)............................................................................25

page 1 out of 27 Last modified on 11/16/2002 12:35:00 AM

Page 2: Physics 219 Fall, 1995academics.wellesley.edu/Physics/Rberg/logochip/docs/... · Web viewWith CMOS logic this asymmetry does not exist, but old habits are hard to break and active

Physics 219, Fall, 2002 Combinational Logic

Digital Building BlocksWe started out in this course by introducing you to the LogoChip, a powerful and relatively easy to use general purpose digital device. While you quickly had a chance to build a wide range of digital circuits, we pretty much treated the LogoChip as a “black box” whose inner workings were kept hidden from view. Now it’s time to look inside the black box.

In the next few labs you will have an opportunity to see the basic building blocks of digital electronics and gain a sense how, remarkably, one can take a collection of transistor switches which when viewed individually seem quite unremarkable, and turn create digital circuits of awesome power and flexibility.

Our present technological state is such that we rely mainly on transistors built out of silicon to create our digital circuits. But there is no fundamental reason we cannot use other materials as building blocks. For example, while they were undergraduates at MIT in the 1970s, Brian Silverman (of LogoChip fame) and his roommate Danny Hillis used Tinker Toys and fishing line to build a computer that could play tic-tac-toe. Their invention, shown in the figure above, can be viewed in person in the lobby of the Museum of Science in Boston. Someday silicon-based

page 2 out of 27 Last modified on 11/16/2002 12:35:00 AM

Page 3: Physics 219 Fall, 1995academics.wellesley.edu/Physics/Rberg/logochip/docs/... · Web viewWith CMOS logic this asymmetry does not exist, but old habits are hard to break and active

Physics 219, Fall, 2002 Combinational Logic

transistors may seem as quaint vacuum tubes seem today, but the basic ideas of digital systems are certain to live on.

Combinational LogicThe basic scheme in most digital electronics is captured in the drawing below. We can view most devices as entities that “map” a set of “inputs” onto a set of “outputs”, according to a set of rules.

There are two basic ways that the inputs can be mapped onto the outputs:

Combinational Logic - In this case the output values at a given moment depend only on the values of the inputs at that moment.

Sequential Logic - In this case the output values at a given moment depend not only on the values of the inputs at that moment, but also on the past history of the device. Thus a sort of "memory" is involved.

We will begin by studying combinational logic in this document and then move on to sequential logic in a separate document.

An example of combinational logic: A car’s warning buzzer

Consider the case of the annoying warning system in place in most cars. There are apparently a set of sensors throughout the car that provide inputs to some digital device whose job it is to decide whether or not to buzz.

At a given instant, each one of the input and output lines above can be thought of as being either TRUE or FALSE. Let's adopt (for now) a convention in which we

page 3 out of 27 Last modified on 11/16/2002 12:35:00 AM

Page 4: Physics 219 Fall, 1995academics.wellesley.edu/Physics/Rberg/logochip/docs/... · Web viewWith CMOS logic this asymmetry does not exist, but old habits are hard to break and active

Physics 219, Fall, 2002 Combinational Logic

associate the "0" state with FALSE condition and the "1" state with the TRUE condition. (This convention is known as positive true logic. (Later we will often use the (more confusing) negative true logic convention, in which we associate the "0" state with the TRUE condition and the "1" state with the FALSE condition.)

Let's construct a truth table for the car warning buzzer example., a table consisting of all possible permutations of inputs along with the desired outputs:

keys in ignition?

seat belt unfastened?

door open? buzzer sounds?

0 0 0 00 0 1 00 1 0 00 1 1 01 0 0 01 0 1 11 1 0 11 1 1 1

How can we implement this truth table (or any other) electronically?

Digital Logic GatesLogic gates are the building blocks used to implement truth tables. Each logic gate can perform a simple logical function. By interconnecting appropriate logic gates, it is possible to build a circuit that implements any desired truth table.

Basic Examples

The most commonly used logic gates are:

OR gate

page 4 out of 27 Last modified on 11/16/2002 12:35:00 AM

Page 5: Physics 219 Fall, 1995academics.wellesley.edu/Physics/Rberg/logochip/docs/... · Web viewWith CMOS logic this asymmetry does not exist, but old habits are hard to break and active

Physics 219, Fall, 2002 Combinational Logic

Truth Table:A B Q0 0 00 1 11 0 11 1 1

AND gate

Truth Table:A B Q0 0 00 1 01 0 01 1 1

INVERTER gate

Truth Table:

A Q0 11 0

A rough implementation of an inverter gate is shown in the following circuit based on a 311 comparator. "Real" digital gates are ~ 20 times faster than the comparator-based circuit, although you give up the flexibility of being able to choose voltage levels.

page 5 out of 27 Last modified on 11/16/2002 12:35:00 AM

Page 6: Physics 219 Fall, 1995academics.wellesley.edu/Physics/Rberg/logochip/docs/... · Web viewWith CMOS logic this asymmetry does not exist, but old habits are hard to break and active

Physics 219, Fall, 2002 Combinational Logic

NAND gate (NOT AND)"Bubbles" in a the schematic symbol denote inversion:

Truth Table:A B Q0 0 10 1 11 0 11 1 0

NOR gate (NOT OR)

Truth Table:A B Q0 0 10 1 01 0 01 1 0

page 6 out of 27 Last modified on 11/16/2002 12:35:00 AM

Page 7: Physics 219 Fall, 1995academics.wellesley.edu/Physics/Rberg/logochip/docs/... · Web viewWith CMOS logic this asymmetry does not exist, but old habits are hard to break and active

Physics 219, Fall, 2002 Combinational Logic

XOR gate (EXCLUSIVE OR)

Truth Table:A B Q0 0 00 1 11 0 11 1 0

(Note that the output bit is 0 if the input bits are the same and 1 if the input bits are different. thus the XOR function provides a convenient test to see if two numbers are the same or not. This is a useful trick to remember down the road when doing assembly language programming, since the XOR function is part of the basic “instruction set” for the microcontrollers we will be using.)

Car warning buzzer implementation using logic gates

It's easy if you first carefully state what you want using words:

The buzzer should sound if (the key is in the ignition) AND ((the seat belt is unfastened) OR (the door is open)).

so, what we want is:

page 7 out of 27 Last modified on 11/16/2002 12:35:00 AM

Page 8: Physics 219 Fall, 1995academics.wellesley.edu/Physics/Rberg/logochip/docs/... · Web viewWith CMOS logic this asymmetry does not exist, but old habits are hard to break and active

Physics 219, Fall, 2002 Combinational Logic

DeMorgan's Theorem

With the help of some inverters and an observation made a long time ago by DeMorgan it is possible to build an OR function using AND gates and vice versa. DeMorgan noticed that the following gates have the same truth tables (remember, the bubbles are really shorthand for inverters):

A B Q0 0 10 1 11 0 11 1 0

In words: "You can switch an AND gate with an OR gate if you also invert all inputs and outputs."

page 8 out of 27 Last modified on 11/16/2002 12:35:00 AM

Page 9: Physics 219 Fall, 1995academics.wellesley.edu/Physics/Rberg/logochip/docs/... · Web viewWith CMOS logic this asymmetry does not exist, but old habits are hard to break and active

Physics 219, Fall, 2002 Combinational Logic

Active High vs. Active Low Logic

As mentioned earlier there are two possible conventions that one can adopt for identifying the conditions TRUE and FALSE with our logic states HIGH and LOW:

In positive true logic (also called active high logic) the HIGH state is identified with a condition being TRUE and the LOW state is identified with the condition being FALSE.

In negative true logic (also called active low logic) the LOW state is identified with a condition being TRUE and the HIGH state is identified with the condition being FALSE.

Although it may seem less intuitive, active low logic is often used, for reasons that are mainly "historical". With the older TTL logic it made sense to have "control lines" be active low. As we will see a control line, like a "READY" line, is most often found in the FALSE state. Only occasionally, for brief periods of time, does it become TRUE. Now, for TTL logic it is desirable to have the most common state be the HIGH one, because the HIGH TTL state is less vulnerable to noise and because it requires essentially no power to drive a TTL input HIGH while to drive it LOW requires a fair amount of power. Thus when TTL reigned supreme, it became standard to employ active low logic, which minimized the amount of time control lines spent in the LOW state.

With CMOS logic this asymmetry does not exist, but old habits are hard to break and active low logic remains standard at this time.

Suppose we have adopted active low logic and one wants to choose a logic gate whose output will be TRUE if either of the inputs is TRUE. Making use of DeMorgan's Theorem, what kind of logic gate should we use?

Field Effect Transistors

MOSFETs

MOSFET is an acronym for Metal Oxide Semiconductor Field Effect Transistor

Like the bipolar junction transistors (BJTs) that we have used up until now,

page 9 out of 27 Last modified on 11/16/2002 12:35:00 AM

Page 10: Physics 219 Fall, 1995academics.wellesley.edu/Physics/Rberg/logochip/docs/... · Web viewWith CMOS logic this asymmetry does not exist, but old habits are hard to break and active

Physics 219, Fall, 2002 Combinational Logic

MOSFETs come in two flavors:

The n-channel MOSFET is analogous to an npn bipolar transistor.

The p-channel MOSFET is analogous to an pnp bipolar transistor.

The circuit symbols for these MOSFETs are shown below:

The terminals are given names that parallel the ones used in the bipolar world:

source <==> emitter

drain <==> collector

gate <==> base

In addition, the MOSFETs have a fourth terminal, called the "body", which we will discuss in a moment. (The direction of the arrow on the body connection distinguishes n-channel MOSFETs from p-channel MOSFETs.)

In a BJT, a small base current controls a large current that flows between the emitter and the collector. Similarly, in a MOSFET, a voltage applied to the gate controls the amount of current that flows between the source and the drain. Whereas a BJT is like a current-controlled valve, a MOSFET is like a voltage-controlled valve. Because the gate terminal of a MOSFET draws very little current (just enough to charge or discharge the capacitor-like gate) the input impedance of a MOSFET is much higher than that of a BJT.

page 10 out of 27 Last modified on 11/16/2002 12:35:00 AM

Page 11: Physics 219 Fall, 1995academics.wellesley.edu/Physics/Rberg/logochip/docs/... · Web viewWith CMOS logic this asymmetry does not exist, but old habits are hard to break and active

Physics 219, Fall, 2002 Combinational Logic

The above figure shows the construction of a typical MOSFET as it would be configured when it is part of an integrated circuit. The drain terminal is connected to the island of n-type material on the left side of the figure while the source terminal is connected to the island of n-type material on the right side of the figure. The substrate of p-type material in which the transistor is embedded is reffered to as the body.

The simplest way to think of a MOSFET is as a voltage-controlled resistor. Depending on the voltage of the gate (relative to the source) the channel of the MOSFET will either be in a conducting or a non-conducting state.

These days, MOSFETs are by far the most common type of transistor used in digital circuits, primarily because of the following factors:

• It is possible to make MOSFETs that very tiny (~ 1 m in overall dimension with “features” ~ 0.1 m and shrinking as manufacturing processes continue to improve) and to incorporate literally tens of millions of them onto a chip of silicon the size of a thumbnail.

• They dissipate very little power, a necessary condition for so many of them to be

page 11 out of 27 Last modified on 11/16/2002 12:35:00 AM

Page 12: Physics 219 Fall, 1995academics.wellesley.edu/Physics/Rberg/logochip/docs/... · Web viewWith CMOS logic this asymmetry does not exist, but old habits are hard to break and active

Physics 219, Fall, 2002 Combinational Logic

crammed into such a small space.

• They are reasonably fast. That is they can "switch" their state from conducting to non-conducting very quickly, in times on the order of 1 nanosecond (and getting shorter all the time).

Essential MOSFET Rules:

Rule 1a) For an n-channel MOSFET if VGS ≤0 V (i.e., if the gate is not more positive than the source) then the channel is "pinched off" and it is non-conducting.

Rule 1b) For an n-channel MOSFET if VGS > +1.5 V (i.e., if the gate is greater than 1.5 V more positive than the source) then the channel is "open" and it is conducting.

Rule 2a) For an p-channel MOSFET if VGS ≥0 V (i.e., if the gate is more positive than the source) then the channel is "pinched off" and it is non-conducting.

Rule 2b) For an p-channel MOSFET if VGS < -1.5 V (i.e., if the gate is more than 1.5 V more negative than the source then the channel is "open" and it is conducting.

MOSFET Switches

(Student Manual, Lab 11-1, parts a, b, c)

Recall the transistor switch that you previously built using a bipolar (npn) transistor. (Student Manual Lab 4-9).I

page 12 out of 27 Last modified on 11/16/2002 12:35:00 AM

Page 13: Physics 219 Fall, 1995academics.wellesley.edu/Physics/Rberg/logochip/docs/... · Web viewWith CMOS logic this asymmetry does not exist, but old habits are hard to break and active

Physics 219, Fall, 2002 Combinational Logic

The point of this switch is that if point A is connected to + 5 V, only a small current will flow into the base. Due to the large value of 0, this will result in a rather large collector current, IC to flow into the 100 resistor / lamp combination.

Because the gate terminal of a MOSFET needs very little charge to “turn on” it can be used to build a switch that requires ridiculously small currents to turn on and off. In Lab 11-1 you will build and study the following circuit.

page 13 out of 27 Last modified on 11/16/2002 12:35:00 AM

Page 14: Physics 219 Fall, 1995academics.wellesley.edu/Physics/Rberg/logochip/docs/... · Web viewWith CMOS logic this asymmetry does not exist, but old habits are hard to break and active

Physics 219, Fall, 2002 Combinational Logic

Building Logic Gates Out of Transistors

MOSFET Inverters

Passive Pull-Up

It is easy to build an inverter using a single MOSFET employing a pull-up resistor:

This circuit is very closely analogous to the transistor switch that you built in lab section 4-9. This approach is referred to as "passive" because in one of the two output states the output is not stiffly tied down. Although simple, this passive pull-up scheme has major disadvantages:

page 14 out of 27 Last modified on 11/16/2002 12:35:00 AM

Page 15: Physics 219 Fall, 1995academics.wellesley.edu/Physics/Rberg/logochip/docs/... · Web viewWith CMOS logic this asymmetry does not exist, but old habits are hard to break and active

Physics 219, Fall, 2002 Combinational Logic

• It is relatively slow due to the RC time constant associated with having to charge or discharge the inevitable stray capacitance through the pull-up resistor.

• It is susceptible to noise pick-up when the output is not stiffly tied down.

page 15 out of 27 Last modified on 11/16/2002 12:35:00 AM

Page 16: Physics 219 Fall, 1995academics.wellesley.edu/Physics/Rberg/logochip/docs/... · Web viewWith CMOS logic this asymmetry does not exist, but old habits are hard to break and active

Physics 219, Fall, 2002 Combinational Logic

CMOS Inverter

CMOS stands for Complementary Metal Oxide Semiconductor. This scheme should bring to mind the push-pull amplifier that we encountered a while back. One of the MOSFETs is always "on" while the other is "off". Thus the output is always stiffly tied to either ground or to 5 V. CMOS-based logic dominates today's digital circuits. This arrangement should seem familiar. The situation is very similar to the push-pull amplifier from the analog world:

If you look back at our schematic drawing of the LogoChip output pins you’ll find a CMOS logic inverter. This circuit fragment is highly useful and ubiquitous in the digital world.

page 16 out of 27 Last modified on 11/16/2002 12:35:00 AM

Page 17: Physics 219 Fall, 1995academics.wellesley.edu/Physics/Rberg/logochip/docs/... · Web viewWith CMOS logic this asymmetry does not exist, but old habits are hard to break and active

Physics 219, Fall, 2002 Combinational Logic

MOSFET Body Connections

The "body" (or substrate) of a MOSFET forms a pn-junction with the channel, and thus can behave like a diode. When using MOSFETs it is necessary to explicitly tie the body to a voltage such that this "diode" is not conducting. (That is, we want the substrate to behave like an inert insulator that doesn't affect the transistor's operation.)

For an n-channel MOSFET this can be accomplished by

a) tying the body directly to the source, or

b) tying the body to ground, which will always be at a voltage less than or equal to the source voltage for an n-channel MOSFET.

For an p-channel MOSFET this can be accomplished by

a) tying the body directly to the source, or

b) tying the body to +5 V, which will always be at a voltage greater than or equal to the source voltage for an n-channel MOSFET.

CMOS NAND Gate

It can be shown that he NAND gate is a universal gate; any logic circuit can be built using NAND gates as building blocks. Thus it is worthwhile to see how a NAND gate is implemented using the CMOS scheme, which is the scheme employed in most the ICs you will be using to build your computer.

page 17 out of 27 Last modified on 11/16/2002 12:35:00 AM

Page 18: Physics 219 Fall, 1995academics.wellesley.edu/Physics/Rberg/logochip/docs/... · Web viewWith CMOS logic this asymmetry does not exist, but old habits are hard to break and active

Physics 219, Fall, 2002 Combinational Logic

It's easy to understand how the CMOS NAND gate works:

If the inputs A and B are both HIGH (i.e. at 5 V) then the series NMOS switches Q1 and Q2 are "on" (i.e. conducting) and the output Q is tied stiffly to ground. The parallel PMOS switches Q3 and Q4 co-operate nicely in this case by being "off" (i.e. non-conducting) so that Q is isolated from the +5 V supply. Note that there is essentially no "quiescent" current in this state.

If either of the inputs A or B are LOW (or if both A and B are LOW) then either Q1 or Q2 (or both Q1 and Q2 ) are "off" and Q is not pulled to ground. In this case either Q3 or Q4 (or both Q3 and Q4 ) are "on" so that Q is actively pulled HIGH. Again, note that there is no "quiescent" current in this state. Thus we begin to see why CMOS-based logic consumes very little power. (Note however the importance of making certain that the inputs are tied either to HIGH or LOW, even if a particular gate is not being used. If the inputs are allowed to "float" to some intermediate voltage then the both the n-channel and p-channel MOSFETs can end up in a "partially conducting" state and quiescent power consumption can soar. See the related laboratory exercise in section 13-1 of the Student Manual.)

To make an AND gate we just need to add a CMOS inverter, which we already

page 18 out of 27 Last modified on 11/16/2002 12:35:00 AM

Page 19: Physics 219 Fall, 1995academics.wellesley.edu/Physics/Rberg/logochip/docs/... · Web viewWith CMOS logic this asymmetry does not exist, but old habits are hard to break and active

Physics 219, Fall, 2002 Combinational Logic

know about, to the NAND gate.

Diode Gates

(See Student Manual, lab section 13-3)

Here's a simple, easy-to-understand OR gate based on diodes. By itself it doesn't work so well, but with the help of some buffering transistors it is the basis for the TTL logic family. (As we've already mentioned, TTL has almost completely been replaced by CMOS these days.):

How it works:

page 19 out of 27 Last modified on 11/16/2002 12:35:00 AM

Page 20: Physics 219 Fall, 1995academics.wellesley.edu/Physics/Rberg/logochip/docs/... · Web viewWith CMOS logic this asymmetry does not exist, but old habits are hard to break and active

Physics 219, Fall, 2002 Combinational Logic

If (A) OR (B) OR (A AND B) are HIGH then current flows through the resistor to ground and Q is HIGH. Only if A and B are both LOW will Q be LOW. Thus we have an OR gate.

The diodes are key because they permit A to be LOW while B is HIGH, and vice versa; they isolate the inputs from one another.

Problem: Due to the 0.6 V drop across a diode, an "output" HIGH is lower in voltage than an "input" HIGH. This means that you can't "cascade very many of these gates sequentially. In TTL logic, bipolar transistors are used to "buffer" the diode gate, boosting the output voltage back to the same level as the input voltage.

CMOS Three-State

(See Student Manual, lab section 13-6)

As the name implies, the three-state output stage can go into a third state besides HIGH and LOW: OFF. This ability is of critical importance in computers: it allows multiple drivers to share a single driven wire or bus line. (If multiple outputs are connected to a common bus line it is imperative that we avoid the situation where two outputs are simultaneously trying to assert different levels onto the line. We will arrange this by always using three-state outputs and making sure that all of the three-states are in the OFF state except for one which is actively asserting a level onto the bus line.) In this section you are asked to build a three-state buffer, a gate which, when enabled, does nothing but give the signal a fresh start. When not enabled the output of the gate is OFF. Again thinking back to the LogoChip example, we see how important it is to have the ability to turn the outputs OFF. (This is necessary if a single pin is to be able to serve as either an input or an output.)

As the Student Manual says: "The trick is to add some logic that can turn off both the pull-up and pull-down transistors. When that happens the output is disconnected from both + 5 V and ground; the output is then OFF or 'floating'". When the gate is enabled the output level simply follows the input level. An implementation of a three-state CMOS buffer is shown in the Student Manual.

page 20 out of 27 Last modified on 11/16/2002 12:35:00 AM

Page 21: Physics 219 Fall, 1995academics.wellesley.edu/Physics/Rberg/logochip/docs/... · Web viewWith CMOS logic this asymmetry does not exist, but old habits are hard to break and active

Physics 219, Fall, 2002 Combinational Logic

How do you get from logic gates to higher level computation?Above we saw how you could use transistors to construct simple logic gates. The next step is to see how these logic gates can be combined to perform more sophisticated computation.

Adder

Let’s consider one relatively simple, yet instructive, example: an “adder” circuit that can add together two binary numbers. We can get started by thinking about how you do addition in base two. For example:

Our goal is to be able to implement this adder with simple logic gates. Towards this end, the first challenge is to build a “one-bit adder” of the form

This adder takes as inputs three one bit numbers, A and B , along with a “carry in” bit and adds them together to produce a sum between 0 and 3. The sum is expressed as a two bit binary number. The least significant bit of the result is produced on the line labeled S, while the most significant bit of the result is produced on the line labeled “carry out”.

The desired truth table of the one bit adder is thus:

page 21 out of 27 Last modified on 11/16/2002 12:35:00 AM

Page 22: Physics 219 Fall, 1995academics.wellesley.edu/Physics/Rberg/logochip/docs/... · Web viewWith CMOS logic this asymmetry does not exist, but old habits are hard to break and active

Physics 219, Fall, 2002 Combinational Logic

INPUTS: Carry In

A B OUTPUTS:

Carry Out

Sum

0 0 0 0 0

0 0 1 0 1

0 1 0 0 1

0 1 1 1 0

1 0 0 0 1

1 0 1 1 0

1 1 0 1 0

1 1 1 1 1

The one bit adders can be readily “cascaded” together by tying the carry out of one adder to the carry in of another adder to produce a multi-bit adder. For example the scheme shown in the figure below will add two arbitrary 4 bit numbers together to produce a 5 bit result (the most significant bit of the sum being contained on the carry out line of the last stage.)

page 22 out of 27 Last modified on 11/16/2002 12:35:00 AM

Page 23: Physics 219 Fall, 1995academics.wellesley.edu/Physics/Rberg/logochip/docs/... · Web viewWith CMOS logic this asymmetry does not exist, but old habits are hard to break and active

Physics 219, Fall, 2002 Combinational Logic

4-bit adder

The main challenge then in implementing the above plan is to figure out how to implement the one bit adder using simple logic gates.

Let us first figure out the logic required to produce each of the two output bits,

S and

Cout .

1) Least Significant bit S. Note that the sum S =AXOR B when

Cin is LOW. When

Cin is HIGH S =AXOR B. Thus we can implement this part of the truth table using two XOR gates:

page 23 out of 27 Last modified on 11/16/2002 12:35:00 AM

Page 24: Physics 219 Fall, 1995academics.wellesley.edu/Physics/Rberg/logochip/docs/... · Web viewWith CMOS logic this asymmetry does not exist, but old habits are hard to break and active

Physics 219, Fall, 2002 Combinational Logic

2) Most Significant bit Cout . Note from the above truth table that Cout is HIGH when either

(A and B are both HIGH) OR ((Cin is HIGH) AND (A OR B is HIGH))

which we can represent symbolically by

Cout =AB+ Cin A+ B( )

We can implement this with the following logic gates:

Putting the two parts together, the logic gate implementation of a one bit full adder is:

page 24 out of 27 Last modified on 11/16/2002 12:35:00 AM

Page 25: Physics 219 Fall, 1995academics.wellesley.edu/Physics/Rberg/logochip/docs/... · Web viewWith CMOS logic this asymmetry does not exist, but old habits are hard to break and active

Physics 219, Fall, 2002 Combinational Logic

Being able to add two numbers together might not seem like that big a deal, but you will see that the “instruction set” of operations that our microcontrollers is capable of performing consists of only a handful of very basic operations, none of which is much more complicated than simple addition.

It is the ability of the digital circuits to do lots of fairly simple operations very quickly and accurately that leads to the incredible power of modern computers. This leads to the very powerful idea of abstraction: Very simple building blocks can be “glued together” to creative more powerful (and specialized) building blocks, which can in turn be glued together to create even more powerful building blocks...

Arithmetic Logic Unit (ALU)

(See page 307 of Student Manual.)

An arithmetic logic unit (ALU), is a device which can perform any one of a selected instruction from the instruction set. It is a central feature of just about any computer.

Design a “1-bit ALU”. Two select lines should determine which of the following set of instructions the ALU performs on two input bits A and B: AND, OR, XOR,

page 25 out of 27 Last modified on 11/16/2002 12:35:00 AM

Page 26: Physics 219 Fall, 1995academics.wellesley.edu/Physics/Rberg/logochip/docs/... · Web viewWith CMOS logic this asymmetry does not exist, but old habits are hard to break and active

Physics 219, Fall, 2002 Combinational Logic

and ADD. Include “carry in” and “carry out” lines to support the ADD function.

Schematically the ALU will look like:

page 26 out of 27 Last modified on 11/16/2002 12:35:00 AM

Page 27: Physics 219 Fall, 1995academics.wellesley.edu/Physics/Rberg/logochip/docs/... · Web viewWith CMOS logic this asymmetry does not exist, but old habits are hard to break and active

Physics 219, Fall, 2002 Combinational Logic

Implementation:

The MUX is a “multiplexer” unit. A two bit “select” number chooses one of four input lines to be output. It can readily be built out of simple logic gates. See pages 296 – 299 of the Student Manual for more on multiplexers.

page 27 out of 27 Last modified on 11/16/2002 12:35:00 AM