Commit Graph
13 Commits
Author SHA1 Message Date
Cryan209andClaude Opus 5.5 bbed293b1d x86 engine: run the 386's SETcc, CBW and CWD natively
The I-modem left the engine about 115k times a call for one CBW (at
0xa7515) and 85k for a SETZ (at 0xa5e50), each a round trip through
Python. SETcc is done in the engine on the 386 profile (the 80186 still
refuses the 0x0f escape, as the reference does); CBW and CWD no longer
yield there, since the engine already stops for any register with its
upper half set, and with those zero the 16-bit forms write exactly what
the reference's full-register write does. New differential test for
SETcc on both profiles; the full x2 call is bit-identical, wall 30.2 s ->
28.4 s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 11:27:03 +13:00
Cryan209andClaude Opus 5.5 896f5e9462 Run the analog worker's fast services inside the x86 engine
courier_worker_poll (c5x_capi.cpp) does what interpreter_service,
fast_service and clock_x86_fast do for a service in which only the DSP,
the clocks and the DSP's frame edge move: the codec-frame, line-sample and
probe tests, the DSP step with the same debt and CPI arithmetic, and the
INT0 frame-edge entry. Python arms it at the start of the batch after each
service of its own when every test of Python-only state comes out the
fast way, with a deadline before a timer's max count (the 80186 timers
advance lazily, as every access to one does first), the board tick, typed
input or the end of the run; the fields come back whenever the engine
returns. End-of-interrupt writes logged in the batch are applied to the
in-service stack before the frame-edge decision and marked, so the replay
leaves the stack alone. A DSP message, the call TDM starting, the loader
loop changing or a DSP error hand the rest of the service back to Python
(resume codes 2 and 3). The engine lends the poll its guard bytes and the
batch's port and memory-mapped write logs; lamp writes that repeat the
latch no longer force a Python poll.

64% of services now run natively. The x2 call, a Bell 103 call and a V.34
dial are bit-identical; the x2 call goes from 37 s to 33.6 s wall time
(CPU 60.7 s -> 56.3 s). COURIER_WORKER_POLL=0 turns it off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 10:16:19 +13:00
Claude 984cf83541 Replay the interrupt controller's EOI writes in batches
The native x86 engine logs writes to bytes whose guard has bit 64 and the
harness replays them in order before it next runs any Python, so the end-of-
interrupt write no longer takes the engine out of its loop. Fix the poll-exit
bookkeeping to look at whether a poll is installed rather than at how many
arguments the engine was given.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012FxMN2ECAudm1U2CeD998v
2026-10-07 10:55:07 +00:00
Claude 6a17534c89 Serve the PIC and timers natively in the poll
Share the interrupt controllers, PIT wrap state and service deadlines in a
ctypes PollState, serve the PIC ports and the poll tail natively, and enter
interrupts in the engine. Bit-identical; full call 169 s -> 155 s.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012FxMN2ECAudm1U2CeD998v
2026-10-07 10:22:21 +00:00
Claude bddfcd6d28 Let the native engine run the I-modem's poll when nothing else in it is due
With a call up on the bearer line, the engine settles PCM frames, feeds the
DSP ahead and advances it at each poll boundary itself, calling Python only
when a timer falls due, a device is touched, or the line clock has a frame to
send. What the skipped polls would have done to the interrupt controller is
done before anything looks at it. Bit-identical on the full call.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012FxMN2ECAudm1U2CeD998v
2026-10-07 09:50:04 +00:00
Claude 8c2442e691 Native I-modem lane port model with a native DSP advance
- libcourier_c5x: an I-modem port model serving the data lanes' stores,
  the 0x18/0x1a status reads and latch writes and the lane window reads
  from the DSP's I/O cells, together with the same C5x advance the
  harness runs on every access and service pass (with the same read
  quantum). It stops, leaving needs_service set, wherever the harness has
  to act - a finished PCM frame or a reply to offer - and ImodemDsp
  .service_pending performs that work and continues in Python.
