<<

Architecture

Lecture A3: Boolean Circuits Lecture A1 –A2. ■ TOY machine.

Lecture A3 – A4.

■ Digital circuits.

Lecture A5.

■ Putting it all together.

George Boole Claude Shannon (1815 – 1864) (1916 – present)

2

Digital Circuits Switches

What is a digital system? Abstract switch. ! Digital: signals only assume discrete values (0, 1). ■ Electrical (transistor). ! Analog: signals vary continuously. ■ Electro-mechanical (relay).

■ Hydraulic (water valve). Hydraulic OR Gate Why digital systems? ! Accuracy and reliability.

Basic abstraction.

■ On, off.

■ Switch that can turn something on or off.

Digital circuits and you.

.

■ Antilock brakes.

■ VCR.

■ Cell phone.

3 4 Logical Gates Multiway AND Gates

Logical gates. AND(x0, x1, x2, x3, x4, x5, x6, x7).

■ Fundamental building blocks. ■ 1 if all inputs are 1.

■ 0 otherwise. x x x x' xy x + y y y

0 0 0 0 0 0

0 0 0 1 0 1 1 1 1 1 1 0 0 1 0 0

1 1 1 1 1 1

NOT AND OR

5 6

Multiway OR Gates

OR(x0, x1, x2, x3, x4, x5, x6, x7). History.

■ 1 if at least one input is 1. ■ Developed by Boole to solve mathematical logic problems (1847).

■ 0 otherwise. ■ Shannon first applied to digital circuits (1939).

Basics.

■ Boolean variable: value is 0 or 1.

: function whose inputs and outputs are 0, 1.

Relationship to circuits.

■ Boolean variables: signals.

■ Boolean functions: circuits.

7 8 Truth Table Truth Table

Truth table. Truth table.

■ Systematic method to describe Boolean function. ■ 16 Boolean functions of 2 variables.

■ One row for each possible input combination. – every 4-bit value represents one N ■ N inputs ⇒ 2 rows. Truth Table for All Boolean Functions of 2 Variables 0 0 x y ZERO AND ??? X ??? Y XOR OR AND Truth Table 0 0 0 0 0 0 0 0 0 0 0 x y AND 0 0 1 0 0 0 0 1 1 1 1 0 0 0 0 1 1 0 0 0 1 1 0 0 1 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 Truth Table for All Boolean Functions of 2 Variables 1 1 1 1 1 x y NOR EQ Y' ??? X' ??? NAND ONE 1 0 0 1 1 1 1 1 1 1 1 0 1 0 0 0 0 1 1 1 1 AND 1 0 0 0 1 1 0 0 1 1 1 1 0 1 0 1 0 1 0 1

9 10

Truth Table Universality of AND, OR, NOT

Truth table. Any Boolean function can be expressed using AND, OR, NOT.

■ 16 Boolean functions of 2 variables. ■ "Universal."

– every 4-bit value represents one ■ XOR(x,y) = xy' + x'y

■ 256 Boolean functions of 3 variables. – every 8-bit value represents one Expressing XOR Using AND, OR, NOT ■ 2^2^N Boolean functions of N variables! x y x' y' x'y xy' x'y + xy' XOR 0 0 1 1 0 0 0 0 Some Functions of 3 Variables 0 1 1 0 1 0 1 1 x y z AND OR MAJ ODD MUX 1 0 0 1 0 1 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 0 1 0 1 0 0 1 0 0 1 0 1 0 0 1 1 0 1 1 0 1 1 0 0 0 1 0 1 1 1 0 1 0 1 1 0 0 1 1 0 0 1 1 0 1 Exercise: {AND, NOT}, {OR, NOT}, {NAND} are universal. 1 1 1 1 1 1 1 1

11 12 Sum-of-Products Translate Boolean Formula to Boolean Circuit

Any Boolean function can be expressed using AND, OR, NOT. Use sum-of-products form.

■ Sum-of-products is systematic procedure. ■ XOR(x, y) = xy' + x'y. – form AND term for each 1 in Boolean function – OR terms together

Expressing MAJ Using Sum-of-Products x y z MAJ x'yz xy'z xyz' xyz x'yz + xy'z + xyz' + xyz 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 1 1 0 0 0 0 0 0 0 0 1 0 1 1 0 1 0 0 1 1 1 0 1 0 0 1 0 1 1 1 1 1 0 0 0 1 1

13 14

Translate Boolean Formula to Boolean Circuit Simplification Using Boolean Algebra

Use sum-of-products form. Many possible circuits for each Boolean function.

■ MAJ(x, y, z) = x'yz + xy'z + xyz' + xyz. ■ Sum-of-products not optimal. ! number of gates ! depth of circuit

■ MAJ(x, y, z) = x'yz + xy'z + xyz' + xyz = xy + yz + xz.

size = 8, depth = 4 size = 4, depth = 3

15 16 Recipe for Making Combinational Circuit ODD Parity Circuit

Ingredients. ODD(x, y, z).

■ AND White Chocolate Mousse ■ 1 if odd number of inputs are 1.

■ OR Cake, Balducci's ■ 0 otherwise.

■ NOT

