Files
ROT-8-Machine/tools/bringup_sketch.py
T
dsh d0dc2d4d66 ROT-8-Machine: one physical ROT-8, split out of R8Forge
This repository is a machine, not a toolchain.  R8Forge keeps the language, the ISA
specification and the tools that assemble, pack and run tapes; this one keeps what it
takes to build the thing: the RTL and its testbench, the requirements note, the 34 chip
board wiring, the panel design and its mockups, the mechanics analysis, the bill of
materials, the buying guide and the order sheet, the bring up plan, and the microcode
directory that is still empty.

The equivalence test came with the RTL, since it needs both halves: it assembles a tape
with r8forge, packs it with tape_pack, runs it with tape_run --loop-stack --retest, then
compiles rtl/rot8.v with iverilog and requires the same OUT stream and the same step
count.  It takes those three binaries as parameters and its header says they must be
built for eight bit cells and sixty four cells, because an eleven bit packer feeding an
eight bit machine produces different output and looks like an RTL bug.

Verified here: hello 577 instructions 417 steps, calc 51378 instructions 166741 steps
with "12 34 + ." fed in, both agreeing with the interpreter.
2026-11-25 17:02:09 +08:00

105 lines
3.6 KiB
Python

"""Block diagram for stage 1: ip counter, ROM, data lamps.
A breadboard top view looked like a drawer of parts; this says the same thing in
the form that is actually checkable: which block feeds which, and on which bus.
The pin table in bringup.md is the wiring; this is the shape of it.
python tools/bringup_sketch.py img/bringup.png
"""
import sys
from PIL import Image, ImageDraw, ImageFont
S = 7
W, H = 200 * S, 96 * S
BG = (247, 245, 239)
BOX = (255, 254, 250)
EDGE = (52, 48, 44)
TEXT = (40, 36, 32)
DIM = (120, 112, 100)
BUS = (44, 82, 150)
CTRL = (172, 48, 40)
DATA = (36, 116, 74)
def font(pt):
for path in (r"C:\Windows\Fonts\consola.ttf", r"C:\Windows\Fonts\lucon.ttf"):
try:
return ImageFont.truetype(path, int(pt * S))
except OSError:
continue
return ImageFont.load_default()
def p(v):
return int(round(v * S))
def box(d, x, y, w, h, title, sub, fill=BOX):
d.rounded_rectangle([p(x), p(y), p(x + w), p(y + h)], radius=p(1.4),
fill=fill, outline=EDGE, width=p(0.35))
d.text((p(x + 3.0), p(y + 3.2)), title, font=font(2.0), fill=TEXT)
if sub:
for i, line in enumerate(sub.split("|")):
d.text((p(x + 3.0), p(y + 7.6 + i * 3.0)), line, font=font(1.35),
fill=DIM)
def bus(d, pts, label, colour, at=0.5, above=True):
d.line([(p(a), p(b)) for a, b in pts], fill=colour, width=p(0.8), joint="curve")
# arrow head on the last segment
(x0, y0), (x1, y1) = pts[-2], pts[-1]
d.polygon([(p(x1), p(y1)), (p(x1 - 2.0), p(y1 - 1.4)),
(p(x1 - 2.0), p(y1 + 1.4))] if abs(x1 - x0) > abs(y1 - y0) else
[(p(x1), p(y1)), (p(x1 - 1.4), p(y1 - 2.0)), (p(x1 + 1.4), p(y1 - 2.0))],
fill=colour)
# label along the first segment
seg = pts[0], pts[1]
lx = seg[0][0] + (seg[1][0] - seg[0][0]) * at
ly = seg[0][1] + (seg[1][1] - seg[0][1]) * at
tw = d.textlength(label, font=font(1.4)) / S
d.text((p(lx - tw / 2), p(ly - (3.4 if above else -1.4))), label,
font=font(1.4), fill=colour)
def main():
out = sys.argv[1] if len(sys.argv) > 1 else "bringup.png"
img = Image.new("RGB", (W, H), BG)
d = ImageDraw.Draw(img)
d.text((p(6), p(5)), "STAGE 1 · ip COUNTER → ROM → DATA LAMPS", font=font(2.6),
fill=TEXT)
d.text((p(6), p(10.6)),
"the whole point is to watch the address walk and the fetched byte change",
font=font(1.5), fill=DIM)
# blocks
box(d, 22, 30, 34, 22, "74LS161", "ip[3:0]|TC → next CET", BOX)
box(d, 22, 62, 34, 22, "74LS161", "ip[7:4]", BOX)
box(d, 82, 38, 34, 30, "28C256", "A0..A7 in|D0..D7 out|low 3 bits = opcode",
(250, 250, 244))
box(d, 144, 38, 34, 30, "8 LEDS", "330 Ω each|D0 left, D7 right", (250, 250, 244))
# buses
bus(d, [(56, 41), (70, 41), (70, 46), (82, 46)], "A0..A3", BUS, 0.45)
bus(d, [(56, 73), (70, 73), (70, 52), (82, 52)], "A4..A7", BUS, 0.45)
bus(d, [(39, 52), (39, 62)], "TC", CTRL, 0.5, above=False)
bus(d, [(116, 50), (144, 50)], "D0..D7", DATA, 0.5)
bus(d, [(6, 39), (22, 39)], "CLK", CTRL, 0.4)
bus(d, [(6, 73), (22, 73)], "RST", CTRL, 0.4)
# power and notes
d.text((p(6), p(86)), "5 V / GND to every part · ~CE and ~OE tied low (always "
"selected) · ~WE tied HIGH (read only!)", font=font(1.4), fill=DIM)
d.text((p(6), p(90)),
"clock: a button for single step first, then 74LS14 RC at ~5 Hz, 1 MHz only "
"when it all works", font=font(1.4), fill=DIM)
img.save(out)
print("wrote", out)
if __name__ == "__main__":
main()