Machine Problem 4, due Nov 9

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

Extending MP3: Consider the posted solution to Machine Problem 3. This solution is only the first step on the road to a useful logic simulator.

Breaking up the file: First note that the simulator is getting ungainly. It is time to break it up into smaller pieces. Class Simulator is an obvious one to break off, but we can break things down considerably. Broken up code will be available on line shortly after the solution to MP3 is posted.

Outputs: Having the simulator generate a trace of all the events that occur is hardly useful in a simulation of a large system. For a large system you really only want to look at some of the outputs of the circuit. If you were debugging a real circuit, you might hook these outputs to LED lamps that glow when the output is true and are dark when the output is false. If you had more resources, you might use a digital storage oscilloscope to display graphs of each output as a function of time.

How can we incorporate support for this kind of output into the logic simulator? Consider adding a new class of gate, output. Here is a simulation specification that incorporates an output:

gate not a 0.5
gate output b 0
gate output c 0
wire a a in 0.5
wire a b in 0.5
wire a c in 1.5

This circuit never terminates because the output of gate a is fed back into its input. As a result, the output of gate a bounces from false to true and back again every 2 time units. The output device, gate b, samples this changing output. A simulation user would connect output gates to the points in the circuit that were interesting, and the simulator would display only those points and none others.

If we show the output using one line per time unit, it might look like this:

 a    b
 |_    _|
  _|  |_
 |_    _|
  _|  |_

This is a plot using time as the vertical axis and putting false oututs to the left and true outputs to the right. It is essentially a normal graph of the outputs a and b as a function of time except that it is turned 90 degrees. Note that each column is headed with the name of the output in that column (up to 4 letters, if the name is longer than that, it should be truncated).

During each time step for each output, one of the following strings is shown:

If there are more than one output, they should be listed across the output line in the order the outputs were declared. The result is one output every 5 spaces in the output line, so an 80-column output line can handle 16 outputs.

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 Output, 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 Output.java This must be in the current directory. Follow the usual submission instructions, but submit to mp4 instead of mp3.