Added codec_rx_size, line_frame_irq, frame_period, line_frame_next_cycle and
cycles to codec_state(), and surfaced the core's codec state as `core_codec` on
the bridge status, which nothing reported before. One instrumented dial answers
what three commits of reading the code could not:
line_frame_irq 5
frame_period 3472
line_frame_next_cycle 3472
cycles 0
codec_rx_size 228480
frames_clocked 0
pc / instructions 0 / 0
active False
bootstraps 1
m_cycles is zero because the C52 never executes an instruction. The frame
driver compares m_cycles against m_line_frame_next_cycle, 0 >= 3472 is never
true, codec_frame() never runs, and the queue fills to 228,480 undrained.
The reason is bridge.py:1327. A DSP reset closes the core, builds a fresh
NativeC5x and sets active = False; active only returns when a re-download
reaches bootstrap_target_size, and that second download never comes -
bootstraps stays at 1 - so the part is held dead for the rest of the dial.
Under ATX0 the supervisor skips the wait, loads the call overlay, and the DSP
comes back, which is why that path has always worked.
So the dial-tone failure is not a missing detector, not a missing flag and not
a gated ISR. Three separate conclusions in this document said otherwise and all
three were reached by reading code rather than by asking the core what it was
doing. The instrumentation is kept for that reason.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The core carried hand-written sin() in C++ that stood in for the datapump's
DAC output: a DTMF pair generator, a 1300 Hz V.8 calling indicator and a
2100 Hz ANSam approximation, armed from the bridge through set_dtmf_digits
and gated by set_synthetic_line. While it ran it also *discarded* the C52's
own DAC accumulation to make room, so the assist did not merely supplement
the firmware, it displaced it.
It is gone. dtmf_sample(), m_dtmf_digits, m_synthetic_line and the three
substitution sites (the 0xb2e5 write guard, the call-TDM V.8 branch and the
idle branch) are removed, along with the C API exports, the Python bindings
and the bridge's arming calls. V8Mode stays: the role still gates the
receive-side indicator qualification, which observes the line rather than
driving it.
Nothing is lost on the image that matters. Rerunning the 3.0.13 capture with
the generator deleted produces line audio byte-identical to the reference
(sha256 ccad9c62...), and decoding it independently at 7200 Hz returns
5551212 - the number the firmware was asked to dial. The C52 was already
doing the work; only the stand-in's presence obscured that.
The three tests that covered the generator went with it. They asserted on
main211, which is not modelled well enough to be a behavioural reference.
The bridge tests that used core.dtmf as a proxy for reaching the dial phase
now assert on bridge.dial_digits and daa.operation instead.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
--dsp-write-watch ADDR records every write to one C52 data cell with the
program address that made it. The write trace was unfiltered and its
4096-event buffer covers milliseconds; the read side also traces a fixed
set of cells and floods the buffer on its own. Both honour the filter now.
Watching 39a across a 403 dial gives four arm/restore pairs, one per
digit: ee2b writes 8743, and about 2.3M instructions later - roughly the
tone's duration - 86dc restores 8128. That is a one-shot callback
lifetime, not a clobber, so the end-of-run 8128 was just the idle state.
Watching 3c0 inside one of those windows shows the phase advancing by
0x2f81 per sample, exactly the increment tblr loaded into 3f2. The
oscillator runs at the right rate from the right table entry.
So the mailbox-to-oscillator path is sound and the tone is generated but
never reaches the line. What is left is the mixer's output path: the
work pointer at 390 reads 0bd8 in the full-board run where audio312,
which does produce output from this ROM, supplies 0bc0.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The core's PC trace was two hardcoded ranges. set_pc_trace_range adds a
third, settable one, exposed as --dsp-trace-range FIRST:LAST. Pointed at
ee00:ef00 it catches 3.1.2's tag 0x13 handler four times in a dial, once
per digit, and the handler is correct: it indexes the frequency table at
ee34, loads both increments, installs 8743 - the DTMF pair generator -
in the mixer's callback slot at 39a, sets the amplitude and clears both
phases. Every cell is one answer-tone.md already named.
So the silence is downstream of the handler. --dsp-peek reads C52 data
cells at the end of a run, and after a 403 dial the increments are still
loaded while 39a holds 8128 rather than 8743. Whether that is the
firmware restoring a silence generator after the tone or something
writing one cell low is not separable from an end-of-run value; it needs
39a sampled while a tone plays.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Adds arcr/indx to State so the auxiliary-register compare that gates the
resident's block-level work can be observed rather than inferred.
With them visible: over a 600,000-instruction warm start, ARCR changes exactly
once - the reset to zero - and is never written again. AR7 meanwhile cycles the
mailbox ring 0x0bd0-0x0bde under the circular-buffer registers, so cmpr eq at
0x80d1 can never match and the block holding the mailbox poll never runs.
CMPR itself is confirmed correct in the core: it compares m_ar[arp] against
m_arcr, and ARP is 7 there, set by the mar *, ar7 before the loop's delayed
branch.
Also records what the idle state actually is, which was misread earlier as the
DSP being stuck: 0x822b sets @1a to 0x8139, a bare ret, and @1b to 0x8138, which
is intr 17 - vectoring through ROM 0x0022 to @69 = 0x81b7. That accounts for the
two largest slices of the PC histogram. A dozen sites across the resident reset
@1a to idle when a task ends, so the cells are a task pointer and the firmware
is idling by design, waiting to be given work.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
XRDY says DXR can accept another word, which becomes true when a frame sync
moves the last one into the transmit shift register. It was reported set
whenever XRST was set, so the firmware's reset handshake at 0x8097 - write DXR,
spin on XRDY, write again - fell straight through instead of waiting a frame.
It now clears on a DXR write, sets on a frame sync, and is released by a 0 -> 1
edge on XRST.
Scoped to the AC01 path: the legacy TDM path models no framing on this port, so
nothing there would set XRDY again after a write and a spin would never end.
That is a limit of this model rather than hardware behaviour, and it is
commented as such.
Also records what the boot table sharing the port actually rests on. TI's
application guide puts the AC01 on the primary serial port and leaves the TDM
port pulled to COM, which the firmware agrees with; the ROM loader is on that
same port and is receive-only. The datasheet holds DOUT in high impedance until
the eighth primary frame sync, and the firmware issues exactly eight primary
frames first - two priming writes plus six register writes - so the ASIC can
drive DR with the boot table unopposed until the codec is fully programmed.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
DRR was filled lazily, when the firmware happened to read it, so a run whose
receive queue was empty returned the same stale word every frame - 28,212 reads
of one value in the survey run.
codec_frame now runs at every frame sync:
- one ADC word per primary frame (section 2.4, "one word for each primary
communication interval"), delivering a zero for a quiet line rather than
repeating the last word;
- no sample on a secondary frame, which carries the addressed register when a
read was requested and zeros otherwise, so a readback arrives with the frame
rather than with the host's read;
- the secondary frame sync half a frame period after the primary that asked for
it, which is Figure 2-1's (B/2) FCLK periods given fs = FCLK/B;
- RRDY following a word having been clocked in.
The ROM boot table shares the port but is not the sample stream: a frame sync
consuming those words breaks the download. queue_codec_boot keeps them in their
own queue, drained only by the loader's polls.
302 boot measures 1911 frame syncs and 1911 samples consumed, one each, with
DRR carrying live audio.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The rate was hardcoded: 3472 cycles in the core and 9600 Hz in every generator
that filled the receive queue. The firmware retunes register 2 at runtime for
each V.34 symbol rate, so a constant is wrong by construction - and the two
figures disagreed with each other, making the DSP hear every frequency scaled
by 4/3.
C5xCore now decodes DXR the way the part does. Which kind of frame a word
belongs to is decided by the previous frame's control bits, which replaces a
test against two hardcoded ISR addresses that recognised the samples of two
known builds and nothing else. Secondary words are parsed into a nine-register
file; writing register 1 or 2 recomputes fs = MCLK/(2 x A x B) and the frame
period with it. Register reads, the no-op register, forced secondary and
software reset are handled.
bridge.LineToCodec resamples line audio to whatever rate the codec currently
reports, so the harness can keep carrying the line at a fixed rate without that
rate reaching the DSP. A 2100 Hz tone now measures 2100 Hz after conversion
instead of 1575.
Booting 302 through the ROM recovers the six reset registers, 7200 Hz, and a
frame period of 3472 - the constant it replaces, now derived.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The previous commit claimed the resident performs no data read in
0x8000-0xfeff but the bldp's. That count was taken on the boot path alone, and
taking it for the whole firmware was wrong: the V.34 arming path reads data
0xfea1 six times from 0xd668, walking the capability descriptor list.
That read is not evidence against the shared model - 0xfea1 is above the
resident's 0xec3d and above the highest overlay's 0xf8b5, so it is free RAM in
use as data, which is what one memory answering both spaces predicts. What it
exposed was a harness split: set_data and data() reached m_data while the
running program reached m_program, two arrays for one RAM, so a staged
descriptor was invisible to the code that read it. Both accessors follow the
window now.
main211.xmf is a different matter. It offers a first segment at origin 0x0000
alongside one at 0x8000, and which is its real payload is unresolved, so the
harness cannot say where its RAM sits; with the window on, its call-overlay run
never armed IMR. NativeC5x now switches the window off when any program segment
origin is below 0x8000, leaving such an image exactly as it was. The window is
a fact about the 20.16 MHz ROM downloads, whose segments are all at 0x8000 or
above, and an open question elsewhere.
Seven tests across test_v34.py and test_bridge.py were failing on the previous
two commits and pass again. 302 is unchanged by the gating: one bootstrap, idle
at 0x814d, 120 shared-window accesses.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>