GE-115 Emulator
An Emulator of the General Electrics GE-115 computer
signals.h
Go to the documentation of this file.
1 
9 #ifndef SIGNALS_H
10 #define SIGNALS_H
11 
12 #include <stdint.h>
13 #include "bit.h"
14 #include "ge.h"
15 #include "log.h"
16 
17 #define SIG( name ) static inline uint8_t name (struct ge *ge)
18 
24 SIG(RESI) { return ge->RESI; }
25 SIG(RESI1) { return RESI(ge); }
26 SIG(RESIA) { return !RESI1(ge); }
27 SIG(RIA01) { return ge->RIA0; }
28 SIG(RIA2A) { return !ge->RIA2; }
29 SIG(RIA3A) { return !ge->RIA3; }
30 
31 SIG(RIUCA) { return !(RIA01(ge) && RESIA(ge) && RIA2A(ge) && RIA3A(ge)); }
32 
33 /* adding RIUCA here breaks machine startup */
34 SIG(RES01) { return !(RESIA(ge) /* && RIUCA(ge) */); }
35 
37 SIG(RES0) { return RES01(ge); }
38 
42 SIG(RES2) {
43  /* cpu fo. 116 */
44  /* maybe this equation is incorrect in manual? it's
45  * documented as `!RIA2`, but it seems it should not
46  * be negated. */
47  return !ge->RIA3 & !ge->RESI & ge->RIA2;
48 }
49 
53 SIG(RES3) {
54  /* cpu fo. 115 */
55  return ge->RIA3 & !ge->RESI;
56 }
57 
61 SIG(RIUC) {
62  return ge->RIA0 & !ge->RESI & !ge->RIA3 & !ge->RIA2;
63 }
64 
65 SIG(RES31) { return RES3(ge); };
66 
75 SIG(verified_condition) {
76  /* cpu fo 56, 57 */
77  uint8_t M = ge->rL1;
78  uint8_t M7 = BIT(M, 7);
79  uint8_t M6 = BIT(M, 6);
80  uint8_t M5 = BIT(M, 5);
81  uint8_t M4 = BIT(M, 4);
82 
83  uint8_t FA5 = BIT(ge->ffFA, 5);
84  uint8_t FA4 = BIT(ge->ffFA, 4);
85 
86  return (((ge->rFO == JC_OPCODE) &&
87  ((M7 && !FA4 && !FA5) ||
88  (M6 && !FA4 && FA5) ||
89  (M5 && FA4 && !FA5) ||
90  (M4 && FA4 && FA5))) ||
91  (ge->rFO == JS1_OPCODE && ge->rL1 == JS1_2NDCHAR && ge->JS1) ||
92  (ge->rFO == JS2_OPCODE && ge->rL1 == JS2_2NDCHAR && ge->JS2) ||
93  0);
94 }
95 
102 SIG(AF10) { return ge->register_selector == RS_V4; }
103 
105 SIG(AF20) { return ge->register_selector == RS_L3; }
106 
108 SIG(AF21) { return ge->register_selector == RS_L1; }
109 
111 SIG(AF30) { return ge->register_selector == RS_V3; }
112 
114 SIG(AF31) { return ge->register_selector == RS_V1; }
115 
117 SIG(AF32) { return ge->register_selector == RS_NORM; }
118 
120 SIG(AF40) { return ge->register_selector == RS_R1_L2; }
121 
123 SIG(AF41) { return ge->register_selector == RS_V1_SCR; }
124 
126 SIG(AF42) { return ge->register_selector == RS_PO; }
127 
129 SIG(AF43) { return ge->register_selector == RS_SO; }
130 
132 SIG(AF50) { return ge->register_selector == RS_V2; }
133 
135 SIG(AF51) { return ge->register_selector == RS_V1_LETT; }
136 
138 SIG(AF52) { return ge->register_selector == RS_FI_UR; }
139 
141 SIG(AF53) { return ge->register_selector == RS_FO; }
144 static inline uint16_t ge_counting_network_output(struct ge *ge) {
146  return ge->rBO + 1;
147  }
148  else {
149  return ge->rBO;
150  }
151 }
152 
165 static inline uint16_t NO_knot(struct ge *ge)
166 {
167  uint16_t no = 0;
168 
169  switch (ge->kNO.cmd) {
170  case KNOT_PO_IN_NO: no = ge->rPO; break;
171  case KNOT_V1_IN_NO: no = ge->rV1; break;
172  case KNOT_V2_IN_NO: no = ge->rV2; break;
173  case KNOT_V3_IN_NO: no = ge->rV3; break;
174  case KNOT_V4_IN_NO: no = ge->rV4; break;
175  case KNOT_L1_IN_NO: no = ge->rL1; break;
176  case KNOT_L2_IN_NO: no = ge->rL2; break;
177  case KNOT_L3_IN_NO: no = ge->rL3; break;
178  case KNOT_AM_IN_NO: no = ge->console_switches.AM; break;
179  case KNOT_RI_IN_NO_43: no = ge->rRI << 8; break;
180  }
181 
182  switch (ge->kNO.force_mode) {
183  case KNOT_FORCING_NONE: break;
184  case KNOT_FORCING_NO_21: no = (no & 0x00ff) | (ge->kNO.forcings << 0); break;
185  case KNOT_FORCING_NO_43: no = (no & 0xff00) | (ge->kNO.forcings << 8); break;
186  }
187 
188  return no;
189 }
190 
209 static inline uint8_t NA_knot(struct ge *ge) {
210  uint8_t na = 0;
211 
212  if (RES0(ge) || (RIUC(ge) && AF32(ge)))
213  na = ge->rSO;
214 
215  if (RES2(ge))
216  na = ge->rSI & 0x0f;
217 
218  if (RES0(ge) || RES3(ge))
219  na = na | 0x01;
220 
221  if (RIUC(ge) && !AF32(ge))
222  na = na | 0x08;
223 
224  return na;
225 }
226 
227 static inline uint8_t NI_source(struct ge *ge, enum knot_ni_source source) {
228  uint16_t cn = ge_counting_network_output(ge);
229 
230  switch (source) {
231  case NS_CN1: return (cn & 0x000f) >> 0;
232  case NS_CN2: return (cn & 0x00f0) >> 4;
233  case NS_CN3: return (cn & 0x0f00) >> 8;
234  case NS_CN4: return (cn & 0xf000) >> 12;
235  case NS_RO1: return (ge->rRO & 0x0f) >> 0;
236  case NS_RO2: return (ge->rRO & 0xf0) >> 4;
237  case NS_UA2: return 0;
238  case NS_UA1: return 0;
239  }
240 }
241 
263 static inline uint16_t NI_knot(struct ge *ge) {
264  uint16_t ni1 = NI_source(ge, ge->kNI.ni1);
265  uint16_t ni2 = NI_source(ge, ge->kNI.ni2);
266  uint16_t ni3 = NI_source(ge, ge->kNI.ni3);
267  uint16_t ni4 = NI_source(ge, ge->kNI.ni4);
268 
269  return ((ni4 << 12) |
270  (ni3 << 8) |
271  (ni2 << 4) |
272  (ni1 << 0));
273 }
274 
282 SIG(DI01A) { return !(BIT(ge->rSA, 0) && !BIT(ge->rSA, 1)); }
283 SIG(DI011) { return !DI01A(ge); }
284 SIG(DI02A) { return !(BIT(ge->rSA, 0) && BIT(ge->rSA, 1)); }
285 SIG(DI021) { return !DI02A(ge); }
286 SIG(DI03A) { return !(BIT(ge->rSA, 0) && BIT(ge->rSA, 1)); }
287 SIG(DI031) { return !DI03A(ge); }
288 SIG(DI06A) { return !(!BIT(ge->rSA, 7) && BIT(ge->rSA, 6) && BIT(ge->rSA, 2)); }
289 SIG(DI062) { return !DI06A(ge); }
290 SIG(DI10A) { return !(BIT(ge->rSA, 7) && BIT(ge->rSA, 6) && BIT(ge->rSA, 5) && !BIT(ge->rSA, 4)); }
291 SIG(DI101) { return !DI10A(ge); }
292 SIG(DI11A) { return !(BIT(ge->rSA, 3) && DI101(ge) && !BIT(ge->rSA, 2)); }
293 SIG(DI111) { return !DI11A(ge); }
294 SIG(DI12A) { return !(!BIT(ge->rSA, 3) && DI101(ge)); }
295 SIG(DI121) { return !DI12A(ge); }
296 SIG(DI14A) { return !(BIT(ge->rSA, 7) && !BIT(ge->rSA, 5) && BIT(ge->rSA, 6)); }
297 SIG(DI141) { return !DI14A(ge); }
298 SIG(DI15A) { return !(DI141(ge) && !BIT(ge->rSA, 3)); }
299 SIG(DI151) { return !DI15A(ge); }
300 SIG(DI17A) { return !(!BIT(ge->rSA, 1) && DI121(ge) && !BIT(ge->rSA, 2)); }
301 SIG(DI18A) { return !(!BIT(ge->rSA, 2) && DI121(ge) && BIT(ge->rSA, 1)); }
302 SIG(DI181) { return !DI18A(ge); }
303 SIG(DI18B) { return !DI181(ge); }
304 SIG(DI19A) { return !(!BIT(ge->rSA, 1) && DI121(ge) && BIT(ge->rSA, 2)); }
305 SIG(DI20A) { return !(BIT(ge->rSA, 1) && BIT(ge->rSA, 2) && DI121(ge)); }
306 SIG(DI201) { return DI20A(ge); }
307 SIG(DI21A) { return !( DI141(ge) && BIT(ge->rSA, 4) && BIT(ge->rSA, 3) && !BIT(ge->rSA, 2)); }
308 SIG(DI211) { return !DI21A(ge); }
309 SIG(DI22A) { return !(DI141(ge) && BIT(ge->rSA, 4) && BIT(ge->rSA, 3) && BIT(ge->rSA, 2)); }
310 SIG(DI23A) { return !(DI141(ge) && BIT(ge->rSA, 3) && !BIT(ge->rSA, 4)); }
311 SIG(DI231) { return !DI23A(ge); }
312 SIG(DI24A) { return !(DI231(ge) && BIT(ge->rSA, 2)); };
313 SIG(DI25A) { return !( DI231(ge) && !BIT(ge->rSA, 1) && !BIT(ge->rSA, 2)); };
314 SIG(DI27A) { return !(!BIT(ge->rSA, 4) && !BIT(ge->rSA, 6) && BIT(ge->rSA, 7)); }
315 SIG(DI271) { return !DI27A(ge); }
316 SIG(DI28A) { return !(DI271(ge) && !BIT(ge->rSA, 5)); }
317 SIG(DI281) { return !DI28A(ge); }
318 SIG(DI28B) { return !DI281(ge); }
319 SIG(DI29A) { return !(DI271(ge) && BIT(ge->rSA, 5) && BIT(ge->rSA, 3)); };
320 SIG(DI291) { return !DI29A(ge); }
321 SIG(DI48A) { return !(!BIT(ge->rSA, 4) && !BIT(ge->rSA, 5) && !BIT(ge->rSA, 6) && !BIT(ge->rSA, 7)); }
322 SIG(DI481) { return !DI48A(ge); }
323 SIG(DI58A) { return !(BIT(ge->rSA, 3) && !BIT(ge->rSA, 6)); }
324 SIG(DI581) { return !DI58A(ge); }
325 SIG(DI69A) { return !(DI481(ge) && !BIT(ge->rSA, 2)); }
326 SIG(DI691) { return !DI69A(ge); }
327 SIG(DI57A) { return !(!BIT(ge->rSA, 1) && DI581(ge) && DI691(ge)); }
328 SIG(DI572) { return !DI57A(ge); }
329 SIG(DI57B) { return DI57A(ge) ; }
330 SIG(DI79A) { return !(DI151(ge) && DI021(ge)); }
331 SIG(DI82A) { return 0; } // TODO: MISSING MANUAL PAGE!!
332 SIG(DI83A) { return 1; } // TODO: MISSING MANUAL PAGE!!
333 SIG(DI84A) { return !(DI011(ge) && DI291(ge)); }
334 SIG(DI85A) { return !(DI291(ge) && DI031(ge)); }
335 SIG(DI86A) { return !(!BIT(ge->rSA, 0) && DI291(ge)); }
336 SIG(DI87A) { return !(!BIT(ge->rSA, 1) && DI291(ge)); }
337 SIG(DI91A) { return !(DI031(ge) && DI211(ge)); }
338 SIG(DI931) { return !(DI21A(ge) && DI29A(ge) && DI21A(ge) && DI15A(ge)); }
339 SIG(DI93A) { return !DI931(ge); }
340 SIG(DI94A) { return !(BIT(ge->rSA, 0) && DI931(ge)); }
341 SIG(DI95A) { return !(DI931(ge) && DI031(ge)); }
342 SIG(DI971) { return !(DI29A(ge) && DI25A(ge) && DI24A(ge) && DI29A(ge)); }
343 SIG(DI97A) { return !DI971(ge); }
344 
345 SIG(DO01A) { return !(BIT(ge->rFO, 6) && !BIT(ge->rFO, 3) && !BIT(ge->rFO, 7)); }
346 SIG(DO011) { return !DO01A(ge); }
347 SIG(DO02A) { return !(BIT(ge->rFO, 3) && !BIT(ge->rFO, 7) && BIT(ge->rFO, 6)); }
348 SIG(DO021) { return !(DO02A(ge) && DO02A(ge)); }
349 SIG(DO04A) { return !(!BIT(ge->rFO, 5) && BIT(ge->rFO, 7)); }
350 SIG(DO041) { return !DO04A(ge); }
351 SIG(DO07A) { return !(!BIT(ge->rFO, 0) && !BIT(ge->rFO, 6) && DO041(ge)); }
352 SIG(DO071) { return !DO07A(ge); }
353 
354 // TODO: doesn't work for nop/lon/loff ecc
355 SIG(DE00A) { return 0; !(DO011(ge) && DI062(ge)); }
356 SIG(DE001) { return !DE00A(ge); }
357 SIG(DE07A) { return !(DO071(ge) && DI062(ge)); }
358 SIG(DE23A) { return !(DE001(ge) && BIT(ge->rFO, 4) && BIT(ge->rL1, 5)); }
359 SIG(DE231) { return !(DE23A(ge) && DE23A(ge)); }
360 
361 SIG(DA25A) { return !(DI111(ge) && DO021(ge)); }
362 
363 SIG(PC011); SIG(PC111); SIG(PC211);
364 SIG(DU161) { return !(BIT(ge->rSA, 1) && PC111(ge) && PC211(ge) && PC111(ge)); }
365 SIG(DU18A) { return !(ge->RIG3 && BIT(ge->rL2, 7)); }
366 SIG(DU19A) { return !(ge->RIG1 && PC011(ge) && !ge->RACI); }
367 SIG(DU201) { return !(DU18A(ge) && DU19A(ge)); }
368 SIG(EC56A) { return !(DI201(ge) && BIT(ge->rL2, 7)); }
369 SIG(EC69A) { return !(AF41(ge) && DI572(ge));}
370 SIG(EC70A) { return !(AF51(ge) && DI572(ge)); }
371 SIG(ED70A) { return !(!ge->AINI && DI971(ge)); }
372 SIG(ED75A) { return !(ge->AINI && DI011(ge) && DI291(ge)); }
373 SIG(ED79A) { return !(DI291(ge) && DU161(ge) && BIT(ge->rSA, 0)); }
374 SIG(ED91A) { return !(DE231(ge) && DU201(ge)); }
375 
376 SIG(DE00A0) { return !DE00A(ge); }
377 SIG(DE07A0) { return !DE07A(ge); }
378 SIG(DE08A0) { return !(!BIT(ge->rFO, 1) && DI062(ge) && DO071(ge)); }
379 
380 SIG(DA25A0) { return !DA25A(ge); }
381 SIG(DI11A0) { return !DI11A(ge); }
382 SIG(DI12A0) { return !DI12A(ge); }
383 SIG(DI17A0) { return !DI17A(ge); }
384 SIG(DI18A0) { return !DI18A(ge); }
385 SIG(DI18B0) { return !DI18B(ge); }
386 SIG(DI19A0) { return !DI19A(ge); }
387 SIG(DI20A0) { return !DI20A(ge); }
388 SIG(DI21A0) { return !DI21A(ge); }
389 SIG(DI22A0) { return !DI22A(ge); }
390 SIG(DI24A0) { return !DI24A(ge); }
391 SIG(DI25A0) { return !DI25A(ge); }
392 SIG(DI28A0) { return !DI28A(ge); }
393 SIG(DI28B0) { return !DI28B(ge); }
394 SIG(DI29A0) { return !DI29A(ge); }
395 SIG(DI57A0) { return !DI57A(ge); }
396 SIG(DI57B0) { return !DI57B(ge); }
397 SIG(DI60A0) { return 1; } // TODO: Missing page in manual (!)
398 SIG(DI79A0) { return !DI79A(ge); }
399 SIG(DI82A0) { return !DI82A(ge); }
400 SIG(DI83A0) { return !DI83A(ge); }
401 SIG(DI84A0) { return !DI84A(ge); }
402 SIG(DI85A0) { return !DI85A(ge); }
403 SIG(DI86A0) { return !DI86A(ge); }
404 SIG(DI87A0) { return !DI87A(ge); }
405 SIG(DI91A0) { return !DI91A(ge); }
406 SIG(DI93A0) { return !DI93A(ge); }
407 SIG(DI94A0) { return !DI94A(ge); }
408 SIG(DI95A0) { return !DI95A(ge); }
409 SIG(DI97A0) { return !DI97A(ge); }
410 
411 SIG(EC56A0) { return !EC56A(ge); }
412 SIG(EC69A0) { return !EC69A(ge); }
413 SIG(EC70A0) { return !EC70A(ge); }
414 SIG(ED70A0) { return !ED70A(ge); }
415 SIG(ED75A0) { return !ED75A(ge); }
416 SIG(ED79A0) { return !ED79A(ge); }
417 SIG(ED91A0) { return !ED91A(ge); }
418 
426 /* MC */
427 SIG(AITE) { return ge->console_switches.SITE; }
428 SIG(AITEA) { return !AITE(ge); }
429 
430 /* RI */
431 SIG(LU081) { return reader_get_LU08(ge); }
432 SIG(LUPO1) { return reader_get_LUPO1(ge); }
433 SIG(FINI1) { return reader_get_FINI1(ge); }
434 
435 /* PI */
436 SIG(FUSE1) { return 0; }
437 SIG(FINA1) { return 0; }
438 
439 /* ST3 */
440 SIG(MARE3) { return connector_get_MARE(&ge->ST3); }
441 SIG(TE103) { return connector_get_TE10(&ge->ST3); }
442 SIG(TE203) { return connector_get_TE20(&ge->ST3); }
443 SIG(TE303) { return connector_get_TE30(&ge->ST3); }
444 SIG(FINE3) { return connector_get_FINE(&ge->ST3); }
445 
446 /* ST4 */
447 SIG(MARE4) { return connector_get_MARE(&ge->ST4); }
448 SIG(TE104) { return connector_get_TE10(&ge->ST4); }
449 SIG(TE204) { return connector_get_TE20(&ge->ST4); }
450 SIG(TE304) { return connector_get_TE30(&ge->ST4); }
451 SIG(FINE4) { return connector_get_FINE(&ge->ST4); }
452 
455 SIG(PC111); SIG(PC131); SIG(PC141); SIG(PC121);
456 
457 SIG(PB11A) { return !(FINA1(ge) && PC111(ge)); }
458 SIG(PB13A) { return !(TE303(ge) && PC131(ge)); }
459 SIG(PB14A) { return !(TE304(ge) && PC141(ge)); }
460 
461 SIG(RT121) { /* UNIV 1.2µs */ return ge->RT121; }
462 SIG(RT131) { /* UNIV 1.2µs */ return ge->RT131; }
463 
464 SIG(RB101) { return !(AITEA(ge) && PB11A(ge) && PB13A(ge) && PB14A(ge)); }
465 SIG(RB121) { /* UNIV 1.2µs */ return RB101(ge); }
466 SIG(RB12A) { return !RB121(ge); }
467 SIG(RB01A) { return !(RT121(ge) && RB101(ge)); }
468 SIG(RB111) { return !(RB12A(ge) && RB01A(ge)); }
469 
470 SIG(PF12A) { return !(FINI1(ge) && PC121(ge)); }
471 SIG(PF13A) { return !(FINE3(ge) && PC131(ge)); }
472 SIG(PF14A) { return !(FINE4(ge) && PC141(ge)); }
473 SIG(RF101) { return !(PF12A(ge) && PF13A(ge) && PF14A(ge)); }
474 
483 SIG(PC11A); SIG(PC12A); SIG(PC13A); SIG(PC14A);
484 
485 SIG(PC111) { return !PC11A(ge); };
487 SIG(PC121) { return !PC12A(ge); };
488 SIG(PC131) { return !PC13A(ge); };
489 SIG(PC141) { return !PC14A(ge); };
490 
491 SIG(RUF11) { return ge->RUF1; }
492 SIG(RUF1A) { return !ge->RUF1; }
493 SIG(RASI1) { return ge->RASI; }
494 SIG(TO501) { return ge->current_clock == TO50; }
495 
496 SIG(PELEA) { return !(LU081(ge) && LUPO1(ge)); }
497 SIG(RELO1) { return !(PELEA(ge) && RUF1A(ge)); }
498 SIG(PAM4A) { return !(RELO1(ge) && RASI1(ge) && PC121(ge)); }
499 SIG(PM11A) { return !(FUSE1(ge) && PC111(ge)); }
500 SIG(PM13A) { return !(MARE3(ge) && PC131(ge)); }
501 SIG(PM14A) { return !(MARE4(ge) && PC141(ge)); }
502 SIG(RM101) { return !(PM11A(ge) && PM13A(ge) && PM14A(ge)); }
503 SIG(PAM1A) { return !(RASI1(ge) && RM101(ge)); }
504 SIG(RS011) { return !(PAM4A(ge) && PAM1A(ge)); }
505 SIG(PIM1A) { return !(TO501(ge) || RS011(ge) || RB111(ge) || RUF11(ge)); }
506 SIG(PIM11) { return !PIM1A(ge); }
507 SIG(PIC1A) { return !ge->PIC1; }
508 SIG(PUC11) { return !(PIC1A(ge) && PIM1A(ge)); }
509 SIG(PUC1) { return PUC11(ge); }
510 
511 /* !(channel 2 non overlap) */
512 SIG(PC01A) { return !(!BIT(ge->rL2, 3) && !BIT(ge->rL2, 0)); }
514 SIG(PC011) { return !PC01A(ge); }
515 
516 /* !(channel2 overlapped) */
517 SIG(PC03A) { return !(!BIT(ge->rL2, 0) && BIT(ge->rL2, 3)); }
519 SIG(PC031) { return !PC03A(ge); }
520 
523 SIG(PUC26) { return ge->PUC2; }
524 SIG(PUC36) { return ge->PUC3; }
525 
534 SIG(PB061) { return ge->PB06; }
535 SIG(PB06A) { return !ge->PB06; }
536 SIG(PB071) { return ge->PB07; }
537 SIG(PB07A) { return !ge->PB07; }
538 SIG(PB261) { return ge->PB26; }
539 SIG(PB26A) { return !ge->PB26; }
540 SIG(PB361) { return ge->PB36; }
541 SIG(PB36A) { return !ge->PB36; }
542 SIG(PB371) { return ge->PB37; }
543 SIG(PB37A) { return !ge->PB37; }
544 SIG(PUC21) { return ge->PUC2; }
545 SIG(PUC2A) { return !ge->PUC2; }
546 SIG(PUC31) { return ge->PUC3; }
547 SIG(PUC3A) { return !ge->PUC3; }
548 
549 SIG(PC11A) { return !(PUC11(ge) && PB071(ge) && PB061(ge)); }
550 SIG(PC12A) { return !(PUC11(ge) && PB071(ge) && PB06A(ge)); }
551 SIG(PC13A) { return !(PUC11(ge) && PB07A(ge) && PB06A(ge)); }
552 SIG(PC14A) { return !(PUC11(ge) && PB07A(ge) && PB061(ge)); }
553 SIG(PC21A) { return !(PUC21(ge) && PB261(ge)); }
554 SIG(PC22A) { return !(PUC21(ge) && PB26A(ge)); }
555 SIG(PC31A) { return !(PUC31(ge) && PB371(ge) && PB361(ge)); }
556 SIG(PC32A) { return !(PUC31(ge) && PB371(ge) && PB36A(ge)); }
557 SIG(PC33A) { return !(PUC31(ge) && PB37A(ge) && PB36A(ge)); }
558 SIG(PC34A) { return !(PUC31(ge) && PB37A(ge) && PB361(ge)); }
559 
560 SIG(SEPEI) { return !(PC11A(ge) && PC21A(ge) && PC31A(ge)); }
561 SIG(PU002) { return !(PC12A(ge) && PC22A(ge) && PC32A(ge)); }
562 SIG(PU003) { return !(PC13A(ge) && PC33A(ge)); }
563 SIG(PU004) { return !(PC14A(ge) && PC34A(ge)); }
564 
565 SIG(PUB01_d1) { return !(SEPEI(ge) && BIT(ge->rL1, 7) && BIT(ge->rL1, 6)); }
566 SIG(PUB01_d2) { return !(PU002(ge) && BIT(ge->rL1, 7) && BIT(ge->rL1, 6)); }
567 SIG(PUB01_d3) { return !(PU003(ge) && BIT(ge->rL1, 7) && BIT(ge->rL1, 6)); }
568 SIG(PUB01_d4) { return !(PU004(ge) && BIT(ge->rL1, 7) && BIT(ge->rL1, 6)); }
569 
571 SIG(PUB01) { return !(PUB01_d1(ge) && PUB01_d2(ge) && PUB01_d3(ge) && PUB01_d4(ge)); }
572 
574 SIG(PC211) { return !PC21A(ge); }
575 
576 SIG(PC321) { return !PC32A(ge); }
577 SIG(PC331) { return !PC33A(ge); }
578 SIG(PC341) { return !PC34A(ge); }
579 
582 /* !(!rejected && in transfer) => rejected || !in_transfer */
583 SIG(DU871) { return !(!ge->RACI && ge->RASI); }
584 /* for state b8, FA is set if L200 && L203, which is channel 2 in overlap */
585 /* !(channel2 in overlap && channel2 in transfer */
586 SIG(DU881) { return !(BIT(ge->ffFA, 2) && ge->PUC2); }
587 
588 SIG(DU89A) { return !(DU871(ge) && DU881(ge) && PC011(ge) && DU881(ge)); }
589 
590 SIG(DU90A) { return !(PUC26(ge) && !BIT(ge->rRO, 0)); }
591 SIG(DU91A) { return !(BIT(ge->rRO, 0) && !BIT(ge->rRO, 3) && PUC36(ge)); }
592 
594 SIG(DU92) { return !(DU90A(ge) && DU91A(ge)); }
595 
596 SIG(DU93A) { return !(BIT(ge->rL2, 7) && BIT(ge->rL2, 5)); }
597 
599 SIG(DU93) { return !DU93A(ge); }
600 
601 SIG(DU95A) { return !(!BIT(ge->rRO, 1) && !BIT(ge->rRO, 2) && BIT(ge->rRO, 6)); }
602 SIG(DU95) { return !DU95A(ge); }
603 
604 SIG(DU96A) { return !(BIT(ge->rL2, 7) && BIT(ge->rL2, 7)); }
605 SIG(DU96) { return !DU96A(ge); }
606 
607 SIG(DU97A) { return !(ge->PUC2 ^
608  BIT(ge->rL2, 0) ^
609  BIT(ge->rL2, 0) ^
610  BIT(ge->rL2, 3)); }
611 
612 SIG(DU97) { return !DU97A(ge); }
613 
614 SIG(DU98) { return !(DU89A(ge) && PC03A(ge)); }
615 
616 /* RI outgoing */
617 SIG(TU00A) { return !(RT121(ge) && RUF1A(ge) && PC121(ge));}
618 
627 SIG(FU091) { return 0; } /* todo: printer */
628 
629 SIG(PTA3A) { return !(TE103(ge) && TE203(ge)); }
630 SIG(PTA31) { return !PTA3A(ge); }
631 
632 SIG(PTA4A) { return !(TE104(ge) && TE204(ge)); }
633 SIG(PTA41) { return !PTA4A(ge); }
634 
635 SIG(PA11A) { return !(FU091(ge) && PC111(ge)); }
636 SIG(PA12A) { return !(LU081(ge) && PC121(ge)); }
637 SIG(PA13A) { return !(PTA31(ge) && PC131(ge)); }
638 SIG(PA14A) { return !(PTA41(ge) && PC141(ge)); }
639 SIG(RA101) { return !(PA11A(ge) && PA12A(ge) && PA13A(ge) && PA13A(ge) && PA14A(ge)); }
640 
641 /* } */
642 
643 SIG(RET21) { return 0; };
644 SIG(PC221) { return 0; };
645 
654 SIG(PIB1A) { return !(RET21(ge) && PC211(ge)); }
655 SIG(PIB11) { return !PIB1A(ge); }
656 
657 SIG(PB12A) { return !(RESI1(ge) && PC121(ge)); }
658 SIG(PB22A) { return !(RET21(ge) && PC221(ge)); }
659 SIG(PB32A) { return !(RES31(ge) && PC321(ge)); }
660 SIG(PIB21) { return !(PB12A(ge) && PB22A(ge) && PB32A(ge)); }
661 
662 SIG(RB13A) { return !(RESI1(ge) && PC131(ge)); }
663 SIG(RB33A) { return !(RES31(ge) && PC331(ge)); }
664 SIG(PIB31) { return !(RB13A(ge) && RB33A(ge)); }
665 
666 SIG(RB14A) { return !(RESI1(ge) && PC141(ge)); }
667 SIG(RB34A) { return !(RES31(ge) && PC341(ge)); }
668 SIG(PIB41) { return !(RB14A(ge) && RB34A(ge)); }
669 
678 static inline uint16_t NE_knot(struct ge *ge) {
679  uint16_t ret = 0;
680  const char *where = "";
681 
682  uint8_t count = PIB11(ge) + PIB21(ge) + PIB31(ge) + PIB41(ge);
683 
684  if (count > 1) {
685  ge_log(LOG_PERI, "multiple input signals for NE knot (?!)\n");
686  }
687 
688  if (PIB11(ge)) {
689  where = "PI";
690  ge_log(LOG_PERI, "TODO -- printer\n");
691  }
692 
693  if (PIB21(ge)) {
694  where = "RI";
695  ret = ge->integrated_reader.data;
696  }
697 
698  if (PIB31(ge)) {
699  where = "ST3";
700  ret = ge->ST3.data;
701  }
702 
703  if (PIB41(ge)) {
704  where = "ST4";
705  ret = ge->ST3.data;
706  }
707 
708  ge_log(LOG_PERI, "READING FROM NE KNOT %s --> %03x\n", where, ret);
709  return ret;
710 }
711 
712 /* } */
713 
722 #define NAOR(a, b, c, d) !(a || b || c || d)
723 
724 SIG(RT111) { return 0; }
725 
726 SIG(RT311) { return 0; }
727 SIG(RT321) { return 0; }
728 SIG(RT331) { return 0; }
729 
730 SIG(RATE1) { return 0; }
731 SIG(PUOO3) { return 0; }
732 SIG(RUF31) { return 0; }
733 SIG(RAVI1) { return 0; }
734 
735 SIG(TU10C) { return NAOR(RT111(ge), PC131(ge), RT311(ge), PC331(ge)); }
736 SIG(TU20C) { return NAOR(RT121(ge), PC131(ge), RT321(ge), PC331(ge)); }
737 SIG(TU30C) { return NAOR(RT131(ge), PC131(ge), RT331(ge), PC331(ge)); }
738 SIG(AEBEC) { return !(RATE1(ge) && PC131(ge)); }
739 SIG(AECO3) { return !PUOO3(ge); }
740 SIG(FINUC) { return NAOR(RUF11(ge), PC131(ge), RUF31(ge), PC331(ge)); }
741 SIG(PV13A) { return !(RAVI1(ge) && PC131(ge)); }
742 SIG(VICU3) { return !(FINUC(ge) && PV13A(ge)); }
743 /* } */
744 
745 #endif
Bit manipulation helpers.
#define BIT(V, X)
Definition: bit.h:9
@ RS_FI_UR
Definition: console.h:20
@ RS_V1_SCR
Definition: console.h:16
@ RS_SO
Definition: console.h:21
@ RS_R1_L2
Definition: console.h:12
@ RS_PO
Definition: console.h:19
@ RS_V1_LETT
Definition: console.h:17
@ RS_V1
Definition: console.h:15
@ RS_L1
Definition: console.h:14
@ RS_V3
Definition: console.h:11
@ RS_NORM
Definition: console.h:18
@ RS_L3
Definition: console.h:10
@ RS_FO
Definition: console.h:22
@ RS_V4
Definition: console.h:9
@ RS_V2
Definition: console.h:13
knot_ni_source
Definition: ge.h:72
@ NS_RO1
Definition: ge.h:77
@ NS_UA1
Definition: ge.h:80
@ NS_UA2
Definition: ge.h:79
@ NS_CN1
Definition: ge.h:73
@ NS_CN2
Definition: ge.h:74
@ NS_CN4
Definition: ge.h:76
@ NS_CN3
Definition: ge.h:75
@ NS_RO2
Definition: ge.h:78
#define NAOR(a, b, c, d)
Definition: signals.h:722
static uint16_t NI_knot(struct ge *ge)
NI Knot.
Definition: signals.h:263
static uint8_t NI_source(struct ge *ge, enum knot_ni_source source)
Definition: signals.h:227
static uint16_t NO_knot(struct ge *ge)
Knot driven by P0, V1, V2, V4, L1, R1, V3 and L3.
Definition: signals.h:165
static uint8_t NA_knot(struct ge *ge)
Knot driven by SO or SI.
Definition: signals.h:209
static uint16_t NE_knot(struct ge *ge)
NE Knot.
Definition: signals.h:678
void ge_log(ge_log_type type, const char *format,...)
Log message.
Definition: log.c:31
@ LOG_PERI
Peripherals IO.
Definition: log.h:27
#define JS1_2NDCHAR
Definition: opcodes.h:36
#define JC_OPCODE
Definition: opcodes.h:39
#define JS2_OPCODE
Definition: opcodes.h:32
#define JS1_OPCODE
Definition: opcodes.h:35
#define JS2_2NDCHAR
Definition: opcodes.h:33
uint8_t reader_get_LUPO1(struct ge *ge)
Definition: reader.c:81
uint8_t connector_get_TE30(struct ge_connector *conn)
Definition: reader.c:111
uint8_t reader_get_LU08(struct ge *ge)
Definition: reader.c:68
uint8_t connector_get_MARE(struct ge_connector *conn)
Definition: reader.c:93
uint8_t reader_get_FINI1(struct ge *ge)
Definition: reader.c:87
uint8_t connector_get_TE10(struct ge_connector *conn)
Definition: reader.c:99
uint8_t connector_get_TE20(struct ge_connector *conn)
Definition: reader.c:105
uint8_t connector_get_FINE(struct ge_connector *conn)
Definition: reader.c:117
#define SIG(name)
Definition: signals.h:17
static uint16_t ge_counting_network_output(struct ge *ge)
Definition: signals.h:144
uint8_t data
Definition: reader.h:28
uint16_t SITE
Don't wait for external unit availability.
Definition: console.h:145
uint16_t AM
Forcing bits.
Definition: console.h:155
uint8_t from_zero
Definition: ge.h:44
struct ge_counting_network::cmds cmds
enum knot_ni_source ni4
Definition: ge.h:87
enum knot_ni_source ni2
Definition: ge.h:85
enum knot_ni_source ni1
Definition: ge.h:84
enum knot_ni_source ni3
Definition: ge.h:86
uint8_t forcings
Definition: ge.h:50
enum ge_knot_no::@1 cmd
enum ge_knot_no::@0 force_mode
The entire state of the emulated system, including registers, memory, peripherals and timings.
Definition: ge.h:94
uint8_t RT121
Definition: ge.h:499
uint8_t PB37
Definition: ge.h:342
uint8_t AINI
Program Loading.
Definition: ge.h:254
struct ge_integrated_reader integrated_reader
The I/O interface for the integrated reader (RI)
Definition: ge.h:535
uint8_t JS2
Console jump condition 2.
Definition: ge.h:332
struct ge_connector ST4
The I/O interface for the ST4 connector.
Definition: ge.h:545
uint8_t ffFA
Special conditions register 2.
Definition: ge.h:239
uint16_t rPO
Program addresser.
Definition: ge.h:111
uint8_t PIC1
Selection Channel 1.
Definition: ge.h:360
enum ge_console_rotary register_selector
The current state of the console register rotary switch.
Definition: ge.h:513
uint8_t RIA0
Synchronous CPU Cycle Request.
Definition: ge.h:462
uint8_t RIA2
Synchronous Channel 2 Cycle Request.
Definition: ge.h:476
uint16_t rV1
Addresser for the first operand.
Definition: ge.h:113
uint8_t rSO
Main sequencer.
Definition: ge.h:196
uint16_t rRO
Multipurpose 8+1 bit register.
Definition: ge.h:147
struct ge_counting_network counting_network
Definition: ge.h:530
struct ge_console_switches console_switches
The current state of the console switches.
Definition: ge.h:518
struct ge_connector ST3
The I/O interface for the ST3 connector.
Definition: ge.h:540
uint8_t RIA3
Synchronous Channel 3 Cycle Request.
Definition: ge.h:483
uint8_t PUC3
Channel 3 in transfer.
Definition: ge.h:381
uint8_t rL2
Auxiliary register.
Definition: ge.h:131
uint8_t PUC2
Channel 2 in transfer.
Definition: ge.h:374
uint8_t rRI
Photoprint register 8-bit register used to store the photodisc codes.
Definition: ge.h:122
uint16_t rBO
Default operator.
Definition: ge.h:164
uint8_t PB06
Unconditionally stores L106.
Definition: ge.h:338
struct ge_knot_ni kNI
Knot driven by counting network, or by the UA to store the result of the operation.
Definition: ge.h:140
uint8_t RACI
Rejected Command.
Definition: ge.h:494
uint8_t RT131
Definition: ge.h:500
uint16_t rV4
Addresser for external instructions using channel 2.
Definition: ge.h:116
uint8_t RASI
Channel 1 in transfer.
Definition: ge.h:367
uint16_t rL1
Length of the operand.
Definition: ge.h:130
uint8_t RUF1
Definition: ge.h:385
uint8_t rSA
Future state configuration.
Definition: ge.h:218
uint16_t rV2
Addresser for the second operand.
Definition: ge.h:114
uint8_t RESI
Synchronous Channel 1 Cycle Request.
Definition: ge.h:469
uint8_t RIG1
End from controller 1.
Definition: ge.h:489
uint8_t rSI
Peripheral unit sequencer.
Definition: ge.h:210
enum clock current_clock
Definition: ge.h:96
uint8_t PB26
Stores L106 if channel 2 is selected.
Definition: ge.h:340
uint16_t rL3
Length of operands involving channel 3.
Definition: ge.h:132
uint8_t PB07
Unconditionally stores L106.
Definition: ge.h:339
uint8_t RIG3
Definition: ge.h:491
uint16_t rV3
Addresser for external instructions using channel 3.
Definition: ge.h:115
uint8_t PB36
Definition: ge.h:341
struct ge_knot_no kNO
Definition: ge.h:134
uint8_t rFO
Current function code.
Definition: ge.h:171
uint8_t JS1
Console jump condition 1.
Definition: ge.h:331