Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
CE 454 Computer Architecture Lecture 5 Ahmed Ezzat The Digital Logic, Ch-3.1, 3.2 1 Outline 2 Transistors and Logic Gates Boolean Algebra Implementation of Boolean Algebra Circuit Equivalence Integrated Circuits Combinational Circuits Arithmetic Circuits Clocks CE 454 Ahmed Ezzat Transistors and Logic Gates 3 Border of Computer Science and Electrical Engineering Digital circuit has 2 logical values: (0 – 2.5) volts and (3.5 – 5) volts. Values outside these ranges are not allowed. Gates are the devices that can compute various functions for these two-values signals. Gates are the basis of digital computers. The heart of the Gate logic is the transistor and its use as a binary switch! Details of how to build gates (device level) is not in our scope – pure Electrical Engineering. CE 454 Ahmed Ezzat Transistors and Logic Gates Transistor Types: Bipolar Transistor: MOSFET (Metal Oxide Semiconductor Field Effect Transistors): 4 TTL (Transistor-Transistor Logic) ECL (Emitter-Coupled Logic) PMOS: p-channel (switch is ON when input is low) NMOS: n-channel (switch is ON when input is high) CMOS: Complementary Metal Oxide Semiconductor Bipolar is faster than CMOS. CMOS is much more dense and uses less power than Bipolar. Functionality is the same. Most modern CPUs (logic functions) and Memories (storage elements) use CMOS technology CE 454 Ahmed Ezzat Transistors and Logic Gates Drain Gate Source Switch 5 CE 454 Ahmed Ezzat Transistors and Logic Gates 6 CE 454 Ahmed Ezzat Transistors and Logic Gates XOR Logic Gate: Input A Output Input B Input A Input B Output 0 0 0 0 1 1 1 0 1 1 1 0 Logical function “Exclusive OR” AB + AB alternatively A’B + AB’ CE 454 Ahmed Ezzat Transistors and Logic Gates 8 Transistors can be connected together with wires, and create logic functions – these functions are called logic gates In modern computer chips, the transistors and wires are very, very, very small... CE 454 Ahmed Ezzat Boolean Algebra – George Boole 9 New type of algebra is needed to describe these binary devices/Gates – Boolean Algebra! Boolean algebra can take on variables and functions that can have only binary values. Functions in boolean algebra can have one or more input variables and yield a result that only depends on these inputs! F(), can be defined as f(A) = 1 if A = 0, and f(A) = 0 if A = 1 –- this is the “NOT” function A boolean function of n variables has only 2n possible combinations on inputs, as a result it can be described by a table with 2n rows, each row stating the outcome for specific combination of the inputs –- called a truth table. CE 454 Ahmed Ezzat Boolean Algebra M = f(A, B, C): M = ABC + ABC + ABC + ABC 10 CE 454 Ahmed Ezzat Implementation of Boolean Algebra A boolean function can be implemented by logic gates in more than one way. A Generalized Procedure for Generating a Digital Logic Design from a Truth Table: 1. 2. 3. 4. 5. 11 Write down the truth table for the function Provide inverters to generate the complement of each input Draw an AND gate for each term with a 1 in the result column Wire the AND gates to the appropriate inputs Feed the output of all the AND gates into one OR logic gate. The above model uses AND, OR and NOT logic gates, however, we can also use NANDs and NORs logic gates as well CE 454 Ahmed Ezzat Implementation of Boolean Algebra 12 CE 454 Ahmed Ezzat Implementation of Boolean Algebra Switching Expression Digital Logic Circuit: Example: M = xy + z’ x y M z 13 CE 454 Ahmed Ezzat Circuit Equivalence 14 Typically start with Boolean function, apply laws of Boolean algebra to find simpler but equivalent one. CE 454 Ahmed Ezzat Circuit Equivalence Identity Table for Boolean Algebra: 15 Each law has 2 forms that are dual of each other: by interchanging AND and OR, and 0 and 1, either form can be produced from the other. Except DeMorgan’s law, the absorption law, and the AND form of the distributive law, the result is intuitive! CE 454 Ahmed Ezzat Circuit Equivalence Alternative Boolean Algebra Symbols for the same Gates: 16 CE 454 Ahmed Ezzat Circuit Equivalence 17 CE 454 Ahmed Ezzat Circuit Equivalence Same Gate can Compute Different Functions (conventions used): 18 +ve logic is an AND function, and –ve logic is an OR function. CE 454 Ahmed Ezzat Circuit Equivalence Working with Switching Algebra F(A,B,C) = A’ + B’ + A’BC = A’ + B’ = (AB)’ F(X,Y,Z,W) = XY + W’XYZ + X’Y = XY + X’Y = Y Input A Output Input B 19 Logic function = ((A + B’)’ B’)’ … using DeMorgan’s law: = (A + B’) + B = A + 1 = 1 CE 454 Ahmed Ezzat Integrated Circuits 20 Gates are not manufactured or sold individually, but in units called ICs or chips. IC classes: SSI: Small Scale Integrated Circuit – 1 to 10 gates MSI: Medium Scale Integrated Circuit – 10 - 100 gates LSI: Large Scale Integrated Circuit – 100 – 100,000 gates VLSI: Very Large Scale Integrated Circuit – > 100,000 gates ICs introduce delay (1 – 10 nsec) due to gate delay and switching time delay. Current state-of-the art is close to 100,000,000 transistor on a chip. CE 454 Ahmed Ezzat Combinational Circuits Digital logic that is designed so that the outputs are dependent only upon the current set of inputs is called COMBINATIONAL LOGIC – this is in contrast to SEQUENTIONAL LOGIC where output is a function of input and the current state (i.e., circuits containing memory elements). In the following we will cover few frequently-used combinational circuits: 21 Multiplexers Decoders Comparators Programmable Logic Arrays (PLA) CE 454 Ahmed Ezzat Combinational Circuits Multiplexers: 22 Eight data inputs, and three control inputs. The control lines (A,B,C) select which of the 8 input lines to be “gated” out. Each AND is enabled by a different combination of the control lines. CE 454 Ahmed Ezzat Combinational Circuits Decoders: 23 The set of n-inputs are decoded to select exactly one of the 2n output lines. CE 454 Ahmed Ezzat Combinational Circuits Comparators: 24 Compares 2 input words, and produces 1 iff they are equal, otherwise it produces 0. CE 454 Ahmed Ezzat Combinational Circuits PLA: 25 This PLA consists of: 12 inputlines and their inverse (24inputs), 50 AND gates, each can have any subset of the 24 inputs (supplied by the user), and 6 OR gates as output lines. Total # pins = 12 + 6 + power, ground = 20 pins. With appropriate internal connections, you can use PLA to implement multiple separate functions. Custom PLA are more common and cheaper. CE 454 Ahmed Ezzat Arithmetic Circuits Shifters: 26 8-input, 8-output, 1control line (C) to determine the direction of shift (left/right). Don’t deal with overflow. CE 454 Ahmed Ezzat Arithmetic Circuits Half Adders (Integers): 27 1-bit integer addition logic, with 2-bits input and 2-bits as out (sum, carry). Not suitable by-itself as it does not propagate carry as input to the next bit! CE 454 Ahmed Ezzat Arithmetic Circuits Full Adders (Integers): 28 1-bit integer addition logic, with 3-bits input (including carry-bit from previous stage) and 2-bits as out (sum, carry). Full adder is built out of 2 half adders. This type of adder is called ripple carry adder. Addition do not complete until the carry has rippled to the rightmost bit! CE 454 Ahmed Ezzat Arithmetic Circuits Full Adders (Integers): A3 Carry Full Adder Sum3 29 A2 B3 Carry B2 Full Adder Sum2 CE 454 A1 Carry A0 B1 Full Adder Sum1 Carry B0 Full Adder Sum0 Carry “0” Ahmed Ezzat Arithmetic Circuits 30 Full Adders (Integers): Consider breaking a 32-bit adder up into a 16-bit lower half and two upper 16-bit halves. The circuit consists of three 16-bit adders. Let the lower half start as usual, feed 0 in one of the two upper halves, and feed 1 in the other. After 16-bit addition times, it will be known what the carry is into the upper half is, so select the correct upper half immediately. This reduces the addition time by factor of 2! Such an adder is called carry select adder. This trick can then be repeated to build each 16-bit adder out of replicated 8-bit adder, etc. CE 454 Ahmed Ezzat Arithmetic Circuits Arithmetic Logic Unit (ALU): 31 ALU is the math engine for modern digital computers. Performs 4 simple functions: A AND B // bitwise AND A OR B // bitwise OR NOT B // bitwise NOT A + B // addition operator Operates on single bits “A” and “B” CE 454 Ahmed Ezzat Arithmetic Circuits ALU Block Diagram: Inv A A Enable A B Enable B Carry In A B Logic Unit (AND, OR, NOT) Output A B Cntl 1 Cntl 0 32 2 to 4 Decoder En En En En OR AND NOT ADD Sum Full Adder Carry Out CE 454 Ahmed Ezzat Arithmetic Circuits Bit Slice ALU: Four Functions (AND, OR, NOT B, ADDITION) for single bits Ai and Bi Inputs – – – – – – – – Inverse of Ai The single bit Ai Enable the A input The single bit Bi Enable the B input Control signal 0 Control signal 1 Carry-in signal (usually the carry out signal from the previous state) Outputs – – 33 INV A A ENA B ENB FO F1 Carry In Output Result of ALU computation Carry Out Carry out signal from full adder circuit CE 454 Ahmed Ezzat Arithmetic Circuits Control Signals F0 and F1: 34 What do the control signals F0 and F1 do? Both signals go into the 2 to 4 decoder Between the two signals, one of the four ALU functions is selected to be the ALU’s output CE 454 F0 F1 Output Function 0 0 A AND B 0 1 A OR B 1 0 NOT B 1 1 A + B Ahmed Ezzat Arithmetic Circuits How would the ALU subtract two integers? A–B Think about the two’s complement procedure 1. 2. 3. 4. 35 NOT B (take the complement of B) NOT B + 1 (add one to the result of step 1) 2’s complement of B A + (NOT B + 1) (add A to the result of step 2) Ignore any carry out signals CE 454 Ahmed Ezzat Arithmetic Circuits How would the ALU multiply or divide two integers? 36 How about a shifter? Multiplication and division can be thought of as “shift and add” or “shift and subtract” procedures CE 454 Ahmed Ezzat Clocks Just about like everything else in this world, many digital logic designs “run on the clock” Digital circuit designs that use a clock are called synchronous circuits The clock synchronizes when things happen in the digital circuit CE 454 Ahmed Ezzat Clocks Clock Signals: Clocks send out a series of pulses, where the signal alternates between high and low Ideally, a clock signal will look like a square wave Rising Clock Edge Falling Clock Edge High Low One Clock Cycle CE 454 Ahmed Ezzat Clocks Synchronous Digital Circuits: Synchronous digital circuits operation can be thought of as a series of discrete events The clock is used to trigger these discrete events Clock “triggers” can be on: – Rising clock edge – Falling clock edge – Clock low – Clock high CE 454 Ahmed Ezzat Clocks Asymmetric Clock: Introducing delay can generate asymmetric clock In (b) events can happen when C1 or when C2 is high for example If more intervals are needed, more clocks can be provided, or the state of the clocks can overlap partially which produces 4 distinct intervals: (C1 AND C2), (C1 AND C2), (C1 AND C2), and (C1 AND C2). CE 454 Ahmed Ezzat Clocks How Might You Use a Clock with ALU to Subtract 2 Integers: 1. Cycle 1: • • • – 2. Cycle 2: • • • 41 Get the value of B from a register and onto the input lines of the ALU Enable B Select the NOT B function (store the intermediate results back into a register) – Get the value of B from the intermediate results register and place on the input lines of the ALU Enable B Select the increment function (add with first stage’s carry in = 1) (store the intermediate results back into a register) CE 454 Ahmed Ezzat Clocks How Might You Use a Clock with ALU to Subtract 2 Integers: Cycle 3: • • • • 42 Get the values of A and (NOT B + 1) from the appropriate registers and onto the input lines of the ALU Enable both A and B Select the ADD A + B function Store the result in the appropriate register CE 454 Ahmed Ezzat Clocks How else Might You Use the ALU to Subtract 2 Integers: 1. Cycle 1: • • • • • • • – 43 Get the value of “B” from a register and place it onto the input lines of the ALU (make it the “A” value) Enable A Enable INV A Note: You now have “the complement of A” going into the ALU Get the value of “A” from a register and place it onto the input lines of the ALU (make it the “B” value) Configure the first stage of the ALU to have “Carry In” signal set to “1” (equivalent of adding 1 or incrementing) Add A and B inputs (store the results into a register) CE 454 Ahmed Ezzat 44 CE 454 Ahmed Ezzat