lecture 3 combinational circuits topics basic gates (3.1) adders: half-adder, full-adder gray code...

24
Lecture 3 Combinational Circuits Topics Topics Basic Gates (3.1) Adders: half-adder, full-adder Gray Code (2.11) N-cube (2.14) Error Correcting codes (2.15) Boolean Algebra (4.1) Combinational-Circuit Analysis (4.2) August 28, 2003 CSCE 211 Digital Design

Upload: corey-smith

Post on 21-Jan-2016

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture 3 Combinational Circuits Topics Basic Gates (3.1) Adders: half-adder, full-adder Gray Code (2.11) N-cube (2.14) Error Correcting codes (2.15) Boolean

Lecture 3Combinational Circuits

Lecture 3Combinational Circuits

TopicsTopics Basic Gates (3.1) Adders: half-adder, full-adder Gray Code (2.11) N-cube (2.14) Error Correcting codes (2.15) Boolean Algebra (4.1) Combinational-Circuit Analysis (4.2)

August 28, 2003

CSCE 211 Digital Design

Page 2: Lecture 3 Combinational Circuits Topics Basic Gates (3.1) Adders: half-adder, full-adder Gray Code (2.11) N-cube (2.14) Error Correcting codes (2.15) Boolean

– 2 – CSCE 211H Fall 2003

OverviewOverview

Last TimeLast Time Conversion of Fractions decimal base-r Representations of Integers

Unsigned, signed magnitude, one’s complement, two’s complement Arithmetic BCD, representations of characters BCD, unicode

On last Time’s Slides(what we didn’t get to)On last Time’s Slides(what we didn’t get to) Basic gates (well almost on transparencies) Adder circuits

NewNew Boolean algebra Combinational circuits

VHDLVHDL ButNot Table 4-36 page 277

History: George BooleHistory: George Boole

Page 3: Lecture 3 Combinational Circuits Topics Basic Gates (3.1) Adders: half-adder, full-adder Gray Code (2.11) N-cube (2.14) Error Correcting codes (2.15) Boolean

– 3 – CSCE 211H Fall 2003

Page 4: Lecture 3 Combinational Circuits Topics Basic Gates (3.1) Adders: half-adder, full-adder Gray Code (2.11) N-cube (2.14) Error Correcting codes (2.15) Boolean

– 4 – CSCE 211H Fall 2003

Basic GatesBasic Gates

ANDAND

OROR

NOTNOT

Page 5: Lecture 3 Combinational Circuits Topics Basic Gates (3.1) Adders: half-adder, full-adder Gray Code (2.11) N-cube (2.14) Error Correcting codes (2.15) Boolean

– 5 – CSCE 211H Fall 2003

Basic GatesBasic Gates

NANDNAND

NORNOR

XORXOR

Page 6: Lecture 3 Combinational Circuits Topics Basic Gates (3.1) Adders: half-adder, full-adder Gray Code (2.11) N-cube (2.14) Error Correcting codes (2.15) Boolean

– 6 – CSCE 211H Fall 2003

Half Adder CircuitHalf Adder Circuit

Page 7: Lecture 3 Combinational Circuits Topics Basic Gates (3.1) Adders: half-adder, full-adder Gray Code (2.11) N-cube (2.14) Error Correcting codes (2.15) Boolean

– 7 – CSCE 211H Fall 2003

Full AdderFull Adder

Page 8: Lecture 3 Combinational Circuits Topics Basic Gates (3.1) Adders: half-adder, full-adder Gray Code (2.11) N-cube (2.14) Error Correcting codes (2.15) Boolean

– 8 – CSCE 211H Fall 2003

Ripple Carry AdderRipple Carry Adder

Page 9: Lecture 3 Combinational Circuits Topics Basic Gates (3.1) Adders: half-adder, full-adder Gray Code (2.11) N-cube (2.14) Error Correcting codes (2.15) Boolean

– 9 – CSCE 211H Fall 2003

Gray CodeGray Code

In some mechanical devices you want to encode In some mechanical devices you want to encode positions as binary strings in such a way that positions as binary strings in such a way that positions close to each other are represented by positions close to each other are represented by strings that are close together. strings that are close together.

Gray code – adjacent position differ in only one bitGray code – adjacent position differ in only one bit 000 001 011 010 110 111 101 100

Figure 2-6 encoding diskFigure 2-6 encoding disk

Page 10: Lecture 3 Combinational Circuits Topics Basic Gates (3.1) Adders: half-adder, full-adder Gray Code (2.11) N-cube (2.14) Error Correcting codes (2.15) Boolean

– 10 – CSCE 211H Fall 2003

Construction of Gray CodesConstruction of Gray Codes

Gray Codes are reflectiveGray Codes are reflective

Algorithm for construction of Gray Codes on n-bitsAlgorithm for construction of Gray Codes on n-bits

1.1. A 1-bit Gray code has two words 0 and 1.A 1-bit Gray code has two words 0 and 1.

