diff --git a/docs/hardware.md b/docs/hardware.md index 8cadd14..58a5605 100644 --- a/docs/hardware.md +++ b/docs/hardware.md @@ -283,6 +283,11 @@ rnz, 最低位 == 1: ip-- ; 深度=0 28C256(32 KB,DIP-28,5 V,150 ns)装得下计算器(19.3 KB)+ 终端(6.2 KB)+ 监控程序。 芯片插在宽体座上就是"卡带":拔下来用 CH341A 重写。**没有 loader、没有程序 RAM、没有启动步骤。** +> **面板形态(已定)**:做成**卡边卡带** —— 一片小 PCB 焊 27C512,金手指插进 2×22 卡边 +> 连接器;面板上就是一条带两颗螺钉的槽(和游戏机卡带一个套路,见 `hardware/panel-mockup-vintage.png`)。 +> 省钱版是裸 **ZIF-28**:面板开一条缝、插拔芯片。两者都不需要电缆 —— 严格哈佛下**没有 +> "接一根线灌程序"的通路**,唯一的装法就是换片。 + **装法 2:板上程序 RAM + 一次性装入(你说的那种)** 程序存储器换成一片**独立的** RAM/BRAM(62256、或 FPGA 的 BRAM),复位时由一小段 boot 逻辑从**任意小介质**(串行 flash、microSD、UART、甚至一块 24C512 EEPROM)把镜像搬进去, diff --git a/hardware/README.md b/hardware/README.md index e3b9364..825cbb5 100644 --- a/hardware/README.md +++ b/hardware/README.md @@ -1,7 +1,7 @@ # ROT-8 硬件:这个目录里有什么 做完大概就是 panel-mockup.png 那样(panel_mockup.py 画的草图,200 x 100 mm 面板、inside 是 160 x 100 mm Eurocard): -面板**不显示数字** —— 数字归终端(`0046`),面板只显示状态:`panel-mockup-vintage.png` 是最终取向(氖泡 + 灯泡 + 胶木按钮 + 锤纹漆):`n`n![辉光管面板](panel-mockup-vintage.png)`n +面板**不显示数字** —— 数字归终端(`0046`),面板只显示状态。`panel-mockup-vintage.png` 是 1970 年代"训练机"取向(米白漆 + 橙色分组线 + 灯泡 + 拨码 + 卡边卡带槽 + DE-9):`n`n![辉光管面板](panel-mockup-vintage.png)`n `docs/hardware.md` 的落地部分。三样东西都跑通了(Icarus Verilog 14.0): diff --git a/hardware/panel-mockup-vintage.png b/hardware/panel-mockup-vintage.png index 0d8f07c..a6deaa3 100644 Binary files a/hardware/panel-mockup-vintage.png and b/hardware/panel-mockup-vintage.png differ diff --git a/hardware/panel_mockup_vintage.py b/hardware/panel_mockup_vintage.py index 715055c..78b2e75 100644 --- a/hardware/panel_mockup_vintage.py +++ b/hardware/panel_mockup_vintage.py @@ -1,11 +1,12 @@ -"""Vintage ROT-8 panel: two rows, three columns, state only. +"""ROT-8 front panel: light "trainer" paint, orange group rules, real hardware I/O. -Every block sits in a cell of the same module grid: three columns of 56 mm at the -same x origins, two rows with the same top line, uniform 4 mm gutters, one rule -under the title. The panel shows machine state and nothing else -- the pointed -cell's eight bits on a dial, the current instruction, the 64 cells as a lamp -matrix with a blinking cursor, and the input byte. Numbers come out of the -serial port: no digits, no step counter, no dp bit row, no dial. +Two rows of sections divided by orange hairlines, the way a 1970s instrument panel +was painted: cell bits on a dial (LSB at nine o'clock, wedge marked 0, the rest +labelled 1..7), the instruction lamps, eight labelled slide switches with a SEND +button, the 64 cells as an 8 x 8 lamp matrix with the pointer blinking, a card edge +cartridge slot for the 27C512 program "tape", and a DE-9 for the 6850 serial line. + +Nothing numeric is displayed: results come out of the serial port. python hardware/panel_mockup_vintage.py hardware/panel-mockup-vintage.png """ @@ -17,30 +18,28 @@ from PIL import Image, ImageDraw, ImageFilter, ImageFont S = 7 W, H = 200 * S, 100 * S -PAINT = (46, 44, 42) -PAINT_EDGE = (22, 21, 20) -RULE = (86, 82, 75) -ENGRAVE = (216, 205, 178) -ENGRAVE_DIM = (150, 141, 122) -ENGRAVE_FAINT = (116, 110, 98) -NEON = (255, 92, 58) -BULB = (255, 196, 96) -BAKELITE = (72, 33, 30) -CHROME = (178, 180, 184) -DARK = (16, 15, 14) -DEAD = (38, 34, 28) -DEAD_EDGE = (70, 65, 55) +BEZEL = (176, 173, 166) +BEZEL_EDGE = (128, 125, 119) +PAINT = (206, 200, 188) +PAINT_SHADE = (196, 190, 177) +ORANGE = (181, 78, 42) +INK = (62, 56, 48) +INK_DIM = (116, 108, 96) +STEEL = (150, 148, 144) +DARK = (30, 27, 24) +LAMP_OFF = (58, 44, 32) +LAMP_ON = (255, 178, 56) +RED_BUTTON = (122, 40, 32) -# ---- the module grid -------------------------------------------------------- -COL = (12.0, 72.0, 132.0) # column origins, 56 mm wide, 4 mm gutters +# one module grid: three columns, two rows, 4 mm gutters +COL = (12.0, 72.0, 132.0) COLW = 56.0 -ROW_A = 25.0 # display row -ROW_B = 67.0 # controls and I/O row RIGHT = 188.0 +ROW_B = 68.0 def font(pt, serif=False): - names = ([r"C:\Windows\Fonts\georgia.ttf", r"C:\Windows\Fonts\georgiab.ttf"] + names = ([r"C:\Windows\Fonts\georgiab.ttf", r"C:\Windows\Fonts\georgia.ttf"] if serif else [r"C:\Windows\Fonts\consola.ttf"]) for path in names: try: @@ -54,135 +53,177 @@ def p(v): return int(round(v * S)) -def head(d, x, y, text): - d.text((p(x), p(y)), text, font=font(1.35), fill=ENGRAVE_DIM) +def spaced(d, x, y, text, f, fill, tracking=1.6): + """Letter spaced small caps, the way panel legends were engraved.""" + cx = x + for ch in text: + d.text((p(cx), p(y)), ch, font=f, fill=fill) + cx += (d.textlength(ch, font=f) / S) + tracking / 10.0 + + +def section(d, x, y, text, width): + d.text((p(x), p(y)), text, font=font(1.6), fill=INK) + d.line([p(x), p(y + 3.4), p(x + width), p(y + 3.4)], fill=ORANGE, + width=max(1, p(0.3))) + + +def screw(d, x, y, r=1.5): + d.ellipse([p(x - r), p(y - r), p(x + r), p(y + r)], fill=STEEL, + outline=(96, 94, 90), width=max(1, p(0.2))) + d.line([p(x - r * 0.65), p(y), p(x + r * 0.65), p(y)], fill=(84, 82, 78), + width=max(1, p(0.25))) + + +def lamp(d, g, x, y, r, lit): + d.ellipse([p(x - r - 0.5), p(y - r - 0.5), p(x + r + 0.5), p(y + r + 0.5)], + fill=(92, 86, 78), outline=(70, 65, 58), width=max(1, p(0.18))) + if lit: + g.ellipse([p(x - r * 1.5), p(y - r * 1.5), p(x + r * 1.5), p(y + r * 1.5)], + fill=LAMP_ON + (190,)) + d.ellipse([p(x - r), p(y - r), p(x + r), p(y + r)], + fill=LAMP_ON if lit else LAMP_OFF) + + +def slide_switch(d, x, y, up): + d.rounded_rectangle([p(x), p(y), p(x + 3.4), p(y + 6.0)], radius=p(0.4), + fill=(150, 146, 138), outline=(104, 100, 94), + width=max(1, p(0.18))) + ly = y + 1.0 if not up else y + 3.0 + d.rounded_rectangle([p(x + 0.7), p(ly), p(x + 2.7), p(ly + 2.0)], + radius=p(0.3), fill=(226, 222, 210), + outline=(120, 116, 108), width=max(1, p(0.15))) + + +def de9(d, x, y, w, h): + d.polygon([(p(x + 2.4), p(y)), (p(x + w - 2.4), p(y)), + (p(x + w), p(y + h)), (p(x), p(y + h))], + fill=STEEL, outline=(104, 102, 98)) + d.polygon([(p(x + 3.4), p(y + 1.2), ), (p(x + w - 3.4), p(y + 1.2)), + (p(x + w - 1.4), p(y + h - 1.2)), (p(x + 1.4), p(y + h - 1.2))], + fill=(64, 62, 58)) + for i in range(5): + px = x + 5.0 + i * (w - 10.0) / 4.0 + d.ellipse([p(px - 0.75), p(y + 2.4), p(px + 0.75), p(y + 3.9)], + fill=(198, 194, 184)) + for i in range(4): + px = x + 7.1 + i * (w - 14.2) / 3.0 + d.ellipse([p(px - 0.75), p(y + 4.6), p(px + 0.75), p(y + 6.1)], + fill=(198, 194, 184)) + + +def card_slot(d, x, y, w, h): + d.rounded_rectangle([p(x), p(y), p(x + w), p(y + h)], radius=p(1.0), + fill=(44, 42, 39), outline=(104, 100, 94), + width=max(1, p(0.3))) + d.rounded_rectangle([p(x + 3.0), p(y + 3.0), p(x + w - 3.0), p(y + h - 3.0)], + radius=p(0.5), fill=(18, 17, 16)) + for i in range(22): + fx = x + 5.2 + i * (w - 10.4) / 21.0 + d.line([p(fx), p(y + 4.2), p(fx), p(y + h - 4.2)], fill=(120, 108, 84), + width=max(1, p(0.2))) + for sx in (x + 2.2, x + w - 2.2): + screw(d, sx, y + h / 2, r=1.2) def main(): out = sys.argv[1] if len(sys.argv) > 1 else "panel-mockup-vintage.png" - img = Image.new("RGB", (W, H), (14, 14, 14)) + img = Image.new("RGB", (W, H), (18, 18, 18)) d = ImageDraw.Draw(img) - d.rounded_rectangle([p(4), p(4), p(196), p(96)], radius=p(2.2), fill=PAINT, - outline=PAINT_EDGE, width=p(0.8)) - d.rounded_rectangle([p(8), p(8), p(192), p(92)], radius=p(1.2), - outline=(74, 71, 65), width=p(0.3)) + # bezel, paint, corner screws + d.rounded_rectangle([p(2.5), p(2.5), p(197.5), p(97.5)], radius=p(2.6), + fill=BEZEL, outline=BEZEL_EDGE, width=p(0.5)) + d.rounded_rectangle([p(6.5), p(6.5), p(193.5), p(93.5)], radius=p(1.4), + fill=PAINT, outline=PAINT_SHADE, width=p(0.3)) + for sx, sy in ((10.5, 10.5), (189.5, 10.5), (10.5, 89.5), (189.5, 89.5)): + screw(d, sx, sy, r=1.6) glow = Image.new("RGBA", (W, H), (0, 0, 0, 0)) g = ImageDraw.Draw(glow) - # ---- title, rule -------------------------------------------------------- - d.text((p(12), p(10.6)), "ROT-8", font=font(4.4, serif=True), fill=ENGRAVE) - d.text((p(38.6), p(15.2)), "8 BIT · 64 CELLS · ONE INSTRUCTION PER BYTE", - font=font(1.3), fill=ENGRAVE_DIM) - d.line([p(12), p(21.5), p(RIGHT), p(21.5)], fill=RULE, width=p(0.25)) + # ---- title ------------------------------------------------------------- + d.text((p(12), p(10.4)), "ROT-8", font=font(5.2, serif=True), fill=INK) + d.rectangle([p(41.5), p(10.8), p(43.0), p(19.6)], fill=ORANGE) + spaced(d, 45.0, 14.2, "8-BIT MICROCOMPUTER TRAINER", font(1.55), INK) + d.line([p(12), p(22.4), p(RIGHT), p(22.4)], fill=ORANGE, width=max(1, p(0.3))) - # ---- column 1: the pointed cell, eight lamps on a dial ------------------ - # bit 0 (the LSB, the only bit biz and rnz test) sits at nine o'clock, marked - # with a wedge pointing at it from outside; bits run clockwise from there, so - # bit 7 ends up at half past ten. - head(d, COL[0], ROW_A + 0.6, "CELL") - ccx, ccy, cr = COL[0] + 28.0, 45.0, 11.2 + # ---- CELL: eight lamps on a dial, LSB at nine o'clock ------------------- + section(d, COL[0], 24.6, "CELL", 44) + ccx, ccy, cr = COL[0] + 26.0, 47.0, 11.0 d.ellipse([p(ccx - cr), p(ccy - cr), p(ccx + cr), p(ccy + cr)], - outline=(52, 57, 62), width=p(0.25)) - bits = [1, 0, 0, 1, 1, 0, 1, 0] # bit 0 .. bit 7 - lr = 3.0 + outline=(178, 172, 160), width=p(0.25)) + bits = [1, 0, 0, 1, 1, 0, 1, 0] # bit 0 .. bit 7 + lr = 2.9 for i, bit in enumerate(bits): - a = math.pi - i * (2 * math.pi / 8) + a = math.pi - i * (2 * math.pi / 8) # bit 0 at nine, clockwise px, py = ccx + cr * math.cos(a), ccy + cr * math.sin(a) - if bit: - g.ellipse([p(px - lr * 1.35), p(py - lr * 1.35), - p(px + lr * 1.35), p(py + lr * 1.35)], fill=BULB + (195,)) - d.ellipse([p(px - lr), p(py - lr), p(px + lr), p(py + lr)], fill=BULB, - outline=(122, 90, 34), width=p(0.3)) - else: - d.ellipse([p(px - lr), p(py - lr), p(px + lr), p(py + lr)], - fill=DEAD, outline=DEAD_EDGE, width=p(0.3)) - # the LSB wedge: apex at the bit 0 lamp, widening to the left - tip = (ccx - (cr + lr + 0.6), ccy) - base = (ccx - (cr + lr + 4.4), ccy) - d.polygon([(p(tip[0]), p(tip[1])), (p(base[0]), p(base[1] - 2.1)), - (p(base[0]), p(base[1] + 2.1))], fill=ENGRAVE_DIM) - d.text((p(base[0] - 3.6), p(ccy - 0.9)), "0", font=font(1.5), fill=ENGRAVE_DIM) + lamp(d, g, px, py, lr, bool(bit)) + if i: + lx = ccx + (cr + lr + 2.6) * math.cos(a) - 0.8 + ly = ccy + (cr + lr + 2.6) * math.sin(a) - 1.1 + d.text((p(lx), p(ly)), str(i), font=font(1.5), fill=INK_DIM) + tip = (ccx - (cr + lr + 0.7), ccy) + base = (ccx - (cr + lr + 4.6), ccy) + d.polygon([(p(tip[0]), p(tip[1])), (p(base[0]), p(base[1] - 2.2)), + (p(base[0]), p(base[1] + 2.2))], fill=INK) + d.text((p(base[0] - 3.4), p(ccy - 1.0)), "0", font=font(1.6), fill=INK) - # ---- column 2: the current instruction, then the input byte ------------- - head(d, COL[1], ROW_A + 0.6, "INSTRUCTION") + # ---- INSTRUCTION ------------------------------------------------------- + section(d, COL[1], 24.6, "INSTRUCTION", 50) for i, op in enumerate("><+-[].,"): - x = COL[1] + i * 6.9 - lit = i == 1 - if lit: - g.ellipse([p(x - 0.6), p(ROW_A + 4.0 - 0.6), p(x + 5.4), p(ROW_A + 4.0 + 5.4)], - fill=BULB + (205,)) - d.ellipse([p(x + 0.3), p(ROW_A + 4.3), p(x + 4.5), p(ROW_A + 8.5)], - fill=BULB, outline=(122, 90, 34), width=p(0.3)) - else: - d.ellipse([p(x + 0.3), p(ROW_A + 4.3), p(x + 4.5), p(ROW_A + 8.5)], - fill=DEAD, outline=DEAD_EDGE, width=p(0.3)) - d.text((p(x + 1.4), p(ROW_A + 10.2)), op, font=font(1.7), fill=ENGRAVE) + x = COL[1] + 2.4 + i * 6.9 + lamp(d, g, x, 33.6, 2.5, i == 1) + d.text((p(x - 1.2), p(38.0)), op, font=font(1.9), fill=INK) - head(d, COL[1], ROW_A + 20.4, "INPUT BYTE") - d.rounded_rectangle([p(COL[1]), p(ROW_A + 23.4), p(COL[1] + 44), p(ROW_A + 30.6)], - radius=p(0.5), outline=(104, 99, 90), width=p(0.3)) + # ---- INPUT BYTE: eight switches, numbered, plus SEND ------------------- + section(d, COL[1], 43.4, "INPUT BYTE", 34) for i in range(8): - d.rectangle([p(COL[1] + 1.6 + i * 5.2), p(ROW_A + 24.8), - p(COL[1] + 4.6 + i * 5.2), p(ROW_A + 29.2)], - fill=(226, 216, 190), outline=(94, 89, 79)) - d.text((p(COL[1]), p(ROW_A + 31.6)), "8 SWITCHES + SEND", font=font(1.2), - fill=ENGRAVE_FAINT) + x = COL[1] + 2.6 + i * 5.4 + slide_switch(d, x, 48.8, up=(i % 3 != 0)) + d.text((p(x + 0.5), p(55.8)), str(7 - i), font=font(1.5), fill=INK_DIM) + d.text((p(COL[1] + 46.0), p(44.4)), "SEND", font=font(1.5), fill=INK) + d.ellipse([p(COL[1] + 44.4), p(48.0), p(COL[1] + 53.6), p(57.2)], + fill=STEEL, outline=(104, 100, 94), width=p(0.25)) + d.ellipse([p(COL[1] + 45.4), p(49.0), p(COL[1] + 52.6), p(56.2)], + fill=RED_BUTTON, outline=(70, 24, 20), width=p(0.25)) - # ---- column 3: the 64 cells as a lamp matrix --------------------------- - # An unbounded line in the ISA, a ring of 64 cells in this machine: one lamp - # per cell showing that cell's LSB, and the pointer blinks like a cursor so - # dp needs no number. - head(d, COL[2], ROW_A + 0.6, "DATA 64 · LSB PER CELL · BLINKS") - mx, my, pitch, lrad = COL[2] + 6.0, ROW_A + 4.0, 4.35, 1.42 + # ---- DATA 64: the lamp matrix ------------------------------------------ + section(d, COL[2], 24.6, "DATA 64", 56) + mx, my, pitch, lrad = COL[2] + 2.6, 30.4, 4.6, 1.5 pattern = [0x9C, 0x71, 0x23, 0xC8, 0x4E, 0x96, 0x3B, 0xA5] for row in range(8): for col in range(8): idx = row * 8 + col - bit = (pattern[row] >> (7 - col)) & 1 x = mx + col * pitch y = my + row * pitch if idx == 33: - g.ellipse([p(x - lrad * 2.1), p(y - lrad * 2.1), - p(x + lrad * 2.1), p(y + lrad * 2.1)], - fill=NEON + (150,)) - d.ellipse([p(x - lrad - 0.45), p(y - lrad - 0.45), - p(x + lrad + 0.45), p(y + lrad + 0.45)], - outline=NEON, width=p(0.42)) - elif bit: - g.ellipse([p(x - lrad * 1.4), p(y - lrad * 1.4), - p(x + lrad * 1.4), p(y + lrad * 1.4)], fill=BULB + (180,)) - d.ellipse([p(x - lrad), p(y - lrad), p(x + lrad), p(y + lrad)], - fill=BULB, outline=(122, 90, 34), width=p(0.2)) + g.ellipse([p(x - lrad * 2.2), p(y - lrad * 2.2), + p(x + lrad * 2.2), p(y + lrad * 2.2)], + fill=(255, 120, 60, 170)) + d.ellipse([p(x - lrad - 0.5), p(y - lrad - 0.5), + p(x + lrad + 0.5), p(y + lrad + 0.5)], + outline=(196, 74, 40), width=max(1, p(0.45))) else: - d.ellipse([p(x - lrad), p(y - lrad), p(x + lrad), p(y + lrad)], - fill=DEAD, outline=DEAD_EDGE, width=p(0.2)) + lamp(d, g, x, y, lrad, bool((pattern[row] >> (7 - col)) & 1)) - # ---- row B: cartridge, then the serial line ---------------------------- - d.rounded_rectangle([p(COL[0]), p(ROW_B), p(COL[0] + COLW), p(ROW_B + 18)], - radius=p(0.6), fill=(20, 19, 18), outline=(104, 99, 90), - width=p(0.3)) - d.text((p(COL[0] + 1.8), p(ROW_B + 2.0)), "27C512 · UV WINDOW", font=font(1.4), - fill=ENGRAVE) - d.text((p(COL[0] + 1.8), p(ROW_B + 5.8)), "program cartridge", font=font(1.3), - fill=ENGRAVE_DIM) - d.text((p(COL[0] + 1.8), p(ROW_B + 9.4)), "64K x 8, one byte", font=font(1.3), - fill=ENGRAVE_DIM) - d.text((p(COL[0] + 1.8), p(ROW_B + 12.8)), "per instruction", font=font(1.3), - fill=ENGRAVE_DIM) + # ---- lower row --------------------------------------------------------- + d.line([p(12), p(65.4), p(RIGHT), p(65.4)], fill=ORANGE, width=max(1, p(0.3))) + d.text((p(COL[0]), p(ROW_B)), "PROGRAM / 27C512", font=font(1.6), fill=INK) + card_slot(d, COL[0], ROW_B + 3.6, COLW, 13.0) + d.text((p(COL[2]), p(ROW_B)), "SERIAL / 6850", font=font(1.6), fill=INK) + de9(d, COL[2] + 4.0, ROW_B + 3.6, 30.0, 10.0) - head(d, COL[1], ROW_B + 0.4, "SERIAL 9600 8N1") - for k, txt, col in ((ROW_B + 3.6, "> 12 34 + .", (188, 178, 156)), - (ROW_B + 10.6, "0046", NEON)): - d.rounded_rectangle([p(COL[1]), p(k), p(RIGHT), p(k + 6.0)], - radius=p(0.4), fill=DARK, outline=(94, 89, 79), - width=p(0.25)) - d.text((p(COL[1] + 1.4), p(k + 1.2)), txt, font=font(1.4), fill=col) + # the middle of the lower row carries the plate legend, not a readout + d.text((p(COL[1]), p(ROW_B + 1.0)), "1 MHz · 8 BIT CELLS · 64 CELL DATA RING", + font=font(1.4), fill=INK_DIM) + d.text((p(COL[1]), p(ROW_B + 5.0)), "27C512 PROGRAM · 6116 DATA · 74LS CONTROL", + font=font(1.4), fill=INK_DIM) + d.text((p(COL[1]), p(ROW_B + 9.0)), "NO NUMBERS ON THE PANEL: RESULTS VIA SERIAL", + font=font(1.4), fill=INK_DIM) img = Image.alpha_composite( img.convert("RGBA"), - glow.filter(ImageFilter.GaussianBlur(p(0.6)))).convert("RGB") + glow.filter(ImageFilter.GaussianBlur(p(0.55)))).convert("RGB") img.save(out) print("wrote", out)