SW15 switches the terminal from the PC's serial line to a Z-80 running at 90 MHz from its own clock, with 64 KB of block RAM preloaded with BASIC. - rtl/z80_cpu.v: Z-80 built for speed (one clock per memory access, next byte read during decode), full documented instruction set plus the common undocumented forms; no interrupts. - rtl/z80_system.v: RAM, console/timer/7-segment ports, toggle handshakes to the terminal clock. - basic/: BASIC interpreter in C for SDCC, start-up code, prebuilt image. - tools/z80emu.py, tools/cputest.py, scripts/cpusim.sh: reference emulator and random tests comparing the CPU after every instruction. - SW14 feeds the PC's UART into the Z-80 for pasting programs; BTND resets the Z-80 only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
21 lines
755 B
Python
21 lines
755 B
Python
#!/usr/bin/env python3
|
|
"""Compare two register traces; print the first difference with context."""
|
|
import sys
|
|
|
|
names = "pc af bc de hl ix iy sp".split()
|
|
a = open(sys.argv[1]).read().split("\n")
|
|
b = open(sys.argv[2]).read().split("\n")
|
|
for i, (x, y) in enumerate(zip(a, b)):
|
|
if x != y:
|
|
print("MISMATCH at instruction %d" % i)
|
|
for j in range(max(0, i - 4), i):
|
|
print(" ", a[j])
|
|
print("sw:", x)
|
|
print("hw:", y)
|
|
print(" ", " ".join(n for n, u, v in zip(names, x.split(), y.split()) if u != v), "differ")
|
|
sys.exit(1)
|
|
print("traces match: %d instructions" % (min(len(a), len(b)) - 1))
|
|
if len(a) != len(b):
|
|
print("lengths differ: sw %d hw %d" % (len(a) - 1, len(b) - 1))
|
|
sys.exit(1)
|