Frame

Struct Frame 

pub struct Frame {
    pub reset_pending: bool,
    pub requests: u8,
    pub polled: Option<u8>,
    pub deferred: Option<u8>,
    pub stalled: Option<u8>,
    pub stalled_before: Option<u8>,
    pub polled_i: Option<u8>,
    pub halted: bool,
    pub dma_stalled: bool,
}
Expand description

The interrupt inputs and the poll’s memory, shared by every 65xx part.

The fields are the subclassing surface (the Python frame’s underscored attributes); a host uses the methods.

Fields§

§reset_pending: bool§requests: u8

IRQ_LINE | NMI_LATCH, as the host has set them.

§polled: Option<u8>

The chip polls its interrupt detectors in an instruction’s last cycle, so what counts is the requests as they stood at the end of the second-to-last cycle (NESdev, “CPU interrupts”, “Detailed interrupt behavior”). Usually that is the requests as they stand, and polled is None. It holds what the poll saw instead, for the next boundary only, when that differs: a bus callback changed a request in the last cycle, too late (deferred, see Frame::request), or the step was BRK, an interrupt entry or reset, which do not poll (NO_POLL). A request the host makes between steps is taken at the next boundary, unless that step did not poll.

§deferred: Option<u8>§stalled: Option<u8>

The requests as a host’s last two note_stall calls found them, for a branch’s poll: None when the read has not been stalled.

§stalled_before: Option<u8>§polled_i: Option<u8>

CLI, SEI and PLP change I after the chip has polled for interrupts, so the next boundary decides on the old I. None: poll P as it is.

§halted: bool

The CPU has stopped (JAM on the NMOS part); halted_cycle decides what a step does until reset.

§dma_stalled: bool

The NMOS part’s DMA input (MOS6502.dma_stalled in the reference): set by a host whose bus callback stretched the current read cycle with RDY low, cleared by it on the next read that is not. SHA, SHX, SHY and TAS look at it on their write. Kept here because the bus callback reaches the CPU only through the frame.

Implementations§

§

impl Frame

pub fn access(&mut self)

Make an access: confirm a request change made since the last one.

The first change since the last access keeps the requests from before it in deferred (see Frame::request). If an access comes in the same step, the change was before the last cycle and the poll sees it; if the step ends first, the poll saw deferred.

pub fn request(&mut self, requests: u8)

Change the requests, and arrange to learn whether a bus access follows.

pub fn note_stall(&mut self)

Say, from inside a read callback, that RDY is holding this read (a DMA).

Call it as the stall begins and again after each halted cycle, then make the access. The halted chip repeats the cycle and its interrupt detectors keep sampling, so a request raised during the stall is polled at the end of the read it stretched, whichever cycle that is, even the last (perfect6502 with RDY held low). A taken branch’s next-opcode read, which does not poll, takes requests raised by the start of the stall’s last halted cycle, not during it (perfect6502; AccuracyCoin “Interrupt flag latency” test A).

The frame only records what the requests were at each call, in stalled and stalled_before; a part’s branch sequence reads them (the NMOS one does) and resets both to None.

pub fn boundary_interrupt(&mut self, p: u8) -> u8

The interrupt this boundary takes: NMI_LATCH, IRQ_LINE, or 0 for none.

pub fn request_reset(&mut self)

Run the start sequence at the next boundary.

The start sequence begins when RESET is released (PM section 9.2), so one request is one reset, whenever the host’s board releases the line. Reset has priority over everything, and restarts a halted CPU.

pub fn clear_reset(&mut self)

Cancel a requested reset that has not yet reached a boundary.

pub fn maskable_interrupt_pending(&self) -> bool

Whether the IRQ line is asserted.

pub fn request_maskable_interrupt(&mut self)

Assert IRQ, a level: it stays asserted until Frame::clear_maskable_interrupt.

Taking the interrupt does not clear it; on a board the device holds IRQ low until its handler acknowledges it, and so must the host. While it is asserted and I is clear, every poll takes the interrupt.

pub fn clear_maskable_interrupt(&mut self)

Release IRQ.

pub fn non_maskable_interrupt_pending(&self) -> bool

Whether an NMI edge has been latched and not yet taken.

pub fn request_non_maskable_interrupt(&mut self)

Latch an NMI edge; the next poll takes it, whatever I says.

NMI is edge-triggered: call this on the line’s falling edge. Requests made while one is pending coalesce into one NMI.

pub fn clear_non_maskable_interrupt(&mut self)

Cancel a latched NMI that has not yet been taken, even one already polled.

pub fn poll_fields(&self) -> PollFields

The frame’s part of a state snapshot.

pub fn restore_poll(&mut self, state: &PollFields)

Restore the fields Frame::poll_fields captured.

Trait Implementations§

§

impl Clone for Frame

§

fn clone(&self) -> Frame

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
§

impl Debug for Frame

§

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

Formats the value using the given formatter. Read more
§

impl Default for Frame

§

fn default() -> Frame

Returns the “default value” for a type. Read more
§

impl PartialEq for Frame

§

fn eq(&self, other: &Frame) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl Eq for Frame

§

impl StructuralPartialEq for Frame

Auto Trait Implementations§

§

impl Freeze for Frame

§

impl RefUnwindSafe for Frame

§

impl Send for Frame

§

impl Sync for Frame

§

impl Unpin for Frame

§

impl UnwindSafe for Frame

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.