Skip to main content

Upd77c25

Struct Upd77c25 

Source
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

Source

pub fn new(revision: Revision) -> Self

Construct a powered-on engine for revision with zeroed (unloaded) firmware.

Source

pub fn power(&mut self)

Reset all programmer-visible state (NEC power-on). Firmware contents are retained.

Source

pub const fn firmware_loaded(&self) -> bool

Whether a firmware image has been loaded (the chip is functional).

Source

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.

Source

pub fn read_sr(&self) -> u8

Read the status register (the high byte the host sees at the SR port).

Source

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.

Source

pub fn read_dr(&mut self) -> u8

Read a byte from the data register, then catch the engine up to its next parked state.

Source

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.

Source

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).

Source

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).

Source

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.

Source

pub fn exec(&mut self)

Execute one instruction, then update the M/N multiplier outputs (NEC pipelines a signed K×L multiply each cycle).

Source

pub const fn host_accesses(&self) -> u64

Count of host DR port accesses since power-on (diagnostics).

Source

pub const fn pc(&self) -> u16

The current program counter (for unit tests / the debugger).

Source

pub const fn rqm(&self) -> bool

The RQM (request-for-master) status bit (for unit tests / the debugger).

Source

pub fn data_ram_word(&self, index: usize) -> u16

Read a data-RAM word directly (for unit tests / save-state inspection).

Source

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.

Source

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.

Source

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).

Trait Implementations§

Source§

impl Clone for Upd77c25

Source§

fn clone(&self) -> Upd77c25

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Upd77c25

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.