Download Tutorial 6

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Computer Organization and
Architecture
Tutorial 6
Kenneth Lee
For example:
2 bits 2s complement:
10 11 00 01
-2 -1 0
+1
4 bits 2s complement:
1000 1001 1010 1011 1100 1101 1110 1111 0000 0001 0010 0011 0100 0101 0110 0111
-8
-7
-6
-5
-4 -3
-2
-1 0
+1 +2 +3 +4 +5 +6
+7
Addition of two 2-bit 2s complements generate a 2-bit result
11
+01
100
Means 3+1=4 or -1+1=0
Multiplication of two 2-bit in 2s complements generate a 4-bit result
11
X 01
0011
0000
0011
In unsigned integer, it means 3x1=3; but in 2s complement, it means (-1)x(+1)=+3.
It is due to the unsigned integer and 2s complement have different extension pattern
11
X 01
1111
0000
1111
Biased representation example:
4-bit biased representation:
4-bit binary unsigned integer is from 0000 (0) ~ 1111 (15)
Bias = 2k-1 – 1 = 23 – 1 = 7
4-bit biased representation is from (0 – 7) ~ (15 – 7)
0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
-7 -6
-5
-4 -3
-2
-1 0
+1
+2 +3 +4 +5 +6 +7 +8
The smallest is 0000 and the largest is 1111
The same with unsigned integer
Examples: Positive overflow (2-1 + 2-2 +…+ 2-n = 1-2-n )
Examples: Exponent overflow
For 4-bit exponent in biased representation, the range is -7 ~ +8,
so the largest exponent is +8
Examples: significant overflow
0.11 + 0.01 = 1.00
a. e is in 0~X with bias q, so the exponent is in –q~X-q
the largest positive significant is 1-b-p
(e.g. if b is 2 and significant is 3 digits, the largest positive is (0.111)2;
if b is 10 and significant is 3 digits, the largest positive is (0.999)10 )
so the largest positive value is (1-b-p)x(bX-q)
the smallest positive significant is b-p
(e.g. if b is 2 and significant is 3 digits, the largest positive is (0.001)2;
if b is 10 and significant is 3 digits, the largest positive is (0.001)10 )
so the smallest positive value is b-px(b-q)
b. For the normalized floating-point numbers, the difference with above is that
the first bit can not be 0, so the largest value will keep the same.
But the smallest positive value will be b-1
(e.g. if b is 2 and significant is 3 digits, the largest positive is (0.1)2;
if b is 10 and significant is 3 digits, the largest positive is (0.1)10 )
so the smallest positive significant is b-1x(b-q)
c. Minus means the sign is 1
(-1.5)10 = (-1.1)2x20 so E is 0 and its biased representation is 01111111 (0+27-1)
(0.5)10 = (0.1)2 so the significant is 100000000000000000000000
d. 384 = 110000000 = 1.1x28 = 1.1x21000
So E is 8 and its biased representation is 8+27-1 = 135 = 10000111
The significant is 0.1 and represented as 100000000000000000000000
e. 1/16 = (0.0001)2 = 1.0x2-4
So E is -4 and its biased representation is -4+27-1=123=01111011
The significant is 0.0 and represented as 000000000000000000000000
f. Minus means the sign is 1
1/32 = 0.0001 = 1.0x2-5
So E is -5 and its biased representation is -5+27-1=122=01111010
The significant is 0.0 and represented as 000000000000000000000000
1 bit
11 bits
52 bits
sign
Biased exponent Fraction (Significant)
The exponent value is in 1~2046 (0 and 2047 are kept for special use)
The bias is 1023 so the biased exponent is in -1022~+1023
So the largest positive is (2-2-52)x21023,
the smallest positive is 2-1022
9.27 Show how the following additions are performed.
a. 5.566 x 102 + 7.777 x 102
b. 3.344 x 101 + 8.877 x 10-2
9.27 Show how the following additions are performed.
a. 7.744 x 10-3 - 6.666 x 10-3
b. 8.844 x 10-3 – 2.233 x 10-1
B.1 Construct a truth table for following expressions:
a=ABC+ABC
b=ABC+ABC  ABC

c=A BC  BC

d=(A+B)(A+C)(A+B)


c=A BC  BC  ABC  ABC
(c is 1 when A=1,B=1,C=0 or A=1,B=0,C=1)
d=(A+B)(A+C)(A+B)
=AAA  AAB+AAC+ABC+AAB+ABB+ABC+BBC
=ABC+AB+ABC
=ABC+AB
(d is 1 when A=0,B=1,C=1, or A=1,B=0)
B.2 simplify the following expressions according to the commutative law
Commutative law: A+B = B+A; AB = BA
AB  BA+CDE+CDE+ECD
=AB  AB  CDE+CDE+CDE
=AB  CDE+CDE
AB+AC+BA
=AB+AC+AB
=AB+AC
(LMN)(AB)(CDE)(MNL)
=(LMN)(AB)(CDE)(LMN)
=(LMN)(AB)(CDE)
F(K+R)+SV+WX  VS+XW+(R+K)F
=F(K+R)+SV+WX  SV+WX+F(K+R)
=F(K+R)+SV+WX
B.4 Apply DeMorgen’s theorem
F=V+A+L=VAL
F=A+B+C+D=ABCD
B.4 Simplify the following expressions
A=ST+VW+RST
=ST+VW
A=TUV+XY+Y
=TUV+Y
A=F(E+F+G)=F
A=(PQ+R+ST)TS=ST
A=DDE
 D+D+E
=D+E
A=Y(W+X+Y+Z)Z
=YZ(W+X+YZ)
=YZ
A=(BE+C+F)C=C
B.5 Construct the operation XOR from Boolean AND, OR, and NOT
A
B
XOR
0
0
0
0
1
1
1
0
1
1
1
0
A XOR B = AB + AB
B.6 Given a NOR gate and NOT gates, draw a three input AND function
AND(A,B,C)
=ABC
=ABC
=A+B+C
=NOR(A,B,C)
B.7 Write the Boolean expression for a four-input NAND gate
NAND(A,B,C,D)
=NOT(AND(A,B,C,D))
=ABCD
Related documents