Merge pull request #11 from MaisiKoleni/config-gh-actions
[Mograsim.git] / plugins / net.mograsim.logic.model.am2900 / src / net / mograsim / logic / model / am2900 / machine / Am2900MicroInstructionDefinition.java
index b67e93d..28f4def 100644 (file)
@@ -1,5 +1,6 @@
 package net.mograsim.logic.model.am2900.machine;
 
 package net.mograsim.logic.model.am2900.machine;
 
+import java.util.Arrays;
 import java.util.Optional;
 
 import net.mograsim.machine.mi.MicroInstructionDefinition;
 import java.util.Optional;
 
 import net.mograsim.machine.mi.MicroInstructionDefinition;
@@ -21,9 +22,9 @@ public class Am2900MicroInstructionDefinition implements MicroInstructionDefinit
                        .add("AQ", "AB", "ZQ", "ZB", "ZA", "DA", "DQ", "DZ").build();
        private static final MnemonicFamily am2901FuncInstructions = new MnemonicFamilyBuilder(3).addX().setXDefault()
                        .add("ADD", "SUBR", "SUBS", "OR", "AND", "NOTRS", "EXOR", "EXNOR").build();
                        .add("AQ", "AB", "ZQ", "ZB", "ZA", "DA", "DQ", "DZ").build();
        private static final MnemonicFamily am2901FuncInstructions = new MnemonicFamilyBuilder(3).addX().setXDefault()
                        .add("ADD", "SUBR", "SUBS", "OR", "AND", "NOTRS", "EXOR", "EXNOR").build();
-       private static final MnemonicFamily am2901DestInstructions = new MnemonicFamilyBuilder(3).addX().setXDefault()
-                       .add("QREG", "NOP", "RAMA", "RAMF", "RAMQD", "RAMD", "RAMQU", "RAMU").build();
-       private static final IntegerClassification register = new IntegerClassification(0, 4);
+       private static final MnemonicFamily am2901DestInstructions = new MnemonicFamilyBuilder(3).addX()
+                       .add("QREG", "NOP", "RAMA", "RAMF", "RAMQD", "RAMD", "RAMQU", "RAMU").setDefault("NOP").build();
+       private static final IntegerClassification register = new IntegerClassification(4);
        private static final BooleanClassification registerSelect = new BooleanClassification("MR", "IR");
        private static final BooleanClassification abus = new BooleanClassification(true, "H", "AB");
        private static final BooleanClassification dbus = new BooleanClassification(true, "H", "DB");
        private static final BooleanClassification registerSelect = new BooleanClassification("MR", "IR");
        private static final BooleanClassification abus = new BooleanClassification(true, "H", "AB");
        private static final BooleanClassification dbus = new BooleanClassification(true, "H", "DB");
@@ -35,37 +36,40 @@ public class Am2900MicroInstructionDefinition implements MicroInstructionDefinit
                        .add("LSLCO", "LSHCO", "LSL", "LSH", "LSDLCO", "LSDHCO", "LSDL", "LSDH", "LSCRO", "LSCRIO", "LSR", "LSLICI", "LSDCIO", "LSDRCO",
                                        "LSDCI", "LDSR")
                        .build();
                        .add("LSLCO", "LSHCO", "LSL", "LSH", "LSDLCO", "LSDHCO", "LSDL", "LSDH", "LSCRO", "LSCRIO", "LSR", "LSLICI", "LSDCIO", "LSDRCO",
                                        "LSDCI", "LDSR")
                        .build();
