113 Commits
Author SHA1 Message Date
Claude e94e79469e Merge cryan209/courier-emu main (3 commits)
Brings in f1ccd92 (board reads move to dumps/), d138dc2 (3453 flash
boot, browser GUI, Apple USB Modem line, RTP/G.711, V.90 and x2 timing,
Quad) and e84e324 (native worker gate and resampler loops).

Conflicts:
- Frame timing (machine.py, worker_poll.py, native/c5x_capi.cpp): keep
  the upstream frame-source code (_frame_irq_due, worker_frame_due, XF
  edges). Add the fork's opt-in COURIER_INT0_TOUT source into those
  functions, and keep COURIER_INT0_EXACT. The new struct fields are at
  the end of WorkerPollState, in C and ctypes.
- bearer_line.py and the closed-loop probe: keep the fork's opt-in line
  loss, noise and A-law test settings, with the upstream imports, frame
  constants and dumps/ paths.
- Docs: keep the STE text of the fork, with the dumps/ paths. Keep the new
  upstream sections. The README stays a short landing page. The new
  README text of the upstream goes to docs/research-log.md,
  docs/current-boundary.md, docs/usage.md and the new docs/gui.md (STE).
  docs/README.md lists the new upstream notes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRyJwNajT59BytMgdQ
2026-11-23 14:32:24 +00:00
Cryan209 d138dc27b5 Extend Courier firmware, line transport, and diagnostics
Add captured 3453 flash boot and modem data-path support, a local browser
console, and an Apple USB Modem line backend. Improve I-modem and Quad
firmware timing, UART framing, and SIP/RTP media handling.

Include regression tests, compact hardware evidence, and documentation
for the measured link behavior. Keep pytest discovery scoped to tests/.
2026-11-23 12:17:28 +13:00
Claude 02656050bb c5x: optional model of SPRU056D's register write latencies
COURIER_C5X_MMR_LATENCY (off by default) delays memory-mapped writes to
the registers of SPRU056D Table 7-10 by their listed words. Used to rule
them out as the cause of the x2 upstream click.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B82eRTieSnZY49zbAZzpUP
2026-11-07 19:39:00 +00:00
Cryan209andClaude Opus 5.5 72e66e1c9a Raise the I-modem's IRQ13 from the DSP's timer output
IRQ13 is the 386EX's INT6 pin (INTCFG 0x0d puts INT6 on slave IR5,
Intel386 EX manual figs 5-4/5-5), and its handler at b3d9:0000 is a
~2400 Hz tick: the firmware converts ms to ticks as ms*256/107. The C5x
runs PRD 0x41a4, 2399 Hz at 40.32 MHz, and on the 403 board its TOUT
goes into the ASIC that drives the CPU's interrupt lines. So instead of a
fixed instruction cadence, each timer expiry - C5xCore::timer_expiries,
counted in advance_timer whether TINT is masked or not - raises IRQ13,
in the Python poll and the native one. Without a DSP the old cadence
stays as the capture-only endpoint's stand-in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 22:50:23 +13:00
Cryan209andClaude Opus 5.5 f000ad1bb1 Count the C5x timer through zero, as SPRU056D 9.3.2 does
PSC and TIM generate their borrow on the CLKOUT cycle after they reach
zero, so TINT rate = CLKOUT / ((TDDR+1) * (PRD+1)). advance_timer
treated the periods as max(TDDR, 1) and PRD (65536 for zero), running
the timer one count fast: PRD=99 gave 1010 expiries in 100000 cycles
instead of 1000, and PRD=0 a TINT every 65536 cycles instead of every
TDDR+1. The first-TINT deadline and the IDLE skip now share
timer_distance() rather than repeating the formula.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 22:39:33 +13:00
Cryan209andClaude Opus 5.5 851a36085c Carry the DSP's stream words to the supervisor
The stream sender (`out *, 0060` at 0x849e on the 403, 0x8980 on the
I-modem) writes a holding register nothing modelled, and flags the word in
a status bit nobody reported, so every streamed reply - ATI11's tag 57,
the idle page's 46, ATY12's 45 - timed out and read zero.

- c5x_core: port 0x60 in ROM-codec mode fills the output latch the CPU's
  0x60/0x62 reads come from.
