You are on page 1of 59

Clase -4: Mapas de Karnaugh, Codificacin

Estudiamos las mapas de Karnaugh para simplificar expresiones booleanas Muchos Ejemplos Codificacin y coma flotante.

Estructura de Computadores I

Karnaugh maps

La ltima vez vimos como usar la lgica boleana para disear circuitos. Las operaciones boleanas bsicas son AND, OR y NOT. Estas operaciones se pueden combinar para formar expresiones complejas, que se pueden traducir directamente a un circuito. La lgebra boleana nos ayuda a simplificar expresiones y los circuitos. Hoy, vamos a utilizar un mtodo grafico para simplificar un expresin a una forma suma minima de productos (MSP) : Hay un nmero mnimo de los trminos del producto en la expresin. Cada trmino tiene un nmero mnimo de literales. Esto proceso nos da una implementacin minima de dos niveles

Estructura de Computadores I

Re-arranging the truth table

Una funcin dos-variable tiene cuatro minterms posibles. Podemos cambiar estos minterms en un mapa de Karnaugh.
x 0 0 1 1 y 0 1 0 1 minterm xy xy xy xy

Y 0 1 0 xy xy 1 xy xy

Ahora podemos ver fcilmente qu minterms contienen literales comunes. Minterms a la izquierdos y derechos contiene y e y respectivamente. Minterms en las filas arriba y abajo contiene x and x respectivamente.
Y 0 1 0 xy xy 1 xy xy
X X Y xy xy Y xy xy
3

Estructura de Computadores I

Karnaugh map simplifications



Imagina una suma de minterms de dos variables : xy + xy Ambos de estos minterms aparecen en la fila superior de un mapa de Karnaugh, que significa que l ambos contiene el literal x..
xy xy Y xy xy

Qu sucede si se simplifica esta expresin usando lgebra boleana? xy + xy = x(y + y) = x 1 = x [ Distributive ] [ y + y = 1 ] [x1=x]
4

Estructura de Computadores I

Ejemplo de ms que dos variables

Otra ejemplo es la expresin xy + xy. Ambos minterms aparecen en el lado derecho, donde y es uncomplemented. Entonces, podemos reducir xy + xy a solo y.
xy xy Y xy xy

Qu pasa con xy + xy + xy? Tenemos xy + xy en la fila en la cima, correspondinedo a x. Hay tambien xy + xy en el lado derecho, correspondiendo a y. Este expresin se puede reducir a x + y.
xy xy Y xy xy
5

Estructura de Computadores I

Una mapa-K de tres variables

Para una expresin de tres-variables con entradas x, y, z, la configuracin de los minterms es ms complicada:
00 xyz xyz 01 xyz xyz YZ 11 xyz xyz 10 xyz xyz 00 m0 m4 01 m1 m5 YZ 11 m3 m7 10 m2 m6

0 1

0 1

Otra manera para etiquetar la mapa-K (se puede usar cualquiera):


Y X xyz xyz xyz xyz Z xyz xyz xyz xyz

Y X m0 m4 m1 m5 Z m3 m7 m2 m6

Estructura de Computadores I

Por qu ordenar tan estrao?

Con esta ordenacin, cualquier grupo de 2, 4 o 8 cuadrados adyacentes en la mapa contiene los literales comunes que se pueden descomponer en factores hacia fuera.
Y X xyz xyz xyz xyz Z xyz xyz xyz xyz

xyz + xyz = xz(y + y) = xz 1 = xz

Adyacente incluye envolverse de los lados izquierdos y derechos:


Y X xyz xyz xyz xyz Z xyz xyz xyz xyz

= = = =

xyz + xyz + xyz + xyz z(xy + xy + xy + xy) z(y(x + x) + y(x + x)) z(y+y) z

Utilizaremos esta caracterstica de cuadrados adyacentes para hacer simplificaciones.


Estructura de Computadores I 7

Ejemplo: mapa-K simplificacin



considera simplificando f(x,y,z) = xy + yz + xz. Primero, debe convertir la expresin en la forma de suma de minterms forma, si no esta ya. La manera ms fcil de hacer esto es hacer una tabla de verdad para la funcin, y despus leer los minterms. Se puede escribir los literales o usar el minterm shorthand. Aqu est la tabla de verdad y la suma de los minterms por nuestro ejemplo:
x 0 0 0 0 1 1 1 1 y 0 0 1 1 0 0 1 1 z 0 1 0 1 0 1 0 1 f(x,y,z) 0 1 0 0 0 1 1 1

