X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.model.am2900%2Ftest%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Fam2900%2Fam2904%2FTestableAm2904Impl.java;h=677a3e1b144b7e85480855dff4b6af37a16005f2;hb=93b398d6271a538a2a4c9f4de07a3b4a8a2a7fd4;hp=e36ca6d46262ce8b4c5fe164870971798787043c;hpb=6d28e5c93c9347784950ca66fb6d1b3a14461ece;p=Mograsim.git diff --git a/net.mograsim.logic.model.am2900/test/net/mograsim/logic/model/am2900/am2904/TestableAm2904Impl.java b/net.mograsim.logic.model.am2900/test/net/mograsim/logic/model/am2900/am2904/TestableAm2904Impl.java index e36ca6d4..677a3e1b 100644 --- a/net.mograsim.logic.model.am2900/test/net/mograsim/logic/model/am2900/am2904/TestableAm2904Impl.java +++ b/net.mograsim.logic.model.am2900/test/net/mograsim/logic/model/am2900/am2904/TestableAm2904Impl.java @@ -1,32 +1,32 @@ package net.mograsim.logic.model.am2900.am2904; -import net.mograsim.logic.core.components.BitDisplay; -import net.mograsim.logic.core.components.ManualSwitch; +import net.mograsim.logic.core.components.CoreBitDisplay; +import net.mograsim.logic.core.components.CoreManualSwitch; import net.mograsim.logic.core.types.Bit; import net.mograsim.logic.core.types.BitVector; import net.mograsim.logic.model.am2900.util.SwitchWithDisplay; import net.mograsim.logic.model.am2900.util.TestEnvironmentHelper; import net.mograsim.logic.model.am2900.util.TestEnvironmentHelper.DebugState; -import net.mograsim.logic.model.model.components.GUIComponent; +import net.mograsim.logic.model.model.components.ModelComponent; public class TestableAm2904Impl implements TestableAm2904 { - private GUIComponent am2904; - private ManualSwitch I; - private ManualSwitch C; - private ManualSwitch Cx; - private ManualSwitch IC, IN, IOVR, IZ; - private ManualSwitch _CEM, _CEmu; - private ManualSwitch _EC, _EN, _EOVR, _EZ; - private ManualSwitch _OECT, _OEY; - private ManualSwitch _SE; - private BitDisplay C0; - private BitDisplay CT; + private ModelComponent am2904; + private CoreManualSwitch I; + private CoreManualSwitch C; + private CoreManualSwitch Cx; + private CoreManualSwitch IC, IN, IOVR, IZ; + private CoreManualSwitch _CEM, _CEmu; + private CoreManualSwitch _EC, _EN, _EOVR, _EZ; + private CoreManualSwitch _OECT, _OEY; + private CoreManualSwitch _SE; + private CoreBitDisplay C0; + private CoreBitDisplay CT; private SwitchWithDisplay SIO0, SIOn, QIO0, QIOn; private SwitchWithDisplay YC, YN, YOVR, YZ; - private final TestEnvironmentHelper testHelper = new TestEnvironmentHelper(this, "file:components/am2904/GUIAm2904.json"); + private final TestEnvironmentHelper testHelper = new TestEnvironmentHelper(this, "Am2904"); @Override public void setup() @@ -88,14 +88,14 @@ public class TestableAm2904Impl implements TestableAm2904 } @Override - public void setY(String ovr_n_c_z) + public void setY(String z_c_n_ovr) { - var bv = BitVector.parse(ovr_n_c_z); - // correct order apparently unknown :/ - YOVR.setState(bv.getLSBit(3).toVector()); - YN.setState(bv.getLSBit(2).toVector()); - YC.setState(bv.getLSBit(1).toVector()); - YZ.setState(bv.getLSBit(0).toVector()); + var bv = BitVector.parse(z_c_n_ovr); + // correct order apparently unknown, most likely Z-C-N-OVR + YZ.setState(bv.getLSBit(3).toVector()); + YC.setState(bv.getLSBit(2).toVector()); + YN.setState(bv.getLSBit(1).toVector()); + YOVR.setState(bv.getLSBit(0).toVector()); } @Override @@ -204,10 +204,16 @@ public class TestableAm2904Impl implements TestableAm2904 public void setDirectly(Register r, String val_1_bit) { var bv = (BitVector) am2904.getHighLevelState(regToStateID(r)); - bv = bv.withBitChanged(3 - r.ordinal() % 4, b -> Bit.parse(val_1_bit)); + bv = bv.withBitChanged(r.ordinal() % 4, b -> Bit.parse(val_1_bit)); am2904.setHighLevelState(regToStateID(r), bv); } + @Override + public void setDirectly(CompleteStatus r, String z_c_n_ovr) + { + am2904.setHighLevelState(regToStateID(r), BitVector.parse(z_c_n_ovr)); + } + @Override public String getC0() { @@ -223,11 +229,11 @@ public class TestableAm2904Impl implements TestableAm2904 @Override public String getY() { - // correct order apparently unknown :/ - var y3 = YOVR.getDisplayedValue(); - var y2 = YN.getDisplayedValue(); - var y1 = YC.getDisplayedValue(); - var y0 = YZ.getDisplayedValue(); + // correct order apparently unknown, most likely Z-C-N-OVR + var y3 = YZ.getDisplayedValue(); + var y2 = YC.getDisplayedValue(); + var y1 = YN.getDisplayedValue(); + var y0 = YOVR.getDisplayedValue(); return y3.concat(y2).concat(y1).concat(y0).toString(); } @@ -259,14 +265,28 @@ public class TestableAm2904Impl implements TestableAm2904 public String getDirectly(Register r) { var bv = (BitVector) am2904.getHighLevelState(regToStateID(r)); - return bv.getLSBit(r.ordinal() % 4).getSymbol(); + return bv.getMSBit(r.ordinal() % 4).getSymbol(); + } + + @Override + public String getDirectly(CompleteStatus r) + { + var bv = (BitVector) am2904.getHighLevelState(regToStateID(r)); + return bv.toString(); } private static String regToStateID(Register r) { - if (r.ordinal() > 3) - return "msr.q"; - return "musr.q"; + if (r.ordinal() < 4) + return "musr.q"; + return "msr.q"; + } + + private static String regToStateID(CompleteStatus r) + { + if (r == CompleteStatus.micro) + return "musr.q"; + return "msr.q"; } @Override