1 package net.mograsim.logic.model.am2900.machine;
3 import java.util.ArrayList;
4 import java.util.Collections;
7 import net.mograsim.logic.model.am2900.machine.registers.InstrRegister;
8 import net.mograsim.logic.model.am2900.machine.registers.muInstrRegister;
9 import net.mograsim.logic.model.am2900.machine.registers.am2901.Am2901RegisterGroup;
10 import net.mograsim.logic.model.am2900.machine.registers.am2904.Am2904RegisterGroup;
11 import net.mograsim.logic.model.am2900.machine.registers.am2910.Am2910RegisterGroup;
12 import net.mograsim.logic.model.model.LogicModelModifiable;
13 import net.mograsim.machine.ISASchema;
14 import net.mograsim.machine.MachineDefinition;
15 import net.mograsim.machine.registers.Register;
16 import net.mograsim.machine.registers.RegisterGroup;
18 //we can't use the Singleton pattern here because a MachineDefinition needs a public parameterless constructor
19 //(used for detecting installed machines in plugin.core)
20 public class AbstractAm2900MachineDefinition implements MachineDefinition
22 public static final String SIMPLE_AM2900_MACHINE_ID = "Am2900Simple";
23 public static final String STRICT_AM2900_MACHINE_ID = "Am2900Strict";
25 public static final List<Register> unsortedRegisters;
26 public static final List<RegisterGroup> registerGroups;
30 List<Register> unsortedRegistersModifiable = new ArrayList<>();
31 unsortedRegistersModifiable.add(muInstrRegister.instance);
32 unsortedRegistersModifiable.add(InstrRegister.instance);
34 unsortedRegisters = Collections.unmodifiableList(unsortedRegistersModifiable);
35 List<RegisterGroup> registerGroupsModifiable = new ArrayList<>();
36 registerGroupsModifiable.add(Am2901RegisterGroup.instance);
37 registerGroupsModifiable.add(Am2904RegisterGroup.instance);
38 registerGroupsModifiable.add(Am2910RegisterGroup.instance);
39 registerGroups = Collections.unmodifiableList(registerGroupsModifiable);
42 public final boolean strict;
44 protected AbstractAm2900MachineDefinition(boolean strict)
52 return strict ? STRICT_AM2900_MACHINE_ID : SIMPLE_AM2900_MACHINE_ID;
56 public Am2900Machine createNew()
58 return createNew(new LogicModelModifiable());
61 public Am2900Machine createNew(LogicModelModifiable model)
63 return new Am2900Machine(model, this);
67 public ISASchema getISASchema()
69 // TODO Auto-generated method stub
74 public List<Register> getUnsortedRegisters()
76 return unsortedRegisters;
80 public List<RegisterGroup> getRegisterGroups()
82 return registerGroups;
86 public int getAddressBits()
92 public Am2900MainMemoryDefinition getMainMemoryDefinition()
94 return Am2900MainMemoryDefinition.instance;
100 return strict ? 12345 : 54321;
104 public boolean equals(Object obj)
106 return obj != null && obj instanceof AbstractAm2900MachineDefinition
107 && ((AbstractAm2900MachineDefinition) obj).strict == this.strict;
111 public Am2900MicroInstructionMemoryDefinition getMicroInstructionMemoryDefinition()
113 return Am2900MicroInstructionMemoryDefinition.instance;