1 package net.mograsim.logic.model.am2900.machine;
3 import java.util.Collections;
4 import java.util.HashSet;
7 import net.mograsim.logic.model.am2900.machine.registers.NumberedRegister;
8 import net.mograsim.logic.model.am2900.machine.registers.QRegister;
9 import net.mograsim.logic.model.model.LogicModelModifiable;
10 import net.mograsim.machine.ISASchema;
11 import net.mograsim.machine.MachineDefinition;
12 import net.mograsim.machine.Register;
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 Set<Register> allRegisters;
25 Set<Register> allRegistersModifiable = new HashSet<>();
26 allRegistersModifiable.add(QRegister.instance);
27 allRegistersModifiable.addAll(NumberedRegister.instancesCorrectOrder);
28 allRegisters = Collections.unmodifiableSet(allRegistersModifiable);
31 public final boolean strict;
33 protected AbstractAm2900MachineDefinition(boolean strict)
41 return strict ? STRICT_AM2900_MACHINE_ID : SIMPLE_AM2900_MACHINE_ID;
45 public Am2900Machine createNew()
47 return createNew(new LogicModelModifiable());
50 public Am2900Machine createNew(LogicModelModifiable model)
52 return new Am2900Machine(model, this);
56 public ISASchema getISASchema()
58 // TODO Auto-generated method stub
63 public Set<Register> getRegisters()
69 public int getAddressBits()
75 public Am2900MainMemoryDefinition getMainMemoryDefinition()
77 return Am2900MainMemoryDefinition.instance;
83 return strict ? 12345 : 54321;
87 public boolean equals(Object obj)
89 return obj != null && obj instanceof AbstractAm2900MachineDefinition
90 && ((AbstractAm2900MachineDefinition) obj).strict == this.strict;
94 public Am2900MicroInstructionMemoryDefinition getMicroInstructionMemoryDefinition()
96 return Am2900MicroInstructionMemoryDefinition.instance;