2.2. The first 2n words of an (n+1)-bit gray code are the The first 2n words of an (n+1)-bit gray code are the words of the n-bit gray code with a leading 0 added.words of the n-bit gray code with a leading 0 added.

3.3. The next 2n words of an (n+1)-bit gray code are the The next 2n words of an (n+1)-bit gray code are the words of the n-bit gray code but written in reverse words of the n-bit gray code but written in reverse order with a leading 1 added.order with a leading 1 added.

Page 11: Lecture 3 Combinational Circuits Topics Basic Gates (3.1) Adders: half-adder, full-adder Gray Code (2.11) N-cube (2.14) Error Correcting codes (2.15) Boolean

– 11 – CSCE 211H Fall 2003

Construction of Gray CodesConstruction of Gray Codes

1-bit gray code1-bit gray code 0 1

2-bit gray code2-bit gray code 00 01 11 10

3-bit gray code3-bit gray code 0 00 0 01 0 11 0 10 1 10 1 11 1 01 1 00

4-bit gray code4-bit gray code 0 000

Page 12: Lecture 3 Combinational Circuits Topics Basic Gates (3.1) Adders: half-adder, full-adder Gray Code (2.11) N-cube (2.14) Error Correcting codes (2.15) Boolean

– 12 – CSCE 211H Fall 2003

Gray Code Generation Algorithm 2Gray Code Generation Algorithm 2

AlgorithmAlgorithm

1.1. The bits of an n-bit binary and n-bit Gray-code code The bits of an n-bit binary and n-bit Gray-code code word are numbered from right to left from 0 to n-1.word are numbered from right to left from 0 to n-1.

2.2. Bit i of a Gray-code word is 0 if bits i and i+1 of the Bit i of a Gray-code word is 0 if bits i and i+1 of the corresponding binary code word are the same, else corresponding binary code word are the same, else bit i is 1. (When i = n-1, bit n is considered to be 0.)bit i is 1. (When i = n-1, bit n is considered to be 0.)

ExampleExample

Given 0100 1010 Given 0100 1010

Add fake 0 on front bit n is 0Add fake 0 on front bit n is 0

0 0100 1010 0 0100 1010 0110 1111 0110 1111

Page 13: Lecture 3 Combinational Circuits Topics Basic Gates (3.1) Adders: half-adder, full-adder Gray Code (2.11) N-cube (2.14) Error Correcting codes (2.15) Boolean

– 13 – CSCE 211H Fall 2003

Codes representing charactersCodes representing characters

ASCII (American Standard Code for Information ASCII (American Standard Code for Information Interchange) – 8 bits = 7 + parityInterchange) – 8 bits = 7 + parity

Unicode 16 bitsUnicode 16 bits

Page 14: Lecture 3 Combinational Circuits Topics Basic Gates (3.1) Adders: half-adder, full-adder Gray Code (2.11) N-cube (2.14) Error Correcting codes (2.15) Boolean

– 14 – CSCE 211H Fall 2003

N-cubesN-cubes

1-cube1-cube

2-cube2-cube

3-cube3-cube

Traversing in gray-code orderTraversing in gray-code order

Page 15: Lecture 3 Combinational Circuits Topics Basic Gates (3.1) Adders: half-adder, full-adder Gray Code (2.11) N-cube (2.14) Error Correcting codes (2.15) Boolean

– 15 – CSCE 211H Fall 2003

Parity BitsParity Bits

Even parity bit – parity bit is set so that the number of Even parity bit – parity bit is set so that the number of ones is evenones is even

Odd parity bitOdd parity bit

Page 16: Lecture 3 Combinational Circuits Topics Basic Gates (3.1) Adders: half-adder, full-adder Gray Code (2.11) N-cube (2.14) Error Correcting codes (2.15) Boolean

– 16 – CSCE 211H Fall 2003

Error Correcting codesError Correcting codes

For an n-bit code, consider the hypercube of dimension nFor an n-bit code, consider the hypercube of dimension n

Choose some subset of the nodes as code words.Choose some subset of the nodes as code words.

Suppose the distance between any two two code words is at least 3.Suppose the distance between any two two code words is at least 3.

Now consider transmission errors.Now consider transmission errors.

Then if there is an error in transmitting just one bit then the distance Then if there is an error in transmitting just one bit then the distance from the received word to one code word is one, distances to from the received word to one code word is one, distances to other code words are at least two.other code words are at least two.

Single error correcting, double error detecting.Single error correcting, double error detecting.

Such codes are called Hamming codes after their inventor Richard Such codes are called Hamming codes after their inventor Richard Hamming. Hamming.

Page 17: Lecture 3 Combinational Circuits Topics Basic Gates (3.1) Adders: half-adder, full-adder Gray Code (2.11) N-cube (2.14) Error Correcting codes (2.15) Boolean

– 17 – CSCE 211H Fall 2003

Boolean AlgebraBoolean Algebra

