Assignment 9, due Mar 29

Part of the homework for CS:2820, Spring 2019
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

Assignments are to be turned in on paper. On every assignment, write your name, course and section number at the top of each page. Write your name as it appears in your university records! Use the section number for which you are registered! We will not do detective work to figure out who did what. Work must be legible.

Homework is due on paper in discussion section, usually at the start except when the assignment indicates that time to work on the assignment will be provided in class. Exceptions will be made only by advance arrangement with your TA (excepting "acts of God" outside your control). Never push homework under someone's door!

  1. Background: Consider this description for a logic circuit designed as input to MP4:
    gate a input 1 1.0 0
    gate b input 1 1.5 1
    gate c input 1 2.0 2
    

    You do not need a working simulator to solve this problem, and having solved it, you can use it to test part of your simulator.

    a) After a while, the simulation will stop. When it stops, what are the values of the outputs of gates a, b and c? (0.4 points)

    b) What output would you expect from a correct solution to MP4 when run on this input file? (0.6 points)

  2. Background: A minimal test for an xor gate requires 2 input gates, one output gate, 3 wires, and of course, the gate being tested. Your test will look something like this:
    gate in1 input ...
    gate in2 input ...
    gate xor xor 0.1
    gate out output
    wire in1 0.1 xor
    wire in2 0.1 xor
    wire xor 0.1 out
    

    a) Finish the definitions of in1 and in2 so that the gate goes through all four possibile combinations exactly once, excluding infinitesimal moments. That is, (in1, in2) should start out (0, 0), then switch to (0, 1), and then (1, 0) and then (1, 1), with changes occuring at times 1.0, 2.0 and 3.0. (0.5 points)

    b) Why did the above problem statement have to say "excluding infinitesimal moments" above? That is, in the sequence of input values required, where will there be an unavoidable if infinitesimally brief extra test of input combinations? (0.3 points)

    c) What change to your answer to part a would you make in order to make the test run two full cycles of all four input combinations instead of one cycle? (0.2 points)

  3. Background: MP4 requires that you simulate gates and wires. Consider the problem of simulating wires first, since they're simple. In our road network simulation, class Road had methods enter and exit for vehicles entering and exiting a road. It would make sense for class Wire to have methods inputChange, called when the input to the wire (from a gate) changes, and outputChange, called when the output from the wire (to some gate) changes. Gates can have similar methods, but their logic will be more complex.

    a) What is (are) the parameter(s) to these methods? (0.2 points)

    b) Give the simplest Java code you can for Wire.inputChange. (0.4 points)

    c) Give the simplest Java code you can for Wire.outputChange. (0.4 points)