f(x,y,z) = xyz + xyz + xyz + xyz = m1 + m5 + m6 + m7

Estructura de Computadores I

Unsimplifying expressions

Se puede tambin convertir la expresin a una suma de minterms con lgebra boleana. Aplique la ley distributiva en revs para agregar en variables que falta. xy + yz + xz = (xy 1) + (yz 1) + (xz 1) = (xy (z + z)) + (yz (x + x)) + (xz (y + y)) = (xyz + xyz) + (xyz + xyz) + (xyz + xyz) = xyz + xyz + xyz + xyz

En ambos casos, no simplificando nuestra expresin del ejemplo. La expresin que resulta es ms grande que la original ! Pero tener todos los minterms individuales hace fcil combinarlos junto con el mapa-K.

Estructura de Computadores I

Making the example K-map

El paso siguiente es de dibujo y que completa el K-mapa. Poner 1s en la mapa para cada minterm, y 0s en los otros cuadros puede utilizar los productos del minterm para demostrarle donde pertenecen los 1s y los 0s. En nuestro ejemplo, podemos escribir el f(x, y, z) en dos maneras equivalentes. f(x,y,z) = xyz + xyz + xyz + xyz
Y X xyz xyz xyz xyz Z xyz xyz xyz xyz X m0 m4 m1 m5 Z
Y

f(x,y,z) = m1 + m5 + m6 + m7
Y m3 m7 m2 m6

En cualquier caso, el K-mapa que resulta se demuestra abajo.


0 0 1 1 Z
Estructura de Computadores I 10

0 1

0 1

K-maps from truth tables

Se puede tambin completar el K-mapa directamente de una tabla de verdad. La salida en la fila i de la tabla entra el cuadrado milla del K-mapa. Recuerde que las columnas de derecha del K-mapa estan intercambiados
Y

x 0 0 0 0

y 0 0 1 1

z 0 1 0 1

f(x,y,z) 0 1 0 0 0 0 1 1 Z

m0 m4

m1 m5 Z

m3 m7

m2 m6

Y X 0 1 0 1

1 1 1 1

0 0 1 1

0 1 0 1

0 1 1 1

Estructura de Computadores I

11

Agrupando los minterms juntos

El paso ms difcil est agrupando todo junto los 1s en el K-mapa. Haga los rectngulos alrededor de grupos de un, dos, cuatro u ocho 1s. Todos los 1s en la mapa debe incluir por minimo en uno de los cuadros. No incluye ninguna de los 0s
Y X 0 0 1 1 Z 0 1 0 1

Cada grupo corresponde a un trmino del producto. Para el resultado ms simple: Haga pocos rectngulos como sea posible, para reducir al mnimo el nmero de productos en la expresin final. Haga cada rectngulo tan grande como sea posible, para reducir al mnimo el nmero de literales en cada trmino. Es aceptable para que los rectngulos se solapan
Estructura de Computadores I 12

Lectura del MSP del K-mapa

Finalmente, se puede encontrar el MSP - Cada rectngulo corresponde a un trmino del producto. - El producto es determinado encontrando los literales comunes en ese rectngulo.
Y 0 0 1 1 Z 0 1 0 1

Para nuestro ejemplo, tenemos xy + yz + xz = yz + xy. (Este es una de los leyes lgebraicas que escribimos la ltima vez)
Y X xyz xyz xyz xyz Z
Estructura de Computadores I 13

xyz xyz

xyz xyz

Practica con mapas-K

Simplificar la suma de minterms m1 + m3 + m5 + m6.


Y X Z

Y X m0 m4 m1 m5 Z m3 m7 m2 m6

Estructura de Computadores I

14

Solutions for practice K-map 1

Aqu es la mapa-K con todos los grupos indicados. Los grupos magentas y verdes se solapan, que hace cada uno de ellos tan grande como sea posible. Minterm m6 esta dentro un grupo solo. Y 0 1 1 0 X 0 1 0 1 Z

El valor final de MSP es xz + yz + xyz.

Estructura de Computadores I

15

Four-variable K-maps

