1 package net.mograsim.logic.model.am2900.components.am2904;
3 import static net.mograsim.logic.core.types.Bit.ONE;
4 import static net.mograsim.logic.core.types.Bit.U;
5 import static net.mograsim.logic.core.types.Bit.X;
6 import static net.mograsim.logic.core.types.Bit.ZERO;
10 import net.mograsim.logic.core.types.Bit;
11 import net.mograsim.logic.core.wires.Wire.ReadEnd;
12 import net.mograsim.logic.core.wires.Wire.ReadWriteEnd;
13 import net.mograsim.logic.model.model.ViewModelModifiable;
14 import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedGUIComponent;
15 import net.mograsim.logic.model.model.wires.Pin;
16 import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
17 import net.mograsim.logic.model.snippets.symbolrenderers.PinNamesSymbolRenderer.PinNamesParams.Position;
19 public class RegCTInstrDecode extends SimpleRectangularHardcodedGUIComponent
21 public RegCTInstrDecode(ViewModelModifiable model, String name)
23 super(model, name, "Instruction\ndecode");
25 addPin(new Pin(this, "I", 6, 0, 40), Usage.INPUT, Position.RIGHT);
31 addPin(new Pin(this, "muSR_MUX", 2, 80, 10), Usage.OUTPUT, Position.LEFT);
32 addPin(new Pin(this, "muSR_OVRRET", 1, 80, 20), Usage.OUTPUT, Position.LEFT);
33 addPin(new Pin(this, "muSR_CINV", 1, 80, 30), Usage.OUTPUT, Position.LEFT);
34 addPin(new Pin(this, "muSR__WEZ", 1, 80, 40), Usage.OUTPUT, Position.LEFT);
35 addPin(new Pin(this, "muSR__WEC", 1, 80, 50), Usage.OUTPUT, Position.LEFT);
36 addPin(new Pin(this, "muSR__WEN", 1, 80, 60), Usage.OUTPUT, Position.LEFT);
37 addPin(new Pin(this, "muSR__WEOVR", 1, 80, 70), Usage.OUTPUT, Position.LEFT);
45 // 110: Swap OVR and C
47 addPin(new Pin(this, "MSR_MUX", 3, 40, 0), Usage.OUTPUT, Position.BOTTOM);
53 addPin(new Pin(this, "CT_SRC_MUX", 2, 10, 80), Usage.OUTPUT, Position.TOP);
55 // see Am2900 Family Data Book, Am2904, Table 4 (CT_MUX2-0 = I3-1)
56 addPin(new Pin(this, "CT_MUX", 3, 30, 80), Usage.OUTPUT, Position.TOP);
57 addPin(new Pin(this, "CT_INV", 1, 50, 80), Usage.OUTPUT, Position.TOP);
58 addPin(new Pin(this, "CT_EXP", 1, 70, 80), Usage.OUTPUT, Position.TOP);
62 protected Object recalculate(Object lastState, Map<String, ReadEnd> readEnds, Map<String, ReadWriteEnd> readWriteEnds)
64 Bit[] IBits = readEnds.get("I").getValues().getBits();
66 for (int i = 0; i < 6; i++)
73 for (ReadWriteEnd e : readWriteEnds.values())
78 for (ReadWriteEnd e : readWriteEnds.values())
84 throw new IllegalArgumentException("Unknown enum constant: " + IBits[i]);
90 readWriteEnds.get("muSR_MUX").feedSignals(ZERO, ONE);
91 readWriteEnds.get("muSR_OVRRET").feedSignals(ZERO);
92 readWriteEnds.get("muSR_CINV").feedSignals(ZERO);
93 readWriteEnds.get("muSR__WEZ").feedSignals(ZERO);
94 readWriteEnds.get("muSR__WEC").feedSignals(ZERO);
95 readWriteEnds.get("muSR__WEN").feedSignals(ZERO);
96 readWriteEnds.get("muSR__WEOVR").feedSignals(ZERO);
99 readWriteEnds.get("muSR_MUX").feedSignals(ONE, ZERO);
100 readWriteEnds.get("muSR_OVRRET").feedSignals(ZERO);
101 readWriteEnds.get("muSR_CINV").feedSignals(ZERO);
102 readWriteEnds.get("muSR__WEZ").feedSignals(ZERO);
103 readWriteEnds.get("muSR__WEC").feedSignals(ZERO);
104 readWriteEnds.get("muSR__WEN").feedSignals(ZERO);
105 readWriteEnds.get("muSR__WEOVR").feedSignals(ZERO);
108 readWriteEnds.get("muSR_MUX").feedSignals(ZERO, ZERO);
109 readWriteEnds.get("muSR_OVRRET").feedSignals(ZERO);
110 readWriteEnds.get("muSR_CINV").feedSignals(ZERO);
111 readWriteEnds.get("muSR__WEZ").feedSignals(ZERO);
112 readWriteEnds.get("muSR__WEC").feedSignals(ZERO);
113 readWriteEnds.get("muSR__WEN").feedSignals(ZERO);
114 readWriteEnds.get("muSR__WEOVR").feedSignals(ZERO);
118 readWriteEnds.get("muSR_MUX").feedSignals(ONE, ONE);
119 readWriteEnds.get("muSR_OVRRET").feedSignals(ONE);
120 readWriteEnds.get("muSR_CINV").feedSignals(ZERO);
121 readWriteEnds.get("muSR__WEZ").feedSignals(ZERO);
122 readWriteEnds.get("muSR__WEC").feedSignals(ZERO);
123 readWriteEnds.get("muSR__WEN").feedSignals(ZERO);
124 readWriteEnds.get("muSR__WEOVR").feedSignals(ZERO);
127 readWriteEnds.get("muSR_MUX").feedSignals(ZERO, ZERO);
128 readWriteEnds.get("muSR_OVRRET").feedSignals(ZERO);
129 readWriteEnds.get("muSR_CINV").feedSignals(ZERO);
130 readWriteEnds.get("muSR__WEZ").feedSignals(ZERO);
131 readWriteEnds.get("muSR__WEC").feedSignals(ONE);
132 readWriteEnds.get("muSR__WEN").feedSignals(ONE);
133 readWriteEnds.get("muSR__WEOVR").feedSignals(ONE);
136 readWriteEnds.get("muSR_MUX").feedSignals(ONE, ZERO);
137 readWriteEnds.get("muSR_OVRRET").feedSignals(ZERO);
138 readWriteEnds.get("muSR_CINV").feedSignals(ZERO);
139 readWriteEnds.get("muSR__WEZ").feedSignals(ZERO);
140 readWriteEnds.get("muSR__WEC").feedSignals(ONE);
141 readWriteEnds.get("muSR__WEN").feedSignals(ONE);
142 readWriteEnds.get("muSR__WEOVR").feedSignals(ONE);
145 readWriteEnds.get("muSR_MUX").feedSignals(ZERO, ZERO);
146 readWriteEnds.get("muSR_OVRRET").feedSignals(ZERO);
147 readWriteEnds.get("muSR_CINV").feedSignals(ZERO);
148 readWriteEnds.get("muSR__WEZ").feedSignals(ONE);
149 readWriteEnds.get("muSR__WEC").feedSignals(ZERO);
150 readWriteEnds.get("muSR__WEN").feedSignals(ONE);
151 readWriteEnds.get("muSR__WEOVR").feedSignals(ONE);
154 readWriteEnds.get("muSR_MUX").feedSignals(ONE, ZERO);
155 readWriteEnds.get("muSR_OVRRET").feedSignals(ZERO);
156 readWriteEnds.get("muSR_CINV").feedSignals(ZERO);
157 readWriteEnds.get("muSR__WEZ").feedSignals(ONE);
158 readWriteEnds.get("muSR__WEC").feedSignals(ZERO);
159 readWriteEnds.get("muSR__WEN").feedSignals(ONE);
160 readWriteEnds.get("muSR__WEOVR").feedSignals(ONE);
163 readWriteEnds.get("muSR_MUX").feedSignals(ZERO, ZERO);
164 readWriteEnds.get("muSR_OVRRET").feedSignals(ZERO);
165 readWriteEnds.get("muSR_CINV").feedSignals(ZERO);
166 readWriteEnds.get("muSR__WEZ").feedSignals(ONE);
167 readWriteEnds.get("muSR__WEC").feedSignals(ONE);
168 readWriteEnds.get("muSR__WEN").feedSignals(ZERO);
169 readWriteEnds.get("muSR__WEOVR").feedSignals(ONE);
172 readWriteEnds.get("muSR_MUX").feedSignals(ONE, ZERO);
173 readWriteEnds.get("muSR_OVRRET").feedSignals(ZERO);
174 readWriteEnds.get("muSR_CINV").feedSignals(ZERO);
175 readWriteEnds.get("muSR__WEZ").feedSignals(ONE);
176 readWriteEnds.get("muSR__WEC").feedSignals(ONE);
177 readWriteEnds.get("muSR__WEN").feedSignals(ZERO);
178 readWriteEnds.get("muSR__WEOVR").feedSignals(ONE);
181 readWriteEnds.get("muSR_MUX").feedSignals(ZERO, ZERO);
182 readWriteEnds.get("muSR_OVRRET").feedSignals(ZERO);
183 readWriteEnds.get("muSR_CINV").feedSignals(ZERO);
184 readWriteEnds.get("muSR__WEZ").feedSignals(ONE);
185 readWriteEnds.get("muSR__WEC").feedSignals(ONE);
186 readWriteEnds.get("muSR__WEN").feedSignals(ONE);
187 readWriteEnds.get("muSR__WEOVR").feedSignals(ZERO);
190 readWriteEnds.get("muSR_MUX").feedSignals(ONE, ZERO);
191 readWriteEnds.get("muSR_OVRRET").feedSignals(ZERO);
192 readWriteEnds.get("muSR_CINV").feedSignals(ZERO);
193 readWriteEnds.get("muSR__WEZ").feedSignals(ONE);
194 readWriteEnds.get("muSR__WEC").feedSignals(ONE);
195 readWriteEnds.get("muSR__WEN").feedSignals(ONE);
196 readWriteEnds.get("muSR__WEOVR").feedSignals(ZERO);
204 readWriteEnds.get("muSR_MUX").feedSignals(ONE, ONE);
205 readWriteEnds.get("muSR_OVRRET").feedSignals(ZERO);
206 readWriteEnds.get("muSR_CINV").feedSignals(ONE);
207 readWriteEnds.get("muSR__WEZ").feedSignals(ZERO);
208 readWriteEnds.get("muSR__WEC").feedSignals(ZERO);
209 readWriteEnds.get("muSR__WEN").feedSignals(ZERO);
210 readWriteEnds.get("muSR__WEOVR").feedSignals(ZERO);
213 readWriteEnds.get("muSR_MUX").feedSignals(ONE, ONE);
214 readWriteEnds.get("muSR_OVRRET").feedSignals(ZERO);
215 readWriteEnds.get("muSR_CINV").feedSignals(ZERO);
216 readWriteEnds.get("muSR__WEZ").feedSignals(ZERO);
217 readWriteEnds.get("muSR__WEC").feedSignals(ZERO);
218 readWriteEnds.get("muSR__WEN").feedSignals(ZERO);
219 readWriteEnds.get("muSR__WEOVR").feedSignals(ZERO);
224 readWriteEnds.get("MSR_MUX").feedSignals(ONE, ONE, ZERO);
227 readWriteEnds.get("MSR_MUX").feedSignals(ONE, ZERO, ZERO);
230 readWriteEnds.get("MSR_MUX").feedSignals(ZERO, ONE, ZERO);
233 readWriteEnds.get("MSR_MUX").feedSignals(ZERO, ZERO, ZERO);
236 readWriteEnds.get("MSR_MUX").feedSignals(ZERO, ONE, ONE);
239 readWriteEnds.get("MSR_MUX").feedSignals(ONE, ONE, ONE);
249 readWriteEnds.get("MSR_MUX").feedSignals(ONE, ZERO, ONE);
252 readWriteEnds.get("MSR_MUX").feedSignals(ZERO, ZERO, ONE);
255 readWriteEnds.get("CT_SRC_MUX").feedSignals(IBits[0], IBits[1]);
256 readWriteEnds.get("CT_INV").feedSignals(IBits[5]);
257 readWriteEnds.get("CT_MUX").feedSignals(IBits[2], IBits[3], IBits[4]);
258 readWriteEnds.get("CT_EXP").feedSignals((IAsInt & 0b1110) == 0b1110 ? ONE : ZERO);
264 IndirectGUIComponentCreator.setComponentSupplier(RegCTInstrDecode.class.getCanonicalName(),
265 (m, p, n) -> new RegCTInstrDecode(m, n));