CSE369 Wi22 Quiz3

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

U niversity of W ashington – C om puter Science & Engineering

Winter 2022 Instructor: Justin Hsia 2022-03-08

N am e: _________________________
Student ID
N um ber: ____________

P lease do not turn the page until 11 :40.

Instructions
• This quiz contains 4 pages, including this cover page.
• Show scratch work for partial credit, but put your final answers in the boxes and blanks
provided.
• The quiz is closed book and closed notes.
• Please silence and put away all cell phones and other mobile or noise-making devices.
• Remove all hats, headphones, and watches.
• You have 60 (+10) minutes to complete this quiz.

A dvice
• Read questions carefully before starting. Read all questions first and start where you
feel the most confident to maximize the use of your time.
• There may be partial credit for incomplete answers; please show your work.
• Relax. You are here to learn.

Question P oints Score


(1) Decoders 12
(2) Routing Elements 11
(3) Cryptography 9
Total: 32
Question 1: Decoders [12 pts]
We are building a 7-seg decoder circuit for Simon, a color-based memory game with 4
buttons. The signals T(op), B(ottom), L(eft), and R(right) are high (1) only if a button in the
corresponding column or row is being pushed. The 2-bit bus K represents which color is
recognized (green = 00, red = 01, blue = 10, yellow = 11). The Valid signal (V) is high when at
least one button is being pressed.

T T
Part V Part 7
B B
K1 S
L A C
K0
R green red blue yellow
L R

(A) Complete the truth table. We give priority to T and L. T B L R V K1 K0


[4 pt] 0 0 0 0 0 X X
0 0 0 1 0 X X
(B) In the space below, solve for the minimal logical
expression for 𝐊 𝟎 . [4 pt] 0 0 1 0 0 X X
0 0 1 1 0 X X
0 1 0 0 0 X X
0 1 0 1 1 1 1
0 1 1 0 1 1 0
0 1 1 1 1 1 0
1 0 0 0 0 X X
1 0 0 1 1 0 1
1 0 1 0 1 0 0
1 0 1 1 1 0 0
1 1 0 0 0 X X
1 1 0 1 1 0 1
(C) For the 7-seg signal numbering and outputs shown 1 1 1 0 1 0 0
above (lit/red = 1), draw the minimal logic for 𝐒𝟐 in
1 1 1 1 1 0 0
terms of V, K1 , and K 0 . All signals should be off when
V = 0. [4 pt]

2
Question 2: Routing Elements [11 pts]
We are creating a sequential circuit with 1-bit inputs (enable), (action), and (direction)
and 𝑛-bit output . When not enabled, stays constant, otherwise, the circuit will either count
( ) or shift ( ) each cycle. indicates to decrement when counting or right-shift when
shifting and indicates the opposites. The circuit always shifts in a bit.
(A) Draw out the circuit below. You can freely use registers, constants, 2:1 MUXes, and the
following logic blocks. Make sure you label the corresponding selector bits for ports of
routing elements. [8 pt] n n n
n n n

n ‫ڿ‬log 2 𝑛‫ۀ‬ ‫ڿ‬log 2 𝑛‫ۀ‬

(B) Now assume that we instantiate our circuit with 𝑛 = 3. In the Verilog testbench below,
fill in the blanks to indicate how the output of our sequential circuit updates. [3 pt]

initial begin
D <= 1; A <= 0; E <= 1; // Q: 000
@(posedge clk); A <= 1; // Q: _____
@(posedge clk); E <= 0; // Q: _____
@(posedge clk); D <= 0; A <= 0; E <= 1; // Q: _____
@(posedge clk); A <= 1; // Q: _____
@(posedge clk); A <= 0; // Q: _____
@(posedge clk); $stop(); // Q: _____
end

3
Question 3: Cryptography [9 pts]
In cryptography, we wish to encode a message to apparent nonsense in a reversible manner so
that the intended recipient can decode it and recover the original message. We can build a
simple encoder using logic gates and a special “key”!
Example: With the message , and key , we get the encrypted message ,
from which we can recover the original message using the same key.

(A) (Circle one) Which type of gate will allow us to reversibly encrypt and decrypt? [1 pt]
AND NAND NOR OR XNOR XOR

(B) Below, implement a 4-bit encryption circuit that computes the encrypted message
from the original message and key . You may only use a single type of 2-input logic
gate. [3 pt]

(C) Assume 𝑡NOT = 10 ns, 𝑡AND = 𝑡OR = 25 ns, and 𝑡XOR = 40 ns. Now we want to implement
a decryption circuit that reverses the encryption. How much slower, if at all, would this
decryption circuit be than the encryption circuit from Part B? [2 pt]
_______ ns

(D) Outline (in writing) a possible solution to handling messages of any length (e.g., ones that
are much longer than the key), assuming that we only have one instance of the encryption
circuit (i.e., we can't spawn extra circuitry on the fly). [3 pt]

You might also like