Fixed a bug in Am2900; created dlatch8/80; relayouted some components
[Mograsim.git] / net.mograsim.logic.model.am2900 / test / net / mograsim / logic / model / am2900 / am2910 / TestableAm2910Impl.java
index 1695eae..48b8569 100644 (file)
@@ -1,34 +1,29 @@
 package net.mograsim.logic.model.am2900.am2910;
 
-import org.junit.Test;
-
-import net.mograsim.logic.core.components.BitDisplay;
-import net.mograsim.logic.core.components.ManualSwitch;
-import net.mograsim.logic.core.timeline.Timeline;
+import net.mograsim.logic.core.components.CoreBitDisplay;
+import net.mograsim.logic.core.components.CoreManualSwitch;
 import net.mograsim.logic.core.types.BitVector;
-import net.mograsim.logic.core.types.BitVectorFormatter;
-import net.mograsim.logic.model.am2900.TestEnvironmentHelper;
-import net.mograsim.logic.model.am2900.TestEnvironmentHelper.DebugState;
-import net.mograsim.logic.model.model.components.GUIComponent;
+import net.mograsim.logic.model.am2900.util.TestEnvironmentHelper;
+import net.mograsim.logic.model.am2900.util.TestEnvironmentHelper.DebugState;
+import net.mograsim.logic.model.model.components.ModelComponent;
 
 public class TestableAm2910Impl implements TestableAm2910
 {
 
-       private GUIComponent am2901;
-       private Timeline timeline;
-       private ManualSwitch I;
-       private ManualSwitch C;
-       private ManualSwitch CI;
-       private ManualSwitch D;
-       private ManualSwitch _CC;
-       private ManualSwitch _CCEN;
-       private ManualSwitch _RDL;
-       private ManualSwitch _OE;
-       private BitDisplay _FULL;
-       private BitDisplay Y;
-       private BitDisplay _PL, _MAP, _VECT;
-
-       private final TestEnvironmentHelper testHelper = new TestEnvironmentHelper(this, "GUIAm2910");
+       private ModelComponent am2901;
+       private CoreManualSwitch I;
+       private CoreManualSwitch C;
+       private CoreManualSwitch CI;
+       private CoreManualSwitch D;
+       private CoreManualSwitch _CC;
+       private CoreManualSwitch _CCEN;
+       private CoreManualSwitch _RLD;
+       private CoreManualSwitch _OE;
+       private CoreBitDisplay _FULL;
+       private CoreBitDisplay Y;
+       private CoreBitDisplay _PL, _MAP, _VECT;
+
+       private final TestEnvironmentHelper testHelper = new TestEnvironmentHelper(this, "Am2910");
 
        @Override
        public void setup()
@@ -54,7 +49,7 @@ public class TestableAm2910Impl implements TestableAm2910
        @Override
        public void setInstruction(Am2910_Inst inst)
        {
-               I.setState(BitVector.of(inst.ordinal(), 4));
+               I.setState(BitVector.from(inst.ordinal(), 4));
        }
 
        @Override
@@ -84,7 +79,7 @@ public class TestableAm2910Impl implements TestableAm2910
        @Override
        public void set_RLD(String val_1_bit)
        {
-               _RDL.setState(BitVector.parse(val_1_bit));
+               _RLD.setState(BitVector.parse(val_1_bit));
        }
 
        @Override
@@ -93,6 +88,12 @@ public class TestableAm2910Impl implements TestableAm2910
                _OE.setState(BitVector.parse(val_1_bit));
        }
 
+       @Override
+       public void setDirectly(Register r, String val_X_bit)
+       {
+               am2901.setHighLevelState(regToStateID(r), BitVector.parse(val_X_bit));
+       }
+
        @Override
        public String getY()
        {
@@ -123,4 +124,36 @@ public class TestableAm2910Impl implements TestableAm2910
                return _VECT.getDisplayedValue().toString();
        }
 
+       @Override
+       public String getDirectly(Register r)
+       {
+               return am2901.getHighLevelState(regToStateID(r)).toString();
+       }
+
+       private static String regToStateID(Register r)
+       {
+               switch (r)
+               {
+               case S_0:
+               case S_1:
+               case S_2:
+               case S_3:
+               case S_4:
+                       return "stack.c" + BitVector.from(r.ordinal(), 3);
+               case SP:
+                       return "sp.q";
+               case PC:
+                       return "mupc.q";
+               case REG_COUNT:
+                       return "r.q";
+               default:
+                       throw new IllegalArgumentException("unknown: " + r);
+               }
+       }
+
+       @Override
+       public TestEnvironmentHelper getTestEnvironmentHelper()
+       {
+               return testHelper;
+       }
 }