advertisement

Boolean Algebra and Digital Circuits Part 3: Logic Gates and Combinatorial Circuits Logic Gates • • a gate implements a simple boolean function • • such as AND, OR or NOT constructed using a few transistors basic building block of digital design x y x AND NOT x.y x̅ x y OR x+y x y XOR x⊕y (the circle in the NOT gate represents complement) Universal Gates • recall that all other gates can be constructed using NAND gates alone, or NOR gates alone • x y so these are our universal gates NAND x̅.̅y̅ x y NOR x̅+̅y̅ Multiple Inputs and Outputs x y z OR x y z AND x y AND x+y+z x.y.z Q = x.y Q̅ = x̅.̅y̅ three input OR gate three input AND gate two output AND gate adapted from figs 3.6-3.8, Computer Organization & Architecture Digital Circuits • • • • we can build boolean functions using gates: F(x, y, z) = y + x̅.z y x z and sum of products can make construction simple: F = x̅yz + xyz + xyz̅ x y • F z …and for efficiency we could always simplify further by using kmaps before construction F Subtle Uses of Logic Gates • • • the functionality we see in high-level languages is built upon lower level circuits and sometimes this can be exploited to improve efficiency and performance: using XOR to swap 2 variables' values: x = x XOR y y = x XOR y x = x XOR y • using AND to mask bits: • • for a byte z, to find if its 4th bit is set use z AND 000010002 in general, set the bits you want to keep to 1, set others to 0, then AND with your byte (/word) Integrated Circuits • • a modular approach • • however gates aren't usually manufactured individually • we use one or many of these ICs to create a boolean function we've seen that individual gates can be combined to perform more complex functions but instead a collection of them are etched onto an integrated circuit IC Small Scale Integration (SSI) Example • • here's an integrated chip with just four NAND gates (note that modern chips have VLSI or ULSI) 1 2 3 4 5 6 7 figure 3.10, Computer Organization & Architecture Implementing a Function on the Simple IC F F(x,y) = x+y converted to just NANDs = (̅x̿.̿x̿)̅.̅(̅y̿.̿y̿)̅ 1 x 2 3 4 y 5 6 7 Combinatorial Circuits • • • the examples we've seen so far are combinatorial circuits • so all input values must arrive at the same time for them to work • the output is based entirely upon the input values they produce an output at the (notional) instant when the input values are specified • they can't 'remember' the inputs if some arrive later than others • we'll see later what to do if the inputs arrive sequentially for now we'll look at some useful combinatorial circuits Half-Adder • we want to be able to add binary numbers in the Arithmetic Logic Unit (ALU) • let's start with a half-adder which can add two bits together: • so could we simply combine a set of half-adders to perform addition on words of any size we choose? • no, because we need to account for the carry in table 3.9, figure 3.11, Computer Organization & Architecture Full-Adder • a full-adder takes account of the carry in... ...and we see how the half-adder got it name figure 3.12, Computer Organization & Architecture Ripple-Carry Adder • the full-adder can be combined to create a ripple-carryadder which can add words together figure 3.13, Computer Organization & Architecture • note that in reality we now have far more efficient adders (40%-90% faster!) through the use of optimisations based upon parallelisation and handling of the carry bit Decoder • • uses the combination of the input values to select one specific output line so, with two inputs x and y, there are 4 possible combinations: x.y, x.y̅, x̅.y, x̅.y̅ • and we create an output line for each: figure 3.14, Computer Organization & Architecture • this is useful for building circuits which can determine which memory address to access, or which function to perform based upon the input Multiplexer • • • selects a single output from several inputs uses control lines to determine which input to route like the inputs & output of a home theatre receiver figure 3.14, Computer Organization & Architecture Simple 2-bit ALU control codes: 00 = A + B 01 = NOT A 10 = A OR B 11 = A AND B figure 3.15, Computer Organization & Architecture Simple 2-bit ALU 01 10 1 0 OR function enabled (code 10) with inputs of 01 & 10 and an output of 11 figure 3.15, Computer Organization & Architecture To Conclude • • • we can build complex circuits in a modular fashion • • either by combining individual gates or by combining integrated circuits but so far these circuits require that the inputs arrive and are handled at the same time • they are memoryless so next lecture we'll see how to account for memory and timing needs References & Further Learning • • • outline primarily based upon: • Chapter 3, Computer Organization & Architecture (3rd Edition), Null & Lobur other material used for reference: • Chapter 3, Fundamentals of Computer Architecture, Burrell suggested learning activities: • • make sure that you understand how the full adder works • perhaps trace the flow for a 4-bit adder try to follow instructions through the simple 2-bit ALU