Podemos hacer una expresin de cuatro variables tambin! Los minterms en la tercer y cuarto columnas, y en la tercera y cuarta fila , estan intercambiado. Otro vez, este garantiza que adyacentes cuadros tiene literales comunes.
Y

wxyz wxyz wxyz wxyz

wxyz wxyz wxyz wxyz Z

wxyz wxyz wxyz wxyz

wxyz wxyz X wxyz wxyz

m0 m4 m12 m8

m1 m5 m13 m9 Z

m3 m7 m15 m11

m2 m6 X m14 m10

Agrupando minterms paracido al caso de tres-variables case, pero: Se puede tener grupos de 1, 2, 4, 8 o 16 minterms. Se puede wrap los cuatro lados .
Estructura de Computadores I 16

Ejemplo: Simplificar m0+m2+m5+m8+m10+m13

La expresin esta ya una suma de minterms, aqu esta la mapa-K:


Y
Y

1 0 0 1

0 1 1 0 Z

0 0 0 0

1 0 0 1

X
W

m0 m4 m12 m8

m1 m5 m13 m9 Z

m3 m7 m15 m11

m2 m6 m14 m10

Podemos hacer la siguiente agrupamiento, resultando en la MSP xz + xyz.


Y 1 0 0 1 0 1 1 0 Z 0 0 0 0 1 0 0 1 X W wxyz wxyz wxyz wxyz wxyz wxyz wxyz wxyz Z wxyz wxyz wxyz wxyz Y wxyz wxyz X wxyz wxyz

Estructura de Computadores I

17

K-maps puede ser complicado!

Puede ser que no hay MSP nicos. El K-mapa debajo da dos versiones vlidas y de MSPs equivalente, porque hay dos maneras posibles a incluir minterm m7.
Y X 0 0 1 1 Z
Y X 0 0 1 1 Z 0 1 1 1 X 0 0 1 1 Z 0 1 Y 1 1

0 1

1 1

yz + yz + xy

yz + yz + xz

Recuerde que los grupos que solapa son posibles, segn lo demostrado arriba.
Estructura de Computadores I 18

Prime implicants
El desafo al usar K-mapas est seleccionando los grupos adecuados. Si no se reduce al mnimo el nmero de grupos y no maximiza el tamao de cada grupo: Su expresin que resulta todava ser equivalente la original. Pero no ser una suma mnima de productos. Cul es un buen manera para encontrar un MSP real? Primero encuentre todas las agrupaciones posibles ms grandes de 1s. stos se llaman los implicants primarios. El MSP final contendr un subconjunto de estos implicants primeros. Aqu est un mapa de Karnaugh del ejemplo con los implicants primeros marcados Y
1 1 0 0 1 1 1 0 Z
Estructura de Computadores I 19

0 0 1 1

0 0 0 1

Essential prime implicants


Y 1 1 0 0 1 1 1 0 Z 0 0 1 1 0 0 0 1 X

Si cualquier grupo contiene un minterm que tambin no sea cubierto por otro grupo solopado, entonces se es un implicant primero esencial. Los implicants primeros esenciales deben aparecer en el MSP, puesto que contienen los minterms que ningunos otros trminos incluyen. Nuestro ejemplo tiene apenas dos implicants primeros esenciales: El grupo rojo (wy) es essencial, por m0, m1 y m4. El grupo verder (wxy) es essencial, por m10.

Estructura de Computadores I

20

Covering the other minterms


Y 1 1 0 0 1 1 1 0 Z 0 0 1 1 0 0 0 1 X

Finalmente escoja como pocos otros implicants primeros como necesarios para asegurarse de que todos los minterms estn cubiertos. Despus de elegir los rectngulos rojos y verdes en nuestro ejemplo, hay apenas dos minterms a la izquierda que se cubrirn , m13 y m15. stos son ambo incluidos en el implicant primero azul , wxz. El MSP que resulta es wy + wxz + wxy. Los grupos negros y amarillos no son necesarios, puesto que todos los minterms son cubiertos por los otros tres grupos.

Estructura de Computadores I

21

Practica 2 con mapa-K

Simplificar la siguiente mapa-K:

Y 0 1 1 0 0 0 1 0 Z 1 1 1 1 0 1 X 1 0

Estructura de Computadores I

22

Solutions for practice K-map 2

Simplifica la siguiente mapa-K:


