Commit Graph
30 Commits
Author SHA1 Message Date
Cryan209andClaude Opus 5 e915079837 Share the board's external RAM between the DSP's two spaces
302's prologue block-moves its mailbox cell-read helper into SARAM with `bldp`
from data 0x80f5, which only yields code if a data read there returns the
downloaded program. An earlier attempt at that was reverted as a regression.

The measurement that note asked for - every data access at or above 0x2c00,
logged with its PC - says the revert was wrong. Across a 2M instruction run the
302 resident touches exactly twenty-five sites: writes at 0xfff0-0xfff7 and
0xff51-0xff5f from the prologue, reads of 0xff60/0xff61, and three reads of
0x80f5-0x80f7 by the bldp. In 0x8000-0xfeff there is no read but the bldp's, so
there is no second read that could depend on getting something other than
program words.

data_region now returns a Shared region for 0x8000-0xfeff, backed by the
program storage in both directions, and the memory map reports data_shared
alongside data_external. The window stops below 0xff00 because the firmware's
own ASIC pages are DP 0x1fe/0x1ff; its exact edges are not otherwise measurable
from a run.

The effect on 302 is not subtle. Copying zeros into 0x23f0 made the
dispatcher's calld execute nothing and the part fall into unloaded low memory
and re-enter its own reset prologue - four passes in 200k instructions, PC at
0x0115 after 20M, 16.3M external program fetches. It now boots once, runs the
real helper out of SARAM, and parks in the idle at 0x814d waiting for a frame
interrupt the harness does not yet deliver: 67k external fetches, 7155 SARAM.

403 is byte-identical either way, with data_shared zero, because it keeps the
same helper in-bank at 0x80e8 and never reads program space as data.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-06 22:35:33 +12:00
Cryan209andClaude Opus 5 8f34738ae0 Model the C50's SARAM, shared between program and data space
SPRU056D puts the 9K part's SARAM at 0x0800-0x2bff in program space when
PMST.RAM is set and at the same addresses in data space when PMST.OVLY is set.
That is one physical memory seen from both spaces, and the core backed the two
with separate 64K arrays, so a data store into the window was invisible to a
fetch from it - which is what the firmware's own block moves rely on.

program_region and data_region now return a Saram region for that window under
the respective bits, fetches and program writes there go to the data storage,
and the memory map reports program_saram and data_saram counts alongside the
existing ones.

No behaviour change on the 302 mailbox probe: @57 still reads a000 and ATY12
still times out. SARAM is RAM, so something still has to fill 0x23f0 before
the dispatcher's calld reaches code, and on hardware that is the firmware's
own block moves, which only run once it gets that far.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-06 22:12:56 +12:00
Cryan209andClaude Opus 5 1dd34e28bb Correct the C5x PMST field layout
The core decoded PMST as iptr = bits 15-11 with the vector base at iptr << 11,
and avis at bit 7. SPRU056 puts IPTR at bits 15-7 with the base at IPTR << 7
and AVIS at bit 6; bits 5-0 were already right. This firmware's own prologue
does apl @07, #07f8 then opl @07, #00b0, which leaves bit 7 set - IPTR 1, a
vector base of 0x0080 - and the old layout read that bit as AVIS and kept IPTR
at zero, so every interrupt vectored to 0x0000.

Measured effect on a 302 run: the DSP now reaches its wait routine at 0x8149
and executes at the configured vector, where before neither appeared in a PC
sample. Pointing the frame interrupt at the ISR entry 0x816b then puts the
histogram on the ISR body, 0x817d..0x8196, with 1000 samples parked on the
idle poll at 0x814d.

Still not a working transfer: @6b is never cleared, because the ISR stores a
continuation in @65 for the next interrupt to run and a fixed configured vector
re-enters 0x816b every time instead. ATY12 still times out.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-06 21:47:48 +12:00
Cryan209andClaude Opus 5 e75167104b Measure the audio path instead of assuming it, and find the receive backlog
Four measurements on an answered call with the synthesizers off.

The overlay runs and stalls where this file already said: 89 dispatches at
c418, 14 entries to the c853 loop, and a PC trace dominated by it.

The frame ISR at 0x0228 is the polyphase resampler, not a DAC writer. It runs
about ten times per codec sample - 10.09 writes per sample to fffd, fffb and
ffff, 20.2 to fffa, 30.3 to fffc - which is the TDM slot rate against 9.6 kHz.
It takes the slot from @52, indexes four descriptors at program 824d, and
filters the ADC pair @78/@79 into the 32-bit accumulator @7c/@7d. So fffd is a
phase accumulator's low word, which is why reading it as the DAC measured as
noise.

