140 likes | 296 Views
Binary logic. Binary logic is a mathematical system that lets us reason about logic statements. IF The garage door is open AND The engine is running THEN The car can be backed out of the garage. The car can be backed out only when both conditions are true.
E N D
Binary logic Binarylogic is a mathematical system that lets us reason about logic statements IFThe garage door is open AND The engine is runningTHEN The car can be backed out of the garage The car can be backed out only when both conditions are true The light will become yellow only if it’s been green for > 45 seconds or nobody is on the road IFTheN-S light is green AND The E-W light is red AND (The N-S light has been green for more than 45 sec.OR There are no cars on the N-S road)THEN The N-S lights can be changed from green to yellow
Door Open? Engine Running? OK to Back Out False False False False True False True False False True True True Combinational Logic Each input can beeither True or False IFThe garage door is open AND The engine is runningTHEN The car can be backed out of the garage What is the output for each combination of inputs? There are 2N combinations to be considered for N binary inputs.
X Y X and Y X Y X or Y X not X F T T F F F F F T T T F T T T T F F F F T F T F F T T T Input Output Truth tables • Truth tables enumerate all possible input combinations • For each input, tabulate the output • There may be more than one independent output • A truth table that enumerates all input combinationscompletely defines any logic function For n inputs: 2n rows
X Y X and Y X Y X or Y X not X 0 1 1 0 0 0 0 0 1 1 1 0 1 1 1 1 0 0 0 0 1 0 1 0 0 1 1 1 Input Output The Binary Connection • Truth or Falsehood is a Binary operation • Everything is either True or False, no in-betweens • Represent True using ‘1’ • Represent False using ‘0’ Note: Number combinations in binary numeric order: 00, 01, 10, 11 2.2
Example a b c d FG 0 0 0 0 1 00 0 0 1 0 10 0 1 0 0 1 0 0 1 1 1 1 0 1 0 0 0 0 0 1 0 1 1 0 0 1 1 0 1 0 0 1 1 1 0 0 1 0 0 0 0 0 1 0 0 1 1 0 1 0 1 0 1 0 1 0 1 1 0 0 1 1 0 0 1 0 1 1 0 1 0 0 1 1 1 0 0 0 1 1 1 1 1 0 • Function F(a,b,c,d) should be 1 whenever there are an even number of inputs that are 1 • Function G(a,b,c,d) should be 1 whenever c is 1 or d is 1, but not when a or b is 1
M F T S Good 0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1 Illegal Inputs • The women’s basketball team is looking for good players (women 5’9” or taller) • The data available is: • M: True if male • F: True if female • T: True if 5’9” or taller • S: True if < 5’9” X X X X X 0 1 X X • Many combinations are impossible • Can’t be Male and Female • Can’t be Tall and Short 0 0 X X • Impossible input combinations are marked with an ‘X’ • Called a don’t care X X X
x’ x not(x) x xy x and y y x x or y x+y y precedence rules Logic Primitives NOT before AND before OR
C T2 D B T1 C D A B Z C D Complex expressions
T1 A Z B T2 C 1 A 0 0 0 0 1 1 1 1 0 1 B 0 0 1 1 0 0 1 1 0 1 C 0 1 0 1 0 1 0 1 0 1 T1 1 1 1 1 0 0 0 0 0 1 T2 0 1 1 1 0 1 1 1 0 1 Z 0 1 1 1 0 0 0 0 0 Timing diagram • A timing diagram may be used to express the behavior of a logic system A B C T1 T2 Z 0 0 0 1 0 0 0 0 1 1 1 1 0 1 0 1 1 1 0 1 1 1 1 1 1 0 0 0 0 0 1 0 1 0 1 0 1 1 0 0 1 0 1 1 1 0 1 0 Inputs
F8 F9 F10 F1 1 F12 F13 F14 F15 X Y F0 F1 F2 F3 F4 F5 F6 F7 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 1 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 1 0 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 1 1 0 1 0 1 0 1 0 1 X • Y X + Y Functions of two variables 0 1 X Y X Y There are sixteen functions of two variables…We’ve only seen eight of them so far
X nand Y = not (X and Y) = X Y Z 0 0 1 0 1 1 1 0 1 1 1 0 X nor Y = not (X or Y) = X Y Z 0 0 1 0 1 0 1 0 0 1 1 0 NANDs and NORs
Exclusive OR - XOR XOR - True if both inputs are different X Y Z 0 0 0 0 1 1 1 0 1 1 1 0 Equivalence gate - XNOR X Y Z 0 0 1 0 1 0 1 0 0 1 1 1 XNOR - True if both inputs are the same XORs and XNORs
F8 F9 F10 F1 1 F12 F13 F14 F15 X Y F0 F1 F2 F3 F4 F5 F6 F7 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 1 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 1 0 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 1 1 0 1 0 1 0 1 0 1 X • Y X + Y What’s left? 0 1 X Y X Y Remaining functions are implication functions, which aren’t commonly used