1010 */
1111public class BasicComp {
1212 private final CPU cpu ;
13- // private final IOCtrl[] ioctrls;
14- // private final IODevTimer timer;
13+ private final IOCtrl [] ioctrls = new IOCtrl [ 4 ] ;
14+ private final IODevTimer timer ;
1515
1616 public BasicComp () throws Exception {
1717 cpu = new CPU ();
1818 cpu .startCPU ();
1919
20- /* CPU2IO cpu2io = cpu.getCPU2IO();
21- ioctrls = new IOCtrl[] {
22- new IOCtrl(0, IOCtrl.Direction.OUT, cpu2io),
23- new IOCtrl(1, IOCtrl.Direction.OUT, cpu2io),
24- new IOCtrl(2, IOCtrl.Direction.IN, cpu2io),
25- new IOCtrl(3, IOCtrl.Direction.INOUT, cpu2io),
26- new IOCtrl(4, IOCtrl.Direction.OUT, cpu2io),
27- new IOCtrl(5, IOCtrl.Direction.OUT, cpu2io),
28- new IOCtrl(6, IOCtrl.Direction.OUT, cpu2io),
29- new IOCtrl(7, IOCtrl.Direction.IN, cpu2io),
30- new IOCtrl(8, IOCtrl.Direction.IN, cpu2io),
31- new IOCtrl(9, IOCtrl.Direction.INOUT, cpu2io),
32- };
33- timer = new IODevTimer(ioctrls[0]);*/
20+ cpu .addDestination (ControlSignal .IRQS ,
21+ (ioctrls [0 ] = new IOCtrlBasicOutput (0 , 0 , cpu ,
22+ (ioctrls [1 ] = new IOCtrlBasicOutput (2 , 1 , cpu ,
23+ (ioctrls [2 ] = new IOCtrlBasicInput (4 , 2 , cpu ,
24+ (ioctrls [3 ] = new IOCtrlBasicInputOutput (6 , 3 , cpu )).getIRQSC ()
25+ )).getIRQSC ()
26+ )).getIRQSC ()
27+ )).getIRQSC ()
28+ );
29+ timer = new IODevTimer (ioctrls [0 ]);
3430 }
3531
3632 public CPU getCPU () {
@@ -58,20 +54,20 @@ public void removeDestination(SignalListener[] listeners) {
5854 cpu .tickUnlock ();
5955 }
6056 }
61-
62- public void loadProgram (ProgramBinary prog ) throws RuntimeException {
63- if (cpu .isLocked ())
64- throw new RuntimeException ("Операция невозможна: выполняется программа" );
65- if (!cpu .executeSetAddr (prog .load_address ))
66- throw new RuntimeException ("Операция прервана: выполняется программа" );
67- for (Integer cmd : prog .binary ) {
68- if (!cpu .executeWrite (cmd ))
69- throw new RuntimeException ("Операция прервана: выполняется программа" );
70- }
71- if (!cpu .executeSetAddr (prog .start_address ))
72- throw new RuntimeException ("Операция прервана: выполняется программа" );
73- }
74- /*
57+
58+ public void loadProgram (ProgramBinary prog ) throws RuntimeException {
59+ if (cpu .isLocked ())
60+ throw new RuntimeException ("Операция невозможна: выполняется программа" );
61+ if (!cpu .executeSetAddr (prog .load_address ))
62+ throw new RuntimeException ("Операция прервана: выполняется программа" );
63+ for (Integer cmd : prog .binary ) {
64+ if (!cpu .executeWrite (cmd ))
65+ throw new RuntimeException ("Операция прервана: выполняется программа" );
66+ }
67+ if (!cpu .executeSetAddr (prog .start_address ))
68+ throw new RuntimeException ("Операция прервана: выполняется программа" );
69+ }
70+
7571 public IOCtrl [] getIOCtrls () {
7672 return ioctrls ;
7773 }
@@ -84,6 +80,7 @@ public void stopTimer() {
8480 timer .done ();
8581 }
8682
83+ /*
8784 private void ctrlDestination(ControlSignal cs, DataDestination dest, boolean remove) {
8885 int iodev;
8986 IOCtrl.ControlSignal iocs;
0 commit comments