-//     private static final MnemonicFamily am2904StatusInstructions = new MnemonicFamily(
-//                     new String[] { "MI_Zero", "MI_NotZero", "MI_UGTEQ", "MI_ULT", "MI_UGT", "MI_ULTEQ", "MI_SGTEQ", "MI_SLT", "MI_SGT", "MI_SLTEQ",
-//                                     "MA_Zero", "MA_NotZero", "MA_UGTEQ", "MA_ULT", "MA_UGT", "MA_ULTEQ", "MA_SGTEQ", "MA_SLT", "MA_SGT", "MA_SLTEQ" },
-//                     new long[] { 0b01_0101, 0b01_0100, 0b01_1101, 0b01_1100, 0b01_1110, 0b01_1111, 0b01_0010, 0b01_0011, 0b01_0000, 0b01_0001,
-//                                     0b10_0101, 0b10_0100, 0b10_1101, 0b10_1100, 0b10_1110, 0b10_1111, 0b10_0010, 0b10_0011, 0b10_0000, 0b10_0001 },
-//                     6);
        // TODO: Maybe "X" and "notX" are swapped.
        private static final MnemonicFamily am2904StatusInstructions = new MnemonicFamilyBuilder(6).addX().setXDefault()
        // TODO: Maybe "X" and "notX" are swapped.
        private static final MnemonicFamily am2904StatusInstructions = new MnemonicFamilyBuilder(6).addX().setXDefault()
