0% found this document useful (0 votes)
27 views

Tut07 Selected Ans

tutorial 7 solutions

Uploaded by

zkyiszky
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

Tut07 Selected Ans

tutorial 7 solutions

Uploaded by

zkyiszky
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

CS2100: Computer Organisation

Tutorial #7: Combinational Circuits


(Week 9: 14 – 18 October 2024)
Answers to Selected Questions

Tutorial questions
Note that for questions on logic design, you may assume that logical constants 0 and 1 are always
available. However, complemented literals are not available unless otherwise stated.

1. [Past-year’s question]
You are to design a circuit to implement a function V(A,B,C,D,E) that takes in input ABCDE and
generates output 1 if ABCDE is a valid input for the circuit in question D3 above, or 0 if ABCDE is an
invalid input. You are allowed to use only the following devices: full adder, 2-bit parallel adder, and 4-
bit magnitude comparator. You should use the fewest number of these approved devices, and no
other devices or logic gates. The block diagrams for these devices are shown below.

2-bit 4-bit
Full Adder COMP
Cin X3
Adder X2
X1 Cout
X Carry X1
X0
Y S1 X0 X<Y
Sum
Z Y1 S0 X=Y
Y0 Y3 X>Y
Y2
Y1
Y0

Answer:
Idea: Count the number of 1’s in ABCDE. If count > 1, then it’s a valid input.

4-bit
COMP
0 X3
0 X2
0 X1
Full 2-bit 1
Adder Adder X0 X<Y V
A D Cin X=Y
X Carry 0 Y3
X1 Cout X>Y
B Y Y2
Sum X0
C Z S1 Y1
0 S0 Y0
Y1
E Y0

AY2024/25 Semester 1 - 1 of 4 - CS2100 Tutorial #7 Selected Answers


2. [Past year’s exam question]
a. You want to construct a circuit that takes in a 4-bit unsigned binary number ABCD and outputs a
4-bit unsigned binary number EFGH where EFGH = (ABCD + 1) / 2. Note that the division is an
integer division. For example, if ABCD = 0110 (or 6 in decimal), then EFGH = 0011 (or 3 in decimal).
If ABCD = 1101 (or 13 in decimal), then EFGH = 0111 (or 7 in decimal).
Construct the above circuit using a single 4-bit parallel adder and at most one logic gate with no
restriction on its fan-in.
b. The following table shows the 4221 code and 8421 code (also known as BCD code) for the ten
decimal digits 0 through 9.

Digit 4221 code 8421 code


0 0000 0000
1 0001 0001
2 0010 0010
3 0011 0011
4 0110 0100
5 1001 0101
6 1100 0110
7 1101 0111
8 1110 1000
9 1111 1001

You want to construct a 4221-to-8421 decimal code converter, which takes in a 4-bit 4221 decimal
code PQRS and generates the corresponding 4-bit 8421 decimal code WXYZ.
Let’s call the circuit you created in part (a) above the A1H (Add-1-then-Half) device, represented
by the block diagram below. Implement your 4221-to-8421 decimal code converter using this A1H
device with the fewest number of additional logic gates.

A1H
A E
B F
C G
D H

AY2024/25 Semester 1 - 2 of 4 - CS2100 Tutorial #7 Selected Answers


Answers: A B C D E F G H
Solution 1:
0 0 0 0 0 0 0 0
2(a)
4-bit 0 0 0 1 0 0 0 1
0 Cin
//adder 0 0 1 0 0 0 0 1
0 X3 Cout 0 0 1 1 0 0 1 0
A X2 Cout 0 1 0 0 0 0 1 0
B X1 S3 E 0 1 0 1 0 0 1 1
C X0 S2 F 0 1 1 0 0 0 1 1
S1 G 0 1 1 1 0 1 0 0
0 Y3 S0 H 1 0 0 0 0 1 0 0
0 Y2
Y1
1 0 0 1 0 1 0 1
0
Y0 1 0 1 0 0 1 0 1
D
1 0 1 1 0 1 1 0
1 1 0 0 0 1 1 0
Solution 2: 1 1 0 1 0 1 1 1
4-bit 1 1 1 0 0 1 1 1
Or Y0 = 1; Cin = 0 1 Cin 1 1 1 1 1 0 0 0
//adder
A X3 Cout
X2 E
B
C X1 S3 F Alternative solution for E:
D X0 S2 G
S1 H A
Y3 S0 B
0 C E
0 Y2 D
0 Y1
0 Y0

2(b) P Q R S W X Y Z
0 0 0 0 0 0 0 0
A1H 0 0 0 1 0 0 0 1
0 A E 0 0 1 0 0 0 1 0
P B F W 0 0 1 1 0 0 1 1
Q C G X 0 1 1 0 0 1 0 0
R D H Y 1 0 0 1 0 1 0 1
1 1 0 0 0 1 1 0
S Z 1 1 0 1 0 1 1 1
1 1 1 0 1 0 0 0
1 1 1 1 1 0 0 1

AY2024/25 Semester 1 - 3 of 4 - CS2100 Tutorial #7 Selected Answers


4. Given a 4-bit magnitude comparator as shown on the right, implement
the following 4-variable Boolean functions using only this single
X3 4-bit
magnitude comparator with no other logic gates. (Note that there
X2 COMP
could be multiple answers.) X1
(a) F(A,B,C,D) = m(12 – 15). X0 X<Y
X=Y
(b) G(A,B,C,D) = m(0, 6, 9, 15). Y3
Y2 X>Y
(c) H(A,B,C,D) = m(0, 1, 6, 7, 8, 9, 14, 15). Y1
(d) Z(A,B,C,D) = m(1, 3, 5, 7, 9, 11, 13). Y0

Answers:
(a) (b)
A X3 4-bit A X3 4-bit
B X2 COMP B X2 COMP
C X1 C X1
D X0 X<Y D X0 X<Y
X=Y X=Y G
1 Y3 D Y3
0 Y2 X>Y F C Y2 X>Y
1 Y1 B Y1
1 Y0 A Y0

Answers for (c) and (d) omitted.


For this type of questions, there could be many possible answers.

AY2024/25 Semester 1 - 4 of 4 - CS2100 Tutorial #7 Selected Answers

You might also like