Professional Documents
Culture Documents
Lect 3
Lect 3
1
To convert the fractional binary number to
decimal, determine the weights if each bit that is
a 1 and then sum the weights to get the decimal
fraction.
Example: 0.1011
Weight: 2-1 2-2 2-3 2-4
Binary Number: 0. 1 0 1 1
= 2-1+2-3+2-4
= 0.5+0.125+0.0625 =
0.6875
2
To convert decimal fraction to binary, sum of
weights method can be used.
Example: 0.625 = 0.5+0.125 = 2-1+2-3
There is a 1 in 2-1 position, a 0 in 2-2 position and
a 1 in 2-3 position.
Thus (0.625)10 = (0.101)2
Repeated multiplication by 2 is another method:
3
Example: 0.625
.625 x 2 = 1.25(MSB)
.25 x 2 = 0.50
(.625)10 = (.101)2
.50 x 2 = 1.00
4
Example: 37.0625
(37)10 = (100101)2
(.0625)10 = (.0001)2
(37.0625)10 = (100101.0001)2
5
Binary Arithmetic
1) Binary Addition
0+0=0
0+1=1
1+0=1
1 + 1 = 10 ------ 1 is carry
6
2) Binary Subtraction
0-0=0
1-1=0
1-0=1
10 - 1 = 1 0-1 with a borrow of 1
7
3) Binary Multiplication
0X0=0
0X1=0
1X0=0
1X1=1
4) Binary Division
Division is performed as decimal division.
8
1’s and 2’s complement
1’s complement of a binary number is found by
changing all the 1s to 0s and all the 0s to 1s.
Example: 10110010
1’s complement is 01001101
2’s complement is found by adding 1 to the LSB
of 1’s complement of a binary number.
Example: 10110010
1’s complement is 01001101
2’s complement is 01001110
9
Given a number N in base r having n digits,
(r-1)’s complement of N is defined as (r n-1)-N,
where n is the number of bits in a N.
9’s complement of a decimal number 546700 is
999999-546700 = 453299.
And 10’s complement is 4533300 (9’s
complement + 1)
10
Signed Numbers
• The left most bit in a signed binary number is the sign
bit, which tells whether the number is positive or
negative.
• A 0 is for positive and 1 is for negative.
• The magnitude bits are in true (uncomplemented)
binary for both positive and negative numbers.
Example: 00011001
13
Arithmetic operations with signed numbers
1) Addition
(a) Both numbers (addend and augend) are positive:
The sum is positive and is in true (uncomplemented)
form.
Example: 00000111 7
+ 00000100 4
00001011 11
14
Overflow condition
When two numbers are added and the number of bits
required to represent the sum exceeds the number of
bits in the two numbers, and overflow results as
indicated by an incorrect sign bit.
An overflow can occur when both the numbers are
positive or both the numbers are negative.
Example: 01111101
+ 00111010
10110111
Sign incorrect
15
(b) Positive number with larger magnitude than negative
number:
The final carry bit is discarded. The sum is positive and
therefore in true binary form.
Example: 00001111 15
+ 11111010 + -6
100001001 9
Discard carry
Note: -6 is expressed as 2’s complement of signed +6.
16
(c) Negative number with magnitude larger than
positive number:
Example: 16-24
00010000 16
+ 11101000 +-24
11111000 -8
The sum is negative and therefore in 2’s complement
form. The final answer in decimal is the 2’s
complement of the answer with a negative sign.
17
(d) Both numbers negative:
The final carry bit is discarded. The sum is negative and
therefore in 2’s complement form.
Example:
11111011 -5
+ 11110111 +-9
111110010 -14
Discard carry
18
• Do the following
– 96-54
– 24-76
– -23-43
– 34+45
Subtraction
20
Example:
00001000 – 00000011 i.e. 8-3
Which is 8+(-3) = 5
00001000 -------Minuend
+ 11111101 -------(2’s complement of subtrahend)
1 00000101
Discard carry
21
Boolean Constants and Variables
22
Three Basic Logic Operations
• OR
• AND
• NOT
23
Truth Tables
A truth table is a means for describing how a
logic circuit’s output depends on the logic
levels present at the circuit’s inputs.
Inputs Output
A B x
A
0 0 1
? x
0 1 0
B
1 0 1
1 1 0
24
OR Operation
25
OR gate
An OR gate is a gate that has two or more
inputs and whose output is equal to the OR
combination of the inputs.
26
Timing diagram
27
AND Operation
28
AND Gate
An AND gate is a gate that has two or more
inputs and whose output is equal to the AND
product of the inputs.
29
Timing Diagram for AND Gate
30
NOT Operation
The NOT operation is an unary operation, taking only one input
variable.
Boolean expression for the NOT operation:
x=A
The above expression is read as “x equals the inverse of A”
Also known as inversion or complementation.
Can also be expressed as: A'
A
31
NOT Circuit
• Also known as inverter.
• Always take a single input
• Application:
32
Examples
Represent the following Boolean expressions
diagrammatically
1. x = A B + C
2. x = (A+B)C
3. x = (A'+B)
4. A'BC(A+D)'
33
x=AB+C
x = (A+B)C
34
x = (A'+B)
35
A'BC(A+D)'
36
Evaluating Logic-Circuit Outputs
• x = ABC(A+D)
37
38
Implementing Circuits from Boolean
Expressions
• y = AC+BC’+A’BC
• x = AB+B’C
39
y = AC+BC’+A’BC
40
x = AB+B’C
41
NOR Gate
• Boolean expression for the NOR operation:
x=A+B
42
Timing diagram for NOR gate
43
NAND Gate
44
Timing diagram for NAND gate
45
Boolean Theorems (Single-Variable)
• x* 0 =0
• x*1=x
• x*x=x
• x*x’=0
• x+0=x
• x+1=1
• x+x=x
• x+x’=1
46
Boolean Theorems (Multivariable)
• x+y = y+x
• x*y = y*x
• x+(y+z) = (x+y)+z=x+y+z
• x(yz)=(xy)z=xyz
• x(y+z)=xy+xz
• (w+x)(y+z)=wy+xy+wz+xz
• x+xy=x
• x+x’y=x+y
• x’+xy=x’+y
47
DeMorgan’s Theorems
• (x+y)’=x’y’
• (xy)’=x’+y’
• Extension to N variables
48
49
50
Universality of NAND Gates
51
Universality of NOR Gates
52
Available ICs
53
Logic Symbol Interpretation
• When an input or output on a logic circuit
symbol has no bubble on it, that line is said to
be active-HIGH.
• Otherwise the line is said to be active-LOW.
54
55
56
Which Gate Representation to Use?
57
58