Renamed core components to have the common prefix Core
[Mograsim.git] / net.mograsim.logic.model.am2900 / src / net / mograsim / logic / model / am2900 / components / GUIram5_12.java
index a8c397c..4a13c47 100644 (file)
@@ -13,8 +13,8 @@ import java.util.regex.Pattern;
 
 import net.mograsim.logic.core.types.Bit;
 import net.mograsim.logic.core.types.BitVector;
-import net.mograsim.logic.core.wires.Wire.ReadEnd;
-import net.mograsim.logic.core.wires.Wire.ReadWriteEnd;
+import net.mograsim.logic.core.wires.CoreWire.ReadEnd;
+import net.mograsim.logic.core.wires.CoreWire.ReadWriteEnd;
 import net.mograsim.logic.model.model.ViewModelModifiable;
 import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedGUIComponent;
 import net.mograsim.logic.model.model.wires.Pin;
@@ -26,7 +26,7 @@ public class GUIram5_12 extends SimpleRectangularHardcodedGUIComponent
 {
        public GUIram5_12(ViewModelModifiable model, String name)
        {
-               super(model, name, "RAM\n5 x 12 Bit");
+               super(model, "GUIram5_12", name, "RAM\n5 x 12 Bit");
                setSize(40, 40);
                addPin(new Pin(this, "A", 3, PinUsage.INPUT, 10, 0), Position.BOTTOM);
                addPin(new Pin(this, "B", 3, PinUsage.INPUT, 30, 0), Position.BOTTOM);
@@ -81,7 +81,6 @@ public class GUIram5_12 extends SimpleRectangularHardcodedGUIComponent
                for (int i = 0; i < 3; i++)
                        if (bits[i] == Z)
                                return -1;
-               // TODO maybe this is the wrong way around
                return (bits[0] == ONE ? 4 : 0) + (bits[1] == ONE ? 2 : 0) + (bits[2] == ONE ? 1 : 0);
        }
 
@@ -104,9 +103,11 @@ public class GUIram5_12 extends SimpleRectangularHardcodedGUIComponent
                {
                        int addr = Integer.parseInt(m.group(1), 2);
                        BitVector newHighLevelStateCasted = (BitVector) newHighLevelState;
-                       if (newHighLevelStateCasted.length() != 3)
-                               throw new IllegalArgumentException("Expected BitVector of length 3, not " + newHighLevelStateCasted.length());
-                       return ((BitVector[]) lastState)[addr] = newHighLevelStateCasted;
+                       if (newHighLevelStateCasted.length() != 12)
+                               throw new IllegalArgumentException("Expected BitVector of length 12, not " + newHighLevelStateCasted.length());
+                       BitVector[] memC = (BitVector[]) lastState;
+                       memC[addr] = newHighLevelStateCasted;
+                       return memC;
                }
                return super.setHighLevelState(lastState, stateID, newHighLevelState);
        }