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.logic.model.serializing.IdentifyParams;
8 import net.mograsim.logic.model.snippets.HighLevelStateHandler;
9 import net.mograsim.machine.ModelMemory;
10 import net.mograsim.machine.mi.MicroInstructionMemory;
11 import net.mograsim.machine.mi.MicroInstructionMemoryDefinition;
13 public abstract class ModelMicroInstructionMemory extends ModelMemory
15 private final Pin addrPin, dataPin;
16 private CoreMicroInstructionMemory memory;
17 private final MicroInstructionMemoryDefinition definition;
19 public ModelMicroInstructionMemory(LogicModelModifiable model, MicroInstructionMemoryDefinition definition, String name)
21 super(model, 120, 150, name, "MPM", false);
22 this.definition = definition;
23 addPin(addrPin = new Pin(model, this, "A", definition.getMemoryAddressBits(), PinUsage.INPUT, getWidth(), 30));
24 addPin(dataPin = new Pin(model, this, "D", definition.getMicroInstructionDefinition().sizeInBits(), PinUsage.OUTPUT, getWidth(),
27 setHighLevelStateHandler(new HighLevelStateHandler()
30 public Object getHighLevelState(String stateID)
32 if (stateID.equals("memory_binding"))
33 return memory.getMemory();
34 throw new IllegalArgumentException("No high level state with ID " + stateID);
38 public void setHighLevelState(String stateID, Object newState)
40 if (stateID.equals("memory_binding"))
41 memory.setMemory((MicroInstructionMemory) newState);
43 throw new IllegalArgumentException("No high level state with ID " + stateID);
47 public String getIDForSerializing(IdentifyParams idParams)
53 public Object getParamsForSerializing(IdentifyParams idParams)
62 public MicroInstructionMemoryDefinition getDefinition()
67 public Pin getAddressPin()
72 public Pin getDataPin()
77 public CoreMicroInstructionMemory getCoreMemory()
82 public void setCoreModelBinding(CoreMicroInstructionMemory memory)
89 LogicCoreAdapter.addComponentAdapter(new MicroInstructionMemoryAdapter());