Logic Design Module
Logic Design Module
1
TABLE OF CONTENTS
2
IV. Sequential circuit design and analysis
3
Lesson 1
Base N
N Digits: 0, 1, 2, 3, 4, 5, …, N-1
Example: 1045N
Positional Number System
N n 1 N 4 N 3 N 2 N 1 N 0
d n1 d 4 d3 d 2 d1 d 0
4
Decimal Number System
Base 10
Ten Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Example: 104510
Positional Number System
10n1 104103102101100
d n1 d 4 d3 d 2 d1 d0
Digit d0 is the least significant digit (LSD).
Digit dn-1 is the most significant digit (MSD).
Base 2
Two Digits: 0, 1
Example: 10101102
Positional Number System
5
Definitions
nybble = 4 bits
byte = 8 bits
(short) word = 2 bytes = 16 bits
(double) word = 4 bytes = 32 bits
(long) word = 8 bytes = 64 bits
1K (kilo or “kibi”) = 1,024
1M (mega or “mebi”) = (1K)*(1K) = 1,048,576
1G (giga or “gibi”) = (1K)*(1M) = 1,073,741,824
Base 16
Sixteen Digits: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
Example: EF5616
Positional Number System
6
Binary Addition
0+0=0
0+1=1
1+0=1
1 + 1 = 10 Note “carry”
Hex Addition
4-bit Addition
4+4=8
4+8=C
8+7=F
F + E = 1D Note “carry”
7
1’s Complements
E.g. 0 1 , 1 0
01010100100 10101011011
2’s Complements
2’s complement
01010100100 10101011011 + 1=
10101011100
Handy Trick: Leave all of the least significant 0’s and first 1
unchanged, and then “flip” the bits for all other digits.
Complements
Note the 2’s complement of the 2’s complement is just the original
number N
8
(2’s comp of N) = M = 10101011100
Theorem: To negate
a two’s complement
number, just complement it and add 1.
−( X YZ 2 )=X YZ 2 +1
9
Proof (for the case of 3-bit numbers XYZ):
−( X YZ 2 )=X YZ 2= X YZ 2 =( X̄ +1)YZ 2
¿ X̄ YZ2 +1002 = X̄ YZ+11 2+1
¿ X̄ (Y +1)( Z +1)2 +1
¿ X YZ2 +1
Two methods:
First method: sign-magnitude
Use one bit to represent the sign
• 0 = positive, 1 = negative
Remaining bits are used to represent the magnitude
Range - (2n-1 – 1) to 2n-1 - 1
where n=number of digits
Example: Let n=4: Range is –7 to 7 or
1111 to 0111
Second method: Two’s-complement
Use the 2’s complement of N to represent
-N
Note: MSB is 0 if positive and 1 if negative
Range - 2n-1 to 2n-1 -1
where n=number of digits
Example: Let n=4: Range is –8 to 7
Or 1000 to 0111
10
Signed Numbers – 4-bit example
11
Signed Numbers-8 bit example
Notes:
Examples
Let N=4: two’s-complement
What is the decimal equivalent of
01012
Since MSB is 0, number is positive
01012 = 4+1 = +510
What is the decimal equivalent of
11012 =
Since MSB is one, number is negative
Must calculate its 2’s complement
11012 = − (0010+1) = − 00112 or −310
12
Arithmetic Subtraction
Borrow Method
This is the technique you learned in grade school
For binary numbers, we have
0–0=0
1–0=1
1–1=0
1
0–1=1 with a “borrow”
Binary Subtraction
A – (+B) = A + (-B)
A – (-B) = A + (-(-B))= A + (+B)
In other words, we can “subtract” B from A by “adding” –B to A.
However, -B is just the 2’s complement of B, so to perform
subtraction, we
1. Calculate the 2’s complement of B
2. Add A + (-B)
Example
Let n=4, A=01002 (410), and
B=00102 (210)
Let’s find A+B, A-B and B-A
A+B 0 1 0 0 (4)10
+ 0 0 1 0 (2)10
=0110 6
A-B 0 1 0 0 (4)10
- 0 0 1 0 (2)10
13
A + (-B) 0 1 0 0 (4)10
+ 1 1 1 0 (-2)10
=1 0 0 1 0 2
B-A 0 0 1 0 (2)10
- 0 1 0 0 (4)10
B + (-A) 0 0 1 0 (2)10
+ 1 1 0 0 (-4)10
1110 -2
1 1 1 02 = - 0 0 1 02 = -210
Since sign bit is one, number is negative. Must calculate the 16’s
complement to find magnitude.
1000016 – B2CE16 = ?
We have
10000
- B2CE
FFF10
- B2CE
=4D32
So,
1000016 – B2CE16 = 4D3216
= 4×4,096 + 13×256 + 3×16 + 2
14
= 19,76210
Thus, B2CE16 (in signed-magnitude)
represents -19,76210.
Sign Extension
Note that:
(−1) = 1 = 11 = 111 = 1111 = 111…1
Thus, any number of leading 1’s is equivalent, so long as the
leftmost one of them is implicitly negative.
Proof:
111…1 = −(111…1) =
= −(100…0 − 11…1) = −(1)
So, the combined value of any sequence of leading ones is always just
−1 times the position value of the rightmost 1 in the sequence.
111…100…0 = (−1)·2n
15
Decimal to Binary Conversion
Method I:
Use repeated subtraction.
Subtract largest power of 2, then next largest, etc.
Powers of 2: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2n
Exponent: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 , n
20 21 22 23 24 25 26 27 28 29 210 2n
16