1 package net.mograsim.machine.standard.memory;
3 import net.mograsim.logic.model.model.LogicModelModifiable;
4 import net.mograsim.logic.model.model.wires.Pin;
5 import net.mograsim.logic.model.model.wires.PinUsage;
6 import net.mograsim.logic.model.modeladapter.LogicCoreAdapter;
7 import net.mograsim.logic.model.serializing.IdentifyParams;
8 import net.mograsim.logic.model.snippets.HighLevelStateHandler;
9 import net.mograsim.machine.MainMemory;
10 import net.mograsim.machine.MainMemoryDefinition;
11 import net.mograsim.machine.ModelMemory;
13 public abstract class ModelWordAddressableMemory extends ModelMemory
15 private final Pin addrPin, dataPin, rWPin;
16 private CoreWordAddressableMemory memory;
17 private MainMemoryDefinition definition;
19 public ModelWordAddressableMemory(LogicModelModifiable model, MainMemoryDefinition definition, String name)
21 super(model, 120, 150, name, "RAM", false);
22 this.definition = definition;
24 addPin(addrPin = new Pin(model, this, "A", definition.getMemoryAddressBits(), PinUsage.INPUT, getWidth(), 30));
25 addPin(dataPin = new Pin(model, this, "D", definition.getCellWidth(), PinUsage.TRISTATE, getWidth(), 50));
26 addPin(rWPin = new Pin(model, this, "RW", 1, PinUsage.INPUT, getWidth(), 70));
28 setHighLevelStateHandler(new HighLevelStateHandler()
31 public Object getHighLevelState(String stateID)
33 if (stateID.equals("memory_binding"))
34 return memory.getMemory();
35 throw new IllegalArgumentException("No high level state with ID " + stateID);
39 public void setHighLevelState(String stateID, Object newState)
41 if (stateID.equals("memory_binding"))
42 memory.setMemory((MainMemory) newState);
44 throw new IllegalArgumentException("No high level state with ID " + stateID);
48 public String getIDForSerializing(IdentifyParams idParams)
54 public Object getParamsForSerializing(IdentifyParams idParams)
63 public MainMemoryDefinition getDefinition()
68 public Pin getAddressPin()
73 public Pin getDataPin()
78 public Pin getReadWritePin()
83 public void setCoreModelBinding(CoreWordAddressableMemory memory)
88 public CoreWordAddressableMemory getCoreMemory()
95 LogicCoreAdapter.addComponentAdapter(new WordAddressableMemoryAdapter());