Computer Science 101 More Devices: Arithmetic. From 1-Bit Equality to N-Bit Equality...
-
Upload
eileen-lindsey -
Category
Documents
-
view
216 -
download
0
Transcript of Computer Science 101 More Devices: Arithmetic. From 1-Bit Equality to N-Bit Equality...
Computer Science 101
More Devices:
Arithmetic
From 1-Bit Equality to N-Bit Equality
11001101011000111100110101101011
11001100
10 =
A
B
A = B
Two bit strings are equal iff the pair of bits at each position are equal
From 1-Bit Equality to N-Bit Equality
=
A0
B0
A0 = B0
=
A1
B1
A1 = B1
=
A2
B2
A2 = B2
=
A3
B3
A3 = B3
Add a = circuit for each column of bits
1100 (A)1100 (B)3 2 1 0
3 2 1 0
From 1-Bit Equality to N-Bit Equality
1100 (A)1100 (B)
=
A0
B0
A0 = B0
=
A1
B1
A1 = B1
=
A2
B2
A2 = B2
=
A3
B3
A3 = B3
AND all the results
3 2 1 0
3 2 1 0
From 1-Bit Addition to N-Bit Addition 0+ 0 0
1+ 0 1
0+ 1 1
1+ 1 10
Rules:
1011+ 0011 1110
1 1 The rules require us to carry a 1 to the next column
We also must carry a 1 from the previous column
From 1-Bit Addition to N-Bit Addition 0+ 0 0
1+ 0 1
0+ 1 1
1+ 1 10
1011+ 0011 1110
0 0 1 1 0 A one-bit adder will always add a column of three bits and always carry to the next column
So, let’s carry a 0 or 1 from each previous column and to each next column
We now have 8 rules!
1 00 00 00 0
0+ 0 1
1+ 0 10
0+ 11 0
1+ 1 11
1 11 11 10 1
A 1-Bit Adder
1011+ 0011 1110
+A
B
SCin
Cout
Has three inputs: A, B, and Cin (Carry in)
Has two outputs: S (Sum) and Cout (Carry out)
0 0 1 1 0
0+ 0 0
1+ 0 1
0+ 1 1
1+ 1 10
1 00 00 00 0
0+ 0 1
1+ 0 10
0+ 1 10
1 11 10 1
1+ 1 11
1 1
Truth Table for 1-Bit Adder 0+ 0 0
1+ 0 1
0+ 1 1
1+ 1 10
1 00 00 00 0
0+ 0 1
1+ 0 10
0+ 1 10
1 11 10 1
1+ 1 11
1 1
A B Cin S Cout
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
Now apply sum of products algorithm!
Boolean Expression for S
A B Cin S Cout
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
+A
B
SCin
Cout
_ _ABCin
ABCin
_ _ABCin
_ _ABCin
_ _ _ _ _ _ABCin + ABCin + ABCin + ABCin
Boolean Expression for Cout
A B Cin S Cout
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 0 1
1 0 0 1 0
1 0 1 0 1
1 1 0 0 1
1 1 1 1 1
+A
B
SCin
Cout
ABCin
_ ABCin
_ABCin
_ ABCin
_ _ _ ABCin + ABCin + ABCin + ABCin
_ _ _ _ _ _ABCin + ABCin + ABCin + ABCin
Construct the Circuit
B
A
+A
B
SCin
Cout
Cin S
Cout
_ _ _ _ _ _ABCin + ABCin + ABCin + ABCin
_ _ _ ABCin + ABCin + ABCin + ABCin
YIKES!!!!
From 1-Bit Addition to N-Bit Addition
1011+ 0011 1110
1 1
+A0
B0
S0
0
Cout0
+A1
B1
S1
Cin1
Cout1
+A2
B2
S2
Cin2
Cout2
+A3
B3
S3
Cin3
Cout3
Carry out of adderN - 1 can indicate overflow
Carry in of adder0 is always 0