- ImodemDsp's ledger and mailbox scalars (dsp_instructions, cycle debt,
  PCM cursor, host_pending, tx_ready, consumed, reply writes, lane bytes)
  live in a shared ctypes struct that Python and the native model use in
  place, so nothing is marshalled per access.
- Status reads advance the C5x only if 32 instructions have passed since
  its last advance; the skipped time stays owed. Writes advance exactly.
- The x86 engine hands port models the harness's instruction count;
  after-I/O refresh is limited to the mailbox's own ports.
- Single-call getters replace dict-building stats reads on hot paths.

The I-modem's complete state, including every I/O tally, is bit-identical
with the native model on and off (COURIER_NATIVE_IO=0 selects the Python
path). Paired x2 still connects at 53333 with both payloads intact; full
call 250 s -> 216 s. Adds tests for both native port models.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012FxMN2ECAudm1U2CeD998v
2026-10-07 02:01:05 +00:00
Claude 620cc530d3 Native lane I/O, batched panel latch, cheaper DSP probes, optional line window
- x86 engine: serve the analogue board's live data-lane ports (command,
  ack, window reads/stores) through a port model in libcourier_c5x, which
  works directly on the DSP's I/O cells. Tallies and last-written values
  are folded back into the machine's I/O accounting; anything the model
  declines still goes to Python.
- Port 0x14 (front-panel latch / board latch) writes are batched and
  replayed in order on both modems.
- C5x core: the per-instruction V.8 dispatch probe is a bitmap lookup
  instead of a vector scan, and the first-execution tracker is per core.
  These ran on every retired instruction.
- I-modem: slimmer per-access DSP advance chain; core PC read through a
  tiny getter; faster advance_imodem result handling.
- LineLink: optional COURIER_LINE_WINDOW (frames in flight, default 1 =
  unchanged) so the two modem processes can run ahead of each other by the
  line's transit delay.

Paired x2 still connects at 53333 with both payloads intact; full call
350 s -> 250 s. Registers, instruction counts and I/O tallies match the
previous build on the 60M control.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012FxMN2ECAudm1U2CeD998v
2026-10-07 00:49:57 +00:00
Claude 4eb6f21830 Speed up the paired I-modem/analog emulation
- Analog bridge: run the C5x to its cycle target in one native call
  (step_cycles) instead of looping step()+state(), which also skips IDLE
  spans; read line_tx_writes/samples and the codec rate through small
  native getters instead of building the full serial/codec state dicts;
  reuse ctypes buffers on the per-chunk calls.
- Line exchange runs once a useful batch of codec samples has accumulated
  (bounded skip, fallback timer credited), not on every service chunk.
- Resampler dot product uses math.sumprod when available.
- x86 native engine retires software INT itself for vectors the harness
  marks (I-modem: all vectors), counting them per vector; null vectors and
  guarded accesses still fall back to the Python hook.
- advance_timer avoids two 64-bit divisions in the common period-1 case.
- Build the C5x library with -fno-semantic-interposition so calls inside it
  skip the PLT and can inline.

Paired x2 (53333) still connects with both payloads intact; the I-modem's
register, interrupt and instruction state is identical to before on the
60M-instruction control. Adds a native-vs-hook INT equivalence test and
updates the audio-rate test double for line_tx_writes().

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012FxMN2ECAudm1U2CeD998v
2026-10-06 23:48:52 +00:00
Cryan209 39241c4a41 Enable bidirectional Bell 103 data on I-modem pairs
Repair call-overlay acknowledgements and wire the six-word runtime data window with separate DSP holding registers. Correct C5x filter timing and x86 interrupt entry, expand pair probes and diagnostics, and retain regression tests and capture evidence.
2026-10-02 09:28:52 +13:00
Cryan209 8c20d25c6b Inject I-modem interrupts in native core 2026-09-30 12:13:57 +13:00
Cryan209 ce766bcd4c Batch native I-modem device writes 2026-09-30 12:05:20 +13:00
Cryan209 1f5b90cc88 Retire x86 port I/O in native core 2026-09-30 10:36:03 +13:00
Cryan209 21661e3e54 Accelerate x86 interpreter with guarded native execution 2026-09-15 16:33:54 +12:00