Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Powers of 2
Powers of 2 Decimal Equivalent Abbreviation
20 1
21 2
22 4
23 8
24 16
25 32
26 64
27 128
28 256
29 512
210 1,024 1K
211 2,048 2K
212 4,096 4K
213 8,192 8K
214 16,384 16K
215 32,768 32K
216 65,536 64K
Arithmetic Circuits
Sign-magnitude numbers
0+0=0
0+1=1
1+0=1
0 - 0 = 0
1 - 0 = 1
1 - 1 = 0
10 - 1 = 1
Binary Subtraction - Review
If any magnitudes are greater than 25510, you should use 16-
bit arithmetic which means operating on the lower 8-bits first,
then on the upper 8-bits.
Unsigned Binary Numbers
OVERFLOW:
In 8-bit arithmetic addition of two unsigned numbers whose
sum is greater than 25510 causes an Overflow, a Carry in the
9th Column.
D3 D2 D1 D0
= - 610
D7 D6 D5 D4 D3 D2 D1 D0
1 0 1 1 0 1 0 0 =-5210
Magnitude = 5210
SIGN BIT
Signed Magnitude (Binary) Numbers
Range of Sign-Magnitude Numbers
D7 D6 D5 D4 D3 D2 D1 D0
0 0 0 0 0 0 0 1 =+110
D7 D6 D5 D4 D3 D2 D1 D0
0 1 1 1 1 1 1 1 =+12710
SIGN BIT
D7 D6 D5 D4 D3 D2 D1 D0
1 0 0 0 0 0 0 1 =-110
D7 D6 D5 D4 D3 D2 D1 D0
1 1 1 1 1 1 1 1 =-12710
Signed Magnitude (Binary) Numbers
Range of Sign-Magnitude Numbers
As long as the data is in the range of -127 to +127 you can use 8-bit
arithmetic. But if the data has magnitude greater than 127, then
you have to use 16-bit arithmetic.
For 16-bit data, the range for negative numbers are from
1000 0000 0000 0001 (-110) to
1111 1111 1111 1111 (-32,76710)
For 16-bit data, the range for positive numbers are from
0000 0000 0000 0001 (+110) to
0111 1111 1111 1111 (+32,76710)
The main advantage of Sign-Magnitude numbers is their
simplicity. The negative numbers are identical to positive numbers
except for the Sign bit.
2’s Complement Representation
Introduction:
X3 X2 X1 X0
X3 X2 X1 X0
X3 X2 X1 X0
-7 - 6 -5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5 +6 +7
This key idea leads to an incredibly simple arithmetic circuit that can
add and subtract.
2’s Complement Arithmetic
ADDITION CASE 2 Positive and
CASE 1 Both positive. smaller negative.
0101 0011 +125 0111 1101
+83
0001 0000 -68 1011 1100
+16
• The computer will fetch these numbers from its memory and send
them to an adding circuit.
• The numbers are then added column by column, including the sign
bits to get result.
2’s Complement Arithmetic
CASE 3 Positive and larger negative.
+37 0010 0101
-115 1000 1101
37 0010 0101
+(-115) +1000 1101
-7810 1011 00102
68 0100 0100
+(+27) +0001 1011
9510 0101 11112
2’s Complement Arithmetic
Subtraction
CASE 3 Positive and larger negative.
Lets use a minuend of +14 and a subtrahend is -108
+14 = 0000 1110
-108 = 1001 0100
The computer produces the 2’s complement of -108 i.e.
+108 = 0110 1100
Then it adds the numbers like this:
14 0000 1110
+(+108) +0110 1100
12210 0111 10102
2’s Complement Arithmetic
Subtraction
CASE 4 Both are negative.
Assume that the numbers are -43 and -78.
In 2’s complement representation the numbers are:
- 43 = 1101 0101
-78 = 1011 0010
First, take the 2’s complement of -78 to get
+78 = 0100 1110
Then add to obtain
-43 1101 0101
+(+78) +0100 1110
3510 1 0010 00112 = 0010 00112
Arithmetic Building Blocks
The basic building blocks which performs the arithmetic functions
are the Half-Adder, the Full-Adder, the Controlled Inverter.
Half Adder:
• When we add two binary numbers, we start with the Least
Significant Column.
• This means that we have to add two bits with the possibility of a
Carry. The circuit used for this is called as the Half – Adder.
• The output of the Ex-OR gate is a called as the SUM and the
output of the AND gate is called as the CARRY.
Arithmetic Building Blocks
A B SUM CARRY
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
The third bit is the Carry, from a lower column. This implies that
we need a logic circuit with 3 inputs and 2 outputs.
Think of Z
as a
CARRY-IN
Arithmetic Building Blocks
Full -Adder
A SUM
B Cin A B SUM CO
FULL ADDER
CO 0 0 0 0 0
Cin
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
S=(AB)C
C = A.B + (A B). C
Arithmetic Building Blocks
Controlled Inverter
INV LOGIC
INV LOGIC
0 A7-A0 0110 1110
0 Y7-Y0 0110 1110
1 Y7-Y0 1001 0001
• When INVERT pin is low, it transmits the 8-bit inputs to the outputs.
• When the INVERT pin is high, it transmits the 1’s complement to the
outputs.
ADDITION
A 3 A2 A 1 A 0
+ B 3 B2 B1 B0
S 3 S2 S1 S0
8 – bit Adder - Subtractor
An 4-bit ADDER-SUBRACTOR circuit can be extended to 8 bits by
adding the Final CARRY-OUT of the 4 bit ADDER-SUBTRACTOR circuit
as CARRY-IN to the next FA as shown below.
SUB
ADDITION
A7 A6 A5 A4 A3 A2 A1 A0
+B7 B6 B5 B4 B3 B2 B1 B0
S7 S6 S 5 S4 S3 S2 S1 S0
8 – bit Adder - Subtractor
During Addition SUB is kept at the LOW State.
Starting at the LSB, the FA adds A0 & B0 and SUB. This produces a
SUM of S0, and a CARRY-OUT to the next higher FULL ADDER.
The next higher FULL ADDER then adds A1 & B1 and the CARRY-IN to
produce S1 and a CARRY-OUT.
A similar addition occurs for each of the remaining FULL ADDERS,
and the correct SUM appears at the output lines.
SUB
8 – bit Adder - Subtractor
A7 A6 A5 A4 A3 A2 A1 A0 = 0111 1101
B7 B6 B5 B4 B3 B2 B1 B0 = 1011 1101
During addition SUB = 0, hence the CARRY-IN to the first column is “0”
+0 SUB
0111 1101 Hence the first FA performs the addition 0+1+1
+ 1011 1101 resulting “0” with a CARRY of 1.
SUB
8 – bit Adder - Subtractor
Subtraction:
During a subtraction, the SUB input is kept in the HIGH State, hence
the Controlled Inverter produces the 1’s Complement of B7 – B0.
Furthermore, because the SUB input is the CARRY-IN to the first FA,
the circuit produces the data like this:
A7 A6 A5 A4 A3 A2 A1 A 0
- - - - - - - -
+ B7 B6 B5 B4 B3 B2 B1 B0 +1
S 7 S6 S5 S4 S3 S2 S1 S 0
SUB
8 – bit Adder - Subtractor
A7 A6 A5 A4 A3 A2 A1 A 0
- - - - - - - -
+ B7 B6 B5 B4 B3 B2 B1 B0 +1
S 7 S6 S5 S4 S3 S2 S1 S 0
When A7 - A0 = 0 the circuit produces the 2’s Complement of B7 - B0,
because 1 is being added to the 1’s Complement of B7 - B0.
And when A7 - A0 does not equal to zero the effect is equivalent to
adding A7 - A0 and the 2’s complement of B7 - B0
SUB
8 – bit Adder - Subtractor
A7 A6 A5 A4 A3 A2 A1 A0 +1 SUB
- - - - - - - - 0101 0010
+ B7 B6 B5 B4 B3 B2 B1 B0 +1
+ 1110 1110
S7 S6 S5 S4 S3 S2 S1 S0
1 0100 0001 = +65
Example: +17 is subtracted from +82.
+82 = A7 - A0 = 0101 0010 and +17 = B7 - B0 = 0001 0001
The Controlled Inverter produces the 1’s Complement of B7 - B0, which
is 1110 1110. As SUB = 1, the circuit performs the addition as shown
SUB
8 – bit Adder – Subtractor with TTL Circuits
IC 7483 is a TTL circuit with 4, FULL ADDERS.
This means that it can add four bits (NIBBLES) at one time.
7483
8 – bit Adder – Subtractor with TTL Circuits
To add BYTES, we need to use two 7483s.
The CARRY-OUT of the Lower 7483 is used as the CARRY-IN to the
Upper 7483. This allows the two 7483’s to add 8-bit numbers.
The two 7486 IC’s form the Controlled Inverter needed for Subtraction.
7483 7483