Switching Theory / Schakeltechniek 5A050
Lab session Arithmetic
Highlights previous session
A0 00 01 11 1
B0 01 01 01 1
C0 01 01 01 1
Z0 01 01 11 1
C AB
Z A
B Z:
1
1 1 1
1
C
smallest possible 2-level SOP expression / implementation truth
table
K-map
Z = AB + C
expression 2-level implementation
Highlights previous session
A
B X:
x
1 x x
x C 1 1 D 1
1 1 1
1 1
X = A + B
• Don’t cares: extra freedom to reduce the circuit
• Multi-level optimization: smaller circuits but not exact
Block 3
• Number systems
• Arithmetic circuits
Number Systems
• Decimal system:
– Representation with base 10:
154 = 1 x 102+ 5 x 101+ 4 x 100
– 10 different symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
• Binary system:
– Representation with base 2:
11010 = 1 x 24+ 1 x 23+ 0 x 22+ 1 x 21+ 0 x 20 – 2 different symbols: 0, 1
Conversions
• From binary to decimal:
11010 = 1 x 24+ 1 x 23+ 0 x 22+ 1 x 21+ 0 x 20= 26
• From decimal to binary:
successive division 47 in binary ?
47 / 2 = 23 23 / 2 = 11 11 / 2 = 5 5 / 2 = 2 2 / 2 = 1 1/2 = 0
remainder 1
“ 1
“ 1
“ 1
“ 0“ 1
1 0 1 1 1 1 check: 32 + 8 + 4 + 2 + 1 = 47 !
Arithmetic operations: addition Decimal:
1 1 + 1 69 7 1 1 3Binary:
1 1 11 1 1
+ 0 1 1
1 0 1 0 carries
Arithmetic operations: subtraction Decimal:
-1 - 1 69 5 7 9Binary:
-1 1 0 1 - 0 1 1 0 1 0borrows
Arithmetic circuits: halfadder
Adds two binary numbers:
1 1 + 1 1 0
+ 00 0 0
+ 10 0 1 (2 outputs needed)
+ 01 0 1
B 0 0 1 1 A 0 0 1 1
S 0 1 1 0
C 0 0 0
halfadder
1
HA A
B
S C
AB S
C
Arithmetic circuits: fulladder
B 0 0 1 0 1 0 1 1
Cin 0 0 1 0 1 0 1 1 A 0
0 0 0 1 1 1 1
S 0 1 1 0 1 0 0 1
Cout 0 0 0 0 1 1 1 1
fulladder FA
A
B S
Cin Cout
Arithmetic circuits: ripple carry adder
FA A3 B3
C S3
FA A2 B2
S2
FA A1 B1
S1
HA A0 B0
S0
A3 A2 A1 A0 + B3 B2 B1 B0 C S3 S2 S1 S0 Addition:
Ripple carry adder: example
FA A3 B3
C S3
FA A2 B2
S2
FA A1 B1
S1
HA A0 B0
S0
1 0 1 1 + 0 0 1 1 Addition:
(A)(B) 1 0 0
0 1 1 1
1
0
0
1
1 1
1 1
1 1
1 1 0
1 0
0
Negative numbers: two’s complement
000
001
010
011 100
101 110
111
Most significant bit:
• 0 for positive numbers
• 1 for negative numbers
0
-2
-3
-4
3 2 -1 1
Negative numbers: two’s complement
2’s complement representation of (decimal) number -p:
• take bit-wise complement of the binary representation of p
• add 1
example: 2’s complement representation of -3
• decimal number p: 3
• binary (2’s complement) representation: 011
• bit-wise complement: 100
• add 1: 101
(consistent with number wheel)
What do you obtain if you apply the conversion to 101 ?