pub struct Upd77c25 { /* private fields */ }Expand description
The NEC µPD77C25 / µPD96050 LLE engine.
Construct with Upd77c25::new, load a dumped firmware image with
Upd77c25::load_firmware, then drive the host interface through the DR/SR/DP methods. The
engine is inert (open-bus reads) until a firmware image is loaded — the honesty posture of
docs/adr/0003: a chip-ROM-dump-dependent coprocessor is non-functional without the dump,
never silently degraded.
Implementations§
Source§impl Upd77c25
impl Upd77c25
Sourcepub fn new(revision: Revision) -> Self
pub fn new(revision: Revision) -> Self
Construct a powered-on engine for revision with zeroed (unloaded) firmware.
Sourcepub fn power(&mut self)
pub fn power(&mut self)
Reset all programmer-visible state (NEC power-on). Firmware contents are retained.
Sourcepub const fn firmware_loaded(&self) -> bool
pub const fn firmware_loaded(&self) -> bool
Whether a firmware image has been loaded (the chip is functional).
Sourcepub fn load_firmware(&mut self, bytes: &[u8]) -> bool
pub fn load_firmware(&mut self, bytes: &[u8]) -> bool
Load a packed NEC DSP firmware dump.
The dump is the program ROM (one little-endian 24-bit word per instruction) immediately
followed by the data ROM (one little-endian 16-bit word per entry) — exactly ares’
upd7725.program.rom + upd7725.data.rom concatenation. For the µPD7725 (DSP-1) that is
2048×3 + 1024×2 = 8192 bytes (dsp1.rom / dsp1b.rom).
Returns false (and loads nothing) if bytes is too short for this revision. On success
the engine is powered on and run to its first parked (RQM-set) state, ready for the first
host command.
Sourcepub fn read_sr(&self) -> u8
pub fn read_sr(&self) -> u8
Read the status register (the high byte the host sees at the SR port).
Sourcepub fn write_sr(&mut self, _data: u8)
pub fn write_sr(&mut self, _data: u8)
Write the status register port. The NEC chip ignores host SR writes (no-op), matching hardware; kept for surface symmetry.
Sourcepub fn read_dr(&mut self) -> u8
pub fn read_dr(&mut self) -> u8
Read a byte from the data register, then catch the engine up to its next parked state.
Sourcepub fn write_dr(&mut self, data: u8)
pub fn write_dr(&mut self, data: u8)
Write a byte to the data register, then catch the engine up to its next parked state.
Sourcepub fn read_dp(&self, address: u16) -> u8
pub fn read_dp(&self, address: u16) -> u8
Read a byte from the data-RAM host port (address is the byte address into the window).
Sourcepub fn write_dp(&mut self, address: u16, data: u8)
pub fn write_dp(&mut self, address: u16, data: u8)
Write a byte to the data-RAM host port (address is the byte address into the window).
Sourcepub fn run_until_rqm(&mut self)
pub fn run_until_rqm(&mut self)
Advance the engine until it parks waiting for the host (RQM set), capped at RUN_CAP
instructions. A no-op when already parked or when no firmware is loaded.
Sourcepub fn exec(&mut self)
pub fn exec(&mut self)
Execute one instruction, then update the M/N multiplier outputs (NEC pipelines a
signed K×L multiply each cycle).
Sourcepub const fn host_accesses(&self) -> u64
pub const fn host_accesses(&self) -> u64
Count of host DR port accesses since power-on (diagnostics).
Sourcepub const fn rqm(&self) -> bool
pub const fn rqm(&self) -> bool
The RQM (request-for-master) status bit (for unit tests / the debugger).
Sourcepub fn data_ram_word(&self, index: usize) -> u16
pub fn data_ram_word(&self, index: usize) -> u16
Read a data-RAM word directly (for unit tests / save-state inspection).
Sourcepub fn flags_packed(&self) -> u16
pub fn flags_packed(&self) -> u16
The condition flags packed (flags.a in the low 6 bits, flags.b in the next 6) — for
unit-test vectors derived from a reference trace.
Sourcepub fn save_state(&self, w: &mut SaveWriter)
pub fn save_state(&self, w: &mut SaveWriter)
Write this engine’s mutable state — every register + the 2048-word data RAM — into a
"NDSP" section. Firmware (program_rom/data_rom) is deliberately NOT written: it is
never embedded in a save-state (the same “never carry a ROM/firmware byte” posture
docs/adr/0003 already applies elsewhere), reloaded fresh via Self::load_firmware
before a matching Self::load_state call. host_accesses (a debugger counter, not
emulated-hardware state) is also omitted — restoring it to a stale value would misrepresent
activity that happened after the save, not before it.
Sourcepub fn load_state(
&mut self,
r: &mut SaveReader<'_>,
) -> Result<(), SaveStateError>
pub fn load_state( &mut self, r: &mut SaveReader<'_>, ) -> Result<(), SaveStateError>
The inverse of Self::save_state.
§Errors
SaveStateError on truncated/corrupt input (the section framing itself already rejects
a wrong tag or a truncated read).