Y 0 1 1 0 0 0 1 0 Z 1 1 1 1 0 1 X 1 0

Se circula todos los implicants primeros. Essencial prime implicants son xz, wx y yz. El MSP es xz + wx + yz. (Incluyendo el grupo xy sera redundante)

Estructura de Computadores I

23

I dont care!

You dont always need all 2n input combinations in an n-variable function. If you can guarantee that certain input combinations never occur. If some outputs arent used in the rest of the circuit. We mark dont-care outputs in truth tables and K-maps with Xs.
x 0 0 0 0 1 1 1 1 y 0 0 1 1 0 0 1 1 z 0 1 0 1 0 1 0 1 f(x,y,z) 0 1 X 0 0 1 X 1

Within a K-map, each X can be considered as either 0 or 1. You should pick the interpretation that allows for the most simplification.
Estructura de Computadores I 24

Practice K-map 3

Buscar un MSP para f(w,x,y,z) = m(0,2,4,5,8,14,15), d(w,x,y,z) = m(7,10,13) Esta notacin significa que las combinaciones de la entrada wxyz = 0111, 1010 y 1101 (correspondiendo a minterms m7, m10 and m13) estan sin utilizar.
Y 1 1 0 1 0 1 x 0 Z 0 x 1 0 1 0 X 1 x

Estructura de Computadores I

25

Solutions for practice K-map 3

Buscar un MSP para: f(w,x,y,z) = m(0,2,4,5,8,14,15), Y 1 0 0 1 1 x W 0 x 1 1 0 0 Z d(w,x,y,z) = m(7,10,13) 1 0 X 1 x

All prime implicants are circled. We can treat Xs as 1s if we want, so the red group includes two Xs, and the light blue group includes one X. The only essential prime implicant is xz. The red group is not essential because the minterms in it also appear in other groups. The MSP is xz + wxy + wxy. It turns out the red group is redundant; we can cover all of the minterms in the map without it.
Estructura de Computadores I 26

Example: Seven Segment Display


A B 0 0 0 0 1 1 1 1 0 0 C 0 0 1 1 0 0 1 1 0 0 D 0 1 0 1 0 1 0 1 0 1 e 1 0 1 0 0 0 1 0 1 0 X X X X X
27

Input: digit encoded as 4 bits: ABCD Table for e a f e d g c


CD AB 00 01 11 10 00 1 0 X 1 01 0 0 X 0

0 1 2 3 4 5 6 7 8 9 X X X X X

0 0 0 0 0 0 0 0 1 1

Assumption: Input represents a legal digit (0-9)


11 0 0 X X 10 1 1 X X

CD + BD
Estructura de Computadores I

Example: Seven Segment Display


A B 0 0 0 0 1 1 1 1 0 0 C 0 0 1 1 0 0 1 1 0 0 D 0 1 0 1 0 1 0 1 0 1 a 1 0 1 1 0 1 1 1 1 1 X X X X X
28

a f e d g c
CD AB 00 01 11 10 X 1

0
b Table for a

0 0 0 0 0 0 0 0 1 1

1 2 3 4 5 6 7 8 9 X X X X X

00 1

01

11 1

10 1 1 X X

1 X 1

1 X X

A + C + BD + BD
Estructura de Computadores I

Summary

K-maps are an alternative to algebra for simplifying expressions. The result is a minimal sum of products, which leads to a minimal two-level circuit. Its easy to handle dont-care conditions. K-maps are really only good for manual simplification of small expressions... but thats good enough for CS231! Things to keep in mind: Remember the correct order of minterms on the K-map. When grouping, you can wrap around all sides of the K-map, and your groups can overlap. Make as few rectangles as possible, but make each of them as large as possible. This leads to fewer, but simpler, product terms. There may be more than one valid solution.

Estructura de Computadores I

29

Basic circuit analysis and design

W have learned all the prerequisite material: Truth tables and Boolean expressions describe functions. Expressions can be converted into hardware circuits. Boolean algebra and K-maps help simplify expressions and circuits. Now, let us put all of these foundations to good use, to analyze and design some larger circuits.

Estructura de Computadores I

30

Circuit analysis

Circuit analysis involves figuring out what some circuit does. Every circuit computes some function, which can be described with Boolean expressions or truth tables. So, the goal is to find an expression or truth table for the circuit. The first thing to do is figure out what the inputs and outputs of the overall circuit are. This step is often overlooked! The example circuit here has three inputs x, y, z and one output f.

