Assignment 11, due Nov
Part of
the homework for 22C:60, Fall 2010
|
Always write your name legibly as it appears on your University ID and on the class list!
Note, only the top 10 homework scores will be counted toward the final grade, but it would not be wise to cease doing homework just because you have 10 strong scores. All material covered in the homework is liable to be covered in exams, and the best way to study it is to work on the homework.
a) Draw the logic circuit in schematic form with the inputs on the left and outputs on the right. (0.5 points)
b)
Draw a timing diagram for this circuit showing how the outputs change
as the inputs move through the following sequence of 13 changes:
(0.5 points)
[a,b]
= [0,0],[0,1],[0,0],[1,0],[1,1],[1,0],[0,0],[1,0],[1,1],[0,1],[1,1],[1,0],[0,0]
c) Is this circuit a kind of flipflop? If so, what input combination causes it to remember a value, how do you set it, and how do you reset it?
An obvious way to deal with such errors is to raise an exception when the interpreter discovers something irregular. It would be easy, for example, to check, before outputting a character, to see if the x and y coordinates are on the screen, and raise an exception if not.
a) Where should the handler be? (0.5 points)
b) What would you check for, and where in the code, to detect unbalanced parentheses as illustrated above? Hint: There is no need to count the parentheses. (0.5 points)
A Problem: Suggest a way to compact the code for raising exceptions by putting most of the code in one place with just one or two instructions that must be duplicated in each place the exception is raised. Your code might take one or two extra instructions to raise an exception, but it should be more compact if there are enough exceptions raised in the program. (0.5 points)