Nothing in the ASIC block is a waveform. De-interleaved by TDM phase - which
line_phase_samples now makes possible - slot ffff carries two to four distinct
values in every phase, peak/rms 0.066. The whole overlay writes 723 cells, and
every one outside fff8..ffff fewer than 200 times in 98,237 codec samples.

And the reason a known far-end tone appears nowhere is not the firmware. With
the ADC injection routed through DM_WRITE16 it becomes visible: 0xfff8 is
written once per codec sample, 24,979 times, every write the same value.
codec_rx_queued 495,360 against codec_rx_consumed 101,020 - the queue fills
about five times faster than the DSP drains it, so the datapump is hearing
silence from about forty seconds ago. That is a harness bug, and it invalidates
any earlier reading that assumed the datapump had heard the line.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-05 15:31:22 +12:00
Cryan209andClaude Opus 5 7cc31046e1 Stop the harness generating line audio, and find what the datapump writes
With a modeled line attached the core's DTMF and V.8 generators are switched
off. They are hand-written sin() in C++ - 1300 Hz gated 500/500 for calling,
2100 Hz with 15 Hz AM and 450 ms reversals for answering - and while they run
they discard the datapump's own DAC accumulation to make room, so the firmware's
output was computed and thrown away. set_synthetic_line(False) ends that, and
is reapplied to every core, including the one a line operation reloads.

The bridge's own DTMF renderer is gone with them. It recorded the digits the
supervisor commands and played none of them, so exchange.dialed - what the line
actually heard - is now the measurement rather than an echo of the harness.

With the tones off, an answered call reaches the overlay: ring the line, let
the firmware answer, and the recovered bank executes. What it writes is not
audio. The frame ISR at 0x0228 keeps a 32-bit phase accumulator in @7c/@7d,
which at DP 0x1ff is 0xfffc/0xfffd - and 0xfffd is what the core read as the
DAC. That is why the output measured as noise: it is a linear ramp stepping
-14704 per sample and wrapping, about 2.15 kHz at the codec rate. The word the
ISR computes from it goes out through @7a to 0xffff, and that slot carries two
distinct values, near DC. Neither is a waveform. set_line_dac_slot makes the
choice measurable instead of assumed; the default is unchanged.

Also here: the exchange drives the ring detector on port 0x14, publishes the
board's call-up edge when it puts a call through, and takes a hotline route
that answers on seizure.

So the datapump runs and where its PCM leaves the C52 is unresolved. The tblr
at 0x022e against a table based at 0x824d is the next thread. V.21 is generated
nowhere and never has been.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-05 15:11:04 +12:00
Cryan209andClaude Opus 5 781993e134 Characterise the CPU/DSP mailbox and the 60/62 window on hardware
A first host-to-DSP write attempt wrote the four data registers and observed
nothing. The supervisor's own mailbox interrupt at 0fda9 explains why, and the
DSP's dispatcher at 839b explains it better still.

The wire format was never the problem. What was missing is the commit: bit 0
of port 1c is the board's standing request, and the interrupt answers it by
writing the status back with that bit still set, clearing it first only on the
path that had nothing to send. An idle unit reads 1c as fd forever because the
supervisor in command mode never has traffic.

With the commit supplied, a tag is repeatable and predictable. Tag 07's
handler is three instructions and reports 8031; tag 62 reports 8069; the tags
that reach the bare ret at 8222 are a null control. Every prediction was fixed
from the disassembly before the runs and held in both directions, and tag 62
even returned its own saturation constant.

That also refutes the shape the emulator models. A mailbox tag is a command
index into a 121-entry jump table bounded at 7f, not a destination address, so
writing an arbitrary DSP data cell through it was never possible. Only 27
handlers store the host's word at all, each at one fixed address, and none of
them is an index either program reader uses. host_write() is kept as a way to
seed modelled state, with a comment saying it is not the board's protocol.

The 60/62 window's producer is now identified as the DSP: 84b7 is out *, 0060
followed by a status bit 2 that the supervisor's interrupt answers by calling
its chain vector. Acknowledging that bit is what pumps it, and pumping tag 46's
streamer returned sixteen words whose first four are DSP program memory,
matching the flash image at addresses predicted beforehand and reproducing
across two runs. So a readback channel exists and works end to end.

What is missing is a reader whose address the host can choose. Both known ones
are shut: 032a's readers compute an unmasked program address but both writers
clamp it below the six-entry jump table it indexes, and 03db's only writer
stores ae12's return, which is a six-way priority encoder and so cannot exceed
five whatever feeds it - tested on hardware by unmasking its one host-writable
AND term, ffb1, which left the index at zero.