Estructura de Computadores I

31

Write algebraic expressions...

Next, write expressions for the outputs of each individual gate, based on that gates inputs. Start from the inputs and work towards the outputs. It might help to do some algebraic simplification along the way. Here is the example again. We did a little simplification for the top AND gate. You can see the circuit computes f(x,y,z) = xz + yz + xyz

Estructura de Computadores I

32

...or make a truth table



Its also possible to find a truth table directly from the circuit. Once you know the number of inputs and outputs, list all the possible input combinations in your truth table. A circuit with n inputs should have a truth table with 2n rows. Our example has three inputs, so the truth table will have 23 = 8 rows. All the possible input combinations are shown.
x 0 0 0 0 1 1 1 1 y 0 0 1 1 0 0 1 1 z 0 1 0 1 0 1 0 1 f

Estructura de Computadores I

33

Simulating the circuit



Then you can simulate the circuit, either by hand or with a program like LogicWorks, to find the output for each possible combination of inputs. For example, when xyz = 101, the gate outputs would be as shown below. Use truth tables for AND, OR and NOT to find the gate outputs. For the final output, we find that f(1,0,1) = 1.

1 0 1

1 1 1 0

x 0 0 0 0 1 1 1 1

y 0 0 1 1 0 0 1 1

z 0 1 0 1 0 1 0 1

0 0

Estructura de Computadores I

34

Finishing the truth table



Doing the same thing for all the other input combinations yields the complete truth table. This is simple, but tedious.

x 0 0 0 0 1 1 1 1

y 0 0 1 1 0 0 1 1

z 0 1 0 1 0 1 0 1

f 0 1 1 0 0 1 0 1

Estructura de Computadores I

35

Expressions and truth tables



Remember that if you already have a Boolean expression, you can use that to easily make a truth table. For example, since we already found that the circuit computes the function f(x,y,z) = xz + yz + xyz, we can use that to fill in a table: We show intermediate columns for the terms xz, yz and xyz. Then, f is obtained by just ORing the intermediate columns.
x 0 0 0 0 1 1 1 1 y 0 0 1 1 0 0 1 1 z 0 1 0 1 0 1 0 1 xz 0 0 0 0 0 1 0 1 yz 0 1 0 0 0 1 0 0 xyz 0 0 1 0 0 0 0 0 f 0 1 1 0 0 1 0 1

Estructura de Computadores I

36

Truth tables and expressions



The opposite is also true: its easy to come up with an expression if you already have a truth table. We saw that you can quickly convert a truth table into a sum of minterms expression. The minterms correspond to the truth table rows where the output is 1.
x 0 0 0 0 1 1 1 1 y 0 0 1 1 0 0 1 1 z 0 1 0 1 0 1 0 1 f 0 1 1 0 0 1 0 1

f(x,y,z) = xyz + xyz + xyz + xyz = m1 + m2 + m5 + m7

You can then simplify this sum of minterms if desiredusing a K-map, for example.
Estructura de Computadores I 37

Circuit analysis summary



After finding the circuit inputs and outputs, you can come up with either an expression or a truth table to describe what the circuit does. You can easily convert between expressions and truth tables.

Find the circuits inputs and outputs

Find a Boolean expression for the circuit

Find a truth table for the circuit

Estructura de Computadores I

38

Basic circuit design



The goal of circuit design is to build hardware that computes some given function. The basic idea is to write the function as a Boolean expression, and then convert that to a circuit. Step 1: Figure out how many inputs and outputs you have. Step 2: Make sure you have a description of the function, either as a truth table or a Boolean expression. Step 3: Convert this into a simplified Boolean expression. (For this course, well expect you to find MSPs, unless otherwise stated.) Step 4: Build the circuit based on your simplified expression.

Estructura de Computadores I

39

Design example: Comparing 2-bit numbers

Lets design a circuit that compares two 2-bit numbers, A and B. The circuit should have three outputs: G (Greater) should be 1 only when A > B. E (Equal) should be 1 only when A = B. L (Lesser) should be 1 only when A < B. Make sure you understand the problem. Inputs A and B will be 00, 01, 10, or 11 (0, 1, 2 or 3 in decimal). For any inputs A and B, exactly one of the three outputs will be 1.

