Hardware Implementations Gates and Circuits
Three Main Gates AND OR NOT
Gate Diagrams Example 1: [(today is Monday) AND (it is raining)] OR (it is snowing)
Gate Diagrams Example: What does it represent?
Gate Diagrams Example: {[(today is Monday) AND (it is raining)] OR (it is snowing)} AND {NOT [(it is raining) AND (it is snowing)]}
Truth Table to Gates First, build the Boolean algebra expression that gives Z Z = AB + A’B’ Z = (A AND B) OR (NOT A AND NOT B) ABZ TTT TFF FTF FFT
Truth Table to Gates Z = AB + A’B’ Next, build the circuit that goes with the Boolean algebra expression Z ABZ TTT TFF FTF FFT
Z = AB + A’B’
Binary Arithmetic We can add binary numbers just like decimal numbers only using base two arithmetic. For example:
Binary Addition Notice in addition: FalseTrue False True Sum Carry ABSum (1) T (0) F (1) T(0) F(1) T (0) F(1) T (0) F
Sum and Carry ABCarry ABSum
Sum Circuit ABSum Sum = AB’ + A’B
Carry Circuit ABCarry Carry = AB
Half Adder - Sum and Carry
Half Adder The sum digit is 0 if the sum is even. The sum digit is 1 if the sum is odd. The carry is 1 if the sum is greater than 1. Handles the case where we add two binary digits with no inward carry.
Full Adder Takes a carry in and produces the result and carry out. So, we have 3 inputs and two outputs. Combine two half-adders together with an OR gate to get a full adder for each binary digit. How many half adders would we need to add two 8-digit binary numbers? How many gates?
Full Adder
Subtraction ABSub ABBorrow
Binary Subtraction We do binary subtraction like decimal subtraction only the borrowing is done in 2’s instead of 10’s
Subtraction as Addition If A = , B = , then using the twos-complement representation for –B, we have –B = = so
Binary Multiplication Again, just like decimal except we add and multiply in binary. * x 7x
NAND Gates and NOT This gate represents (A NAND NOT B).
NAND Truth Table ABA NAND B TTF TFT FTT FFT
NAND Fact: All other gates (AND, OR, NOT) can be constructed using only NAND gates Verification:
Exercises Fill in a truth table and give a Boolean expression for the following circuits.
Exercises - How would you create a one binary digit multiplier? A two-digit by one-digit multiplier? A two-digit by two-digit multiplier? *