Upload
georgiana-craig
View
219
Download
0
Tags:
Embed Size (px)
Citation preview
Number systems, Binary Logic, Gates
Number systems:Roman vs Arabic
The importance of "zero“:
significance of position of digits in a number
Decimal Binary Octal Hex0000 00000 0000 00000001 00001 0001 00010002 00010 0002 00020003 00011 0003 00030004 00100 0004 00040005 00101 0005 00050006 00110 0006 00060007 00111 0007 00070008 01000 0010 00080009 01001 0011 00090010 01010 0012 000A0011 01011 0013 000B0012 01100 0014 000C0013 01101 0015 000D0014 01110 0016 000E0015 01111 0017 000F0016 10000 0020 0010
Number
Number in decimal = Nn + ... + N3 + N2 + N1 + N0
Dn … D3 D2 D1 D0b
D0 x b0 = N0
D1 x b1 = N1
. . .
D2 x b2 = N2
Dn x bn = Nn
D3 x b3 = N3
Number
Number in decimal = Nn + ... + N3 + N2 + N1 + N0
Dn … D3 D2 D1 D0b
Dn … D3 D2 D1 D0b
D0 x b0 = N0
D1 x b1 = N1
. . .
D2 x b2 = N2
Dn x bn = Nn
D3 x b3 = N3
Number systems
Equivalence of numbers in different systems
Convert 2510 to Octal
Convert 258 to Decimal
Coding: Binary representation of non-numbers
Octal characters|000 NUL|001 SOH|002 STX|003 ETX|004 EOT|005 ENQ|006 ACK|007 BEL||010 BS |011 HT |012 NL |013 VT |014 NP |015 CR |016 SO |017 SI ||020 DLE|021 DC1|022 DC2|023 DC3|024 DC4|025 NAK|026 SYN|027 ETB||030 CAN|031 EM |032 SUB|033 ESC|034 FS |035 GS |036 RS |037 US ||040 SP |041 ! |042 " |043 # |044 $ |045 % |046 & |047 ' ||050 ( |051 ) |052 * |053 + |054 , |055 - |056 . |057 / ||060 0 |061 1 |062 2 |063 3 |064 4 |065 5 |066 6 |067 7 ||070 8 |071 9 |072 : |073 ; |074 < |075 = |076 > |077 ? ||100 @ |101 A |102 B |103 C |104 D |105 E |106 F |107 G ||110 H |111 I |112 J |113 K |114 L |115 M |116 N |117 O ||120 P |121 Q |122 R |123 S |124 T |125 U |126 V |127 W ||130 X |131 Y |132 Z |133 [ |134 \ |135 ] |136 ^ |137 _ ||140 ` |141 a |142 b |143 c |144 d |145 e |146 f |147 g ||150 h |151 i |152 j |153 k |154 l |155 m |156 n |157 o ||160 p |161 q |162 r |163 s |164 t |165 u |166 v |167 w ||170 x |171 y |172 z |173 { |174 | |175 } |176 ~ |177 DEL|
Total symbols: 128
Total octal digits required ? Total binary digits required ?
ASCII
Binary Logic and Gates
- We will use electronic circuits to control “logic”
- We can construct circuits that work based on presence/absence of voltage
- Logic circuits (complex) are unreliable if multiple voltage levels have different interpretations
We use BINARY LOGIC CIRCUITS
Basis: Boolean Algebra
Basic operators of Boolean Algebra
1 1 1
0 0 0
0 1 0
1 0 0
0 0 0
0 1 1
1 0 1
1 1 1
1 0
0 1
c o n ju n c t i o n d i s ju n c t i o n n e g at i o n
AND OR NOT
Relation of Boolean Algebra and Discrete Logic:
+ -
Power Cassette-case Door
Motor
M = P AND C
Logic
A
B
A XOR B
A
B
NOT ( A OR B)
A
B
NOT( A AND B)
A NOT A
A
BA OR B
A
B
A AND B
0 1
0
1
AB
0 0
0 1
0 1
0
1
AB
0 1
1 1
0 1
0
1
AB
1 1
1 0
0 1
0
1
AB
1 0
0 0
0 1
0
1
AB
0 1
1 0
0 1A
1 0
Common Logic Gates
Truth Tables: relation of inputs, output of an operator
A B T
0 0
0 1
1 0
1 1
T = A B
0
0
0
1
A B T
0 0
0 1
1 0
1 1
T = A V B
0
1
1
1
A T
0
1
T = ~A
1
0
R1
5V
R2
R3
NOR( A, B)
A
B
A Resistor-Transistor Logic (RTL) NOR gate
A is ON Small current at transistor base Collector-Emitter conducts freely Current through LED LED is ON
LED
NPN transistor
Functioning of an NPN transistor
Gates basics
…you will learn these in detail in ELEC xxx
0V
5V
b
c
eR1
R2
R3
A
Some simple binary number operations
ADDITION: 1 1 0 1 0 0 1+ 0 1 1 0 0 1 1
2’s COMPLEMENT:
- start from the least significant digit- copy bit-by-bit until (including) the first ‘1’- inverted the remaining digits ( ‘0’ ‘1’, and ‘1’ ‘0’)
Example:Binary number, b = 0 0 1 0 1 1 02's complement of b = 1 1 0 1 0 1 0
Binary number operations: motivation
0011
10011000
1001
1011
1001
0011
1100 1 0001 0010 -1 1010
+-+ 1001-
(a) (b) (c) (d)
Consider the following 4-bit additions:
Computers have ‘limited’ representations [fixed length numbers]
overflow borrow
- how to represent negative numbers?- what does the ‘borrow’ mean?
Binary number operations: motivation..
Conventions: - Use of one extra bit, to identify overflow in addition
- Reserve Most-Significant-Bit (MSB) to identify negative number
- Store –ve numbers as 2’s complement of its absolute value
Consequence: - MSB is 1 -ve number
- replace addition by addition of 2’s complement!!
number (nd) binary (nb) -2's complement ( - n )
3 0 : 0011 1 : 1101
5 0 : 0101 1 : 1011
7 0 : 0111 1 : 1001
8 0 : 1000 1 : 1000
Binary number operations: motivation...
CALCULATE:
5 - 7
-3 - 3
8 - 3
Boolean Algebra
- Developed by George Boole- Wanted to develop a language-based logic (“and” “or” “not”)- Boolean Algebra was used by Claude Shannon for design of logic circuits
- What is algebra ?
- Boolean Algebra:
two constants: 0, 1
variable can take value of any constant
rules to construct ‘expressions’
rules to construct statements ( expr1 = expr2)
logic for testing truth of a statement
Boolean Algebra
constants: 1, 0symbols: (, ), , , =, ¬variables: A, B, …
Expressions:a series of symbolsrules:
constant
constant OPb constant
variable
OPu constant
( expression )
( expression ) OPb ( expression )
OPu ( expression )
Boolean Algebra
Evaluating an expression:- substitute the value of each variable- use truth table of operators to evaluate
if X = 1, value of expression X 1 =
Statement:expression = expression X (X Y) = 1
Truth of a statement:if the equality is true for all possible instantiations of variables
X (X Y) = 1
Boolean Algebra
Theorems:Statements that are always true. X 0 X
X 1 X
X 1 1
X 0 0
X X X
X X X
X X 1
X X 0
Some theorems of one variable
Boolean AlgebraX Y Y X ( c o m m u t at i ve )
XY YX
X XY X
X(X Y ) X
(X Y )Y XY
XY Y X Y
XY Y X Y
Some theorems of two variables
(A B C . ..) A B C . ..
(A B C ...) A B C . ..
de Morgan’s theorems
S im plify : ABCD ABC ABD
Ex pre s s io n =
=
=
=
AB((CD C ) D )
AB((D C ) D )
AB(C 1)
AB
Boolean Algebra
Use of theorems: ‘simplification’ of expressions
How many gates would we need to implement the original expression?
How many are needed to implement the equivalent expression?
Karnaugh Maps (K-Maps)
Graphical method to simplify expressions
K-Map:
matrix of 2n elements
each element corresponds to one distinct instantiation of the variables
A B
A B A B
A BA
B
A B C
A B C A B C A B C A B C
A B C A B C A B CA
B
C
A
B
C
D
A B
A B A B
A BA
B
A B
A B A BA B
A BA BA
B
A B C
A B C A B C A B C A B C
A B C A B C A B CA
B
C
A B C
A B CA B C A B CA B C A B CA B C A B CA B C
A B CA B C A B CA B C A B CA B CA
B
C
A
B
C
D
A
B
C
D
T = X (X Y)
K-Maps, example
- Write T as a disjunction of eight conjunction terms (OR of eight AND-terms)
- T = 1 if any AND-term = 1 [WHY ?]
- Put a ‘1’ in each cell corresponding to each AND-term
T = X (X Y) = X (X Y) = X X XY
X X XY = X XY
X
Y
1 1XY
XYXY
XY0 0
- Loop all 1’s into rectangular BLOCKSX
Y
1 1XY
XYXY
XY0 0
Loop = X = T
K-Maps, example
T A B CD A BC D BC D A BCD ABC D ABCD AB C D AB CD
- T is a disjunction of eight conjunction terms (OR of eight AND-terms)
- T = 1 if any AND-term = 1 [WHY ?]
- Put a ‘1’ in each cell corresponding to each AND-term
A
B
C
D
0 1
1
1
1
1
1
1
1
1
0 0
0
0
0 0
NOTE: Which cell corresponds to BCD ?
K-Maps, example
T A B CD A BC D BC D A BCD ABC D ABCD AB C D AB CD
How to make ‘loops’: - Must be rectangular or square - Must contain 2n cells (1, 2, 4, 8, …) - Must contain no ‘0’ - Can join leftmost column with rightmost - Can join top row with bottom - All 1’s must belong to at least one loop - Try to maximize the size of loops
A
B
C
D
0 0 0 1
1 1 0 1
1 0 1
1 0 0 1
1
2
3 3
1
1
2
3 AD
BC
CD
T CD BC AD
K-Maps construction: cells
Example: Elevator control
Elevator is going up: Switch A is ON
Elevator is going down: Switch B is ON
What about the state AB ?
A B denotes that the elevator is neither going up, nor down
AB denotes that the elevator is going up
State that is physically impossible is filled with in K-map
in K-map: may be used as 1 or 0
K-Maps construction
prime implicant: a block which is not entirely included in a larger block
essential prime implicant: a prime implicant with at least one cell thatcannot be included in any other prime implicant
1. Identify input, output variables; formulate the logic expression
2. Re-write the expression: disjunction of purely conjunctive terms
3. Make the K-map
4. Fill a 1 in the cell(s) corresponding to each term, and where possible
5. Identify and "block" each essential prime implicant.
6. If any un-blocked "1" cells remain, create corresponding prime implicant
7. Write output = disjunction of conjunctive terms (1 term for each implicant)