This is the central class in the model directory. It begins with a definition of constants such as the names of the parts of the machine and the numerical value of a CPP (). On creation of an instance of this class, 23 units are created, which are the initiating unit, 20 accumulators, the constant transmitter, and the printing unit. The simulator also creates five digit trunks (I V) and ten program trunks (A-1 A-10). The number of program trunks can easily be changed to suit your needs.
Like most of the classes, eniac.model.Eniac provides data access methods for its units and trunks, some of which are able to find units by name.
eniac.model.Eniac keeps track of all sending action of units, which have to use the method send(). The machine is stopped if there is no more sending activity, and no repetitive program switch is doing repeat cycles.
The central method is start(), which sends init a CPP when a calculation is to be started. It then goes through the predefined number of cycles, which is Long.MAX_VALUE ( ) if no limit is set. Every machine cycle consists of two half-cycles, as on the original ENIAC. In the first half of the cycle, digit transmission takes place through call of the run1() method of all units. CPP sending is done in the second half-cycle, when all run2() methods are invoked. As mentioned above, activity in the machine is obligatory to keep this main loop going.
On invocation of its run2() method, this class send the first CPP to all connected units. init has only one program output port, which is called 1.
The original ENIAC printer was a little different from this implementation. print accepts a CPP on its only input port 1, prints the contents of all accumulators (method dumpAccus()), and sends a final CPP on its output port 1.
In addition, it provides the usual data access methods, and a method called dump(), which can print a core dump of the whole machine if called from anywhere. It is invoked by pressing the dump now button, or automatically during computation processes if core dump is set.
Another deviation from the original: All 30 fields of the constant transmitter are directly settable, as there is no equivalent to the punched cards in the simulator.
The constant transmitter consists of two output ports, A and S, and 30 CFields, constant fields with program input and output connections.
On reception of a CPP, which is detected in the first half-cycle, the content of the appropriate constant field is sent on both digit ports, A and S. The process is completed by a CPP through the program output port of the same field during the second half-cycle in method run2().
Finally, the simulation of the ENIAC's accumulators. An accumulator consists of a Content, i. e. the number it stores. There are the five digit input ports, alpha epsilon, and the two digit output ports, A and S. Furthermore, there are twelve program switches, 1 12, of which the last eight are repetitive ones, and a significant digits switch.
On call of method run1(), the accumulator unit first checks if it is in repetition mode. If yes, the virtual machine is instructed not to stop execution, even if there is no momentary CPP flow--after the last repetition, the repeating switch will send a signal, which is able to continue calculations. The action stated by the active program switch is executed, if it is a sending task (A, AS, S).
If we are not in repetition mode, the unit checks for multiple CPP reception, which would be a ``bug in the wiring'' [2, p. 142]. Otherwise, it executes A, AS, or S commands.
Method run2() begins with the same check for repetition mode, but now it is the turn for receive commands (alpha epsilon) in both modes. On reach of the last repetition, the switch can send a CPP on its output port. The input register (arrival point of CPPs) is cleared, and the content as well according to the significant digits switch, if the clear-correct switch is set.