- 403 (bridge.py, LaneHostIo): status bit 2 is the stream word, cleared
  the way bit 1 is for messages.
- I-modem (ImodemDsp, ImodemHostIo, isdn.py): 0x18 bit 7 is the stream
  word (PA6 bit 7), 0x80 written to 0x18 acknowledges it, and 0x60/0x62
  are routed to the DSP endpoint.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 21:14:12 +13:00
Cryan209andClaude Opus 5.5 6540fe67b4 Trace the writes to one C5x memory-mapped register
COURIER_DSP_TRACE_REGISTER=0x25 records every write to that register (cycle,
writing PC, value) and COURIER_DSP_TRACE_FILE writes them out, one JSON line
per core, as each core is retired. Used to rule out the timer as timing
recovery: on the 403 pair PRD only ever gets 419a/41a4 (16795/16805 cycles,
~2400 Hz) from cells 0bf8/0bf7 at 820b/820e, skew or not - the CPU's fine
timebase - and TDXR is written only from 81b8 with sample data.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 15:19:31 +13:00
Cryan209andClaude Opus 5.5 a7e1075b68 C5x: thread run_cycles' dispatch through the opcode handlers
Each handler now finishes its own step and tail-calls the next opcode's
handler, with the op body inlined into it, so every opcode has its own
dispatch branch instead of all of them sharing the loop's. The step is
split into pieces (step_is_rare, step_begin, step_repeat_edge,
step_retire) that step() and the threaded handlers share; a threaded run
hands back to the loop for anything off the fast path and wherever the
loop would stop. The opcode tables move into the core's translation unit
(c5x_optable.ipp) so the handlers can see the op bodies, and the unread
per-step cycle counter is gone. Full x2 call bit-identical; CPU
65 s -> 62 s on this machine.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 09:26:46 +13:00
Cryan209andClaude Opus 5.5 d087797c6e C5x: inline SARAM/shared data and on-chip fetches, the circular AR update and the step
The worker's datapump reads 20% of its data from SARAM or the shared
external window and fetches 7% of its code from SARAM; those went through
the out-of-line slow paths. They are now a counter and a cell inline, and
the circular-buffer AR update (the filter loops run with one enabled) and
the step body in the run loops are inline too. The full x2 call's results
are bit-identical; CPU 71-72 s -> 64.5-66 s on this machine.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 09:13:08 +13:00
Claude 4a60567583 Speed up the C5x step and the worker's per-service reads
Take the block-repeat edge on step()'s fast path instead of through the rare
path (a third of the worker's DSP steps are inside RPTB bodies), keep XC's
condition sample in one register, and read the serial backlog and the panel
latch's published answer with one cheap call each. Bit-identical results.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012FxMN2ECAudm1U2CeD998v
2026-10-07 12:25:50 +00:00
Claude 8f4bf41d73 Cache the C5x address maps per mode combination
Firmware that flips CNF/OVLY in a tight loop rebuilt the 128K-entry tables
about 1.7M times and slowed the call five-fold; keep up to 16 table pairs
keyed by the inputs to the classification.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012FxMN2ECAudm1U2CeD998v
2026-10-07 07:08:24 +00:00
Claude d59380ad36 C5x interpreter: lazy timer, one-word front flags, raw condition snapshots
The timer is brought up to date only when an expiry is due or its registers
are touched; the rare-step flags are tested as one word.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012FxMN2ECAudm1U2CeD998v
2026-10-07 06:43:32 +00:00
Claude d1814881bf Speed up the C5x interpreter: lean step, address maps, direct dispatch
step() takes a short path unless something rare is pending; the frame-rate
events run from a single deadline; program and data space are classified by a
byte table rebuilt only when CNF/OVLY/RAM/MP-MC/GREG change; opcodes dispatch
through plain function pointers; the common indirect addressing modes and
on-chip RAM accesses are inlined.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012FxMN2ECAudm1U2CeD998v
2026-10-07 06:22:07 +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 13072e9c24 Courier MP is the four-word record: CRC verifies; MP buffer writes traced; data-trace range option 2026-10-04 22:08:53 +13:00
Cryan209 26697d53a5 Courier phase 4: state order, MP decoded at 16 points (Table 20 layout, CRC unverified); data-event limit option 2026-10-04 22:01:44 +13:00
Cryan209andClaude Sonnet 5.5 a0d636ee5d Keep a caller-armed PC trace across DSP resets; c745 is a timing loop, not the scrambler
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-04 20:39:09 +13:00
Cryan209andClaude Sonnet 5.5 e1753340ba Analog DSP tracing: re-arm trace settings after each DSP rebuild, coverage and memory dump, pair-probe write watch
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-04 20:33:14 +13:00
Cryan209andClaude Sonnet 5.5 0926d86ceb Sample XC conditions one cycle early; charge long-immediate APL/CPL/OPL/XPL two cycles
XC now uses the conditions from before a single-cycle predecessor
(SPRU056D 4.5.6). That exposed CPL/APL/OPL/XPL #lk being charged one cycle
instead of two, which dropped the TC of CPL-then-XC and broke the analog
x2 53333 call. Tests cover the sampling rule and the cycle counts.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-04 15:11:29 +13:00
Cryan209 fe0fd6b960 work 2026-10-04 00:37:47 +13:00
Cryan209 7895ecbf66 Model the 3453C SI3034 codec and line interface 2026-10-03 22:24:44 +13:00
Cryan209 05de6e6aa5 Support 3453C board emulation and archive experiment artifacts 2026-10-03 21:44:47 +13:00
Cryan209 93ce822149 Improve I-modem timing, PCM transport and call diagnostics
Correct native C5x digital PCM handling, delay-line moves and instruction timing; keep bearer and peripheral clocks continuous during live calls.

Add repeat inbound calls, SIP registration renewal, buffered RTP pacing and 8N1 defaults. Extend modem probes and preserve supporting audit evidence, including the unresolved saved-profile V.90 corruption reproduction.

Validation: 230 tests passed; staged source and documentation whitespace checks passed.
2026-10-03 17:02:12 +13: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 6fa74eb2ac Fast-forward idle C5x cycles 2026-09-30 12:11:58 +13:00
Cryan209 6c31fb3d41 Accelerate I-modem DSP scheduling 2026-09-30 10:22:39 +13:00
Cryan209andClaude Opus 5.5 457dea0600 Let a filtered data-write trace keep repeated values
set_data_trace_changes_only(false) records every write to the traced
cell; a stream of words (a bitstream) loses data when repeats are dropped.
The default is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 21:44:19 +13:00
Cryan209andClaude Opus 5.5 550e05ac8e Count the serial frames that find the C5x network receive queue empty
In digital PCM mode an empty queue hands the DSP an idle codeword and every
later octet arrives a frame late. NativeC5x.g711_rx_underruns() and
g711_rx_pending() make that visible; on the I-modem line replay it happens
only twice, both during call setup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 19:03:09 +12:00
Cryan209andClaude Opus 5.5 9737b9ea6a Count the C5x timer down in closed form, and skip idle interrupt checks
The timer ran a loop per elapsed CLKOUT cycle after every instruction,
the costliest line in step(). advance_timer() works out the same PSC,
TIM and expiry count arithmetically (checked against the loop over 10.9M
cases, zero PRD and TIM wrap included), and step() raises TINT once per
expiry as before. check_nmi() and check_interrupts() are skipped when
nothing is pending, the condition each already returned on.

MICA's native call is 11% faster and byte-identical.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 18:50:11 +12:00
Cryan209andClaude Opus 5.5 e577ebfa69 Let a harness turn off the per-instruction probes in step()
set_step_probes(false) skips the V.8 dispatch record, the negotiation-
loop capture, the first-execution record and the built-in 0x0200..0x02FF
trace window. They stay on by default, so nothing here changes; the
window set by set_pc_trace_range() is traced either way. MICA's native
board reads none of them, and they are about a tenth of step().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 18:29:22 +12:00
Cryan209 076e00609b c5 core work 2026-09-25 13:00:43 +12:00
Cryan209andClaude Opus 5.5 03e381ed1c Read TREG1 and TREG2 back at their hardware widths
TREG1 is a 5-bit shift count and TREG2 a 4-bit bit pointer (SPRU056D);
the MMR reads returned all sixteen stored bits.  MICA's INFO CRC steps
TREG2 with lamm @0e / sub #01 / samm @0e under SXM clear and relies on
the -1 it stores reading back as 15.  Read back as 0xffff the borrow
never came, every word after the first was skipped, and INFO0d went out
with a wrong CRC.

The two test_c5x_interrupts failures are unchanged by this.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 09:43:31 +12:00
Cryan209andClaude Opus 5.5 9f67a62f29 Clock the Quad's C50 and the I-modem's C51 at 40.32 MHz too
2b89a28 moved the Courier's C52 to the full oscillator. The Quad picked up
half of it through DSP_CYCLES_PER_X86, but its DS0 period still defaulted
to 20.16 MHz (2520 cycles), so octets ran at 16 kHz against the CPU. It now
passes ASIC_DSP_CLOCK_HZ (5040 cycles). The I-modem's step ratio and
digital PCM clock follow the same constant, since its C51 is the same part
fed from the same 40.32 MHz can: 8 DSP instructions per 386 instruction.

configure_digital_pcm no longer has a clock default, and the core's comment
that the C5x halves CLKIN now says the model assumes the PLL x1 strap,
which CLKMD1/CLKMD2 would confirm.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 18:24:43 +12:00
Cryan209 1366b9fb3d work 2026-09-24 13:39:42 +12:00
Cryan209andClaude Opus 5.5 2b89a28dac Clock the C52 at 40.32 MHz, and record ACC in the DSP PC trace
At 20.16 MHz the V.34 answerer's per-sample echo-canceller update
(~2080 instructions) overruns the 1964-cycle sample budget, and B's TRN
task ran 780 of 1026 passes a frame. At the full oscillator both ends
train through phase 3 and 4, and the dialled pair now reaches
CONNECT .../LAPM/V42BIS once the answerer runs V.42 detection. The
clock is inferred, not measured: TCLKX (DSP pin 96) or CLKMD1/CLKMD2
settles it. The AC01 power-up frame period doubles with it.

The PC trace now carries ACC before each instruction (pc << 48 |
opcode << 32 | ACC), which is what read J out of a4b2/a4ca.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 10:18:28 +12:00
Cryan209andClaude Opus 5.5 9307973572 Model the resident's six data lanes on 0x18/0x1a and PA6
Once the resident runs, the ROM transfer window is six banks each way:
CPU 0x40+4i/0x42+4i is PA 0x58+i, which the resident walks with AR6
circular over 0x58..0x5d. PA6 bit i is a CPU word waiting (82c1 takes it)
and bit 8+i is room for a word to the CPU (8320 fills it); the resident
clears each by writing it back. The CPU commits with out 0x18 and
acknowledges with out 0x1a, and reads both as the opposite sense above
0xc0, as the board does under &T8.

0x18 read a constant 0xff, so the frame ISR's lane pump never returned
after V.34 training, and data-mode commits fell into the legacy path that
wrote lane bytes over the codec ports.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 21:10:16 +12:00
Cryan209andClaude Opus 5.5 54b7caa1da Repeated MAC and MACD retire a tap per cycle
Both charged two cycles per iteration, so an n-tap repeated filter cost 2n.
SPRU056D 6-150 and 6-155 give n + 2 with operand 2 in DARAM, and more
only when both operands share a bus (both off-chip, or one SARAM block) or
when MACD's delay-line write lands in SARAM. mac_cycles() applies those
tables with the zero wait states this core models, and a single execution
is n = 1 of the same formula, floored at the table's 3.

The V.34 phase-3 receiver in overlay 6 runs an 82-tap and a 162-tap
repeated MACD every symbol at 3429 baud. Charged 2n, the caller's datapump
fell behind its codec: 862 task passes per 1027 frames, so it dropped 16%
of its samples and could not decode J. It now keeps up (1026 of 1026, one
J-detector pass per symbol). The answerer's TRN task is still short of
real time (780 of 1026), so training still retrains.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 12:38:29 +12:00
Cryan209 1870fee438 dsp work 2026-09-21 00:13:20 +12:00
Cryan209 ac4962829d Support C51 DSP model and document memory maps 2026-09-20 23:51:55 +12:00
Cryan209andClaude Opus 5 c3d1e8ec6d TIM counts CLKOUT, not retired instructions
The on-chip timer was ticked once per instruction, so it ran slow by the
average cycles-per-instruction, roughly 2.5x. Firmware that measures a
hardware period against TIM read the wrong answer.

The MICA portware's frame-rate check is what exposed it. At program 0x80cd
it reloads TIM from PRD, waits one serial frame, averages 256 readings and
requires 0x137e +/- 0x2ca cycles per frame. With the frame period set to
5000 cycles TIM reported 2000, so the check rejected every clock rate and
the datapump never left that loop.

The core already tracks real cycles in m_cycles for the TDM frame clock, so
drive the timer from the same counter. TINT now fires at its true rate,
which is faster than before for any firmware that uses the timer - the
Courier residents leave it counting via splk @26, #0020.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-20 20:22:19 +12:00
Cryan209 a12a9dff8f dsp core fixes 2026-09-20 18:22:37 +12:00
Cryan209andClaude Opus 5 4754e35470 The frame interrupt is the transmitter's, and both halves latch on one edge
Every Courier-family C5x resident programs the primary port identically - 403
and 302 at 0x8090, 2.1.1 at 0x80bd, 2.3.31 at 0x109d - and the sequence says
what the model has to do. SPC goes 0x0008 then 0x40c8, so MCM = 0 and TXM = 0
and the frame edge is external; DXR is primed and the part spins on XRDY
waiting for that edge; IFR is write-1-cleared; and then IMR is written with
0x002a: INT2, TINT and XINT. RINT, bit 4, is not enabled, and `samm @04` - the
only write certain to reach IMR, since `splk @04` is DP-relative - appears
exactly once in each of the 403 and 302 residents.

A cold start confirms it. Parked at 0x813c the 403 has IMR = 002a, SPC = 40c8,
and the mask ROM's dispatch cells hold @65 = 8178 for XINT against @64 = 819d
for RINT, the same unused stub @6a holds for NMI. Only XINT has a handler.

So `serial_receive_interrupt` was raising the right IFR bit for the wrong
reason and gating it on SPC.RRST, the receiver's reset bit, which the 403
never consults. The 2.x residents then show why naming one bit is wrong at
all: they test data 0x012f and, if set, `lamm @04 ; and #ffcf ; or #0010 ;
samm @04` - same frame, service moved to RINT. One edge now latches both, each
behind its own half of the port's reset, and IMR and INTM decide recognition
where the part leaves them.

Three more things the residents reach that the core did not do:

- Recognition ran only from `interrupt()` and the INTM controls, so a flag
  that became eligible without a fresh source edge waited for the next one.
  The 2.x rewrite of IMR above happens with INTM already clear, and RETE
  clears INTM on its way out of a handler. It is checked at every instruction
  boundary now, and taking a vector is its own step.
- A repeated instruction was interruptible. RPTC and the repeat pointers are
  not in the context shadow, so a vector out of the middle of a block lost the
  rest of it; check_nmi has always refused for that reason.
- NMI vectored to a literal 0x0024. Its slot is offset 0x24 inside the same
  IPTR-relocated table as every other vector; 0x0024 is only right because the
  mask ROM runs with IPTR zero.

And the timer ignored TCR.TSS, so a stopped timer still raised TINT - which
matters here because TINT is the other thing 0x002a enables, and it is what
wakes the IDLE at 0x813b when no frame has arrived yet.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-20 12:42:08 +12:00
Cryan209andClaude Opus 5 c08409b53c The V.8 capture read the wrong data page, and DP was reported pre-shifted
Two reporting defects in the same quantity, and the diagnostics needed to
tell where DP actually comes from.

m_st0.dp is held pre-shifted - LDP stores DP<<7 and GET_ADDRESS ORs it
straight into the offset - but two readers treated it as a raw DP:

  - The V.8 dispatch capture computed `(m_st0.dp & 0x1ff) << 7`, which keeps
    only (DP & 3) << 7 and then shifts that again, landing on a page the
    dispatcher never runs on. v8_handler, v8_countdown and v8_flags came back
    0 from every dispatch for that reason - 133,790 of them on the answering
    end alone - which reads exactly like a state machine spinning on an unset
    vector. With the page right, the handler is af12 on the answering end and
    ae7d on the originating one.

  - state() exported m_st0.dp raw, so every consumer printing `dp` was
    printing DP<<7. The answering end's "dp=896" was DP 7.

Added alongside: shadow_dp, the DP an interrupt return is about to reinstate;
last_dp_pc/value/source, where DP was last written and by which instruction;
and stray_cala_pc/target/dp, latching the first CALA whose target leaves the
loaded images, with the DP and target it ran with.

That last one exists because DP cannot be read after the fact here. The
originating end's crash is a CALA to program 0000, and the mask ROM it lands
in rewrites DP itself - `LST #0` at 0676 - so a DP sampled at the end of the
run describes the ROM, not the call. Latched where it happens, the call is:

    9f3a  cala  -> 0000, with DP = 6

so the vector it read is @2f on page 6, data 032f, which holds 0000 on both
ends. The answering end never reaches this call and never makes a stray one.

Why 032f is never written is not answered here.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-20 12:15:33 +12:00
Cryan209andClaude Opus 5 e63293ea8d RPTC idles at 0, not -1, so an unrepeated TBLR actually transfers
Both ends of a leased pair transmitted pure silence, and had since well before
this branch - 0925e22 and f59a824 both record it. The cause is one initialiser.

Fifteen opcodes in the repeatable block-transfer family - TBLR, TBLW, the BLDD
and BLPD forms, MACD and the rest - share this idiom:

    while (m_rptc > -1) { ...; m_rptc--; }

which executes RPTC+1 times. But `reset()` and the member default both set
RPTC to -1, and the loop leaves it at -1 when it finishes. So after a reset,
and after every repeat, RPTC was -1 and every one of those instructions was a
silent no-op: no transfer, no write, no fault. Only once some RPT had run and
step()'s block-repeat tail happened to leave RPTC at 0 did they start working.

On the part RPTC reads 0 whenever no RPT is in force, an unrepeated
instruction runs once, and a repeated one runs RPTC+1 times - both ending at
0. So the loops become do/while and reset to 0.

What this cost: the C51 resident's command dispatcher at 83b5 reads a command
byte from ff5e, bounds-checks it, and does `tblr @7c ; lacc @7c ; bacc` over a
table based at 8401. The resident had downloaded perfectly - 286 words sampled
across it, none differing, and 8402 holding its true entry 8003 - but the TBLR
transferred nothing, so @7c kept its initial 0 and the BACC branched to
program 0000. That is the C51's mask ROM: the part fell through the vector
table into the ROM's serial bootstrap spin at 06dc and waited there for a
word no one was ever going to send. No datapump overlay was ever requested,
because the DSP that would request one was gone.

It was path-dependent, which is why one harness path looked healthy: a run
that happened to execute an RPT before reaching the dispatcher left RPTC at 0
and dispatched correctly.

Measured on `--dip-preset dedicated-line --at 'AT&T1'`, the invocation
docs/datapump-dispatch-gate.md gives, before and after:

    overlay_downloads   0        ->  2  (id 8, verified)
    line_tx_nonzero     0        ->  6732
    dxr_writes          36       ->  16715
    dsp pc              06dc     ->  a2b7

and a leased pair over the socket line now carries audio both ways - each
end's transmit matches the other's receive, rms 2201, peak 16160, with tones
at 1801 and 2199 Hz. Cut-through moves from frame 518 to 93, because the DSP
now reaches the state that answers instead of dying at frame 0.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-20 11:42:00 +12:00
Cryan209andClaude Opus 5 23b41322f4 The call has one state, and it belongs to the line rather than to either end
Three corrections to the sound path.

The switched call now has a single state that both subscribers share.  Each
end used to decide for itself whether the path was through, from a counter
only it could have: the calling end watched the rings it was sending, the
answering end watched the ring bursts it was receiving, and a leased pair
matched neither rule on the answering side, so B never cut through at all.
The two ends could therefore disagree, which is a half-connected call - one
end transmitting into a cut loop.  `call_state` now crosses the line in every
frame; each end advertises the furthest point it knows of and adopts the later
of its own view and the peer's.  Every transition has exactly one end that can
make it - only the calling end can seize and ring, only the called end can
answer - so this converges instead of oscillating, and `_cut_through` is now a
derived property rather than a per-end flag.

RS is shared with the AC01, and a reset pin cannot change the board.  The
reset already returned the codec's registers to power-up but took the MCLK
back to the 2.88 MHz default with them, so every generation after the first
ran at a clock the board never presents; it also left the frame period at the
rate the previous generation had programmed, while the divider registers it
was supposedly derived from had gone back to A = B = 18.  Carry the configured
MCLK across and restart the frame period with the registers.

IRQ5 is the serial port's receive interrupt, not the frame scheduler's.
SPRU056D 5.3: RINT is raised when RSR transfers into DRR, and a receiver held
in reset shifts nothing and raises nothing.  The frame clock itself is
genuinely external - the ASIC is the frame master and keeps running while the
DSP is inside an overlay - but all four sites that load DRR now end at one
port-level entry point that applies the RRST gate.  Suppressions are counted
and exported as `serial_rint_suppressed`, because a receiver left in reset is
otherwise indistinguishable from a frame clock that stopped.  The gate has not
been exercised against a completed call: the C51 ROM loader does not reach its
ASIC poll on either the 302 or the 403 image, which is a fault ahead of it and
predates this change.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-20 10:54:46 +12:00
Cryan209 1f78be8ce5 fixes 2026-09-20 10:43:02 +12:00
Cryan209 f60e434cec work 2026-09-20 01:53:33 +12:00
Cryan209andClaude Opus 5 3b7d47dd14 Aim @48 at the page the dispatcher runs on, and admit a dialed call
Two instrument faults on the way to the doc's "next question, singular".

_maybe_start_originate_engine returned unless daa.operation was "originate".
Its docstring says why - it was written for the leased line, where the
originating end never dials - and the socket path's new digit receiver moves
the operation to "dialing" on the first digit, so the originating end stopped
arming at all. That was a regression from the dial-tone commit. A dialing
seizure now qualifies once the called party has answered, which is when an
originating modem starts V.8 instead of putting CM under its own digits.

And the core read m_data[0x48] for @48. A direct operand resolves to
(DP << 7) | offset, so that asserted DP 0. Measured at the dispatch DP is
0x180, which puts @48 at 0xc048 and @4a/@4d at 0xc04a/0xc04d: every report of
a null handler was reading a cell the firmware does not use. v8_dispatch_dp is
now reported so the page is never assumed again.

The static question the doc asked is answered: the 403 resident segment has 57
sites storing to @48, 26 to @4a and 58 to @4d, and almost every @48 site is
splk @48, #<address two words on>, so @48 is a continuation vector resumed by
lacl @48 ; bacc - the same arrangement as 2.1/2.2. The signature match is not
a false friend for want of writers.

With both faults fixed @48 still reads zero at every dispatch on both ends,
including B, which emits a full 2.98 s answer tone through 62,759 dispatches
of that routine. A routine whose vector is null on the side that is
negotiating is not the one negotiating, so 0xba0b is not the live V.8 state
machine on 403 and none of these counters mean V.8 progress here.

What does separate the ends is the mailbox stream: A originates 0008:* and B
0016:*, overlapping only on three tags. The audio is unchanged by any of this.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-19 23:11:47 +12:00
Cryan209andClaude Opus 5 f97b451512 Aim the V.8 counter at the loaded image, gate the overlay publication
The core no longer hard-codes 2.1/2.2's c418: Bridge._v8_dispatch_addresses
finds every copy of the dispatcher by signature over the resident bank and
each declared overlay, and set_v8_dispatch_pcs hands them to the core, which
now also reports which one fired as v8_dispatch_pc.

_find_call_overlay requires the candidate to be pre-linked for the
destination - first branch target == 0xc418 + 0x0d. 2.1/2.2's stored copy
satisfies it; the self-linked resident copies on 302/403 do not, so nothing
is published there any more.

Measured on a 403 linked pair against the old behaviour as a control: every
V.8 number identical, only call_overlay_available moves, so the gate changed
nothing observable. The dispatcher does run, at 0xba0b, 22,471 times - but
@48, @4a and @4d are all zero, so every entry branches to program 0, and
v8_rx_peak and the audio rms are zero on both sides in the baseline too.

Artifacts in artifacts/v8-dispatcher-403-01/.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-19 12:53:08 +12:00