Machine Problem 5, due Nov 30

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

Extending MP4: The fact is, the way our simulator operates stinks. Running the simultion until there are no more pending changes is hardly ever what a real system designer would want to do, real systems have inputs as well as outputs, and it is reasonable to think that the simulation users might want to control those inputs.

Inputs: After designing a circuit, the designer of that circuit would typically develop tests where inputs are manipulated to see if the circuit behaves as expected. Suppose you have a circuit with inputs named a, b and c. A test script input might look like this:

1.0 a true
1.5 b true
3.5 c true
3.6 c false
3.6 b false
5.0 stop

Lines in this test script give the time of an event and either the input that changes and its new value or the command to stop the simulation. Initially, all inputs are false. The successive lines of this file must be in non-descending numerical order (that is, chronological order with permission for successive events to be simultaneous). The description of a logic circuit stops and the test script begins on the first line starting with a number.

Your job is to implement class Input, a subclass of Gate. Objects of this class will be named input gates; it is illegal to connect a wire to the input of an input gate.

If there are any input gates, a read-next-input-change event is scheduled for time zero. The event service routine for this event uses the same scanner that was passed to Input.scan() to read the time and action. The input changes are scheduled at the indicated times. There should never be more than one pending input-change event.

A minimal test: Here is the bare minimum test program for the simulator:

gate input a 0
gate output b 0
wire a b in 0.5
2.0 a true
5.0 stop

This might give the following simulation output:

 b
 |
 |
 |_
   |
   |

Other outputs are possible because the above input leads to some simultaneous events and we do not have control of the order of their simulation.

Grading criteria: Essentially the same criteria as for MP2

Submission: Your solution should consist of a single file containing the definition of the new class Input, an extension of class Gate. As such, it will conform to the interface specification for Gate.

To submit your solution, make sure it is in a file called Input.java This must be in the current directory. Follow the usual submission instructions, but submit to mp5.