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 <stddef.h>
6#include "opcodes.h"
7#include "console.h"
8#include "reader.h"
9#include "channel.h"
10
11#define CLOCK_PERIOD 14000 /* in usec, interval between pulse lines */
12#define MEM_SIZE 65536
13
14#define ENUMERATE_CLOCKS \
15 X(TO00) \
16 X(TO10) \
17 X(TO11) \
18 X(TO15) \
19 X(TO19) \
20 X(TO20) \
21 X(TO25) \
22 X(TO30) \
23 X(TO40) \
24 X(TO50) \
25 X(TO50_1) \
26 X(TO60) \
27 X(TO64) \
28 X(TO65) \
29 X(TO70) \
30 X(TO80) \
31 X(TO89) \
32 X(TO90) \
33 X(TI05) \
34 X(TI06) \
35 X(TI10) \
36 X(END_OF_STATUS)
37
38enum clock {
39 #define X(name) name ,
41 #undef X
42};
43
45 struct cmds {
46 uint8_t from_zero:1;
47 uint8_t decresing:1;
48 } cmds;
49};
50
73
84
91
96struct ge {
97 /* Main clock */
99 uint8_t halted;
100 uint8_t powered;
101
102 /* Lists of events and operations for all
103 * pulses
104 */
105 struct pulse_event *on_pulse[END_OF_STATUS];
106
113 uint16_t rPO;
114
121 uint16_t instr_pc;
122
123 uint16_t rV1;
124 uint16_t rV2;
125 uint16_t rV3;
126 uint16_t rV4;
127
140 uint16_t cr_cache[8];
141
146 uint8_t rRI;
147
154 uint16_t rL1;
155 uint8_t rL2;
156 uint16_t rL3;
157
159
165
171 uint16_t rRO;
172
179 uint16_t rVO;
180
188 uint16_t rBO;
189
195 uint8_t rFO;
196
220 uint8_t rSO;
221
234 uint8_t rSI;
235
242 uint8_t rSA;
243
244 uint8_t rRE;
245 uint8_t rRA;
246
253 uint8_t ffFI;
254
263 uint8_t ffFA;
264
265 /* Those two store which work channel the present cycle as been attributed to
266 * (cpu fo. 130).
267 * When setting RETO, if PAPA switch is set, rotary is neither in normal, nor
268 * in position 8 to store in memory, should set ALTO */
269 uint8_t RETO:1;
270 uint8_t RET2:1;
271
278 uint8_t AINI:1;
279
285 uint8_t ALOI:1;
286
293 uint8_t ALTO:1;
294
301 uint8_t PODI:1;
302
322 uint8_t ACIC:1;
323
332 uint8_t ALAM:1;
333
343 uint8_t AVER:1;
344
354 uint8_t SA00:1;
355
362 uint8_t ADIR:1;
363
364 uint8_t RINT:1;
365
366 uint8_t JS1:1;
367 uint8_t JS2:1;
368 uint8_t JE:1;
369 uint8_t INTE:1;
370
371 /* Busy Connector Logic */
372
373 uint8_t PB06:1;
374 uint8_t PB07:1;
375 uint8_t PB26:1;
376 uint8_t PB36:1;
377 uint8_t PB37:1;
378
397 uint8_t PIC1:1;
398
404 uint8_t RASI:1;
405
411 uint8_t PUC2:1;
412
418 uint8_t PUC3:1;
419
420 uint8_t PEC1:1;
421 uint8_t PEC1_pending:1;
422
423 uint8_t RUF1:1;
424
425 uint8_t URPE:1;
426 uint8_t URPU:1;
427
428 /* Cycle Attribution Logic */
429 /* ----------------------- */
430
431 /* Asyncronous flip flops */
432
445 uint8_t RC00:1;
446
458 uint8_t RC01:1;
459
473 uint8_t RC02:1;
474
488 uint8_t RC03:1;
489
500 uint8_t RIA0:1;
501
507 uint8_t RESI:1;
508
514 uint8_t RIA2:1;
515
521 uint8_t RIA3:1;
522
524 uint8_t RECE:1;
525
527 uint8_t RIG1:1;
528
529 uint8_t RIG3:1;
530
532 uint8_t RACI:1;
533
535 uint8_t RAVI:1;
536
537 uint8_t RT121:1;
538 uint8_t RT131:1;
539
547
552
557
558 uint8_t step_by_step:1;
559
560 enum {
565
566 uint8_t mem[MEM_SIZE];
567
570
573
575 uint32_t mem_size;
576
578 uint8_t mem_check;
579
581 uint8_t inv_add;
582
589
591
596
607 char out[65536]; /* captured printed chars; per-frame staging only
608 * (the wasm console drains+clears each frame, the
609 * CLI reads it at end). Sized for a catch-up
610 * frame's burst so fast/backgrounded printing
611 * doesn't overflow before the drain. */
613 uint8_t kbd[256]; /* operator keyboard input queue */
615 /* Channel-2 OUTPUT transfer engine (printer.c): while out_active, the
616 * printer requests a channel-2 cycle (RC02) per character so the rSI
617 * output state (0x02) drains out_remaining bytes from V4, then ends.
618 * out_saved_so preserves the CPU sequencer across the (overlapped)
619 * transfer — fsn advances SO on RIA0, which the stolen channel-2 cycles
620 * would otherwise clobber; we restore it when the transfer ends. */
627
632
637
646
647 struct ge_peri *peri;
648
654 void *std_core;
655
668};
669
671void ge_init(struct ge *ge);
672
674int ge_deinit(struct ge *ge);
675
677int ge_load_program(struct ge *ge, uint8_t *program, uint8_t size);
678
681int ge_load_image(struct ge *ge, const uint8_t *image, size_t size,
682 uint16_t origin);
683
686void ge_enter(struct ge *ge, uint16_t entry);
687
691void ge_mem_store8(struct ge *ge, uint16_t addr, uint8_t val);
692
696void ge_seed_segment_bases(struct ge *ge);
697
699int ge_run(struct ge *ge);
700
702int ge_run_pulse(struct ge *ge);
703
705int ge_run_cycle(struct ge *ge);
706
708void ge_clear(struct ge * ge);
709
711void ge_load(struct ge * ge);
712
714void ge_load_1(struct ge * ge);
715
717void ge_load_2(struct ge * ge);
718
720void ge_start(struct ge * ge);
721
722typedef void (*on_pulse_cb)(struct ge *);
723
728
729/* Defined in pulse.c: execute pulse events */
730void pulse(struct ge *ge);
731
732struct ge_peri {
733 struct ge_peri *next;
734 int (*init)(struct ge*, void*);
735 int (*on_pulse)(struct ge*, void*);
736 int (*on_clock)(struct ge*, void*);
737 int (*deinit)(struct ge*, void*);
738 void *ctx;
739};
740
741int ge_register_peri(struct ge *ge, struct ge_peri *p);
742
750void fsn_last_clock(struct ge *ge);
751
752void connectors_first_clock(struct ge *ge);
753
759const char *ge_clock_name(enum clock c);
760
761void ge_print_registers_verbose(struct ge *ge);
762
763#endif /* GE_H */
ge_console_rotary
Definition console.h:8
int ge_deinit(struct ge *ge)
Deinitialize the emulator.
Definition ge.c:360
void ge_seed_segment_bases(struct ge *ge)
Seed the eight change/segment-base registers (mem[240+2N]) to identity bases N<<12.
Definition ge.c:83
void ge_load_1(struct ge *ge)
Emulate the press of the "load 1" button in the console.
Definition ge.c:172
void ge_clear(struct ge *ge)
Emulate the press of the "clear" button in the console.
Definition ge.c:27
#define MEM_SIZE
Definition ge.h:12
#define ENUMERATE_CLOCKS
Definition ge.h:14
knot_ni_source
Definition ge.h:74
@ NS_RO1
Definition ge.h:79
@ NS_UA1
Definition ge.h:82
@ NS_UA2
Definition ge.h:81
@ NS_CN1
Definition ge.h:75
@ NS_CN2
Definition ge.h:76
@ NS_CN4
Definition ge.h:78
@ NS_CN3
Definition ge.h:77
@ NS_RO2
Definition ge.h:80
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:349
const char * ge_clock_name(enum clock c)
The clock period name name.
Definition ge.c:233
void ge_mem_store8(struct ge *ge, uint16_t addr, uint8_t val)
Store a byte with generated odd parity + mark-written (for the hybrid ALU/SS write paths that write g...
Definition ge.c:119
void ge_load_2(struct ge *ge)
Emulate the press of the "load 2" button in the console.
Definition ge.c:189
void(* on_pulse_cb)(struct ge *)
Definition ge.h:722
void ge_enter(struct ge *ge, uint16_t entry)
Enter execution at entry: seed PO and drop into the alpha (fetch) phase, bypassing the peripheral LOA...
Definition ge.c:155
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:293
void fsn_last_clock(struct ge *ge)
Commit the future state.
Definition ge.c:374
int ge_register_peri(struct ge *ge, struct ge_peri *p)
void ge_print_registers_verbose(struct ge *ge)
Definition ge.c:259
void pulse(struct ge *ge)
Definition pulse.c:248
void ge_load(struct ge *ge)
Emulate the press of the "load" button in the console.
Definition ge.c:162
int ge_load_image(struct ge *ge, const uint8_t *image, size_t size, uint16_t origin)
Load a flat image at origin (unified-format payload); origin-aware, not size-capped,...
Definition ge.c:131
int ge_load_program(struct ge *ge, uint8_t *program, uint8_t size)
Copy a program at the start of memory.
Definition ge.c:93
void connectors_first_clock(struct ge *ge)
Definition ge.c:366
clock
Definition ge.h:38
void ge_start(struct ge *ge)
Emulate the press of the "start" button in the console.
Definition ge.c:194
Integrated printer / console typewriter (channel 2) — pragmatic model.
Definition ge.h:605
uint8_t kbd[256]
Definition ge.h:613
char out[65536]
Definition ge.h:607
Console switches.
Definition console.h:71
enum knot_ni_source ni4
Definition ge.h:89
enum knot_ni_source ni2
Definition ge.h:87
enum knot_ni_source ni1
Definition ge.h:86
enum knot_ni_source ni3
Definition ge.h:88
uint8_t forcings
Definition ge.h:52
@ KNOT_PO_IN_NO
Definition ge.h:61
@ KNOT_V3_IN_NO
Definition ge.h:64
@ KNOT_AM_IN_NO
Definition ge.h:69
@ KNOT_V4_IN_NO
Definition ge.h:65
@ KNOT_V1_IN_NO
Definition ge.h:62
@ KNOT_L3_IN_NO
Definition ge.h:68
@ KNOT_L2_IN_NO
Definition ge.h:67
@ KNOT_V2_IN_NO
Definition ge.h:63
@ KNOT_RI_IN_NO_43
Definition ge.h:70
@ KNOT_L1_IN_NO
Definition ge.h:66
enum ge_knot_no::@1 force_mode
enum ge_knot_no::@2 cmd
@ KNOT_FORCING_NO_43
Definition ge.h:57
@ KNOT_FORCING_NONE
Definition ge.h:55
@ KNOT_FORCING_NO_21
Definition ge.h:56
Definition ge.h:732
int(* on_pulse)(struct ge *, void *)
Definition ge.h:735
void * ctx
Definition ge.h:738
struct ge_peri * next
Definition ge.h:733
int(* init)(struct ge *, void *)
Definition ge.h:734
int(* deinit)(struct ge *, void *)
Definition ge.h:737
int(* on_clock)(struct ge *, void *)
Definition ge.h:736
The entire state of the emulated system, including registers, memory, peripherals and timings.
Definition ge.h:96
uint8_t ALAM
Operator Call.
Definition ge.h:332
uint8_t RET2
Definition ge.h:270
uint8_t RINT
Definition ge.h:364
uint8_t INTE
Interruption present.
Definition ge.h:369
uint16_t instr_pc
Instruction-start PC (display aid, not a real register).
Definition ge.h:121
uint8_t ALOI
Load connector selection.
Definition ge.h:285
uint8_t RT121
Definition ge.h:537
void * std_core
Shared core for Standard-GE-100 controllers on connectors 3/4 (disk/tape).
Definition ge.h:654
uint8_t rRA
Definition ge.h:245
uint8_t PB37
Definition ge.h:377
uint8_t rRE
Definition ge.h:244
uint8_t AINI
Program Loading.
Definition ge.h:278
struct ge_integrated_reader integrated_reader
The I/O interface for the integrated reader (RI)
Definition ge.h:595
uint8_t JS2
Console jump condition 2.
Definition ge.h:367
struct ge_connector ST4
The I/O interface for the ST4 connector.
Definition ge.h:636
uint8_t ALTO
Stops internal cycles.
Definition ge.h:293
uint8_t ffFA
Special conditions register 2.
Definition ge.h:263
uint16_t rPO
Program addresser.
Definition ge.h:113
uint8_t PIC1
Selection Channel 1.
Definition ge.h:397
uint8_t future_state
Future state.
Definition ge.h:546
uint8_t inv_add
Invalid-address fault flag: set when rVO >= installed memory size.
Definition ge.h:581
uint8_t PODI
Slow delay line.
Definition ge.h:301
uint8_t mem_written[MEM_SIZE]
1 once a location has been written; prevents false MEM CHECK on cleared memory
Definition ge.h:572
enum ge_console_rotary register_selector
The current state of the console register rotary switch.
Definition ge.h:551
uint8_t RIA0
Synchronous CPU Cycle Request.
Definition ge.h:500
uint32_t mem_size
Installed memory size; 0 is treated as MEM_SIZE (full address space)
Definition ge.h:575
uint8_t inject_chan1_status
Channel-1 peripheral status override for error injection.
Definition ge.h:588
uint8_t RIA2
Synchronous Channel 2 Cycle Request.
Definition ge.h:514
uint8_t PEC1
Definition ge.h:420
uint16_t rV1
Addresser for the first operand.
Definition ge.h:123
uint8_t mem_check
Parity fault flag: set when a READ finds a parity mismatch on a previously-written location.
Definition ge.h:578
uint8_t rSO
Main sequencer.
Definition ge.h:220
uint8_t halted
Definition ge.h:99
uint16_t rRO
Multipurpose 8+1 bit register.
Definition ge.h:171
struct ge_counting_network counting_network
Definition ge.h:590
struct ge_console_switches console_switches
The current state of the console switches.
Definition ge.h:556
struct ge_connector ST3
The I/O interface for the ST3 connector.
Definition ge.h:631
uint8_t RIA3
Synchronous Channel 3 Cycle Request.
Definition ge.h:521
uint8_t PUC3
Channel 3 in transfer.
Definition ge.h:418
uint8_t rL2
Auxiliary register.
Definition ge.h:155
uint8_t powered
Definition ge.h:100
struct pulse_event * on_pulse[END_OF_STATUS]
Definition ge.h:105
uint8_t PUC2
Channel 2 in transfer.
Definition ge.h:411
uint8_t ffFI
Special conditions register 1.
Definition ge.h:253
uint8_t RC00
Asynchronous CPU Cycle Request.
Definition ge.h:445
uint8_t rRI
Photoprint register 8-bit register used to store the photodisc codes.
Definition ge.h:146
uint16_t rBO
Default operator.
Definition ge.h:188
uint8_t PB06
Unconditionally stores L106.
Definition ge.h:373
uint8_t RC01
Asynchronous Channel 1 Cycle Request.
Definition ge.h:458
enum ge::@3 memory_command
uint8_t RECE
Selection Check Byte.
Definition ge.h:524
struct ge_knot_ni kNI
Knot driven by counting network, or by the UA to store the result of the operation.
Definition ge.h:164
uint8_t mem[MEM_SIZE]
The memory of the emulated system.
Definition ge.h:566
uint8_t AVER
Jump Condition Verified.
Definition ge.h:343
struct ge_channel channel2
Integrated channel 2 (CAN2) line bundle — shared by the integrated reader (input),...
Definition ge.h:645
uint8_t RAVI
VICU Support.
Definition ge.h:535
uint8_t RACI
Rejected Command.
Definition ge.h:532
uint8_t RT131
Definition ge.h:538
uint16_t rV4
Addresser for external instructions using channel 2.
Definition ge.h:126
uint8_t RASI
Channel 1 in transfer.
Definition ge.h:404
uint16_t rL1
Length of the operand.
Definition ge.h:154
uint8_t RUF1
Definition ge.h:423
uint8_t rSA
Future state configuration.
Definition ge.h:242
uint8_t PEC1_pending
Definition ge.h:421
uint16_t rV2
Addresser for the second operand.
Definition ge.h:124
uint8_t RC02
Asynchronous Channel 2 Cycle Request.
Definition ge.h:473
uint8_t ADIR
Disable Step By Step.
Definition ge.h:362
struct ge_peri * peri
Definition ge.h:647
uint8_t RESI
Synchronous Channel 1 Cycle Request.
Definition ge.h:507
uint8_t RIG1
End from controller 1.
Definition ge.h:527
uint8_t rSI
Peripheral unit sequencer.
Definition ge.h:234
uint16_t rVO
Default memory addresser.
Definition ge.h:179
uint8_t URPU
Definition ge.h:426
uint8_t RC03
Asynchronous Channel 3 Cycle Request.
Definition ge.h:488
uint8_t JE
JE/AVER jump instruction exectuted.
Definition ge.h:368
uint8_t step_by_step
Step by step execution.
Definition ge.h:558
@ MC_READ
Definition ge.h:562
@ MC_NONE
Definition ge.h:561
@ MC_WRITE
Definition ge.h:563
uint8_t ACIC
Recycle delay line.
Definition ge.h:322
enum clock current_clock
Definition ge.h:98
uint8_t PB26
Stores L106 if channel 2 is selected.
Definition ge.h:375
uint16_t rL3
Length of operands involving channel 3.
Definition ge.h:156
uint8_t mem_parity[MEM_SIZE]
Stored odd-parity bit (1 bit per location) written alongside mem[].
Definition ge.h:569
uint8_t PB07
Unconditionally stores L106.
Definition ge.h:374
uint8_t RETO
Definition ge.h:269
uint8_t RIG3
Definition ge.h:529
uint8_t URPE
Definition ge.h:425
uint16_t rV3
Addresser for external instructions using channel 3.
Definition ge.h:125
uint8_t TO50_did_CI32_or_CI33
Workaround for pulse TO50.
Definition ge.h:667
uint8_t PB36
Definition ge.h:376
struct ge_knot_no kNO
Definition ge.h:158
uint8_t rFO
Current function code.
Definition ge.h:195
uint16_t cr_cache[8]
Change/segment-register CACHE used for modified-address resolution.
Definition ge.h:140
struct ge::ge_integrated_printer integrated_printer
uint8_t SA00
First-vs-second operand flag for address modification.
Definition ge.h:354
uint8_t JS1
Console jump condition 1.
Definition ge.h:366
on_pulse_cb cb
Definition ge.h:725
struct pulse_event * next
Definition ge.h:726