The hardware also corrected a reading: tblr *+ post-increments the auxiliary
register, not the accumulator, so tag 46's paired table reads fetch one address
twice rather than consecutive words.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-04 22:08:16 +12:00
Cryan209 9b95dd2136 courier emu work 2026-09-01 10:48:05 +12:00
Cryan209 2974601cef Restore answer TDM normalization latches 2026-08-27 00:40:18 +12:00
Cryan209 059a60d5a7 Restore C52 call context for answer dispatch 2026-08-27 00:20:16 +12:00
Cryan209 f8da31123b Synthesize answer callback dispatch after V8 2026-08-26 23:59:41 +12:00
Cryan209 d0a1c3a0a0 Trace C52 negotiation state reads 2026-08-26 23:33:05 +12:00
Cryan209 423e4adc58 Preserve TDM receive-ready state across frame service 2026-08-26 23:18:24 +12:00
Cryan209 b617764d97 Mirror codec slots into C52 TDM receive latch 2026-08-26 23:12:18 +12:00
Cryan209 0b69986c80 Route native polyphase DAC output from call overlay 2026-08-26 23:03:22 +12:00
Cryan209 8c01adfc2c Trace C52 V8 execution paths 2026-08-26 22:48:34 +12:00
Cryan209 e2f503f09a Model C52 BIO pin for V8 service 2026-08-26 21:56:13 +12:00
Cryan209 45c47e588e Hand V8 negotiation to downloaded C52 overlay 2026-08-26 21:40:37 +12:00
Cryan209 cd988eca89 Trace codec samples entering native DSP 2026-08-26 20:55:32 +12:00
Cryan209 740a12c99d Expose native V8 receive diagnostics 2026-08-26 20:52:47 +12:00
Cryan209 e2442f22a9 Add native V8 detection and online diagnostics 2026-08-26 20:45:53 +12:00
Cryan209 c4a49a5e18 Model DSP call completion and answer-mode ANSam signaling 2026-08-25 19:31:55 +12:00
Cryan209 b37cfdbdae Support supervisor 2.3 call setup and carrier detection 2026-08-25 15:31:30 +12:00
Cryan209 8623bea0bc Integrate C52 call overlay with codec line operation 2026-08-24 23:39:48 +12:00
Cryan209 1e04eea20f Trace C5x call engine and recover SDL overlays 2026-08-21 00:13:04 +12:00
Cryan209andClaude Opus 5 5ff8f1e3d2 Decode the wait-state registers, and fix the map to the C52's own
PDWSR gives each 16K block of program and data space a two-bit field, IOWSR
gives each pair of I/O ports one - or each 8K block when CWSR's BIG bit is set
- and CWSR decides whether a field means 0/1/2/3 wait states or 0/1/3/7
(SPRU056D sections 9.4.1 to 9.4.3, tables 9-5 and 9-10). Both families write
CWSR 0x0010: BIG set, every space on the plain scale. So:

  2.1/2.2  PDWSR 0x000a  program 0x0000..0x7fff  2 wait states
           IOWSR 0x0001  io      0x0000..0x1fff  1
  2.3.x    PDWSR 0x2000  data    0x8000..0xbfff  2 wait states
           IOWSR 0x0101  io      0x0000..0x1fff  1, io 0x8000..0x9fff  1

and the 2.3.x I/O block that gets a wait state is the one holding port 0x8057,
which its very first instruction writes.

Wait states only apply off-chip, so a non-zero field is the firmware stating it
expects external memory there. The 2.1/2.2 boards put program 0x0000..0x7fff
off-chip, exactly the span of the 30,172-word segment the supervisor downloads,
so the download lives in external program RAM at 0x0000. Table 8-3 makes that
decisive for MP/MC: microcomputer mode would put 4K of on-chip ROM under
0x0000..0x0fff where wait states do nothing, so MP/MC is high. The pin now
defaults high for that reason rather than by convention, and the flat program
space this harness always had turns out to be right for a stated reason.

The map itself was wrong for this part and is corrected against tables 8-3 and
8-10. The C52 has no SARAM at all, which makes PMST.RAM and PMST.OVLY
don't-cares here, so those regions are gone; B0 moving into program 0xfe00
under CNF is modelled; and data is off-chip only from 0x0800 up with reserved
gaps at 0x0080..0x00ff and 0x0500..0x07ff. PDWSR, IOWSR and CWSR are stored and
read back rather than ignored, and reported decoded.

