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.am2901.Am2901RegisterGroup;
8 import net.mograsim.logic.model.model.LogicModelModifiable;
9 import net.mograsim.machine.ISASchema;
10 import net.mograsim.machine.MachineDefinition;
11 import net.mograsim.machine.registers.Register;
12 import net.mograsim.machine.registers.RegisterGroup;
14 //we can't use the Singleton pattern here because a MachineDefinition needs a public parameterless constructor
15 //(used for detecting installed machines in plugin.core)
16 public class AbstractAm2900MachineDefinition implements MachineDefinition
18 public static final String SIMPLE_AM2900_MACHINE_ID = "Am2900Simple";
19 public static final String STRICT_AM2900_MACHINE_ID = "Am2900Strict";
21 public static final List<Register> unsortedRegisters;
22 public static final List<RegisterGroup> registerGroups;
26 List<Register> unsortedRegistersModifiable = new ArrayList<>();
27 // TODO MIR, IR, PC/BZ...
28 unsortedRegisters = Collections.unmodifiableList(unsortedRegistersModifiable);
29 List<RegisterGroup> registerGroupsModifiable = new ArrayList<>();
30 registerGroupsModifiable.add(Am2901RegisterGroup.instance);
31 // TODO Am2904, Am2910
32 registerGroups = Collections.unmodifiableList(registerGroupsModifiable);
35 public final boolean strict;
37 protected AbstractAm2900MachineDefinition(boolean strict)
45 return strict ? STRICT_AM2900_MACHINE_ID : SIMPLE_AM2900_MACHINE_ID;
49 public Am2900Machine createNew()
51 return createNew(new LogicModelModifiable());
54 public Am2900Machine createNew(LogicModelModifiable model)
56 return new Am2900Machine(model, this);
60 public ISASchema getISASchema()
62 // TODO Auto-generated method stub
67 public List<Register> getUnsortedRegisters()
69 return unsortedRegisters;
73 public List<RegisterGroup> getRegisterGroups()
75 return registerGroups;
79 public int getAddressBits()
85 public Am2900MainMemoryDefinition getMainMemoryDefinition()
87 return Am2900MainMemoryDefinition.instance;
93 return strict ? 12345 : 54321;
97 public boolean equals(Object obj)
99 return obj != null && obj instanceof AbstractAm2900MachineDefinition
100 && ((AbstractAm2900MachineDefinition) obj).strict == this.strict;
104 public Am2900MicroInstructionMemoryDefinition getMicroInstructionMemoryDefinition()
106 return Am2900MicroInstructionMemoryDefinition.instance;