George Boole (1854) invented a two valued algebraGeorge Boole (1854) invented a two valued algebra

To “give expression … to the fundamental laws of To “give expression … to the fundamental laws of reasoning in the symbolic language of a Calculus.”reasoning in the symbolic language of a Calculus.”

1938 Claude Shannon at Bell Labs noted that this 1938 Claude Shannon at Bell Labs noted that this Boolean logic could be used to describe switching Boolean logic could be used to describe switching circuits. (Switching Algebra)circuits. (Switching Algebra)

In Shannon’s view a relay had two positions open and In Shannon’s view a relay had two positions open and closed and collections of relays satisfied the closed and collections of relays satisfied the properties of Boolean algebra.properties of Boolean algebra.

Page 18: Lecture 3 Combinational Circuits Topics Basic Gates (3.1) Adders: half-adder, full-adder Gray Code (2.11) N-cube (2.14) Error Correcting codes (2.15) Boolean

– 18 – CSCE 211H Fall 2003

Boolean Algebra AxiomsBoolean Algebra Axioms

The axioms of a mathematical system are a minimal set The axioms of a mathematical system are a minimal set of properties that are assumed to be true.of properties that are assumed to be true.

Axioms of Boolean AlgebraAxioms of Boolean Algebra

1.1. X = 0 if X != 1 X = 0 if X != 1 X=1 if X!=0X=1 if X!=0

2.2. If X = 0, then X’ = 1If X = 0, then X’ = 1 if X=1 then X’=0if X=1 then X’=0

3.3. 0 . 0 = 00 . 0 = 0 1 + 1 = 11 + 1 = 1

4.4. 1 . 1 = 11 . 1 = 1 0 + 0 = 00 + 0 = 0

5.5. 0 . 1 = 1 . 0 = 00 . 1 = 1 . 0 = 0 1 + 0 = 0 + 1 = 11 + 0 = 0 + 1 = 1

Axioms 1-5 and 1-5’ completely define Boolean algebra.Axioms 1-5 and 1-5’ completely define Boolean algebra.

Page 19: Lecture 3 Combinational Circuits Topics Basic Gates (3.1) Adders: half-adder, full-adder Gray Code (2.11) N-cube (2.14) Error Correcting codes (2.15) Boolean

– 19 – CSCE 211H Fall 2003

Boolean Algebra TheoremsBoolean Algebra Theorems

Proofs by perfect inductionProofs by perfect induction

Page 20: Lecture 3 Combinational Circuits Topics Basic Gates (3.1) Adders: half-adder, full-adder Gray Code (2.11) N-cube (2.14) Error Correcting codes (2.15) Boolean

– 20 – CSCE 211H Fall 2003

More TheoremsMore Theorems

N.B. T8N.B. T8, T10, T11, T10, T11

Page 21: Lecture 3 Combinational Circuits Topics Basic Gates (3.1) Adders: half-adder, full-adder Gray Code (2.11) N-cube (2.14) Error Correcting codes (2.15) Boolean

– 21 – CSCE 211H Fall 2003

DualityDuality

Swap 0 & 1, AND & ORSwap 0 & 1, AND & OR Result: Theorems still true

Why?Why? Each axiom (A1-A5) has a dual (A1-A5

Counterexample:Counterexample:X + X X + X Y = X (T9) Y = X (T9)X X X + Y = X (dual) X + Y = X (dual)X + Y = X (T3X + Y = X (T3))????????????????????????

X + (X Y) = X (T9)X (X + Y) = X (dual)(X X) + (X Y) = X (T8)X + (X Y) = X (T3)parentheses,operator precedence!

Page 22: Lecture 3 Combinational Circuits Topics Basic Gates (3.1) Adders: half-adder, full-adder Gray Code (2.11) N-cube (2.14) Error Correcting codes (2.15) Boolean

– 22 – CSCE 211H Fall 2003

N-variable TheoremsN-variable Theorems

Prove using finite inductionProve using finite induction

Most important: DeMorgan theoremsMost important: DeMorgan theorems

Page 23: Lecture 3 Combinational Circuits Topics Basic Gates (3.1) Adders: half-adder, full-adder Gray Code (2.11) N-cube (2.14) Error Correcting codes (2.15) Boolean

– 23 – CSCE 211H Fall 2003

Combinational Circuit AnalysisCombinational Circuit Analysis

A combinational circuit is one whose outputs are a A combinational circuit is one whose outputs are a function of its inputs and only its inputs.function of its inputs and only its inputs.

These circuits can be analyzed using:These circuits can be analyzed using:

1.1. Truth tablesTruth tables

2.2. Algebraic equationsAlgebraic equations

3.3. Logic diagramsLogic diagrams

Page 24: Lecture 3 Combinational Circuits Topics Basic Gates (3.1) Adders: half-adder, full-adder Gray Code (2.11) N-cube (2.14) Error Correcting codes (2.15) Boolean

– 24 – CSCE 211H Fall 2003

Truth TablesTruth Tables