That last region change pays for itself immediately. About 700,000 data
accesses a run land in the reserved windows, and they are the frame-block cells
[0x00ca] to [0x00cd] - the line-DAC source and the gate. On silicon those
addresses hold no storage, which confirms from the part's own memory map what
the vector-table search concluded from the other end.

263 tests pass.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-06 10:51:30 +12:00
Cryan209andClaude Opus 5 604611118e Model the C52's memory map instead of assuming a flat one
The core parsed MP/MC, OVLY and RAM out of PMST and acted on none of them, so
program and data space were flat 64K arrays and where the download lands was
implied rather than stated. Both spaces now decode: program is on-chip ROM
below 0x1000 when MP/MC is low, SARAM at 0x1000 under PMST.RAM, external
otherwise; data is memory-mapped registers below 0x0060, DARAM at B2 0x0060,
B0 0x0100 unless CNF moves it, and B1 0x0300, SARAM at 0x0800 under PMST.OVLY,
external otherwise.

MP/MC is a pin, not something an image records, so it is supplied to the core
through courier_c5x_set_mpmc_pin and defaults to low - the level this core has
always presented when the firmware reads PMST back, and the firmware does read
it. Over a 1.5M-instruction run either level ends at the same PC, so the bit
costs almost nothing in behaviour.

No XMF carries an on-chip ROM, so with none supplied the ROM window still
answers from the downloaded image exactly as before and the fetches are counted
instead. Over a 12M-instruction ATA that is 693,322 of 14,536,050 program
fetches - 4.8% of the run comes out of a window that would be on-chip ROM in
microcomputer mode. courier_c5x_load_rom takes a dump if one ever appears.
Until then dsp_bridge.dsp_memory_map reports the mode bits, the per-region
counts and the hole count on every run, so the assumption is in the output.

One thing the accounting surfaces: OVLY and RAM read zero for most of a run.
The reset code sets them with OPL #0x00b0, @07 and they are cleared again by
the same stores that zero IMR, IFR and PMST from 0xb626, 0xb65f, 0xb667,
0xb677 and 0xb67c. Firmware does not switch the part out of microcomputer mode
and turn off its on-chip RAM mid-run on purpose, so those sites are more
evidence that the addresses the low bank computes land in the wrong place.

263 tests pass.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-06 10:27:04 +12:00
Cryan209andClaude Opus 5 898229f710 Find the bit the datapump idles behind, and map TREG0
Decoding a C5x image statically floods, because any word decodes; taking the
instruction boundaries from a run does not. On that basis the whole of what the
C52 executes in steady state is 167 instructions, one pass is 169, and the loop
head is at 0x0cb1 - inside the bank the supervisor downloads. So the datapump
is resident and running rather than waiting to be entered, and it is using
about 6% of the cycles a 25 MHz part has per 9.6 kHz sample.

It idles behind one bit. Every pass ends with BIT *, 4 on [0x00cc] and a
CC 0xb4d4 taken on the result, and [0x00cc] reads zero on every sample of every
run, so 0xb4d4 is never entered. Setting that bit by hand is the first thing
that has moved it: line-DAC writes go 14,102 to 15,515, non-zero samples 1 to
10, and the parked PC leaves the resident bank at 0x8195 for 0x0bda3 in the
downloaded one. [0x00cc] is the datapump's own status word rather than an input
latch - tracing writes into the frame block shows it zeroed every sample from
four of its own sites, one cell above the DAC source at [0x00cb].

The receiver is gated off rather than listening. Feeding the ASIC line input
2100, 1800 or 980 Hz at the confirmed 9.6 kHz cadence, or noise, instead of
silence leaves every counter identical, including [0x00cc] and the parked PC.

Two core defects turned up on that path. TREG0 is memory-mapped at 0x0c on a
C5x and this core did not map it, so LT wrote m_treg0 while a data-space read
of 0x0c saw a cell nothing updated - its neighbours TREG1, TREG2 and DBMR were
all mapped already. That is fixed here; it is not on the idle loop, so no
measurement above moves. The BIO pin is still unimplemented, and the condition
helper answers "BIO low" false unconditionally, which makes all 711 candidate
sites in the image dead - but none is reached, idle or with the gate forced, so
it costs nothing today.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-06 09:48:52 +12:00
Cryan209 253970d65d emu work 2026-08-06 00:31:13 +12:00
Cryan209 109a85a777 work on emulator 2026-08-04 15:16:26 +12:00
Cryan209 f31ef36302 Initial Courier firmware emulator 2026-08-04 13:01:29 +12:00