0% found this document useful (0 votes)
42 views9 pages

Computer Architecture 1

This document contains the solutions to 9 questions from a homework assignment on computer architecture. The questions cover topics such as: - Converting decimal numbers to 2's complement binary representations - Performing addition and subtraction in 2's complement - Writing floating point representations in IEEE format - Encoding messages using a character code - Designing combinational logic circuits - Creating a circular incrementor circuit using a decoder and encoder The solutions provide worked examples and circuit diagrams.

Uploaded by

Belén Hidalgo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
42 views9 pages

Computer Architecture 1

This document contains the solutions to 9 questions from a homework assignment on computer architecture. The questions cover topics such as: - Converting decimal numbers to 2's complement binary representations - Performing addition and subtraction in 2's complement - Writing floating point representations in IEEE format - Encoding messages using a character code - Designing combinational logic circuits - Creating a circular incrementor circuit using a decoder and encoder The solutions provide worked examples and circuit diagrams.

Uploaded by

Belén Hidalgo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 9

Computer Architecture Homework 1

Question 1 (4 points)
Convert the following decimal numbers to their 2’s complement representations (use 8 bits for each
number and truncate the fractional digits if necessary):
a) 102.3
b) 6.3
c) −13
d) 0.04

Solution:

a) 01100110 - As we can only use 8 bits, we have had to truncate all the fractional digits.
b) 0110.0100 - As we can only use 8 bits, we have had to truncate.
c) 11110011
d) 0.0000101 - As we can only use 8 bits, we have had to truncate.

Question 2 (6 points)
Perform the following operation in 2’s complement. Indicate when an overflow happens.
a) 11001010 + 11101010
b) 01011010 + 00110101
c) 0011.1100 + 0100.0100
d) 11010111 − 00001011

Solution:

a) 10110100
b) 10001111 - There is overflow.
c) 1000.0000 - There is overflow.
d) = 11010111 + 11110101 = 11001100

Question 3 (10 points)


Write IEEE floating point representation of the following decimal numbers.
a) 19.45

1
Computer Architecture Homework 1

b) −0.028

Solution:

a) Sign bit: the number is positive so 0


Number in binary: 10011.0111001100110011001
Fraction field with the leftmost 1: 100110111001100110011001
19.45(10) = 10011.0111001100110011001(2) = 1.00110111001100110011001(2) · 24
Exponent field: 10000011 (as 8-bit excess notation corresponds to 4).
Result: 01000001100110111001100110011001
b) Sign bit: the number is negative so 1
Number in binary: 0.00000111001010110000001000001
Fraction field with the leftmost 1: 111001010110000001000001
0.028(10) = 0.00000111001010110000001000001(2) = 1.11001010110000001000001(2) ·2−6
Exponent field: 01111001 (as 8-bit excess notation corresponds to -6).
Result: 10111100111001010110000001000001

Question 4 (10 points)


The following numbers are in IEEE floating point representation. Write their decimal equivalents.
a) 10111100 11010101 11100000 00000000
b) 00000000 00000100 00000000 00000000

Solution:

a) The sign bit is 1 so the number is negative.


The exponent field is 01111001 so the exponent is 121 − 127 = −6
The number being represented is −1.1010101111 · 2−6 = −0.0261077880859375
b) The sign bit is 0 so the number is positive.
The exponent field is 00000000 , so the number is not normalized. This means that the
implicit 1 is not present before the binary point and the exponent is −126 . The exponent
field is 00000000 so the exponent is 0 − 127 = −127
The number being represented is 0.00001 · 2−126 = 2−131 = 3.673419846 · 10−40

Question 5 (10 points)


Assume we are considering a set of symbols consisting of the capital English letters (26 letters) plus
white-space, question mark, and full stop to communicate messages. In our coding list, the letters
of the alphabet precede white-space, question mark and full stop in this representation.
a) How many bits do we need to encode each symbol in this set?

2
Computer Architecture Homework 1

b) Assume 32-bit words are used for communicating messages. Furthermore, assume the charac-
ter codes cannot span over multiple words. Show how the following message is encoded, and
what will be its equivalence in hexadecimal.
THIS IS A SAMPLE STRING. OR IS IT?

Solution:

a) We have to encode 29 symbols. Each bit can only have two possible values and 24 =
16 < 29 < 25 = 32. Therefore, we would need 5 bits.
b) First, we are going to encode each symbol as a 5-bit pattern
Character bit-pattern
A 00000
B 00001
c 00010
D 00011
E 00100
F 00101
G 00110
H 00111
I 01000
J 01001
K 01010
L 01011
M 01100
N 01101
O 01110
P 01111
Q 10000
R 10001
S 10010
T 10011
U 10100
V 10101
W 10110
X 10111
Y 11000
Z 11001
(space) 11010
. 11011
? 11100

Now we encode the given message:

3
Computer Architecture Homework 1

