1 package net.mograsim.logic.model.am2900.machine;
3 import net.mograsim.logic.core.components.CoreClock;
4 import net.mograsim.logic.core.timeline.Timeline;
5 import net.mograsim.logic.core.types.Bit;
6 import net.mograsim.logic.core.types.BitVector;
7 import net.mograsim.logic.model.am2900.components.ModelAm2900MainMemory;
8 import net.mograsim.logic.model.am2900.components.ModelAm2900MicroInstructionMemory;
9 import net.mograsim.logic.model.model.LogicModel;
10 import net.mograsim.logic.model.model.LogicModelModifiable;
11 import net.mograsim.logic.model.model.components.ModelComponent;
12 import net.mograsim.logic.model.modeladapter.CoreModelParameters;
13 import net.mograsim.logic.model.modeladapter.LogicCoreAdapter;
14 import net.mograsim.logic.model.serializing.IndirectModelComponentCreator;
15 import net.mograsim.machine.Machine;
16 import net.mograsim.machine.MachineDefinition;
17 import net.mograsim.machine.MainMemory;
18 import net.mograsim.machine.Register;
19 import net.mograsim.machine.mi.AssignableMicroInstructionMemory;
20 import net.mograsim.machine.mi.MicroInstruction;
21 import net.mograsim.machine.mi.MicroInstructionDefinition;
22 import net.mograsim.machine.mi.StandardMicroInstructionMemory;
23 import net.mograsim.machine.mi.parameters.MicroInstructionParameter;
24 import net.mograsim.machine.mi.parameters.ParameterClassification;
25 import net.mograsim.machine.standard.memory.WordAddressableMemory;
27 public class Am2900Machine implements Machine
29 private Am2900MachineDefinition machineDefinition;
30 private LogicModelModifiable logicModel;
31 private ModelComponent am2900;
32 private Timeline timeline;
33 private MainMemory mainMemory;
34 private AssignableMicroInstructionMemory instMemory;
35 private CoreClock clock;
37 public Am2900Machine(LogicModelModifiable model, Am2900MachineDefinition am2900MachineDefinition)
39 this.machineDefinition = am2900MachineDefinition;
40 this.logicModel = model;
41 this.am2900 = IndirectModelComponentCreator.createComponent(logicModel,
42 "resloader:Am2900Loader:jsonres:net/mograsim/logic/model/am2900/components/Am2900.json", "Am2900");
43 CoreModelParameters params = new CoreModelParameters();
44 params.gateProcessTime = 50;
45 params.wireTravelTime = 10;
46 mainMemory = new WordAddressableMemory(am2900MachineDefinition.getMainMemoryDefinition());
47 instMemory = new AssignableMicroInstructionMemory(
48 new StandardMicroInstructionMemory(am2900MachineDefinition.getMicroInstructionMemoryDefinition()));
49 logicModel.getComponentBySubmodelPath("Am2900.Am2900MainMemory#0", ModelAm2900MainMemory.class).setMachine(this);
50 logicModel.getComponentBySubmodelPath("Am2900.Am2900MicroInstructionMemory#0", ModelAm2900MicroInstructionMemory.class)
52 timeline = LogicCoreAdapter.convert(logicModel, params);
56 public MachineDefinition getDefinition()
58 return machineDefinition;
64 logicModel.getComponentByName("Am2900").setHighLevelState("c.out", BitVector.of(Bit.ZERO));
65 MicroInstructionDefinition muiDef = getDefinition().getMicroInstructionMemoryDefinition().getMicroInstructionDefinition();
66 ParameterClassification[] paramClassifications = muiDef.getParameterClassifications();
67 MicroInstructionParameter[] defaultParams = muiDef.createDefaultInstruction().getParameters();
68 defaultParams[19] = paramClassifications[19].parse("JZ");
69 MicroInstruction jzMI = MicroInstruction.create(defaultParams);
70 logicModel.getComponentByName("Am2900").setHighLevelState("muir_2.q", jzMI.toBitVector());
74 public LogicModel getModel()
79 public ModelComponent getAm2900()
85 public Timeline getTimeline()
91 public CoreClock getClock()
97 public BitVector getRegister(Register r)
99 // TODO Auto-generated method stub
104 public void setRegister(Register r, BitVector value)
106 // TODO Auto-generated method stub
111 public MainMemory getMainMemory()
117 public AssignableMicroInstructionMemory getMicroInstructionMemory()