<extension
point="net.mograsim.machine.machine_definition">
<machineDefinitionImplementation
- class="net.mograsim.logic.model.am2900.machine.Am2900MachineDefinition"
- unique_id="Am2900">
+ class="net.mograsim.logic.model.am2900.machine.SimpleAm2900MachineDefinition"
+ unique_id="Am2900Simple">
+ </machineDefinitionImplementation>
+ <machineDefinitionImplementation
+ class="net.mograsim.logic.model.am2900.machine.StrictAm2900MachineDefinition"
+ unique_id="Am2900Strict">
</machineDefinitionImplementation>
</extension>
--- /dev/null
+package net.mograsim.logic.model.am2900.machine;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import net.mograsim.logic.model.am2900.machine.registers.NumberedRegister;
+import net.mograsim.logic.model.am2900.machine.registers.QRegister;
+import net.mograsim.logic.model.model.LogicModelModifiable;
+import net.mograsim.machine.ISASchema;
+import net.mograsim.machine.MachineDefinition;
+import net.mograsim.machine.Register;
+
+//we can't use the Singleton pattern here because a MachineDefinition needs a public parameterless constructor
+//(used for detecting installed machines in plugin.core)
+public class AbstractAm2900MachineDefinition implements MachineDefinition
+{
+ public static final String SIMPLE_AM2900_MACHINE_ID = "Am2900Simple";
+ public static final String STRICT_AM2900_MACHINE_ID = "Am2900Strict";
+
+ public static final Set<Register> allRegisters;
+
+ static
+ {
+ Set<Register> allRegistersModifiable = new HashSet<>();
+ allRegistersModifiable.add(QRegister.instance);
+ allRegistersModifiable.addAll(NumberedRegister.instancesCorrectOrder);
+ allRegisters = Collections.unmodifiableSet(allRegistersModifiable);
+ }
+
+ public final boolean strict;
+
+ protected AbstractAm2900MachineDefinition(boolean strict)
+ {
+ this.strict = strict;
+ }
+
+ @Override
+ public String getId()
+ {
+ return strict ? STRICT_AM2900_MACHINE_ID : SIMPLE_AM2900_MACHINE_ID;
+ }
+
+ @Override
+ public Am2900Machine createNew()
+ {
+ return createNew(new LogicModelModifiable());
+ }
+
+ public Am2900Machine createNew(LogicModelModifiable model)
+ {
+ return new Am2900Machine(model, this);
+ }
+
+ @Override
+ public ISASchema getISASchema()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Set<Register> getRegisters()
+ {
+ return allRegisters;
+ }
+
+ @Override
+ public int getAddressBits()
+ {
+ return 16;
+ }
+
+ @Override
+ public Am2900MainMemoryDefinition getMainMemoryDefinition()
+ {
+ return Am2900MainMemoryDefinition.instance;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return strict ? 12345 : 54321;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ return obj != null && obj instanceof AbstractAm2900MachineDefinition
+ && ((AbstractAm2900MachineDefinition) obj).strict == this.strict;
+ }
+
+ @Override
+ public Am2900MicroInstructionMemoryDefinition getMicroInstructionMemoryDefinition()
+ {
+ return Am2900MicroInstructionMemoryDefinition.instance;
+ }
+
+}
import net.mograsim.logic.core.components.CoreClock;
import net.mograsim.logic.core.timeline.Timeline;
+import net.mograsim.logic.core.types.Bit;
import net.mograsim.logic.core.types.BitVector;
import net.mograsim.logic.model.am2900.machine.registers.NumberedRegister;
import net.mograsim.logic.model.am2900.machine.registers.QRegister;
public class Am2900Machine implements Machine
{
- private Am2900MachineDefinition machineDefinition;
+ private AbstractAm2900MachineDefinition machineDefinition;
private LogicModelModifiable logicModel;
private ModelComponent am2900;
private Timeline timeline;
private final Set<ActiveMicroInstructionChangedListener> amicListeners;
private final Map<Register, Map<Consumer<BitVector>, Consumer<Object>>> modelListenersPerRegisterListenerPerRegister;
- public Am2900Machine(LogicModelModifiable model, Am2900MachineDefinition am2900MachineDefinition)
+ public Am2900Machine(LogicModelModifiable model, AbstractAm2900MachineDefinition am2900MachineDefinition)
{
this.machineDefinition = am2900MachineDefinition;
this.logicModel = model;
defaultParams[19] = paramClassifications[19].parse("JZ");
MicroInstruction jzMI = MicroInstruction.create(defaultParams);
am2900.setHighLevelState("muir_2.q", jzMI.toBitVector());
+ if (!machineDefinition.strict)
+ {
+ for (Register r : machineDefinition.getRegisters())
+ setRegister(r, BitVector.of(Bit.ZERO, r.getWidth()));
+ // TODO reset latches?
+ }
}
@Override
+++ /dev/null
-package net.mograsim.logic.model.am2900.machine;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import net.mograsim.logic.model.am2900.machine.registers.NumberedRegister;
-import net.mograsim.logic.model.am2900.machine.registers.QRegister;
-import net.mograsim.logic.model.model.LogicModelModifiable;
-import net.mograsim.machine.ISASchema;
-import net.mograsim.machine.MachineDefinition;
-import net.mograsim.machine.Register;
-
-//we can't use the Singleton pattern here because a MachineDefinition needs a public parameterless constructor
-//(used for detecting installed machines in plugin.core)
-public class Am2900MachineDefinition implements MachineDefinition
-{
- public static final String AM2900_MACHINE_ID = "Am2900";
-
- public static final Set<Register> allRegisters;
-
- static
- {
- Set<Register> allRegistersModifiable = new HashSet<>();
- allRegistersModifiable.add(QRegister.instance);
- allRegistersModifiable.addAll(NumberedRegister.instancesCorrectOrder);
- allRegisters = Collections.unmodifiableSet(allRegistersModifiable);
- }
-
- @Override
- public String getId()
- {
- return AM2900_MACHINE_ID;
- }
-
- @Override
- public Am2900Machine createNew()
- {
- return createNew(new LogicModelModifiable());
- }
-
- public Am2900Machine createNew(LogicModelModifiable model)
- {
- return new Am2900Machine(model, this);
- }
-
- @Override
- public ISASchema getISASchema()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public Set<Register> getRegisters()
- {
- return allRegisters;
- }
-
- @Override
- public int getAddressBits()
- {
- return 16;
- }
-
- @Override
- public Am2900MainMemoryDefinition getMainMemoryDefinition()
- {
- return Am2900MainMemoryDefinition.instance;
- }
-
- @Override
- public int hashCode()
- {
- return 12345;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- return obj != null && obj instanceof Am2900MachineDefinition;
- }
-
- @Override
- public Am2900MicroInstructionMemoryDefinition getMicroInstructionMemoryDefinition()
- {
- return Am2900MicroInstructionMemoryDefinition.instance;
- }
-
-}
--- /dev/null
+package net.mograsim.logic.model.am2900.machine;
+
+public class SimpleAm2900MachineDefinition extends AbstractAm2900MachineDefinition
+{
+ public SimpleAm2900MachineDefinition()
+ {
+ super(false);
+ }
+}
\ No newline at end of file
--- /dev/null
+package net.mograsim.logic.model.am2900.machine;
+
+public class StrictAm2900MachineDefinition extends AbstractAm2900MachineDefinition
+{
+ public StrictAm2900MachineDefinition()
+ {
+ super(true);
+ }
+}
\ No newline at end of file
import net.mograsim.logic.model.SimpleLogicUIStandalone;
import net.mograsim.logic.model.am2900.Am2900Loader;
-import net.mograsim.logic.model.am2900.machine.Am2900MachineDefinition;
+import net.mograsim.logic.model.am2900.machine.StrictAm2900MachineDefinition;
import net.mograsim.logic.model.model.LogicModelModifiable;
import net.mograsim.logic.model.model.components.ModelComponent;
import net.mograsim.logic.model.model.components.atomic.ModelBitDisplay;
public static void createTestbench(LogicModelModifiable model)
{
Am2900Loader.setup();
- ModelComponent comp = new Am2900MachineDefinition().createNew(model).getAm2900();
+ ModelComponent comp = new StrictAm2900MachineDefinition().createNew(model).getAm2900();
List<String> inputPinNames = new ArrayList<>();
List<String> outputPinNames = new ArrayList<>();