Estructura de Computadores I

40

Step 1: How many inputs and outputs?

Two 2-bit numbers means a total of four inputs. We should name each of them. Lets say the first number consists of digits A1 and A0 from left to right, and the second number is B1 and B0. The problem specifies three outputs: G, E and L.

Here is a block diagram that shows the inputs and outputs explicitly. Now we just have to design the circuitry that goes into the box.

Estructura de Computadores I

41

Step 2: Functional specification

For this problem, its probably easiest to start with a truth table. This way, we can explicitly show the relationship (>, =, <) between inputs. A four-input function has a sixteenrow truth table. Its usually clearest to put the truth table rows in binary numeric order; in this case, from 0000 to 1111 for A1, A0, B1 and B0. Example: 01 < 10, so the sixth row of the truth table (corresponding to inputs A=01 and B=10) shows that output L=1, while G and E are both 0.
A1 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 A0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 B1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 B0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 G 0 0 0 0 1 0 0 0 1 1 0 0 1 1 1 0 E 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 L 0 1 1 1 0 0 1 1 0 0 0 1 0 0 0 0

Estructura de Computadores I

42

Step 3: Simplified Boolean expressions

Lets use K-maps. There are three functions (each with the same inputs A1 A0 B1 B0), so we need three K-maps.
B1 0 1 1 1 0 0 1 1 B0 0 0 0 0 0 0 A0 1 0 1 0 0 0 0 1 0 0 B0 0 0 1 0 B1 0 0 A0 0 1 0 0 0 0 1 0 0 0 B0 1 1 0 1 B1 1 1 A0 0 0

A1

A1

A1

G(A1,A0,B1,B0) = A1 A0 B0 + A0 B1 B0 + A1 B1

E(A1,A0,B1,B0) = A1 A0 B1 B0 + A1 A0 B1 B0 + A1 A0 B1 B0 + A1 A0 B1 B0

L(A1,A0,B1,B0) = A1 A0 B0 + A0 B1 B0 + A1 B1

Estructura de Computadores I

43

Step 4: Drawing the circuits


G = A1 A0 B0 + A0 B1 B0 + A1 B1 E = A1 A0 B1 B0 + A1 A0 B1 B0 + A1 A0 B1 B0 + A1 A0 B1 B0 L = A1 A0 B0 + A0 B1 B0 + A1 B1

LogicWorks has gates with NOTs attached (small bubbles) for clearer diagrams.

Estructura de Computadores I

44

Testing this in LogicWorks



Where do the inputs come from? Binary switches, in LogicWorks How do you view outputs? Use binary probes. probe

switches
Estructura de Computadores I 45

Example wrap-up

Data representations. We used three outputs, one for each possible scenario of the numbers being greater, equal or less than each other. This is sometimes called a one out of three code. K-map advantages and limitations. Our circuits are two-level implementations, which are relatively easy to draw and follow. But, E(A1,A0,B1,B0) couldnt be simplified at all via K-maps. Can you do better using Boolean algebra? Extensibility. We used a brute-force approach, listing all possible inputs and outputs. This makes it difficult to extend our circuit to compare three-bit numbers, for instance. Well have a better solution after we talk about computer arithmetic.

Estructura de Computadores I

46

Summary

Functions can be represented with expressions, truth tables or circuits. These are all equivalent, and we can arbitrarily transform between them. Circuit analysis involves finding an expression or truth table from a given logic diagram. Designing a circuit requires you to first find a (simplified) Boolean expression for the function you want to compute. You can then convert the expression into a circuit. Next time well talk about some building blocks for making larger combinational circuits, and the role of abstraction in designing large systems.

Estructura de Computadores I

47

Additional gates

Weve already seen all the basic Boolean operations and the associated primitive logic gates. There are a few additional gates that are often used in logic design. They are all equivalent to some combination of primitive gates. But they have some interesting properties in their own right.

Estructura de Computadores I

48

Additional Boolean operations


Operation: Expressions: Truth table: NAND (NOT-AND) (xy) = x + y
x 0 0 1 1 y (xy) 0 1 0 1 1 1 1 0

NOR (NOT-OR) (x + y) = x y
x 0 0 1 1 y 0 1 0 1 (x+y) 1 0 0 0

