CSE 140 Midterm 3 - Solution
CSE 140 Midterm 3 - Solution
Problem 1
a) True or False?
1-5. _T_Output Y of the circuit below computes the sum bit of a full adder.
b) Multiple Choice
a) 011
b) 100
c) 010
d) 101
1-9.What is the canonical form for Y based on the truth table below?
INPUT OUTPUT
A B C Y
0 0 0 1
0 0 1 X
0 1 0 1
0 1 1 0
1 0 0 0
1 0 1 X
1 1 0 0
1 1 1 X
a) Σm(0,2,5)+d(1,5)
b) ΠM(0,1,2)*d(1,5)
c) Σm(3,4,5,6)+d(1,7)
d) ΠM(3,4,6)*d(1,5,7)
First Name: Last Name: PID:
1-10. What does the circuit in figure below represent? How many transistors
does it have?
A
C
D
B
Problem 2 – ALU
a) Draw the schematic for an ALU with unsigned 3-bit inputs A and B and
two control bits C1 and C0. The ALU implements functionality shown in the
table below. Use a minimum number of 2:1 MUXs, a single 3-bit adder
(with a carry-in input), and a minimum number of inverters.
C1C0 Operation
00 A-B-1
01 A-B
10 B-A-1
11 B-A
b) Using the minimum number of 2:1 MUXs, a single 3-bit adder, and as
few gates as possible, implement the ALU functionality shown in the table
below. The logical outputs should be 0-extended, meaning that if A=001&
B=100, then A<B is true and the output is 001, and B<A is false, so that
output is 000.
Hint: Think about how to use the first four arithmetic functions to perform
the four logical operations. Your solution should be an extension of your
solution to part a)
C2C1C0 Operation
000 A-B-1
001 A-B
010 B-A-1
011 B-A
100 A<=B (zero-extended)
101 A<B (zero-extended)
110 B<=A (zero-extended)
111 B<A (zero-extended)
Problem 3 - Rotator
Design a 4-bit right rotator with 4-bit input A3:0and 4-bit output B3:0. The
two-bit control signal S1:0is used to determine the number of bits for A3:0 to
be shifted, as shown in the table below. For instance, suppose S1:0=10
&A3:0=1100; after rotate is completed the output B3:0=0011.You may use
eight 2:1 MUXes and a minimum number of gates to implement this
functionality.
Problem 4 - Timing
You are given a sequential circuit design as shown below.
b) Fill the state transition table given below using the above FSM. Y2:0 are
state variables.
c) Implement the next state logic for Y1+ & Y0+ with the hardware listed
below. Use minimum number of additional gates.
• Y1+ using a 8:1 Mux with (Y2,Y1,Y0) as select lines.
• Y0+ using a 4:1 Mux with (Y2,Y1) as select lines.
First Name: Last Name: PID:
void main()
{
unsigned int i, start, data, mod4_count, A[128];
while(1) {
while(!start);
i=0;
mod4_count = 0;
while(i<128) {
data = A[i];
if(data%4==0) {
mod4_count++;
}
i++;
}
}
}
First Name: Last Name: PID:
a) Use the code shown above to create the high level FSM
c) Draw the interface between the controller and the datapath, show all
inputs and outputs.
First Name: Last Name: PID: