Magic‐1 Computer Architecture Layers - retrotruestory/M1DEV GitHub Wiki
Magic-1 Computer Architecture Layers
1. Hardware Layer
CPU Core
- 16-bit data path
- Two-bus architecture (L-bus and R-bus)
- Hardware memory management
- Microcode control unit
Core Components:
└── CPU
├── ALU (16-bit)
├── Register File
│ ├── MSW (Machine Status Word)
│ ├── PC (Program Counter)
│ ├── SP (Stack Pointer)
│ ├── A, B (General Purpose)
│ ├── C (General Purpose)
│ └── MDR (Memory Data Register)
├── Memory Management Unit
│ ├── Page Tables
│ └── Address Translation
└── Control Unit
├── Microcode ROM
└── Instruction Decoder
2. Microcode Layer
Control Structure (56-bit microinstruction)
typedef struct {
unsigned next:8; // Next address
unsigned latch:4; // Register control
unsigned mar_latch:1; // MAR control
unsigned mdr_ctrl:2; // MDR control
unsigned priv:1; // Privilege level
unsigned mode:2; // Operating mode
unsigned bus_ctrl:6; // Bus control
unsigned alu_op:4; // ALU operation
unsigned misc:28; // Misc control
} microinstruction_t;
3. Instruction Set Layer
Instruction Categories
Instructions:
├── Data Movement
│ ├── LD/ST (Load/Store)
│ └── PUSH/POP
├── ALU Operations
│ ├── ADD/SUB
│ ├── AND/OR/XOR
│ └── Shift/Rotate
├── Control Flow
│ ├── BR (Branch)
│ ├── CALL/RET
│ └── RETI
└── System Operations
├── CLI/STI
├── HALT
└── Page Table Management
4. Operating System Layer
Memory Organization
Address Space:
0x0000-0x3FFF: ROM (16KB)
0x4000-0x7FFF: Device SRAM (16KB)
0x8000-0xF7FF: Main Memory
0xF800-0xFFFF: Device Page
Device Interface
I/O Devices:
├── UART (2x)
├── RTC
├── IDE Controller
├── CF Card Interface
└── Front Panel
5. Boot Process Layer
Initialization Sequence
1. ROM Boot
2. Hardware Initialize
3. Storage Detection
4. Boot Image Load
5. Memory Setup
6. Transfer Control
6. Application Layer
Program Environment
User Space:
├── Code Segment
├── Data Segment
├── Stack
└── I/O Access
└── System Calls
All layers are accessible through VS Code's integrated development environment, with debugging and testing support for each level.