Machine Problem 4, due Apr 3

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

Write a Java program, in file TernaryLogic.java that can read the description of a system of logic gates from a file called f (presuming that this file exists) when you type the following command to run your program:

[HawkID@serv15 project]$ java TernaryLogic f

When your program is run, it should either:

here is an example description (in the format used for MP3).

gate TIMER istrue     9.0
wire TIMER TIMER      1.0

gate ENABLE isunknown 1.0
wire TIMER ENABLE     1.0

gate CLOCK isfalse    0.5
gate CONTROL min 2    0.5
wire CLOCK CONTROL    0.5
wire CONTROL CLOCK    0.5
wire ENABLE CONTROL   0.5

gate FLIP neg         0.5
gate MIX max 2        0.5
wire TIMER FLIP       1.0
wire FLIP MIX         1.0
wire MIX MIX          1.0

The simulation should implement the following model:

The initial state of the simulator is that all inputs and all outputs of gates and wires are unknown, represented by the value 1. In the case of istrue and isfalse gates, this is an unstable state. Before the simulation begins, each such gate should immediately schedule an output transition from unknown to false (represented by the value 0) at a time equal to the gate's delay. Similarly, for isunknown gates, an output transition to true (represented by the value 2) should be scheduled.

(This model leaves out a huge number of features of real digital logic, most notably, the fact that logic gates act as low pass filters. That is, if an output change is followed swiftly enough by another output change, the first value is lost.)

The output should show one line of text for each change of the output of a logic gate. The output should show the time, the gate name and the new value (0, 1 or 2), with no additional text aside from blanks separating fields.

Grading criteria will be as usual: No credit will be given to programs that do not represent a substantial attempt at meeting the requirements of this assignment. Your program must:

Note that the requirements for header comments in the file header are absolute. Your name must appear in the form that it appears on your ID card. The TAs will not waste their time doing detective work to attempt to figure out who submitted what code.

Submission: Your solution should consist of a single file, with one public method, main. (Later, we will chop the file into smaller more managable pieces, as it grows.)

To submit your solution, make sure it is in a single source file called TernaryLogic.java (not a directory; this requires that the main method be in a class called TernaryLogic. This must be in the current directory which must not be submitted. Then, follow the submission procedures used for MP1, but use mp4 wherever the original instructions specified mp1.