GE-115 Emulator
An Emulator of the General Electrics GE-115 computer
ge.h
Go to the documentation of this file.
1 #ifndef GE_H
2 #define GE_H
3 
4 #include <stdint.h>
5 #include "opcodes.h"
6 #include "console.h"
7 #include "reader.h"
8 
9 #define CLOCK_PERIOD 14000 /* in usec, interval between pulse lines */
10 #define MEM_SIZE 65536
11 
12 #define ENUMERATE_CLOCKS \
13  X(TO00) \
14  X(TO10) \
15  X(TO11) \
16  X(TO15) \
17  X(TO19) \
18  X(TO20) \
19  X(TO25) \
20  X(TO30) \
21  X(TO40) \
22  X(TO50) \
23  X(TO50_1) \
24  X(TO60) \
25  X(TO64) \
26  X(TO65) \
27  X(TO70) \
28  X(TO80) \
29  X(TO89) \
30  X(TO90) \
31  X(TI05) \
32  X(TI06) \
33  X(TI10) \
34  X(END_OF_STATUS)
35 
36 enum clock {
37  #define X(name) name ,
39  #undef X
40 };
41 
43  struct cmds {
44  uint8_t from_zero:1;
45  uint8_t decresing:1;
46  } cmds;
47 };
48 
49 struct ge_knot_no {
50  uint8_t forcings;
51 
52  enum {
57 
58  enum {
69  } cmd;
70 };
71 
81 };
82 
83 struct ge_knot_ni {
84  enum knot_ni_source ni1;
85  enum knot_ni_source ni2;
86  enum knot_ni_source ni3;
87  enum knot_ni_source ni4;
88 };
89 
94 struct ge {
95  /* Main clock */
96  enum clock current_clock;
97  uint8_t halted;
98  uint8_t powered;
99 
100  /* Lists of events and operations for all
101  * pulses
102  */
103  struct pulse_event *on_pulse[END_OF_STATUS];
104 
111  uint16_t rPO;
112 
113  uint16_t rV1;
114  uint16_t rV2;
115  uint16_t rV3;
116  uint16_t rV4;
117 
122  uint8_t rRI;
123 
130  uint16_t rL1;
131  uint8_t rL2;
132  uint16_t rL3;
133 
134  struct ge_knot_no kNO;
135 
140  struct ge_knot_ni kNI;
141 
147  uint16_t rRO;
148 
155  uint16_t rVO;
156 
164  uint16_t rBO;
165 
171  uint8_t rFO;
172 
196  uint8_t rSO;
197 
210  uint8_t rSI;
211 
218  uint8_t rSA;
219 
220  uint8_t rRE;
221  uint8_t rRA;
222 
229  uint8_t ffFI;
230 
239  uint8_t ffFA;
240 
241  /* Those two store which work channel the present cycle as been attributed to
242  * (cpu fo. 130).
243  * When setting RETO, if PAPA switch is set, rotary is neither in normal, nor
244  * in position 8 to store in memory, should set ALTO */
245  uint8_t RETO:1;
246  uint8_t RET2:1;
247 
254  uint8_t AINI:1;
255 
261  uint8_t ALOI:1;
262 
269  uint8_t ALTO:1;
270 
277  uint8_t PODI:1;
278 
298  uint8_t ACIC:1;
299 
308  uint8_t ALAM:1;
309 
319  uint8_t AVER:1;
320 
327  uint8_t ADIR:1;
328 
329  uint8_t RINT:1;
330 
331  uint8_t JS1:1;
332  uint8_t JS2:1;
333  uint8_t JE:1;
334  uint8_t INTE:1;
335 
336  /* Busy Connector Logic */
337 
338  uint8_t PB06:1;
339  uint8_t PB07:1;
340  uint8_t PB26:1;
341  uint8_t PB36:1;
342  uint8_t PB37:1;
343 
360  uint8_t PIC1:1;
361 
367  uint8_t RASI:1;
368 
374  uint8_t PUC2:1;
375 
381  uint8_t PUC3:1;
382 
383  uint8_t PEC1:1;
384 
385  uint8_t RUF1:1;
386 
387  uint8_t URPE:1;
388  uint8_t URPU:1;
389 
390  /* Cycle Attribution Logic */
391  /* ----------------------- */
392 
393  /* Asyncronous flip flops */
394 
407  uint8_t RC00:1;
408 
420  uint8_t RC01:1;
421 
435  uint8_t RC02:1;
436 
450  uint8_t RC03:1;
451 
462  uint8_t RIA0:1;
463 
469  uint8_t RESI:1;
470 
476  uint8_t RIA2:1;
477 
483  uint8_t RIA3:1;
484 
486  uint8_t RECE:1;
487 
489  uint8_t RIG1:1;
490 
491  uint8_t RIG3:1;
492 
494  uint8_t RACI:1;
495 
497  uint8_t RAVI:1;
498 
499  uint8_t RT121:1;
500  uint8_t RT131:1;
501 
508  uint8_t future_state;
509 
514 
519 
520  uint8_t step_by_step:1;
521 
522  enum {
527 
528  uint8_t mem[MEM_SIZE];
529 
531 
536 
540  struct ge_connector ST3;
541 
545  struct ge_connector ST4;
546 
547  struct ge_peri *peri;
548 
561 };
562 
564 void ge_init(struct ge *ge);
565 
567 int ge_deinit(struct ge *ge);
568 
570 int ge_load_program(struct ge *ge, uint8_t *program, uint8_t size);
571 
573 int ge_run(struct ge *ge);
574 
576 int ge_run_pulse(struct ge *ge);
577 
579 int ge_run_cycle(struct ge *ge);
580 
582 void ge_clear(struct ge * ge);
583 
585 void ge_load(struct ge * ge);
586 
588 void ge_load_1(struct ge * ge);
589 
591 void ge_load_2(struct ge * ge);
592 
594 void ge_start(struct ge * ge);
595 
596 typedef void (*on_pulse_cb)(struct ge *);
597 
598 struct pulse_event {
600  struct pulse_event *next;
601 };
602 
603 /* Defined in pulse.c: execute pulse events */
604 void pulse(struct ge *ge);
605 
606 struct ge_peri {
607  struct ge_peri *next;
608  int (*init)(struct ge*, void*);
609  int (*on_pulse)(struct ge*, void*);
610  int (*on_clock)(struct ge*, void*);
611  int (*deinit)(struct ge*, void*);
612  void *ctx;
613 };
614 
615 int ge_register_peri(struct ge *ge, struct ge_peri *p);
616 
624 void fsn_last_clock(struct ge *ge);
625 
626 void connectors_first_clock(struct ge *ge);
627 
633 const char *ge_clock_name(enum clock c);
634 
635 void ge_print_registers_verbose(struct ge *ge);
636 
637 #endif /* GE_H */
ge_console_rotary
Definition: console.h:8
int ge_deinit(struct ge *ge)
Deinitialize the emulator.
Definition: ge.c:234
void ge_load_1(struct ge *ge)
Emulate the press of the "load 1" button in the console.
Definition: ge.c:72
void ge_clear(struct ge *ge)
Emulate the press of the "clear" button in the console.
Definition: ge.c:25
#define MEM_SIZE
Definition: ge.h:10
#define ENUMERATE_CLOCKS
Definition: ge.h:12
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
int ge_run(struct ge *ge)
Run the emulator.
int ge_run_cycle(struct ge *ge)
Run all GE "mastri" clock periods until next clock cycle.
Definition: ge.c:223
void ge_load_2(struct ge *ge)
Emulate the press of the "load 2" button in the console.
Definition: ge.c:89
void(* on_pulse_cb)(struct ge *)
Definition: ge.h:596
void ge_init(struct ge *ge)
Initialize the emulator.
Definition: ge.c:14
int ge_run_pulse(struct ge *ge)
Run a single pulse (i.e. a single GE "mastri" clock periods)
Definition: ge.c:177
void fsn_last_clock(struct ge *ge)
Commit the future state.
Definition: ge.c:248
int ge_register_peri(struct ge *ge, struct ge_peri *p)
Definition: peripherical.c:55
void ge_print_registers_verbose(struct ge *ge)
Definition: ge.c:143
void pulse(struct ge *ge)
Definition: pulse.c:180
void ge_load(struct ge *ge)
Emulate the press of the "load" button in the console.
Definition: ge.c:62
int ge_load_program(struct ge *ge, uint8_t *program, uint8_t size)
Copy a program at the start of memory.
Definition: ge.c:49
const char * ge_clock_name(enum clock c)
The clock period name name.
Definition: ge.c:120
void connectors_first_clock(struct ge *ge)
Definition: ge.c:240
clock
Definition: ge.h:36
void ge_start(struct ge *ge)
Emulate the press of the "start" button in the console.
Definition: ge.c:94
Console switches.
Definition: console.h:71
uint8_t from_zero
Definition: ge.h:44
uint8_t decresing
Definition: ge.h:45
struct ge_counting_network::cmds cmds
Definition: ge.h:83
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
Definition: ge.h:49
@ KNOT_FORCING_NO_43
Definition: ge.h:55
@ KNOT_FORCING_NONE
Definition: ge.h:53
@ KNOT_FORCING_NO_21
Definition: ge.h:54
uint8_t forcings
Definition: ge.h:50
enum ge_knot_no::@1 cmd
@ KNOT_PO_IN_NO
Definition: ge.h:59
@ KNOT_V3_IN_NO
Definition: ge.h:62
@ KNOT_AM_IN_NO
Definition: ge.h:67
@ KNOT_V4_IN_NO
Definition: ge.h:63
@ KNOT_V1_IN_NO
Definition: ge.h:60
@ KNOT_L3_IN_NO
Definition: ge.h:66
@ KNOT_L2_IN_NO
Definition: ge.h:65
@ KNOT_V2_IN_NO
Definition: ge.h:61
@ KNOT_RI_IN_NO_43
Definition: ge.h:68
@ KNOT_L1_IN_NO
Definition: ge.h:64
enum ge_knot_no::@0 force_mode
Definition: ge.h:606
int(* on_pulse)(struct ge *, void *)
Definition: ge.h:609
void * ctx
Definition: ge.h:612
struct ge_peri * next
Definition: ge.h:607
int(* init)(struct ge *, void *)
Definition: ge.h:608
int(* deinit)(struct ge *, void *)
Definition: ge.h:611
int(* on_clock)(struct ge *, void *)
Definition: ge.h:610
The entire state of the emulated system, including registers, memory, peripherals and timings.
Definition: ge.h:94
uint8_t ALAM
Operator Call.
Definition: ge.h:308
uint8_t RET2
Definition: ge.h:246
uint8_t RINT
Definition: ge.h:329
uint8_t INTE
Interruption present.
Definition: ge.h:334
uint8_t ALOI
Load connector selection.
Definition: ge.h:261
uint8_t RT121
Definition: ge.h:499
uint8_t rRA
Definition: ge.h:221
uint8_t PB37
Definition: ge.h:342
uint8_t rRE
Definition: ge.h:220
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 ALTO
Stops internal cycles.
Definition: ge.h:269
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
uint8_t future_state
Future state.
Definition: ge.h:508
uint8_t PODI
Slow delay line.
Definition: ge.h:277
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
uint8_t PEC1
Definition: ge.h:383
uint16_t rV1
Addresser for the first operand.
Definition: ge.h:113
uint8_t rSO
Main sequencer.
Definition: ge.h:196
uint8_t halted
Definition: ge.h:97
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 powered
Definition: ge.h:98
struct pulse_event * on_pulse[END_OF_STATUS]
Definition: ge.h:103
uint8_t PUC2
Channel 2 in transfer.
Definition: ge.h:374
uint8_t ffFI
Special conditions register 1.
Definition: ge.h:229
uint8_t RC00
Asynchronous CPU Cycle Request.
Definition: ge.h:407
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
uint8_t RC01
Asynchronous Channel 1 Cycle Request.
Definition: ge.h:420
uint8_t RECE
Selection Check Byte.
Definition: ge.h:486
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 mem[MEM_SIZE]
The memory of the emulated system.
Definition: ge.h:528
uint8_t AVER
Jump Condition Verified.
Definition: ge.h:319
uint8_t RAVI
VICU Support.
Definition: ge.h:497
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
@ MC_READ
Definition: ge.h:524
@ MC_NONE
Definition: ge.h:523
@ MC_WRITE
Definition: ge.h:525
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 RC02
Asynchronous Channel 2 Cycle Request.
Definition: ge.h:435
uint8_t ADIR
Disable Step By Step.
Definition: ge.h:327
struct ge_peri * peri
Definition: ge.h:547
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
uint16_t rVO
Default memory addresser.
Definition: ge.h:155
uint8_t URPU
Definition: ge.h:388
uint8_t RC03
Asynchronous Channel 3 Cycle Request.
Definition: ge.h:450
uint8_t JE
JE/AVER jump instruction exectuted.
Definition: ge.h:333
uint8_t step_by_step
Step by step execution.
Definition: ge.h:520
uint8_t ACIC
Recycle delay line.
Definition: ge.h:298
enum clock current_clock
Definition: ge.h:96
enum ge::@2 memory_command
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 RETO
Definition: ge.h:245
uint8_t RIG3
Definition: ge.h:491
uint8_t URPE
Definition: ge.h:387
uint16_t rV3
Addresser for external instructions using channel 3.
Definition: ge.h:115
uint8_t TO50_did_CI32_or_CI33
Workaround for pulse TO50.
Definition: ge.h:560
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
on_pulse_cb cb
Definition: ge.h:599
struct pulse_event * next
Definition: ge.h:600