XOR (eXclusive OR) x y = xy + xy


x 0 0 1 1 y 0 1 0 1 xy 0 1 1 0

Logic gates:

Estructura de Computadores I

49

NANDs are special!

The NAND gate is universal: it can replace all other gates! NOT
(xx) = x [ because xx = x ]

AND
((xy) (xy)) = xy [ from NOT above ]

OR
((xx) (yy)) = (x y) =x+y [ xx = x, and yy = y ] [ DeMorgans law ]

Estructura de Computadores I

50

Making NAND circuits



The easiest way to make a NAND circuit is to start with a regular, primitive gate-based diagram. Two-level circuits are trivial to convert, so here is a slightly more complex random example.

Estructura de Computadores I

51

Converting to a NAND circuit

Step 1: Convert all AND gates to NAND gates using AND-NOT symbols, and convert all OR gates to NAND gates using NOT-OR symbols.

Estructura de Computadores I

52

Converting to NAND, concluded

Step 2: Make sure you added bubbles along lines in pairs ((x) = x). If not, then either add inverters or complement the input variables.

Estructura de Computadores I

53

NOR gates

The NOR operation is the dual of the NAND. NOR gates are also universal. We can convert arbitrary circuits to NOR diagrams by following a procedure similar to the one just shown: Step 1: Convert all OR gates to NOR gates (OR-NOT), and all AND gates to NOR gates (NOT-AND). Step 2: Make sure that you added bubbles along lines in pairs. If not, then either add inverters or complement input variables.

Estructura de Computadores I

54

XOR gates

A two-input XOR gate outputs true when exactly one of its inputs is true:
x y 1 0 1 xy 0 1 1 0 0 0 1 1 0

x y = x y + x y

XOR corresponds more closely to typical English usage of or, as in eat your vegetables or you wont get any pudding. Several fascinating properties of the XOR operation: x0=x x 1 = x xx=0 x x = 1 x (y z) = (x y) z xy=yx [ Associative ] [ Commutative ]

Estructura de Computadores I

55

More XOR tidbits



The general XOR function is true when an odd number of its arguments are true. For example, we can use Boolean algebra to simplify a three-input XOR to the following expression and truth table.
x y z x y z 0 1 1 0 1 0 0 1

x (y z) = x (yz + yz) = x(yz + yz) + x(yz + yz) = xyz + xyz + x(yz + yz) = xyz + xyz + x((yz) (yz)) = xyz + xyz + x((y + z)(y + z)) = xyz + xyz + x(yz + yz) = xyz + xyz + xyz + xyz

[ Definition of XOR ] [ Definition of XOR ] [ Distributive ] [ DeMorgans ] [ DeMorgans ] [ Distributive ] [ Distributive ]

0 0 0 0 1 1 1 1

0 0 1 1 0 0 1 1

0 1 0 1 0 1 0 1

XOR is especially useful for building adders (as well see on later) and error detection/correction circuits.
Estructura de Computadores I 56

XNOR gates

Finally, the complement of the XOR function is the XNOR function. A two-input XNOR gate is true when its inputs are equal:
x 0 0 1 1 y (xy) 0 1 0 1 1 0 0 1

(x y) = xy + xy

Estructura de Computadores I

57

Design considerations, and where they come from

Circuits made up of gates, that dont have any feedback, are called

combinatorial circuits

No feedback: outputs are not connected to inputs If you change the inputs, and wait for a while, the correct outputs show up. Why? Capacitive loading: fill up the water level analogy. So, when such ckts are used in a computer, the time it takes to get stable outputs is important. For the same reason, a single output cannot drive too many inputs Will be too slow to fill them up May not have enough power So, the design criteria are: Propagation delay (how many gets in a sequence from in to out) Fan-out Fan-in (Number of inputs to a single gate)
Estructura de Computadores I 58

Summary

NAND and NOR are universal gates which can replace all others. There are two representations for NAND gates (AND-NOT and NOT-OR), which are equivalent by DeMorgans law. Similarly, there are two representations for NOR gates too. You can convert a circuit with primitive gates into a NAND or NOR diagram by judicious use of the axiom (x) = x, to ensure that you dont change the overall function. An XOR gate implements the odd function, outputting 1 when there are an odd number of 1s in the inputs. They can make circuit diagrams easier to understand.

Estructura de Computadores I

59