net.mograsim.logic.model.am2900.components.am2910,
net.mograsim.logic.model.am2900.machine,
net.mograsim.logic.model.am2900.machine.registers,
+ net.mograsim.logic.model.am2900.machine.registers.am2901,
net.mograsim.logic.model.examples
Bundle-RequiredExecutionEnvironment: JavaSE-11
Require-Bundle: org.eclipse.osgi,
import java.util.Collections;
import java.util.List;
+import net.mograsim.logic.model.am2900.machine.registers.am2901.Am2901RegisterGroup;
import net.mograsim.logic.model.model.LogicModelModifiable;
import net.mograsim.machine.ISASchema;
import net.mograsim.machine.MachineDefinition;
// TODO MIR, IR, PC/BZ...
unsortedRegisters = Collections.unmodifiableList(unsortedRegistersModifiable);
List<RegisterGroup> registerGroupsModifiable = new ArrayList<>();
- // TODO Am2901, Am2904, Am2910
+ registerGroupsModifiable.add(Am2901RegisterGroup.instance);
+ // TODO Am2904, Am2910
registerGroups = Collections.unmodifiableList(registerGroupsModifiable);
}
+++ /dev/null
-package net.mograsim.logic.model.am2900.machine.registers;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-
-import net.mograsim.machine.StandardRegister;
-
-public class NumberedRegister extends StandardRegister
-{
- public static final List<NumberedRegister> instancesCorrectOrder;
-
- static
- {
- List<NumberedRegister> instancesCorrectOrderModifiable = new ArrayList<>();
- for (int i = 0; i < 16; i++)
- instancesCorrectOrderModifiable.add(new NumberedRegister(i));
- instancesCorrectOrder = Collections.unmodifiableList(instancesCorrectOrderModifiable);
- }
-
- private final int index;
- private final String indexBitstring;
-
- private NumberedRegister(int i)
- {
- super("R" + i, new HashSet<>(Arrays.asList(new String[] { "R" + i, "Register #" + i, "Register " + i })), 16, new HashMap<>());
- this.index = i;
-
- StringBuilder sb = new StringBuilder();
- sb.append((index & 0b1000) != 0 ? '1' : '0');
- sb.append((index & 0b0100) != 0 ? '1' : '0');
- sb.append((index & 0b0010) != 0 ? '1' : '0');
- sb.append((index & 0b0001) != 0 ? '1' : '0');
- this.indexBitstring = sb.toString();
- }
-
- public int getIndex()
- {
- return index;
- }
-
- public String getIndexAsBitstring()
- {
- return indexBitstring;
- }
-}
\ No newline at end of file
+++ /dev/null
-package net.mograsim.logic.model.am2900.machine.registers;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-
-import net.mograsim.machine.StandardRegister;
-
-public class QRegister extends StandardRegister
-{
- public static final QRegister instance = new QRegister();
-
- private QRegister()
- {
- super("qreg", new HashSet<>(Arrays.asList(new String[] { "qreg", "Q register" })), 16, new HashMap<>());
- }
-}
\ No newline at end of file
--- /dev/null
+package net.mograsim.logic.model.am2900.machine.registers.am2901;
+
+import net.mograsim.logic.model.am2900.machine.registers.Am2900Register;
+import net.mograsim.machine.registers.HighLevelStateBasedRegister;
+
+public class Am2901Register extends HighLevelStateBasedRegister implements Am2900Register
+{
+ public Am2901Register(String id, String cellSuffix, int logicWidthPerAm2901)
+ {
+ super(id, new int[] { logicWidthPerAm2901, logicWidthPerAm2901, logicWidthPerAm2901, logicWidthPerAm2901 },
+ prefixWithAm2901s(cellSuffix));
+ }
+
+ private static String[] prefixWithAm2901s(String suffix)
+ {
+ String[] prefixed = new String[4];
+ for (int i = 0, b = 0; i < 4; i++, b += 4)
+ prefixed[i] = String.format("am2901_%d-%d.%s", (b + 3), b, suffix);
+ return prefixed;
+ }
+}
\ No newline at end of file
--- /dev/null
+package net.mograsim.logic.model.am2900.machine.registers.am2901;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.mograsim.machine.registers.Register;
+import net.mograsim.machine.registers.SimpleRegisterGroup;
+
+public class Am2901RegisterGroup extends SimpleRegisterGroup
+{
+ public static final Am2901RegisterGroup instance = new Am2901RegisterGroup();
+
+ private Am2901RegisterGroup()
+ {
+ super("Am2901", getAllRegisters());
+ }
+
+ private static Register[] getAllRegisters()
+ {
+ List<Register> allRegistersModifiable = new ArrayList<>();
+ allRegistersModifiable.addAll(NumberedRegister.instancesCorrectOrder);
+ allRegistersModifiable.add(QRegister.instance);
+ return allRegistersModifiable.toArray(Register[]::new);
+ }
+}
\ No newline at end of file
--- /dev/null
+package net.mograsim.logic.model.am2900.machine.registers.am2901;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class NumberedRegister extends Am2901Register
+{
+ public static final List<NumberedRegister> instancesCorrectOrder;
+
+ static
+ {
+ List<NumberedRegister> instancesCorrectOrderModifiable = new ArrayList<>();
+ for (int i = 0; i < 16; i++)
+ instancesCorrectOrderModifiable.add(new NumberedRegister(i));
+ instancesCorrectOrder = Collections.unmodifiableList(instancesCorrectOrderModifiable);
+ }
+
+ private NumberedRegister(int index)
+ {
+ super("R" + index, "regs.c" + getIndexAsBitstring(index) + ".q", 4);
+
+ }
+
+ private static String getIndexAsBitstring(int index)
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append((index & 0b1000) != 0 ? '1' : '0');
+ sb.append((index & 0b0100) != 0 ? '1' : '0');
+ sb.append((index & 0b0010) != 0 ? '1' : '0');
+ sb.append((index & 0b0001) != 0 ? '1' : '0');
+ return sb.toString();
+ }
+}
\ No newline at end of file
--- /dev/null
+package net.mograsim.logic.model.am2900.machine.registers.am2901;
+
+public class QRegister extends Am2901Register
+{
+ public static final QRegister instance = new QRegister();
+
+ private QRegister()
+ {
+ super("Q", "qreg.q", 4);
+ }
+}
\ No newline at end of file