CS211 Computer Architecture Digital Logic Class Checkpoint l What have discussed up until l C Programming language l l More low-level then Java. Better idea about what’s really going on. l Covered l Topics l Transistors (Design & Types) l Logic Gates l Combinational Circuits l K-Maps l now & why: data representation Computers manipulate data. How is this data stored and manipulated? l Covered Machine-Level representation of programs (assembly lanaguage - x86) l Computers don’t work on C code (or Java). Need instructions closer to hardware. l What’s next? Processor Design… how does machine instructions actually make the processor work? Figures & Tables borrowed from:! • http://www.allaboutcircuits.com/vol_4/index.html! But first… l Before we go into processor design, we’re going to cover some topics in Digital Logic. l Book covers this only sparingly, we’re going to go into a bit more detail. l Specifically: l Transistors l Logic gates l Combinational & Sequential Circuits l Flip-Flops l Memory Transistor: Building Block of Computers l Microprocessors contain millions of transistors l Intel Pentium 4 (2000): 48 million l IBM PowerPC 750FX (2002): 38 million l IBM/Apple PowerPC G5 (2003): 58 million l Logically, each transistor acts as a switch to implement logic functions l Combined l AND, OR, NOT l Combined l Adder, to build higher-level structures multiplexer, decoder, register, … l Combined to build processor 1 Simple Switch Circuit l Switch n-type MOS Transistor open: No current through circuit l Light is off l Vout is +2.9V l l Switch closed: Short circuit across switch l Current flows l Light is on l Vout is 0V l Switch-based circuits can easily represent two states: on/off, open/closed, voltage/no voltage. p-type MOS Transistor l p-type is complementary l when Gate has positive voltage, open circuit between #1 and #2 (switch open) l when Gate has zero voltage, short circuit between #1 and #2 (switch closed) l MOS l = Metal Oxide Semiconductor two types: n-type and p-type l n-type l when Gate has positive voltage, short circuit between #1 and #2 (switch closed) l when Gate has zero voltage, open circuit between #1 and #2 (switch open) Terminal #2 must be connected to GND (0V). Gate = 1 Gate = 0 Inverter (NOT Gate) to n-type Gate = 1 Truth table In Gate = 0 Out In Out 0 V 2.9 V 0 1 2.9 V 0 V 1 0 Terminal #1 must be connected to +2.9V. 2 NOR Gate OR Gate A B C 0 0 1 0 1 0 1 0 0 1 1 0 A B C 0 0 0 0 1 1 1 0 1 1 1 1 Add inverter to NOR. Note: Serial structure on top, parallel on bottom. NAND Gate (NOT(AND)) AND Gate A B C 0 0 1 0 1 1 1 0 1 1 1 0 A B C 0 0 0 0 1 0 1 0 0 1 1 1 Add inverter to NAND. Note: Parallel structure on top, serial on bottom. 3 Basic Logic Gates Symbols XOR: truth table A^B A B 0 0 0 0 1 1 1 0 1 1 1 0 XOR B A + - - A^B= A & B + A&B XOR + B AO DeMorgan's Law DeMorgan's Law l NOT l Converting (A and B) = NOT (A) OR NOT (B) l NOT (A OR B) = NOT(A) AND NOT (B) AND to OR (with some help from NOT) l Consider the following gate: To convert AND to OR (or vice versa), invert inputs and output. A BB NOT(A NOT AND B) (A) NOT (B) NOT(A) OR NOT(B) 0 0 1 1 1 1 0 1 1 1 0 1 A B 1 0 1 0 1 1 0 0 A B 1 1 1 1 0 0 0 0 0 1 1 1 0 0 1 1 0 A ⋅B 1 A ⋅B 0 0 0 1 1 0 1 0 0 1 Same as A OR B 4 Building Functions from Logic Gates More than 2 Inputs? l AND/OR l l l can take any number of inputs. l Combinational AND = 1 if all inputs are 1. OR = 1 if any input is 1. Similar for NAND/NOR. Logic Circuit l output depends only on the current inputs l stateless l Can implement with multiple two-input gates, or with single CMOS circuit. l Sequential Logic Circuit l output depends on the sequence of inputs (past and present) l stores information (state) from past inputs l We'll first look at some useful combinational circuits, then show how to use sequential circuits to store information. Half adder Full Adder A half adder is used to add just two bits. l The result consists of two bits: a sum (the right bit) and a carry out (the left bit) S l Here is the circuit and its block symbol l Add l X 0 0 1 1 Y +0 +1 +0 +1 CS = 00 = 01 = 01 = 10 C two bits and carry-in, produce one-bit sum and carry-out. A B Cin S Cout 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 0 1 1 0 1 1 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 1 1 1 1 5 Four-bit Adder (carry-ripple adder) Carry Save adder l Compute l 101 l 101 l -----l 000 l Then Disadvantage: Delay through N-1 Stages Sum and Carry independently 101 101 ---------101- add S + C l l l Carry Save Adder Design Carry Save adder l Delay reduced compared to Carry ripple adder l Add 3 Numbers and Produce two numbers S and C X: 10011 X: 10011 l Final result is S + shifted carry Y: + 1 1 0 0 1 Y: + 1 1 0 0 1 Z: C: + 01011 11011 X: Y: Z: 10011 + 11001 + 01011 S: 00001 C: Sum: 11011 110111 000 101---------------1010 Z: S: + 01011 00001 X Y Z Xn-1 Yn-1 Zn-1 FA CSA n+1 n C=carry Xn-2 Yn-2 Z n-2 FA Cn Sn-1 Cn-1 Sn-2 X0 Y0 Z0 FA C1 S0 C =0 0 S=sum + N Bit Carry Save Adder Block 6 Decoder l n inputs, l exactly 2n Decoder outputs one output is 1 for each possible input pattern l n inputs, 2n outputs l exactly one output is 1 for each 0 possible input pattern 1 2-bit decoder 2-bit decoder 2 3 Selecting Memory Multiplexer (MUX) A0 . . A7 l n-bit selector and 2n inputs, one output l output 256 x 8 RAM 256 x 8 RAM equals one of the inputs, depending on selector 256 x 8 RAM 256 x 8 RAM A8 A9 2 to 4 decoder 4-to-1 MUX 7 Circuit Design l 1. 2. 3. 4. Converting Truth Table to Boolean Expression Designing circuits is a process… Have a good idea. What kind of circuit might be useful? Derive a truth table for this circuit. Derive a Boolean expression for the truth table. Build a circuit given the Boolean expression l Building the circuit involves mapping the Boolean expression to actual gates. This part is easy. l Deriving the Boolean expression is easy. Deriving a good one is tricky. Converting Truth Table to Boolean Expression l Given a circuit, isolate that rows in which the output of the circuit should be true. l A product term that contains exactly one instance of every variable is called a minterm. l Given a circuit, isolate that rows in which the output of the circuit should be true. Converting Truth Table to Boolean Expression l Given the expressions for each row, build a larger Boolean expression for the entire table. l This is a sum-of-products (SOP) form. 8 Converting Truth Table to Boolean Expression First Approach: Algebraic l Simply l Finally use the rules of Boolean logic build the circuit. l Problem: l Solution: SOP forms are often not minimal. Make it minimal. We’ll go over two ways. The Result Karnaugh Maps or K-Maps l K-maps are a graphical technique to view minterms and how they relate. l The “map” is a diagram made up of squares, with each square representing a single minterm. l Minterms resulting in a “1” are marked as “1”, all others are marked “0” 9 2 Variable K-Map 2 Variable K-Map 2 Variable K-Map Finding Commonality 0 1 0 1 10 Finding the “best” solution Simplify Example l Grouping become simplified products. l Both are “correct”. “A+B” is preferred. Simplify Example 3 Variable K-Maps C B l Note in higher maps, several variables occupy a given axis l The sequence of 1s and 0s follow a Gray Code Sequence. 11 3 Variable K-Maps 3 Variable K-Maps C B 3 Variable K-Maps 3 Variable K-Maps 12 Back to our earlier example….. 3 Variable K-Maps l The K-map and the algebraic produce the same result. D Up… up… and let’s keep going Few more examples D B A B A C C 13 Few more examplesD B A C 14
© Copyright 2026 Paperzz