1 package net.mograsim.machine.mi.components;
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.ModelMemory;
8 import net.mograsim.machine.mi.MicroInstructionMemory;
9 import net.mograsim.machine.mi.MicroInstructionMemoryDefinition;
11 public abstract class ModelMicroInstructionMemory extends ModelMemory
13 private final Pin addrPin, dataPin;
14 private CoreMicroInstructionMemory memory;
15 private final MicroInstructionMemoryDefinition definition;
17 public ModelMicroInstructionMemory(LogicModelModifiable model, MicroInstructionMemoryDefinition definition, String name)
19 super(model, 120, 150, name, "MPM", false);
20 this.definition = definition;
21 addPin(addrPin = new Pin(model, this, "A", definition.getMemoryAddressBits(), PinUsage.INPUT, getWidth(), 30));
22 addPin(dataPin = new Pin(model, this, "D", definition.getMicroInstructionDefinition().sizeInBits(), PinUsage.OUTPUT, getWidth(),
28 public MicroInstructionMemoryDefinition getDefinition()
33 public Pin getAddressPin()
38 public Pin getDataPin()
43 public CoreMicroInstructionMemory getCoreMemory()
48 public void setCoreModelBinding(CoreMicroInstructionMemory memory)
54 public void setHighLevelState(String stateID, Object newState)
56 if (stateID.equals("memory_binding"))
57 memory.setMemory((MicroInstructionMemory) newState);
59 super.setHighLevelState(stateID, newState);
63 public Object getHighLevelState(String stateID)
65 if (stateID.equals("memory_binding"))
66 return memory.getMemory();
67 return super.getHighLevelState(stateID);
72 LogicCoreAdapter.addComponentAdapter(new MicroInstructionMemoryAdapter());