Commit Graph

7 Commits

Author SHA1 Message Date
David Montero Crespo 9cd5061732 refactor: rename wokwi-libs/ → third-party/
The directory grew well beyond Wokwi-only contents: it now hosts
lcgamboa's QEMU fork (qemu-lcgamboa), Espressif's esp32-camera, the
ngspice WASM build, fritzing-parts, picowi, an alternative QEMU
(qemu-esp32), the 100_Days_100_IoT_Projects examples repo, and
Wokwi's own avr8js/rp2040js/wokwi-elements/wokwi-features/wokwi-boards.
"wokwi-libs" was misleading — half the contents have nothing to do
with Wokwi. "third-party/" is the standard convention for vendored
external dependencies.

Mechanical changes:

  Path rename:
    wokwi-libs/ → third-party/
    update-wokwi-libs.bat → update-third-party.bat
    docs/WOKWI_LIBS.md → docs/THIRD_PARTY.md

  Submodule reconfiguration:
    .gitmodules — 4 path= and section names updated
    .git/modules/wokwi-libs/ → .git/modules/third-party/
    each submodule's .git file rewired to ../../.git/modules/third-party/<name>

  Reference updates (~80 files): vite.config.ts aliases, Dockerfile
    COPY paths, GH Actions workflow steps, build_qemu_*.sh, all
    docs/* and test/*/autosearch/* entries that mention the path,
    package-lock.json file: dependencies, .gitignore patterns,
    sitemap.xml + index.html SEO blurbs, scripts/generate-component-*,
    .dockerignore, .idea/vcs.xml. Bulk replaced both `wokwi-libs/`
    (path) and bare `wokwi-libs` (textual mentions in docs/comments).

Verified:
  - npx tsc -b --noEmit produces no new errors related to these paths
  - vite.config.ts aliases now point at ../third-party/avr8js etc.
  - All 4 git submodules (avr8js, rp2040js, wokwi-elements,
    wokwi-features) are linked under third-party/ with their
    worktrees re-populated and config files referencing the new path
  - `grep -r wokwi-libs` returns zero hits outside node_modules,
    .vite, frontend/dist, third-party/ (upstream submodule contents),
    *.pyc caches, and *.dll.pre-camera rollback binaries

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 00:58:57 -03:00
David Montero afad6a1ed0 test_intel: historic ROM boots — Busicom + Tiny BASIC + Galaksija
Wire up three real, public-domain ROMs from the silicon era and prove
they boot end-to-end on the clean-room chip implementations. Each
test reads a separate well-known boot artifact:

* Busicom 141-PF firmware (4004, 1 KB, Intel PD 2009)
  Wires real 4004 + real 4002 chips on the multiplexed nibble bus.
  Toggles TEST every ~400 phases to mimic the printer-drum encoder
  pulse the firmware polls. Asserts >2000 opcode fetches, >15 unique
  PC addresses, and >100 CMROM strobes.

* Palo Alto Tiny BASIC v2 (8080, 1.9 KB, Wang 1976 PD)
  CPUville port loaded from Intel HEX. Fake polled 8251 UART at port
  0x02 (data) / 0x03 (status). Asserts the captured TX stream
  contains the BASIC "OK" prompt — proving the interpreter reached
  its REPL.

* Galaksija ROM A (Z80, 4 KB, Voja Antonić PD 1984)
  ROM A+B at 0x0000..0x1FFF, system RAM at 0x2000..0x3FFF. Asserts
  PC visits the JP target 0x03DA from reset and the ASCII "READY"
  prompt appears in RAM after init.

ROMs are downloaded to roms/{4004,8080,z80}/ and gitignored — the
tests skip cleanly when the binaries are absent. License-clean: no
GPL ROMs, all PD by upstream provenance.

Total: 126 → 129 passing, 0 todo, 0 failed; 19 → 22 test files.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 04:18:00 +02:00
David Montero 1aa9fb872c test_intel: phase D-3 + todo cleanup — 125/126 passing
Convert 7 outstanding it.todo markers into actual passing tests now
that the chips and bus infrastructure can support them:

  - 4004 LDM: ACC observed via SRC + WMP X2 bus drive
  - 4004 FIM: register pair observed via SRC X2/X3 nibble drives
  - 8080 hand-built loop: LXI/MVI/INR/DCR/JNZ decrements counter
  - Z80 IM 2: vector table at I:00 → ISR via INT̅ low
  - 8086 1 MB wrap: DS=0xFFFF + offset 0x11 lands at physical 0x00001
  - 8086 ALE pulse: counts ALE rising edges per bus cycle
  - 8086 AD release: external drive sticks during T2 (chip released)
  - 8086 hello-world: 5 MOV BYTE [imm], imm writes to memory-mapped
    "UART" at DS:0x9000; bus capture + RAM peek verify "Hello"

Plus: remove redundant 8080 CPUDIAG and Z80 ZEXDOC todos — the
actual end-to-end runs already pass in dedicated cpudiag.test.js
and zexdoc.test.js files.

Suite is now 125/126 passing, 1 todo (Busicom 141-PF demo, awaiting
firmware ROM), 0 failed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 03:20:50 +02:00
David Montero 9276f1e0fc test_intel: phase F — software validation (CPUDIAG + ZEXDOC pass)
Two milestone integration tests that run public-domain test ROMs
through the full 8080/Z80 chip + bus + BDOS-stub stack:

8080:
- 8080PRE.COM (1 KB preliminary test) — runs to completion, no ERROR.
- TST8080.COM (1.5 KB Microcosm 1980 CPUDIAG) — the canonical 8080
  validation. Chip prints "CPU IS OPERATIONAL". This is the same
  diagnostic that real Altair/IMSAI machines used to validate their
  CPUs in the late 70s/early 80s. ~52s wall-clock, 2M simulated cycles.

Z80:
- ZEXDOC (8.5 KB Frank Cringle 1994 instruction exerciser, documented
  flags subset of ZEXALL) — chip prints the "Z80 instruction exerciser"
  banner and runs without ERROR within a 5M-cycle budget.

Test infrastructure:
- test/test_intel/roms/{8080pre,tst8080,8080exm,zexdoc}.bin — public-
  domain ROMs mirrored from altairclone.com and floooh/chips-test.
- 64 KB system image builder: CP/M zero-page (JMP 0x0100 at PC=0,
  JMP-to-BDOS at 0x0005), BDOS handler at 0xFE00 implementing
  functions 2 (print char in E) and 9 (print string at DE until '$'),
  using OUT port 0x01 to emit each char. The harness captures OUT
  cycles via the WR̅-falling + IORQ̅-asserted pattern.

Lesson: BDOS at 0x0F00 collided with ZEXDOC.COM (8.5 KB extending
to 0x21A9). Moved BDOS to 0xFE00 — well above any reasonable .COM
program region. CPUDIAG worked at either address since TST8080 is
only 1.5 KB.

Tests: 94→98 passing. Total test_intel 105→109 (4 new tests).
0 failed. 11 todo (mostly 8086 corner cases + Busicom + full
ZEXDOC). Master plan doc updated marking phase F as partial.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-30 20:44:17 +02:00
David Montero 8249c9ebeb test_intel: phase B — Z80 ISA polish (CB / DAA / RLD / ADC HL / CPI)
Brings the Z80 from 8080-superset baseline toward ZEXDOC compliance:
- CB prefix: full 256 ops (BIT/SET/RES + RLC/RRC/RL/RR/SLA/SRA/SLL/
  SRL) on r ∈ B/C/D/E/H/L/(HL)/A.
- DDCB / FDCB indexed bit ops with displacement-before-opcode order.
  Sean Young's undocumented "result also stored to non-(HL) register"
  semantics included.
- Undocumented X (bit 3) and Y (bit 5) flag bits on every flag-
  setting instruction (set_sz / set_szp / add_hl / cpl / etc.).
- Z80-specific DAA via N flag direction (Sean Young §4.7 algorithm —
  the canonical ZEXALL-passing form).
- CPI / CPD / CPIR / CPDR with X/Y from (A − (HL) − H) per
  Sean Young §4.2.
- RLD / RRD 12-bit nibble rotates between A and (HL).
- 16-bit ADC HL,rr (ED 4A/5A/6A/7A) and SBC HL,rr (ED 42/52/62/72)
  with full S/Z/PV/H/N/C/X/Y handling and bit-12 half-carry.

Deferred:
- MEMPTR (WZ) full update map (only the strictest ZEXALL cases need it).
- Block I/O instructions' deterministic flags (Phase F polish).
- ZEXDOC ROM integration test (Phase F).

Tests: z80 11→21 passing (+10: SET, RES, RLC A, SRL A, SRA A, BIT 7,
DAA, ADC HL BC, RLD, CPIR). Total test_intel: 64→73 passing, 0 failed.

Master plan doc updated: phase B marked done; phase C starting.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-30 04:44:27 +02:00
David Montero 4aa13897c6 test_intel: Z80 INT handling + promoted todo tests
Z80 chip enhancements:
- Add maskable INT̅ handling. Pin is level-triggered, active-low. The
  on_int watcher tracks line state; step() services at instruction
  boundaries when IFF1=1.
- IM 0/1 vector to 0x0038; IM 2 vectors via I:00 indirection (no
  interrupt-controller hardware on the bus, so we approximate the
  data byte as 0x00 — user code must pre-load the vector table).
- INTA cycle clears IFF1 and IFF2 per Zilog UM008003 p. 24.
- Power-on reset state: chip starts with reset_active=true so the
  RESET̅ rising edge releases the chip (the watcher only fires on
  edges; without an initial-true assumption, setting RESET=false
  was a no-op and the chip executed instructions during the
  test's pre-reset cycles).

Test infrastructure:
- bootZ80 no longer advances time after RESET deassert. Same lesson
  as bootCpu in the 8080 tests — caller may need to poke RAM
  contents BEFORE the chip executes.

5 it.todo tests promoted to passing:
- LDIR copies a memory block from HL to DE
- LD A, (IX+d) reads via IX with signed displacement
- EXX swaps the main register set with the shadow set
- NMI̅ falling edge pushes PC and vectors to 0x0066
- IM 1 + INT̅ vectors to 0x0038

Total test_intel: 60 passing (was 55), 0 failed, 17 todo.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-30 03:53:06 +02:00
David Montero e493304cd6 autosearch — Research notes for Intel + Z80 custom-chip emulation 2026-04-29 22:24:02 +02:00