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.machine.MainMemory;
8 import net.mograsim.machine.MainMemoryDefinition;
9 import net.mograsim.machine.ModelMemory;
11 public abstract class ModelWordAddressableMemory extends ModelMemory
13 private final Pin addrPin, dataPin, rWPin;
14 private CoreWordAddressableMemory memory;
15 private MainMemoryDefinition definition;
17 public ModelWordAddressableMemory(LogicModelModifiable model, MainMemoryDefinition definition, String name)
19 super(model, 120, 150, name, "RAM", false);
20 this.definition = definition;
22 addPin(addrPin = new Pin(model, this, "A", definition.getMemoryAddressBits(), PinUsage.INPUT, getWidth(), 30));
23 addPin(dataPin = new Pin(model, this, "D", definition.getCellWidth(), PinUsage.TRISTATE, getWidth(), 50));
24 addPin(rWPin = new Pin(model, this, "RW", 1, PinUsage.INPUT, getWidth(), 70));
29 public MainMemoryDefinition getDefinition()
34 public Pin getAddressPin()
39 public Pin getDataPin()
44 public Pin getReadWritePin()
49 public void setCoreModelBinding(CoreWordAddressableMemory memory)
54 public CoreWordAddressableMemory getCoreMemory()
60 public void setHighLevelState(String stateID, Object newState)
62 if (stateID.equals("memory_binding"))
63 memory.setMemory((MainMemory) newState);
65 super.setHighLevelState(stateID, newState);
69 public Object getHighLevelState(String stateID)
71 if (stateID.equals("memory_binding"))
72 return memory.getMemory();
73 return super.getHighLevelState(stateID);
78 LogicCoreAdapter.addComponentAdapter(new WordAddressableMemoryAdapter());