# Exam#2 sol_A

## Transcription

Exam#2 sol_A
``` CSE 140 Midterm 2 version A Tajana Simunic Rosing Spring 2015 Name of the person on your left​
: ________________________________ Name of the person on your right:​
________________________________ 1. 9 points 2. 16 points 3. 15 points 4. 20 points 5. 20 points 6. 20 points Total (100 pts.) ●
●
●
●
●
Do not start the exam until you are told. Write your name and PID at the top of every page. Write the names of people on your left and right on the first page. Turn off and put away all your electronics. This is a closed­book, closed­notes. You may only refer to one 8 ½ x 11” page of your handwritten notes. By turning in this exam for grading you are stating that you have followed the UCSD’s academic honesty policies. Do not look at anyone else’s exam or talk to anyone but an exam proctor. If you have a question, raise your hand and an exam proctor will come to you. ●
You have 80 minutes to finish the exam. When the time is finished, you must stop writing. Write your answers in the space provided. To get the most partial credit, clearly show all the steps of your work. Full credit may not be given for correct answers with no work shown. Problem 1 (9pts) Consider the following flip­flop constructed using a D flip flop: a. Write the next­state equation for the above flip flop Q(t+1) = f(Q(t), X). Q(t+1) = Q(t) ⊕ X 4pts b. Plot the output(Q) waveform for the following clock and input sequence. Assume initial state is Q = 0. Solution: 5pts Problem 2 (16pts) Design an arithmetic unit (AU) which takes in two 4­bit binary number that are already in 2s complement, A (a​
a​
a​
a​
) and B (b​
b​
b​
b​
). For example, A=1101 when A is ­3 in decimal, or 3​
2​
1​
0​
3​
2​
1​
0​
A=0011 when A is 3 in decimal. AU’s block diagram and the functional table are given below. M​
is the operation selection input of 0​
the AU. M​
0 Function Name F(A,B) 0 Decrement A by 2 A ­ 2 1 Add A and 2*B and 1 A + 2*B + 1 Specify your design of the Operation Selection Unit by defining what ​
y​
,y​
,y​
,y​
​
3​
2​
1​
0 should be as a function of the inputs A & B and selector M​
. Cell entries in the table 0​
below should use 0s, 1s or input variable bits : {a​
,a​
’ ,b​
,b​
’ ; (0 ≤ i ≤ 3); e.g. a​
.
i ​
i​
i ​
i​
2​
M​
0 y​
3 y​
2 y​
1 y​
0 0 1 Solution: M​
0 y​
3 y​
2 y​
1 y​
0 0 1 1 1 0 1 b​
2 b​
1 b​
0 1 2 pts per each correct answer in the table Problem 3 (15pts) The timing characteristics of the components of the circuit shown in figure below are: ● Flip­flop: clock­to­Q maximum delay (propagation delay) 50ps, clock­to­Q minimum delay (contamination delay) 20ps, setup time 25ps, hold time 30ps ● Logic gate (each AND, OR, XOR): propagation delay 25ps, contamination delay 15ps. ● Zero clock skew a. What is the maximum clock frequency of this circuit? tpcq + tpd + tsetup < T c 50ps + 5 × 25ps + 25ps < T c 1 = 5GHz f ≤ T1c = 200ps
• 2pts for the correct formula; • 1pts for correctly substituting t​
and t​
into formula; pcq​
setup​
• 2pts for correctly substituting t​
into formula; pd​
• 3pts for obtaining the correct final solution. b. How much clock skew can the circuit tolerate before it experiences a hold time violation? tccq + tcd > tskew + thold tskew < 20ps + 15ps − 30ps = 5ps • 2pts for the correct formula; • 1pts for correctly substituting t​
and t​
into formula; ccq​
hold​
• 1pts for correctly substituting t​
into formula; cd​
• 3pts for obtaining the correct final solution. Problem 4 (20pts) Answer the following questions for the FSM shown in the figure. a. Circle if it is Mealy or Moore Moore machine 1 point b. Fill in the state transition table: Q​
Q​
\ a 1​
0​
0 1 00 01, 1 00,0 01 01, 1 10, 1 10 11,0 11, 0 11 00, 0 00 ,0 8 points (­1 for each element) (Note: the output is not required here. You won’t lose any point if you didn’t write down or you had incorrect output) (Note: if you wrote output instead of the next state, ­6 points) c. Fill in the excitation table Q​
Q​
1 0 a D​
D​
1 0 y(current state) y(next state) 0 0 0 0 1 0 1 0 0 1 0 0 0 0 0 1 0 0 1 1 1 0 1 1 1 0 1 1 1 0 0 1 1 1 0 1 0 1 1 1 1 0 1 1 0 0 0 0 0 1 1 1 0 0 0 0 8 points (­1 for each row) (Note: for the output, conventionally we use the output of the current state, but you won’t lose points if you use the output of the next state) d. Write the Boolean equation for the next state of MSB: D​
= 1​
kmap and equation for D​
1 D​
= Q​
*Q​
’ + Q​
’*Q​
*a 1​
1​
0​
1​
0​
Q​
\ Q​
a 1​
0​
00 01 11 10 0 0 0 1 0 1 1 1 0 0 3 points (­1 for each error) Problem 5 (20pts) A sequential circuit has two inputs w1 and w2, and an output, z. Its function is to compare the input sequences of the two inputs. If w1=w2 during any four consecutive clock cycles, the circuit produces z=1; otherwise, z=0. For example w1:0110111000110 w2:1110101000111 z:0000100001110 Draw the state diagram using the minimum number of states. Solution X = w1 XOR w2 Grading: For each state: +1 for each correct transition
= 2 total per state +2 for each correct output = 2 total per state Total for every state
= 4 Max 4*5 = 20 If more than 5 states are used, but the logic is correct: +10 for the entire answer Full credits for any other possible solution using 5 states. NOTE: input labeled as (w1=w2), (w1==w2), (w1 XOR w2), 00,11 and similar also OK NOTE: The solution here uses moore machine. You can also use mealy machine. For mealy machine, only 4 states are enough. If you use 5 states we don’t deduct points. Problem 6 (20pts) For the sequential circuit shown in the figure do the following: a. Fill in the excitation table Q1Q0A Q1(t+1) Q0(t+1) Y 000 0 0 0 001 0 0 0 010 0 1 1 011 0 1 1 100 0 0 1 101 1 0 1 110 0 1 1 111 1 1 1 8 pts b. Write down Boolean equations for next state and output Q0(t+1) = (Q0A + Q0’A’) XOR (Q0A + Q0’A’) XOR Q0 = Q0 (simplified) Q1(t+1) = AQ1 + A’0 = AQ1 + 0 = AQ1 Y = Q0 + Q1 6 pts c. Draw the state diagram representing this FSM 6 (1.5 per state; 0.5 per each transition, 0.5 output) ```