0a0787cc5ea2f7fcebd8fdb0797fd67d9ffd1c26
[Mograsim.git] /
1 package net.mograsim.logic.model.am2900.machine;
2
3 import net.mograsim.logic.core.components.CoreClock;
4 import net.mograsim.logic.core.timeline.Timeline;
5 import net.mograsim.logic.core.types.BitVector;
6 import net.mograsim.logic.model.am2900.components.ModelAm2900MainMemory;
7 import net.mograsim.logic.model.am2900.components.ModelAm2900MicroInstructionMemory;
8 import net.mograsim.logic.model.model.LogicModel;
9 import net.mograsim.logic.model.model.LogicModelModifiable;
10 import net.mograsim.logic.model.modeladapter.CoreModelParameters;
11 import net.mograsim.logic.model.modeladapter.LogicCoreAdapter;
12 import net.mograsim.logic.model.serializing.IndirectModelComponentCreator;
13 import net.mograsim.machine.Machine;
14 import net.mograsim.machine.MachineDefinition;
15 import net.mograsim.machine.MainMemory;
16 import net.mograsim.machine.Register;
17 import net.mograsim.machine.mi.MicroInstructionMemory;
18 import net.mograsim.machine.mi.StandardMicroInstructionMemory;
19 import net.mograsim.machine.standard.memory.WordAddressableMemory;
20
21 public class Am2900Machine implements Machine
22 {
23         private Am2900MachineDefinition machineDefinition;
24         private LogicModelModifiable logicModel;
25         private Timeline timeline;
26         private MainMemory mainMemory;
27         private MicroInstructionMemory instMemory;
28         private CoreClock clock;
29
30         public Am2900Machine(Am2900MachineDefinition am2900MachineDefinition)
31         {
32                 this.machineDefinition = am2900MachineDefinition;
33                 logicModel = new LogicModelModifiable();
34                 IndirectModelComponentCreator.createComponent(logicModel,
35                                 "resloader:Am2900Loader:jsonres:net/mograsim/logic/model/am2900/components/Am2900.json", "Am2900");
36                 CoreModelParameters params = new CoreModelParameters();
37                 params.gateProcessTime = 50;
38                 params.wireTravelTime = 10;
39                 mainMemory = new WordAddressableMemory(am2900MachineDefinition.getMainMemoryDefinition());
40                 instMemory = new StandardMicroInstructionMemory(am2900MachineDefinition.getMicroInstructionMemoryDefinition());
41                 logicModel.getComponentBySubmodelPath("Am2900.Am2900MainMemory#0", ModelAm2900MainMemory.class).setMachine(this);
42                 logicModel.getComponentBySubmodelPath("Am2900.Am2900MicroInstructionMemory#0", ModelAm2900MicroInstructionMemory.class)
43                                 .setMachine(this);
44                 timeline = LogicCoreAdapter.convert(logicModel, params);
45         }
46
47         @Override
48         public MachineDefinition getDefinition()
49         {
50                 return machineDefinition;
51         }
52
53         @Override
54         public void reset()
55         {
56                 // TODO Auto-generated method stub
57
58         }
59
60         @Override
61         public LogicModel getModel()
62         {
63                 return logicModel;
64         }
65
66         @Override
67         public Timeline getTimeline()
68         {
69                 return timeline;
70         }
71
72         @Override
73         public CoreClock getClock()
74         {
75                 return clock;
76         }
77
78         @Override
79         public BitVector getRegister(Register r)
80         {
81                 // TODO Auto-generated method stub
82                 return null;
83         }
84
85         @Override
86         public void setRegister(Register r, BitVector value)
87         {
88                 // TODO Auto-generated method stub
89
90         }
91
92         @Override
93         public MainMemory getMainMemory()
94         {
95                 return mainMemory;
96         }
97
98         @Override
99         public MicroInstructionMemory getMicroInstructionMemory()
100         {
101                 return instMemory;
102         }
103
104 }