X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.ui.am2900%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fui%2Fmodel%2Fcomponents%2Fmi%2Fnandbased%2FGUIram2.java;h=3e4d013d6dc61778cb3d37db02ab01a0ac6a3ecf;hb=74bced7a3a38f65c65f3395cc422eb98e34da0b8;hp=f94ca923a20d26e2ebc09f5ac2f985f9e4c2671d;hpb=05e36ce451a394259e3ed21ea21ac3a1fd7d4e40;p=Mograsim.git diff --git a/net.mograsim.logic.ui.am2900/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIram2.java b/net.mograsim.logic.ui.am2900/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIram2.java index f94ca923..3e4d013d 100644 --- a/net.mograsim.logic.ui.am2900/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIram2.java +++ b/net.mograsim.logic.ui.am2900/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIram2.java @@ -1,6 +1,7 @@ package net.mograsim.logic.ui.model.components.mi.nandbased; import net.haspamelodica.swt.helper.swtobjectwrappers.Point; +import net.mograsim.logic.core.types.BitVector; import net.mograsim.logic.ui.model.ViewModelModifiable; import net.mograsim.logic.ui.model.components.SimpleRectangularSubmodelComponent; import net.mograsim.logic.ui.model.wires.GUIWire; @@ -9,6 +10,11 @@ import net.mograsim.logic.ui.model.wires.WireCrossPoint; public class GUIram2 extends SimpleRectangularSubmodelComponent { + private GUIdlatch4 cell00; + private GUIdlatch4 cell01; + private GUIdlatch4 cell10; + private GUIdlatch4 cell11; + public GUIram2(ViewModelModifiable model) { super(model, 1, "GUIram2"); @@ -43,10 +49,10 @@ public class GUIram2 extends SimpleRectangularSubmodelComponent GUIdemux2 demuxA = new GUIdemux2 (submodelModifiable); GUIdemux2 demuxB = new GUIdemux2 (submodelModifiable); GUIand41 weAndB = new GUIand41 (submodelModifiable); - GUIdlatch4 cell00 = new GUIdlatch4 (submodelModifiable); - GUIdlatch4 cell01 = new GUIdlatch4 (submodelModifiable); - GUIdlatch4 cell10 = new GUIdlatch4 (submodelModifiable); - GUIdlatch4 cell11 = new GUIdlatch4 (submodelModifiable); + cell00 = new GUIdlatch4 (submodelModifiable); + cell01 = new GUIdlatch4 (submodelModifiable); + cell10 = new GUIdlatch4 (submodelModifiable); + cell11 = new GUIdlatch4 (submodelModifiable); GUIand41 andA00 = new GUIand41 (submodelModifiable); GUIandor414 andorA01 = new GUIandor414(submodelModifiable); GUIandor414 andorA10 = new GUIandor414(submodelModifiable); @@ -272,4 +278,73 @@ public class GUIram2 extends SimpleRectangularSubmodelComponent new GUIWire(submodelModifiable, andorB11.getPin("Y4"), QB4 , new Point(175, 770), new Point(175, 895), new Point(340, 895), new Point(340, 750)); //@formatter:on } + + @Override + public void setHighLevelState(String stateID, Object newState) + { + switch (stateID) + { + case "q": + BitVector newStateCasted = (BitVector) newState; + setHighLevelState("c00.q", newStateCasted.subVector(0, 4)); + setHighLevelState("c01.q", newStateCasted.subVector(4, 8)); + setHighLevelState("c10.q", newStateCasted.subVector(8, 12)); + setHighLevelState("c11.q", newStateCasted.subVector(12, 16)); + break; + default: + int indexOfDot = stateID.indexOf('.'); + if (indexOfDot != -1) + switch (stateID.substring(0, indexOfDot)) + { + case "c00": + cell00.setHighLevelState(stateID.substring(indexOfDot + 1), newState); + break; + case "c01": + cell01.setHighLevelState(stateID.substring(indexOfDot + 1), newState); + break; + case "c10": + cell10.setHighLevelState(stateID.substring(indexOfDot + 1), newState); + break; + case "c11": + cell11.setHighLevelState(stateID.substring(indexOfDot + 1), newState); + break; + default: + super.setHighLevelState(stateID, newState); + break; + } + else + super.setHighLevelState(stateID, newState); + } + } + + @Override + public Object getHighLevelState(String stateID) + { + switch (stateID) + { + case "q": + BitVector q00 = (BitVector) getHighLevelState("c00.q"); + BitVector q01 = (BitVector) getHighLevelState("c01.q"); + BitVector q10 = (BitVector) getHighLevelState("c10.q"); + BitVector q11 = (BitVector) getHighLevelState("c11.q"); + return q00.concat(q01).concat(q10).concat(q11); + default: + int indexOfDot = stateID.indexOf('.'); + if (indexOfDot != -1) + switch (stateID.substring(0, indexOfDot)) + { + case "c00": + return cell00.getHighLevelState(stateID.substring(indexOfDot + 1)); + case "c01": + return cell01.getHighLevelState(stateID.substring(indexOfDot + 1)); + case "c10": + return cell10.getHighLevelState(stateID.substring(indexOfDot + 1)); + case "c11": + return cell11.getHighLevelState(stateID.substring(indexOfDot + 1)); + default: + return super.getHighLevelState(stateID); + } + return super.getHighLevelState(stateID); + } + } } \ No newline at end of file