Magic‐1 Microcode File Format - retrotruestory/M1DEV GitHub Wiki
Magic-1 Microcode File Format
Based on the provided source files, here's the technical information about the Magic-1's microcode format:
Microinstruction Word Format (56 bits)
typedef struct {
// Control Fields
unsigned next:8; // Next microinstruction address
unsigned latch:4; // Register latch control
unsigned lmar:1; // Latch MAR
unsigned lmdrlo:1; // Latch MDR low byte
unsigned lmdrhi:1; // Latch MDR high byte
unsigned emdrlo:1; // Drive MDR low byte
unsigned emdrhi:1; // Drive MDR high byte
unsigned priv:1; // Privileged instruction
unsigned lmode:1; // Latch mode bit
unsigned lpaging:1; // Latch paging enable
unsigned misc:4; // Misc control signals
unsigned e_l:4; // Left bus enable
unsigned e_r:2; // Right bus enable
unsigned immval:2; // Immediate value
unsigned aluop_size:1; // ALU operation size
unsigned aluop:2; // ALU operation
unsigned carry:1; // Carry control
unsigned l_size:1; // Latch size
unsigned br_sense:1; // Branch sense
unsigned user_ptb:1; // User page table base
unsigned code_ptb:1; // Code/data selection
} mcode_rec_t;
Storage Format
1. Physical Storage
- 5 PROMs (512x8 bits each)
- Each PROM contains different fields of the 56-bit word
prom0.hex - MSBs (next field)
prom1.hex - Next control bits
prom2.hex - Middle control bits
prom3.hex - Additional control bits
prom4.hex - LSBs
2. Memory Organization
#define MICROCODE_WIDTH 56
#define MICROCODE_DEPTH 512
// Bottom 256 locations: Direct opcode mapping
// Upper 256 locations: Microcode sequences
3. File Generation Process
# Generate microcode files from HTML source
./gen_files.pl microcode.htm ./Autogen/
# Files generated:
- mcode.h # Microinstruction structure definition
- mcode.c # Initialized microcode array
- prombits.h # Bit patterns for PROM programming
- mcdefs.h # Control signal definitions
4. Key Control Fields
// Register selects
#define R_MSW 1 // Machine Status Word
#define R_C 2 // C register
#define R_PC 3 // Program Counter
#define R_DP 4 // Data Pointer
#define R_SP 5 // Stack Pointer
#define R_A 6 // A register
#define R_B 7 // B register
#define R_MDR 8 // Memory Data Register
// ALU Operations
#define OP_IR13 0 // From instruction
#define OP_AND 1 // Logical AND
#define OP_SUB 2 // Subtract
#define OP_ADD 3 // Add
The microcode is loaded through PROM programmers and provides the fundamental control layer for the Magic-1 CPU.