Solutions for 2004 midterm

Question 1

a) What function does the following logic gate diagram compute?



Answer:

b) Simplify this formula (using any appropriate technique).

Answer:

c) Draw a logic gate diagram for your simplified formula.


Question 2

Draw a sequential circuit with three outputs and one input line in addition to the clock. While the data input is 0, your circuit functions as a three-bit counter (counting clock pulses). While the data input is 1, your circuit skips the value 010 (it goes from 001 to 011, but all other transitions are the same). When the data input goes back to 0, the count continues (it doesn't jump back for a missed 010 or anything like that).

Answer:

The clock is not shown above; it is wired into the input of each flip flop.


Question 3

Using four-bit numbers, show how the addition of 3+(-2) in the signed representation is the same as adding 3+14 in the unsigned representation. What is the value of the result?

Answer:
3 is 0011
-2 is 1110
14 is also 1110

 0011
+1110
 ----
 0001
(probably best to show the carries too)

The result is 1. This is the correct value for 3+(-2); it represents an overflow of 3+14, where the result is congruent to the right answer mod 16 (24).


Question 4

Write machine-language (assembly language) instructions to assign z to be (x-y)2, if x is in register R0, y is in register R1, and z is in register R2. (To square an integer, you can just multiply it by itself, of course.)

Answer:

	MOV R0, R2
	SUB R1, R2
	MUL R2, R2


[midterm information]
[main course page]