Professional Documents
Culture Documents
Yes, overflow only occurs in part a) where an asl operation causes the msb (sign bit) to
change (from 0 to 1).
This can be detected by EXOR’ing the 2 most significant bits where overflow would be
detected if the bits are different.
1
University of Ottawa, Faculty of Engineering, School of Electrical Engineering and Computer Science
CEG2136 Midterm Exam 2016
Design a 3-bit multi-function bidirectional shift register whose function is described in the
following table, where M and N are two control bits.
Using the proper digital components (encoders, decoders, multiplexers, etc.), logic gates, and D
flip-flops, draw a detailed diagram of the logic circuit of the register.
Clock M N Operation I2 Q2
↑ 0 0 Store current value / No change I1 Q1
↑ 0 1 Decrement by 3 I0 Multi
↑ 1 0 Load external inputs (I2 I1 I0) Q0
Function
↑ 1 1 Increment by 2 Register
M
N
Clock
MN= 01 =>Decrement by 3
2
University of Ottawa, Faculty of Engineering, School of Electrical Engineering and Computer Science
CEG2136 Midterm Exam 2016
D0 = Q0’
D1:
Q1 Q0 00 01 11 10
Q2
0 0 1 0 1
1 0 1 0 1
D1 = Q1Q0’ + Q1’Q0 or D1 = Q1 ⊕ Q0
D2:
Q1 Q0 00 01 11 10
Q2
0 1 1 0 1
1 0 0 1 0
MN=11 =>Increment by 2
D0 = Q0
D2:
Q1 Q0
00 01 11 10
Q2
0 0 0 1 1
1 1 1 0 0
D2= Q2Q1’ + Q2’Q1 or D2 = Q2 ⊕ Q1
D1:
Q1 Q0
00 01 11 10
Q2
0 1 1 0 0
1 1 1 0 0
D1=Q1’
3
University of Ottawa, Faculty of Engineering, School of Electrical Engineering and Computer Science
CEG2136 Midterm Exam 2016
4
University of Ottawa, Faculty of Engineering, School of Electrical Engineering and Computer Science
CEG2136 Midterm Exam 2016
Q0
or only Q’02
one
3-input
Q’1
gateQ0
Q’2
Q2
Q1
Q0
5
University of Ottawa, Faculty of Engineering, School of Electrical Engineering and Computer Science
CEG2136 Midterm Exam 2016
Design a synchronous modulo-4 binary counter that has one control input W and that counts
forward or backward, as follows (assume an initial count value of 0):
• if W=0: counts backward by one (03210…) at each clock pulse
• if W=1: counts forward by one (01230…) at each clock pulse
a) Derive the state transition table and state diagram of the counter.
Transition table
W Q1(n) Q0(n) Q1(n+1) Q0(n+1) J1 K1 J0 K0
0 0 0 1 1 1 x 1 x
0 0 1 0 0 0 x x 1
0 1 0 0 1 x 1 1 x
0 1 1 1 0 x 0 x 1
1 0 0 0 1 0 x 1 x
1 0 1 1 0 1 x x 1
1 1 0 1 1 x 0 1 x
1 1 1 0 0 x 1 x 1
or
Transition table FF inputs #
Q1(n) Q0(n) W Q1(n+1) Q0(n+1) J1 K1 J0 K0
0 0 0 1 1 1 x 1 x
0 0 1 0 1 0 x 1 x
0 1 0 0 0 0 x x 1
0 1 1 1 0 1 x x 1
1 0 0 0 1 x 1 1 x
1 0 1 1 1 x 0 1 x
1 1 0 1 0 x 0 x 1
1 1 1 0 0 x 1 x 1
b) Design the sequential circuit by using JK flip flops and the required logic gates.
J1 :
Q1Q0W 00 01 11 10
Q1=0 1 0 1 0
Q1=1 X x x X
J1 = Q0’W’ + Q0W = or = (Q0 ⊕ W)’
6
University of Ottawa, Faculty of Engineering, School of Electrical Engineering and Computer Science
CEG2136 Midterm Exam 2016
K1:
Q1Q0W 00 01 11 10
Q1=0 X x x x
Q1=1 1 0 1 0
K1 = Q0’W’ + Q0W = or = (Q0 ⊕ W)’
7
University of Ottawa, Faculty of Engineering, School of Electrical Engineering and Computer Science
CEG2136 Midterm Exam 2016
xy z=0 z=1
00 F = A’ + 1 (2’s complement) F = A – 1 (decrement)
01 F = A – B (subtract) F = A – B + 1 (subtract with borrow)
10 F = A + 1 (increment) F = A (transfer)
11 F = A + B + 1 (add with carry) F = A + B (add)
z=0 z=1
xy FAA + FAB + Cy FAA + FAB + Cy
00 A’2A’1A’0+ 0 0 0 + 1 A2 A1 A0 + 1 1 1 + 0
01 A2 A1 A0 + B2’B1’B0’+ 1 A2 A1 A0 + (B2’B1’B0’+1)+1 0
10 A2 A1 A0 + 0 0 0 + 1 A2 A1 A0 + 0 0 0 + 0
11 A2 A1 A0 + B2 B1 B0 + 1 A2 A1 A0 B2 B1 B0 + 0
z=0 z=1
xy FAA + FAB + Cy FAA + FAB + Cy
00 A’2A’1A’0+ 0 0 0 + 1 A2 A1 A0 + 1 1 1 + 0
01 A2 A1 A0 + B2’B1’B0’+ 000 1 A2 A1 A0 + B2’B1’B0’+ 010 0
10 A2 A1 A0 + 0 0 0 + 1 A2 A1 A0 + 0 0 0 + 0
11 A2 A1 A0 + B2 B1 B0 + 1 A2 A1 A0 B2 B1 B0 + 0
8
University of Ottawa, Faculty of Engineering, School of Electrical Engineering and Computer Science
CEG2136 Midterm Exam 2016
9
University of Ottawa, Faculty of Engineering, School of Electrical Engineering and Computer Science