hardware: the 74LS machine gets a period bill of materials, and a mechanics plan
Two things: the TTL build is now the main target (Tang Nano looks too modern), and the packer learned the format that makes the TTL build simple. Format: r8forge_tape_pack --eprom writes one byte per instruction with the opcode in the low three bits. Then ip is the EPROM address and D2..D0 are the opcode -- no shift register, no 16 bit window, no decoder. It wastes five bits per instruction, and a 27C512 is exactly 64K, which is the historical instruction budget: the 8 bit calculator (51378) and the flagship (43676) both fit. Both formats live in the same .r8t trailer now (format byte 1 = packed, 2 = one byte per instruction), decode dispatches on it, and the test runs both and requires the same output and step count. Carrier: 74LS DIPs on a green board, 27C512 in a socket with its quartz window, 6116 SRAM, 74LS299 for the rotate, 6850 ACIA for serial, 74LS47 and four seven segment displays on the panel, 1 MHz can oscillator. About 31 to 40 chips, 400 to 700 CNY, a few weeks. The FPGA stays as a bench-only stepping stone. hardware/mechanics.md: where mechanics actually pays. The program must stay electronic (130 metres of paper tape for the calculator), and 512 relays for the data ring are out, but the pointer is worth it -- > and < are 71 to 73 percent of all steps, so a 64 position ratchet or uniselector makes the machine physically walk the ring. Also listed: an electromagnetic step counter (10 to 20 Hz, so only in single step mode, with a clutch for free running), a paper tape punch or plotter for output, a tape/card reader or plain keypad for input, and a hand crank as the clock. The rule that keeps this safe: mechanics only ever sit on sensor and actuator pins and never in the logic path, and the handshake just stops the sequencer while something moves -- since nothing in the ISA can observe time, slower is not different. A relay-only machine is priced honestly too: 60 to 120 relays, 10 to 50 Hz, hello in 10 to 40 seconds, the calculator in four hours, so that one is an exhibit. Also fixed: the synthesised macro fallback file name now carries a per-run token. When the system temp directory is not writable every r8asm falls back to the same working directory, so parallel ctest runs could write and import the same file -- which showed up as a random one-test failure in 0.39 seconds and nothing else.
This commit is contained in:
1 parent
9b31a51fec
commit
1e7acc018e
7 files changed
+241
-44
No files matched your search
+47
-35
@@ -132,56 +132,68 @@ rnz, 最低位 == 1: ip-- ; 深度=0
|
||||
|
||||
## 5. 载体三档
|
||||
|
||||
### A. FPGA(建议先做这一档)
|
||||
**取向:越复古越好** —— 面板、器件、封装都要 1980 年代那味,所以 **B(74LS + EPROM + 数码管
|
||||
面板)是主目标**;A 只当"先把逻辑跑通"的跳板(Tang Nano 那种指甲盖板子长得太现代,真要
|
||||
做板就用 74LS 分立件 + 绿色 PCB + 大号丝印)。
|
||||
|
||||
### B'. 分立 74LS 机器(主目标,博物馆档)
|
||||
|
||||
按 **8 位 / 64 格**、**一条指令一个字节**(低 3 位是操作码)算 —— 这个格式让线路简单一大截:
|
||||
`ip` 直接当 EPROM 地址,取出的字节 `D2..D0` 就是操作码,**不需要移位寄存器、不需要 16 位
|
||||
窗口、不需要查表**。代价是每条指令浪费 5 bit,而 **27C512 正好 64K 字节**,正好等于项目
|
||||
历史上那条 `INS_SIZE = 65536` 的预算 —— 8 位计算器(51 378 条)和全家桶(43 676 条)都装得下 ✓。
|
||||
|
||||
| 部件 | 选型 | 片数 | 年代感 |
|
||||
|---|---|---|---|
|
||||
| 程序 ROM | **27C512**(64K×8,UV 擦除窗口)一条指令一字节 | 1 | 石英窗 + 紫外线擦除,最有味 |
|
||||
| `ip` 计数器 | 74LS161 ×4(16 位,接 EPROM 的 A0..A15) | 4 | |
|
||||
| 数据 RAM | **6116**(2K×8)—— 只用 64 字节 | 1 | 1980 年代的 SRAM |
|
||||
| 数据寄存器 + 右旋 | **74LS299**(8 位通用移位寄存器,右旋 / 保持) | 1 | |
|
||||
| `dp` 计数器 | 74LS161 ×2(6 位,回绕免费) | 2 | |
|
||||
| 循环栈 | 74LS670(4×4 寄存器堆)×2 + 74LS161 当栈指针(8 深够用) | 3 | |
|
||||
| 控制/微码 | 28C64 微码 ROM ×1 + 74LS161 微序列计数器 + 74LS138 译码 | 3 | 微码控制,8086 同代做法 |
|
||||
| 串口 | **6850 ACIA** + 74LS4060(分频出 9600 baud) | 2 | 8080 时代的经典 ACIA |
|
||||
| 面板 | 74LS47 ×4(七段译码)+ 4 位数码管 + LED(指令/`ip`/`dp`)+ 拨动开关 + 大红按钮 | 6~8 | 前面板就是"机器"的脸 |
|
||||
| 胶合 | 74LS00/04/08/32/244/245 | 6~9 | |
|
||||
| 时钟/复位 | 1 MHz 罐头晶振(或 74LS04 + 2 MHz 晶体 ÷2)+ 74LS14 + RC | 2 | |
|
||||
| **合计** | | **~31~40 片**,¥400~700 | 5 V 2 A,绿色 PCB,全 DIP 插座 |
|
||||
|
||||
速度:1~2 MHz、约 4 拍/指令 → 0.25~0.5 M 指令/秒;8 位计算器一次会话(166 k 步)0.4~0.7 s ✓。
|
||||
工作量:几周(面包板先通,再画 PCB;面板可以最后做)。
|
||||
|
||||
**面板**(这才是"8086 那种"的来源):4 位数码管显示当前格(十六进制),一排 8 个 LED 显示
|
||||
当前指令,一排 16 个 LED 显示 `ip` 低 16 位(或 4 位数码管显示 `ip`),一排 6 个 LED 显示
|
||||
`dp`,外加 **RUN / STEP / RESET** 三个带灯按钮和一个 8 位拨码当"输入字节"。外壳用
|
||||
铝型材/亚克力开窗都行,丝印上写满信号名。
|
||||
|
||||
### A. FPGA(跳板,不是终态)
|
||||
|
||||
| 项 | 选择 |
|
||||
|---|---|
|
||||
| 板子 | Tang Nano 9K(GW1NR-9):≈58 KB BSRAM、HDMI、板载 USB 串口,¥100 上下 |
|
||||
| 能跑 | 8 位全家桶(16.4 KB)✓、8 位计算器(19.3 KB)✓;11/16/32 位纸带只当对照(37 KB / — / ✗) |
|
||||
| 工具 | Gowin IDE 或开源的 yosys + nextpnr-gowin(后者更符合这个项目的脾气) |
|
||||
| I/O | UART 115200 进/出,HDMI 画 64 格环 + `dp`/`ip`/当前格 |
|
||||
| 工作量 | 300~500 行 Verilog + testbench,一个周末 |
|
||||
| 速度 | 50 MHz / 4 拍 ≈ 12 M 指令/秒(比软件快一个量级,面板上能看到"瞬间算完") |
|
||||
| 板子 | 任意(Tang Nano 9K 一类,¥100 上下)——只用来先把逻辑跑通,外形不讲究 |
|
||||
| 能跑 | 8 位全家桶(16.4 KB)✓、8 位计算器(19.3 KB)✓ |
|
||||
| 工具 | Gowin IDE 或 yosys + nextpnr-gowin |
|
||||
| 速度 | 50 MHz / 2~4 拍 ≈ 10 M 指令/秒 |
|
||||
| 价值 | `hardware/rot8.v` 已经在它上面验证过逻辑;烧上去只是看灯,最终机器是 B' |
|
||||
|
||||
### B. 分立 TTL("真机器",博物馆档)
|
||||
|
||||
按 **8 位**算,片数比原来那版少一截(没有 11 位那种 8+3 的拼法,也没有位宽开关):
|
||||
|
||||
| 部件 | 选型 | 片数 |
|
||||
|---|---|---|
|
||||
| 程序 ROM | 29C010 / 39SF010(128 KB flash,用低 3 bit;8 位全家桶只要 16.4 KB) | 1 |
|
||||
| `ip` 计数器 | 74HC161 ×4(16 位够装 51 378 条;做 20 位就 ×5) | 4~5 |
|
||||
| 数据 RAM | 6116(2K×8)—— 只用 64 字节,一片能用 32 台 | 1 |
|
||||
| 数据寄存器/右旋 | 74HC299(8 位通用移位寄存器,右旋 + 保持一片搞定) | 1 |
|
||||
| `dp` 计数器 | 74HC161 ×2(6 位,回绕免费,不用比较器) | 2 |
|
||||
| 括号扫描 | 74HC191 ×2(上下计数)+ 比较器,或塞进 CPLD | 3~4 |
|
||||
| 控制/微码 | GAL22V10 ×2 或 ATF1502 CPLD(一片搞定解码 + 微序列) | 1~3 |
|
||||
| UART | 6850 ACIA 或 ATmega/CH340 桥 | 1~2 |
|
||||
| 时钟/复位/面板 | 555 或晶振、74HC14、LED/数码管 | 5~8 |
|
||||
| **合计** | | **~20~28 片**,¥250~500 |
|
||||
|
||||
速度:1~2 MHz、4 拍/指令 → 0.25~0.5 M 指令/秒,8 位计算器一次会话(166 k 步)0.4~0.7 s ✓。
|
||||
工作量:几周(面包板先通,再画 PCB)。
|
||||
|
||||
### C. 机电(艺术品档)
|
||||
### C. 机电(艺术品档,另外的野心)
|
||||
|
||||
* **数据环做转鼓**:**8 条磁道 × 64 格**、一个读头 + 一个写头(写头在下游**一格**处)。
|
||||
`>`/`<` 的"访问"就是等下一个格脉冲;`+`/`-` 在读到写头之间的那一格时间里改好写回,
|
||||
所以每条指令 ≈ 一格时间。3000 rpm、64 格/圈 → 312 µs/格 → 166 k 步 ≈ **52 s**(环小了每圈格子少,鼓要转快点才追得上:10000 rpm → 16 s)。
|
||||
代价是机加工(或找一个旧磁鼓/软盘改)。
|
||||
* **程序做纸带**:3 bit 数据 + 1 孔同步,2.54 mm 孔距。`hello`(727 条)≈ 1.8 m ✓;
|
||||
计算器(73 624 条)≈ **187 m** ✗ —— 所以纸带只适合演示级小程序,大纸带还是进 EEPROM。
|
||||
折中:**卡带**(FSK 1200~9600 baud)当"装载介质",23 KB 在 20~160 s 内装进 RAM。
|
||||
计算器(51 378 条)≈ **130 m** ✗ —— 所以纸带只适合演示级小程序,大纸带还是进 EPROM。
|
||||
* 也可以只做"面板 + 真 I/O"的半机电:MCU 跑 ISA,面板是真按键/LED/数码管。
|
||||
|
||||
| | A FPGA | B TTL | C 机电 |
|
||||
| | A FPGA 跳板 | **B' 分立 74LS** | C 机电 |
|
||||
|---|---|---|---|
|
||||
| 上手时间 | 一个周末 | 几周 | 几个月起 |
|
||||
| 成本 | ¥100~300 | ¥250~500 | ¥1000+ + 机加工 |
|
||||
| 速度 | 12 M 指令/秒 | 0.25~0.5 M | 40~45 k |
|
||||
| 成本 | ¥100~300 | ¥400~700 | ¥1000+ + 机加工 |
|
||||
| 速度 | ~10 M 指令/秒 | 0.25~0.5 M | 40~45 k |
|
||||
| 能跑 8 位全家桶/计算器 | ✓ | ✓ | ✓(慢,但够:一次会话 ~20 s) |
|
||||
| 教学/观赏性 | 中 | **高** | **最高** |
|
||||
| 可改 ISA/调试 | 改一行重烧 | 换 ROM | 换凸轮/继电器 |
|
||||
| 复古程度 | ✗ | **✓✓**(DIP、UV EPROM、数码管、拨码) | ✓✓✓ |
|
||||
| 可改 ISA/调试 | 改一行重烧 | 换 EPROM(擦 20 分钟,仪式感) | 换凸轮/继电器 |
|
||||
|
||||
建议:**A 先做**(一周内能跑真纸带),B 作为"正式机器"的目标(A 的 RTL 状态机原样翻成
|
||||
微码表,接口和时序都不变),C 当展示件。8 位让 B 的片数掉到 20~28 片、C 的鼓只要 8 条磁道。
|
||||
|
||||
Reference in new issue
Block a user