-                       .add("LoadM_LoadY_µ_NxorOVRorZ", "Set_Set_µ_NxnorOVRornotZ", "Swap_Swap_µ_NxorOVR", "Reset_Reset_µ_NxnorOVR",
-                                       "Load_LoadForShiftThroughOvr_µ_Z", "Load_Invert_µ_notZ", "LoadOvrRetain_Load_µ_OVR", "LoadOvrRetain_Load_µ_notOVR",
-                                       "ResetZ_LoadCarryInvert_µ_CorZ", "SetZ_LoadCarryInvert_µ_notCandnotZ", "ResetC_Load_µ_C", "SetC_Load_µ_notC",
-                                       "ResetN_Load_µ_notCorZ", "SetN_Load_µ_CandnotZ", "ResetOvr_Load_IM_NxorN", "SetOvr_Load_IM_NxnorN",
-                                       "Load_Load_µ_NxorOVRorZ", "Load_Load_µ_NxnorOVRornotZ", "Load_Load_µ_NxorOVR", "Load_Load_µ_NxnorOVR", "Load_Load_µ_Z",
-                                       "Load_Load_µ_notZ", "Load_Load_µ_OVR", "Load_Load_µ_notOVR", "LoadCarryInvert_LoadCarryInvert_µ_CorZ",
-                                       "LoadCarryInvert_LoadCarryInvert_µ_notCandnotZ", "Load_Load_µ_C", "Load_Load_µ_notC", "Load_Load_µ_notCorZ",
-                                       "Load_Load_µ_CandnotZ", "Load_Load_µ_N", "Load_Load_µ_notN", "Load_Load_M_NxorOVRorZ", "Load_Load_M_NxnorOVRornotZ",
-                                       "Load_Load_M_NxorOVR", "Load_Load_M_NxnorOVR", "Load_Load_M_Z", "Load_Load_M_notZ", "Load_Load_M_OVR",
-                                       "Load_Load_M_notOVR", "LoadCarryInvert_LoadCarryInvert_M_CorZ", "LoadCarryInvert_LoadCarryInvert_M_notCandnotZ",
-                                       "Load_Load_M_C", "Load_Load_M_notC", "Load_Load_M_notCorZ", "Load_Load_M_CandnotZ", "Load_Load_M_N", "Load_Load_M_notN",
-                                       "Load_Load_I_NxorOVRorZ", "Load_Load_I_NxnorOVRornotZ", "Load_Load_I_NxorOVR", "Load_Load_I_NxnorOVR", "Load_Load_I_Z",
-                                       "Load_Load_I_notZ", "Load_Load_I_OVR", "Load_Load_I_notOVR", "LoadCarryInvert_LoadCarryInvert_I_notCorZ",
-                                       "LoadCarryInvert_LoadCarryInvert_I_CandnotZ", "Load_Load_I_C", "Load_Load_I_notC", "Load_Load_I_notCorZ",
-                                       "Load_Load_I_CandnotZ", "Load_Load_I_N", "Load_Load_I_notN")
+                       .add(new String[] { "LOAD", "MI_Zero", "MI_NotZero", "MI_UGTEQ", "MI_ULT", "MI_UGT", "MI_ULTEQ", "MI_SGTEQ", "MI_SLT", "MI_SGT",
+                                       "MI_SLTEQ", "MA_Zero", "MA_NotZero", "MA_UGTEQ", "MA_ULT", "MA_UGT", "MA_ULTEQ", "MA_SGTEQ", "MA_SLT", "MA_SGT",
+                                       "MA_SLTEQ" },
+                                       new long[] { 0b01_0000, 0b01_0101, 0b01_0100, 0b01_1101, 0b01_1100, 0b01_1110, 0b01_1111, 0b01_0010, 0b01_0011,
+                                                       0b01_0000, 0b01_0001, 0b10_0101, 0b10_0100, 0b10_1101, 0b10_1100, 0b10_1110, 0b10_1111, 0b10_0010, 0b10_0011,
+                                                       0b10_0000, 0b10_0001 })
+                       .add("LoadM_LoadY_\u00b5_NxorOVRorZ", "Set_Set_\u00b5_NxnorOVRornotZ", "Swap_Swap_\u00b5_NxorOVR",
+                                       "Reset_Reset_\u00b5_NxnorOVR", "Load_LoadForShiftThroughOvr_\u00b5_Z", "Load_Invert_\u00b5_notZ",
+                                       "LoadOvrRetain_Load_\u00b5_OVR", "LoadOvrRetain_Load_\u00b5_notOVR", "ResetZ_LoadCarryInvert_\u00b5_CorZ",
+                                       "SetZ_LoadCarryInvert_\u00b5_notCandnotZ", "ResetC_Load_\u00b5_C", "SetC_Load_\u00b5_notC",
+                                       "ResetN_Load_\u00b5_notCorZ", "SetN_Load_\u00b5_CandnotZ", "ResetOvr_Load_IM_NxorN", "SetOvr_Load_IM_NxnorN",
+                                       "Load_Load_\u00b5_NxorOVRorZ", "Load_Load_\u00b5_NxnorOVRornotZ", "Load_Load_\u00b5_NxorOVR",
+                                       "Load_Load_\u00b5_NxnorOVR", "Load_Load_\u00b5_Z", "Load_Load_\u00b5_notZ", "Load_Load_\u00b5_OVR",
+                                       "Load_Load_\u00b5_notOVR", "LoadCarryInvert_LoadCarryInvert_\u00b5_CorZ",
+                                       "LoadCarryInvert_LoadCarryInvert_\u00b5_notCandnotZ", "Load_Load_\u00b5_C", "Load_Load_\u00b5_notC",
+                                       "Load_Load_\u00b5_notCorZ", "Load_Load_\u00b5_CandnotZ", "Load_Load_\u00b5_N", "Load_Load_\u00b5_notN",
+                                       "Load_Load_M_NxorOVRorZ", "Load_Load_M_NxnorOVRornotZ", "Load_Load_M_NxorOVR", "Load_Load_M_NxnorOVR", "Load_Load_M_Z",
+                                       "Load_Load_M_notZ", "Load_Load_M_OVR", "Load_Load_M_notOVR", "LoadCarryInvert_LoadCarryInvert_M_CorZ",
+                                       "LoadCarryInvert_LoadCarryInvert_M_notCandnotZ", "Load_Load_M_C", "Load_Load_M_notC", "Load_Load_M_notCorZ",
+                                       "Load_Load_M_CandnotZ", "Load_Load_M_N", "Load_Load_M_notN", "Load_Load_I_NxorOVRorZ", "Load_Load_I_NxnorOVRornotZ",
+                                       "Load_Load_I_NxorOVR", "Load_Load_I_NxnorOVR", "Load_Load_I_Z", "Load_Load_I_notZ", "Load_Load_I_OVR",
+                                       "Load_Load_I_notOVR", "LoadCarryInvert_LoadCarryInvert_I_notCorZ", "LoadCarryInvert_LoadCarryInvert_I_CandnotZ",
+                                       "Load_Load_I_C", "Load_Load_I_notC", "Load_Load_I_notCorZ", "Load_Load_I_CandnotZ", "Load_Load_I_N", "Load_Load_I_notN")
                        .build();
                        .build();
+       // 00b5 = micro symbol
        private static final BooleanClassification ccen = new BooleanClassification(true, "PS", "C");
        private static final BooleanClassification ccen = new BooleanClassification(true, "PS", "C");
