X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=plugins%2Fnet.mograsim.machine%2Fsrc%2Fnet%2Fmograsim%2Fmachine%2Fstandard%2Fmemory%2FModelWordAddressableMemory.java;h=b2498498133d6599ae8930780529a3a992ab81b4;hb=0c97f70d199e1ffcd2bc13817f7bb12867ba033e;hp=986dbe5028f7b736696e2d91c789092853f8ef42;hpb=58babf45ae7d259a296656451d796dbe601377a4;p=Mograsim.git diff --git a/plugins/net.mograsim.machine/src/net/mograsim/machine/standard/memory/ModelWordAddressableMemory.java b/plugins/net.mograsim.machine/src/net/mograsim/machine/standard/memory/ModelWordAddressableMemory.java index 986dbe50..b2498498 100644 --- a/plugins/net.mograsim.machine/src/net/mograsim/machine/standard/memory/ModelWordAddressableMemory.java +++ b/plugins/net.mograsim.machine/src/net/mograsim/machine/standard/memory/ModelWordAddressableMemory.java @@ -3,11 +3,14 @@ package net.mograsim.machine.standard.memory; import net.mograsim.logic.model.model.LogicModelModifiable; import net.mograsim.logic.model.model.wires.Pin; import net.mograsim.logic.model.model.wires.PinUsage; -import net.mograsim.machine.Machine; +import net.mograsim.logic.model.modeladapter.LogicCoreAdapter; +import net.mograsim.logic.model.serializing.IdentifyParams; +import net.mograsim.logic.model.snippets.HighLevelStateHandler; +import net.mograsim.machine.MainMemory; import net.mograsim.machine.MainMemoryDefinition; import net.mograsim.machine.ModelMemory; -public abstract class ModelWordAddressableMemory extends ModelMemory +public abstract class ModelWordAddressableMemory extends ModelMemory { private final Pin addrPin, dataPin, rWPin; private CoreWordAddressableMemory memory; @@ -22,6 +25,38 @@ public abstract class ModelWordAddressableMemory extends Mode addPin(dataPin = new Pin(model, this, "D", definition.getCellWidth(), PinUsage.TRISTATE, getWidth(), 50)); addPin(rWPin = new Pin(model, this, "RW", 1, PinUsage.INPUT, getWidth(), 70)); + setHighLevelStateHandler(new HighLevelStateHandler() + { + @Override + public Object getHighLevelState(String stateID) + { + if (stateID.equals("memory_binding")) + return memory.getMemory(); + throw new IllegalArgumentException("No high level state with ID " + stateID); + } + + @Override + public void setHighLevelState(String stateID, Object newState) + { + if (stateID.equals("memory_binding")) + memory.setMemory((MainMemory) newState); + else + throw new IllegalArgumentException("No high level state with ID " + stateID); + } + + @Override + public String getIDForSerializing(IdentifyParams idParams) + { + return null; + } + + @Override + public Object getParamsForSerializing(IdentifyParams idParams) + { + return null; + } + }); + init(); } @@ -54,4 +89,9 @@ public abstract class ModelWordAddressableMemory extends Mode { return memory; } -} + + static + { + LogicCoreAdapter.addComponentAdapter(new WordAddressableMemoryAdapter()); + } +} \ No newline at end of file