■ wire

Expressing ODD Using Sum-of-Products x y z ODD x'y'z x'yz' xy'z' xyz x'y'z + x'yz' + xy'z' + xyz 0 0 0 0 0 0 0 0 0 Instructions. 0 0 1 1 1 0 0 0 1

■ Step 1: represent input and output signals with Boolean variables. 0 1 0 1 0 1 0 0 1

■ Step 2: construct truth table to carry out computation. 0 1 1 0 0 0 0 0 0 1 0 0 1 0 0 1 0 1 ■ Step 3: derive (simplified) Boolean expression using sum-of products. 1 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 ■ Step 4: transform Boolean expression into circuit. 1 1 1 1 0 0 0 1 1

17 18

ODD Parity Circuit Let's Make an Circuit

ODD(x, y, z). Goal: x + y = z.

■ 1 if odd number of inputs are 1. ■ We build 4-bit adder: 8 inputs, 4 outputs.

■ 0 otherwise. (Same idea scales to 64-bit adder.) 1 1 1 2 4 8 7 Step 1. + 3 5 7 9 ■ Represent input and output in binary. 6 1 6 6

1 1 0 c3 c2 c1

0 0 1 0 x3 x2 x1 x0

+ 0 1 1 1 + y3 y2 y1 y0

1 0 0 1 z2 z1 z0

19 20 Let's Make an Adder Circuit Let's Make an Adder Circuit

Goal: x + y = z. Goal: x + y = z. c3 c2 c1 c0 = 0

Step 2. x3 x2 x1 x0 Step 2. x3 x2 x1 x0

■ Build truth table. + y3 y2 y1 y0 ■ Build truth table for carry bit. + y3 y2 y1 y0

z3 z2 z1 z0 ■ Build truth table for summand bit. z3 z2 z1 z0

Adder Truth Table Carry Bit Summand Bit

x0 x1 x2 x3 y0 y1 y2 y3 z0 z1 z2 z3 xi yi ci ci+1 xi yi ci zi 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0 1 1 0 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0 1 0 1 0 0 0 0 0 0 1 1 0 0 1 1 0 1 1 1 0 1 1 0 0 0 0 0 0 1 0 0 0 1 0 0 28 = 256 rows! 1 0 0 0 1 0 0 1 0 0 0 0 0 1 0 1 0 1 0 1 1 0 1 1 1 0 1 0 ...... 1 1 0 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1

21 22

Let's Make an Adder Circuit Let's Make an Adder Circuit

Goal: x + y = z. Goal: x + y = z. c3 c2 c1 c0 = 0

Step 3. x3 x2 x1 x0 Step 4.

■ Derive (simplified) Boolean expression. + y3 y2 y1 y0 ■ Transform Boolean expression into circuit.

z3 z2 z1 z0

Carry Bit Summand Bit

xi yi ci ci+1 MAJ xi yi ci zi ODD 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 1 1 0 1 0 0 0 0 1 0 1 1 0 1 1 1 1 0 1 1 0 0 1 0 0 0 0 1 0 0 1 1 1 0 1 1 1 1 0 1 0 0 1 1 0 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 1 1

23 24 Let's Make an Adder Circuit

Goal: x + y = z. Lecture A1: Extra Slides Step 4.

■ Transform Boolean expression into circuit.

25

Two Important Combinational Circuits

Multiplexer. N-bit multiplexer. N ■ Selects an addressed input line. ■ N address inputs, 2 data inputs.

■ 1 output.

Decoder. ■ Copies one data input to output.

■ Converts from binary to unary. ■ Which one? ! The one specified by the address inputs. Translates directly to circuit without sum-of-products. Ex. Useful to implement key computer components. ■ 2-bit multiplexer. s1 s0 x3 x2 x1 x0

■ Address inputs: s0, s1. 1 1 1 0 0 1

■ Data inputs: x0, x1, x2, x3. 11 = 3 ■ Output: Q. 2 10

Q 1

28 29 2-Bit Multiplexer Circuit Decoder

MUX(x0, x1, x2, x3, s0, s1). N-bit decoder.

■ x0 if s1 = 0, s0 = 0. ■ N inputs. s1 s0 N ■ x1 if s1 = 0, s0 = 1. ■ 2 outputs.

■ x2 if s1 = 1, s0 = 0. ■ Exactly one of outputs is 1; rest are 0.

■ x3 if s1 = 1, s0 = 1. ■ Which one? ! View inputs as binary representation of address.

s0 s1 Ex.

■ 3-bit decoder. x2 x1 x0 0112 = 310 ■ Inputs: x0, x1, x2. 0 1 1

■ Outputs: Q0, Q1, Q2, …, Q7. x0 x 1 2-bit Mux Q Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 x2 0 0 0 0 1 0 0 0 x3

30 31

3-Bit Decoder Cheat Sheet

DECODE(x, y, z).

x x' x2 x1 x0 NOT

MUX DEC

Q0 x Q x + y 1 y 2-bt Multiplexer 3-bit Decoder Q 2 OR Q 3-bit Decoder 3 Q4 Q5 Q 6 Adder Q7 x xy y AND 4-bit Adder

32 33