1 package net.mograsim.logic.model.am2900.am2904;
3 import java.util.Collections;
4 import java.util.HashMap;
7 import net.mograsim.logic.model.am2900.TestableCircuit;
9 public interface TestableAm2904 extends TestableCircuit
12 void setInstruction(Am2904_Inst inst);
14 void setCarry(Am2904_Carry carry);
16 void setShiftCode(String val_4_bit);
18 void setI10(Am2904_ShiftDir dir);
20 void setCX(String val_1_bit);
22 void setY3(String val_1_bit);
24 void setIZ(String val_1_bit);
26 void setIC(String val_1_bit);
28 void setIOVR(String val_1_bit);
30 void setIN(String val_1_bit);
32 default void setI(String z_c_ovr_n)
34 setIZ(z_c_ovr_n.substring(0, 1));
35 setIC(z_c_ovr_n.substring(1, 2));
36 setIOVR(z_c_ovr_n.substring(2, 3));
37 setIN(z_c_ovr_n.substring(3, 4));
40 void set_CEM(String val_1_bit);
42 void set_CEµ(String val_1_bit);
44 void set_OEY(String val_1_bit);
46 void set_OECT(String val_1_bit);
48 void set_SE(String val_1_bit);
50 void set_EZ(String val_1_bit);
52 void set_EC(String val_1_bit);
54 void set_EOVR(String val_1_bit);
56 void set_EN(String val_1_bit);
58 default void set_E(String z_c_ovr_n)
60 set_EZ(z_c_ovr_n.substring(0, 1));
61 set_EC(z_c_ovr_n.substring(1, 2));
62 set_EOVR(z_c_ovr_n.substring(2, 3));
63 set_EN(z_c_ovr_n.substring(3, 4));
66 void setSIO0(String val_1_bit);
68 void setSIO3(String val_1_bit);
70 void setQIO0(String val_1_bit);
72 void setQIO3(String val_1_bit);
88 public enum Am2904_ShiftDir
93 public enum Am2904_Carry
100 * [microSR]_[machineSR]_[condCodeSource]_[condCode]<br>
102 * <li>Load = load from I inputs (Am2904s)</li>
103 * <li>condCodeSource = µ, M, I (and a special case: I and M)</li>
104 * <li>condCode = the boolean term defining the CT output</li>
107 public enum Am2904_Inst
110 LoadM_LoadY_µ_NxorOVRorZ(0_00),
111 Set_Set_µ_NxnorOVRornotZ(0_01),
112 Swap_Swap_µ_NxorOVR(0_02),
113 Reset_Reset_µ_NxnorOVR(0_03),
114 Load_LoadForShiftThroughOvr_µ_Z(0_04),
115 Load_Invert_µ_notZ(0_05),
116 LoadOvrRetain_Load_µ_OVR(0_06),
117 LoadOvrRetain_Load_µ_notOVR(0_07),
118 ResetZ_LoadCarryInvert_µ_CorZ(0_10),
119 SetZ_LoadCarryInvert_µ_notCandnotZ(0_11),
120 ResetC_Load_µ_C(0_12),
121 SetC_Load_µ_notC(0_13),
122 ResetN_Load_µ_notCorZ(0_14),
123 SetN_Load_µ_CandnotZ(0_15),
124 ResetOvr_Load_IM_NxorN(0_16),
125 SetOvr_Load_IM_NxnorN(0_17),
126 Load_Load_µ_NxorOVRorZ(0_20),
127 Load_Load_µ_NxnorOVRornotZ(0_21),
128 Load_Load_µ_NxorOVR(0_22),
129 Load_Load_µ_NxnorOVR(0_23),
131 Load_Load_µ_notZ(0_25),
132 Load_Load_µ_OVR(0_26),
133 Load_Load_µ_notOVR(0_27),
134 LoadCarryInvert_LoadCarryInvert_µ_CorZ(0_30),
135 LoadCarryInvert_LoadCarryInvert_µ_notCandnotZ(0_31),
137 Load_Load_µ_notC(0_33),
138 Load_Load_µ_notCorZ(0_34),
139 Load_Load_µ_CandnotZ(0_35),
141 Load_Load_µ_notN(0_37),
142 Load_Load_M_NxorOVRorZ(0_40),
143 Load_Load_M_NxnorOVRornotZ(0_41),
144 Load_Load_M_NxorOVR(0_42),
145 Load_Load_M_NxnorOVR(0_43),
147 Load_Load_M_notZ(0_45),
148 Load_Load_M_OVR(0_46),
149 Load_Load_M_notOVR(0_47),
150 LoadCarryInvert_LoadCarryInvert_M_CorZ(0_50),
151 LoadCarryInvert_LoadCarryInvert_M_notCandnotZ(0_51),
153 Load_Load_M_notC(0_53),
154 Load_Load_M_notCorZ(0_54),
155 Load_Load_M_CandnotZ(0_55),
157 Load_Load_M_notN(0_57),
158 Load_Load_I_NxorOVRorZ(0_60),
159 Load_Load_I_NxnorOVRornotZ(0_61),
160 Load_Load_I_NxorOVR(0_62),
161 Load_Load_I_NxnorOVR(0_63),
163 Load_Load_I_notZ(0_65),
164 Load_Load_I_OVR(0_66),
165 Load_Load_I_notOVR(0_67),
166 LoadCarryInvert_LoadCarryInvert_I_notCorZ(0_70),
167 LoadCarryInvert_LoadCarryInvert_I_CandnotZ(0_71),
169 Load_Load_I_notC(0_73),
170 Load_Load_I_notCorZ(0_74),
171 Load_Load_I_CandnotZ(0_75),
173 Load_Load_I_notN(0_77);
176 public final int code;
178 private Am2904_Inst(int code)
183 private static final Map<Integer, Am2904_Inst> instCodes;
187 Map<Integer, Am2904_Inst> instCodesMod = new HashMap<>();
188 Am2904_Inst[] vals = values();
189 for (Am2904_Inst inst : vals)
191 assert inst.code == inst.ordinal();
192 instCodesMod.put(inst.code, inst);
194 if (instCodesMod.size() != 64)
195 throw new IllegalStateException("There must be exactly 64 Am2904 instruction codes, but was " + instCodesMod.size());
196 instCodes = Collections.unmodifiableMap(instCodesMod);
199 public static Am2904_Inst getInstFor(int I_543210)
201 Am2904_Inst inst = instCodes.get(I_543210);
204 throw new IllegalArgumentException("Invaild Am2904 instruction code: " + I_543210);
207 public int getBlock()
212 public boolean isLoadCarryInvert()
214 return (code & 0b001_110) == 0b001_000;