-       private static final MnemonicFamily am2910Instructions = new MnemonicFamilyBuilder(4).addX().setXDefault()
+       private static final MnemonicFamily am2910Instructions = new MnemonicFamilyBuilder(4).addX()
                        .add("JZ", "CJS", "JMAP", "CJP", "PUSH", "JSRP", "CJV", "JRP", "RFCT", "RPCT", "CRTN", "CJPP", "LDCT", "LOOP", "CONT", "TWB")
                        .add("JZ", "CJS", "JMAP", "CJP", "PUSH", "JSRP", "CJV", "JRP", "RFCT", "RPCT", "CRTN", "CJPP", "LDCT", "LOOP", "CONT", "TWB")
-                       .build();
+                       .setDefault("CONT").build();
 
 
-       private static final IntegerClassification constant_12bit = new IntegerClassification(0, 12);
-       private static final IntegerClassification constant_16bit = new IntegerClassification(0, 16);
+       private static final IntegerClassification constant_12bit = new IntegerClassification(12);
+       private static final IntegerClassification constant_16bit = new IntegerClassification(16);
        private static final BooleanClassification hE = new BooleanClassification(true, "H", "E");
        private static final BooleanClassification hI = new BooleanClassification(true, "H", "I");
        private static final BooleanClassification hL = new BooleanClassification(true, "H", "L");
        private static final BooleanClassification hE = new BooleanClassification(true, "H", "E");
        private static final BooleanClassification hI = new BooleanClassification(true, "H", "I");
        private static final BooleanClassification hL = new BooleanClassification(true, "H", "L");
@@ -76,6 +80,10 @@ public class Am2900MicroInstructionDefinition implements MicroInstructionDefinit
                        dbus, am2904CarryInstructions, am2904ShiftInstructions, hL, hL, am2904StatusInstructions, ccen, am2910Instructions,
                        constant_12bit, hL, hE, hI, hE, hL, rW };
 
                        dbus, am2904CarryInstructions, am2904ShiftInstructions, hL, hL, am2904StatusInstructions, ccen, am2910Instructions,
                        constant_12bit, hL, hE, hI, hE, hL, rW };
 
+       private static final String[] paramTitle = { "IE", "I", "KMUX", "K", "ALU Src", "ALU Func", "ALU Dest", "ALU RA", "ALU ASel", "ALU RB",
+                       "ALU BSel", "_ABus", "_DBus", "SU Cin", "SU Shift", "SU _CE\u00b5", "SU _CEM", "SU Op", "CU _CCEN", "CU I", "D", "BZ_LD",
+                       "BZ_ED", "BZ_INC", "BZ_EA", "IR_LD", "_MWE" };
+
        private static final String[] paramDesc = { "Allow interrupts?", "Interrupt instructions; omitted for simplicity",
                        "Get D-input from data bus/constant value", "Constant value", "Operand sources for ALU operation", "ALU operation",
                        "Destination of ALU calculation", "Register for A-operand", "Get A-operand from instruction register/micro instruction?",
        private static final String[] paramDesc = { "Allow interrupts?", "Interrupt instructions; omitted for simplicity",
                        "Get D-input from data bus/constant value", "Constant value", "Operand sources for ALU operation", "ALU operation",
                        "Destination of ALU calculation", "Register for A-operand", "Get A-operand from instruction register/micro instruction?",
@@ -89,7 +97,7 @@ public class Am2900MicroInstructionDefinition implements MicroInstructionDefinit
        @Override
        public ParameterClassification[] getParameterClassifications()
        {
        @Override
        public ParameterClassification[] getParameterClassifications()
        {
-               return classes;
+               return Arrays.copyOf(classes, classes.length);
        }
 
        @Override
        }
 
        @Override
@@ -98,6 +106,12 @@ public class Am2900MicroInstructionDefinition implements MicroInstructionDefinit
                return classes[index];
        }
 
                return classes[index];
        }
 
+       @Override
+       public Optional<String> getParameterTitle(int index)
+       {
+               return Optional.of(paramTitle[index]);
+       }
+
        @Override
        public Optional<String> getParameterDescription(int index)
        {
        @Override
        public Optional<String> getParameterDescription(int index)
        {