T: 10011 M: 01100 (space): 11010


H: 00111 P: 01111 O: 01110
I: 01000 L: 01011 R: 10001
S: 10010 E: 00100 (space): 11010
(space): 11010 (space): 11010 I: 01000
I: 01000 S: 10010 S: 10010
S: 10010 T: 10011 (space): 11010
(space): 11010 R: 10001 I: 01000
A: 00000 I: 01000 T: 10011
(space): 11010 N: 01101 ?: 11100
S: 10010 G: 00110
A: 00000 .: 11011

Then we have to convert these strings of bits into 32-bit words. However, since character
codes cannot span over multiple words we are missing 2 bits per word. Therefore, we
add two 0s at the beginning of each word except for the last one, since it only encodes 4
characters and we need 12 extra 0s at the beginning for it to be 32 bits long.
00100110 01110100 01001011 01001000
00100101 10100000 01101010 01000000
00011000 11110101 10010011 01010010
00100111 00010100 00110100 11011011
00110100 11101000 11101001 00010010
00000000 00001101 00100010 01111100
And its conversion to hexadecimal notation is the following:
26744B48 25A06A40 18F59352 271434DB 34E8E912 000D227C

Question 6 (10 points)


Consider the following circuit, depicted in Figure 1. What is its output for the following inputs?
a) a1 a2 = 10, b1 b2 = 11
b) a1 a2 = 01, b1 b2 = 00
Moreover, what does the circuit do?

4
Computer Architecture Homework 1

Figure 1

Solution:

a) The output is 1
b) The output is 0
The circuit gives the following outputs for these possible inputs:
a1 a2 a3 a4 output
0 0 0 0 0
0 0 0 1 1
0 0 1 0 1
0 0 1 1 1
0 1 0 0 0
0 1 0 1 0
0 1 1 0 0
0 1 1 1 1
1 0 0 0 0
1 0 0 1 1
1 0 1 0 0
1 0 1 1 1
1 1 0 0 0
1 1 0 1 0
1 1 1 0 0
1 1 1 1 0
From this we can conclude that the circuit compares the 2-bit numbers a and b. It outputs 1
if at least one of the digits of a is 0 and at least one of the digits of b is 1, and 0 otherwise.

5
Computer Architecture Homework 1

Question 7 (10 points)


Design a combinational logic circuit to compare two 2-bit numbers. The output should be 0 if the
numbers are not equal, and 1 if they are equal.

Solution:

Figure 2

Question 8 (10 points)


Using a decoder and an encoder design a circular incrementor circuit for 4-bit positive binary
numbers. The input (a number between 0 and 7) will be incremented by one if it is less than 7. If
the input is 7, the output should be zero.

Solution:

6
Computer Architecture Homework 1

Figure 3

Where A0, A1, A2 and A3 are the binary digits from the input and B0, B1, B3 and B4 the
binary digits from the output.

Question 9 (15 points)


We want to design a circuit to detect if an 8-bit positive binary number is divisible by 5 or not.
Use a multiplexer and any necessary logic gates to design your circuit. Justify your solution.

Solution:

First we create a state diagram with the possible remainders

7
Computer Architecture Homework 1

Figure 4

Question 10 (15 points)


Adding two numbers represented in scientific notation requires shifting floating points to make
exponents equal before adding the fractions. Consider the following example:
1.34 · 103 + 2.1 · 10−1

First, shift the decimal point of the smaller number to equalize the exponents:

1.34 · 103 + 0.00021 · 103

Then add the fractions, and normalize the result if necessary.

1.34021 · 103
Follow the procedure described above to add the following numbers:
N = 14.25, M = 0.5
a) Convert the numbers to IEEE floating point format.
b) Add the numbers.
c) Normalize the result to put it in IEEE format again.

Solution:

a) 14.25
Sign bit: the number is positive so 0
Number in binary: 1110.01
Fraction field with the leftmost 1: 111001000000000000000000
14.25(10) = 1110.01(2) = 1.11001(2) · 23
Exponent field: 10000010 (as 8-bit excess notation corresponds to 3).
Result: 01000001011001000000000000000000

8
Computer Architecture Homework 1

0.05
Sign bit: the number is positive so 0
Number in binary: 0.1
Fraction field with the leftmost 1: 10000000000000000000000
0.5(10) = 0.1(2) = 1.0(2) · 2−1
Exponent field: 01111110 (as 8-bit excess notation corresponds to -1).
Result: 00111111000000000000000000000000
b) 14.25(10) +0.5(10) = 1.11001(2) ·23 +1.0(2) ·2−1 = 1.11001(2) ·23 +0.0001·23 = 1.11011(2) ·23
c) Sign bit: 0
Fraction field with the leftmost 1: 111011000000000000000000
Exponent field: 10000010 (as 8-bit excess notation corresponds to 3).
Result: 01000001011011000000000000000000

You might also like