|
epio
A cycle-accurate RP2350 PIO emulator
|
Functions for reading internal state machine and block state for testing. More...
Functions | |
| EPIO_EXPORT uint8_t | epio_peek_sm_pc (epio_t *epio, uint8_t block, uint8_t sm) |
| Get the current program counter (PC) for a state machine. | |
| EPIO_EXPORT uint32_t | epio_peek_sm_x (epio_t *epio, uint8_t block, uint8_t sm) |
| Get the current X register value for a state machine. | |
| EPIO_EXPORT uint32_t | epio_peek_sm_y (epio_t *epio, uint8_t block, uint8_t sm) |
| Get the current Y register value for a state machine. | |
| EPIO_EXPORT uint32_t | epio_peek_sm_isr (epio_t *epio, uint8_t block, uint8_t sm) |
| Get the current Input Shift Register (ISR) value for a state machine. | |
| EPIO_EXPORT uint32_t | epio_peek_sm_osr (epio_t *epio, uint8_t block, uint8_t sm) |
| Get the current Output Shift Register (OSR) value for a state machine. | |
| EPIO_EXPORT uint8_t | epio_peek_sm_isr_count (epio_t *epio, uint8_t block, uint8_t sm) |
| Get the current ISR bit counter for a state machine. | |
| EPIO_EXPORT uint8_t | epio_peek_sm_osr_count (epio_t *epio, uint8_t block, uint8_t sm) |
| Get the current OSR bit counter for a state machine. | |
| EPIO_EXPORT uint8_t | epio_peek_sm_osr_empty (epio_t *epio, uint8_t block, uint8_t sm) |
| Check whether the OSR is considered empty for a state machine. | |
| EPIO_EXPORT uint8_t | epio_peek_sm_stalled (epio_t *epio, uint8_t block, uint8_t sm) |
| Check if a state machine is currently stalled. | |
| EPIO_EXPORT uint8_t | epio_peek_sm_delay (epio_t *epio, uint8_t block, uint8_t sm) |
| Get the current delay counter for a state machine. | |
| EPIO_EXPORT uint8_t | epio_peek_sm_exec_pending (epio_t *epio, uint8_t block, uint8_t sm) |
| Check if a state machine has a pending EXEC instruction. | |
| EPIO_EXPORT uint16_t | epio_peek_sm_exec_instr (epio_t *epio, uint8_t block, uint8_t sm) |
| Get the pending EXEC instruction for a state machine. | |
| EPIO_EXPORT uint32_t | epio_peek_block_irq (epio_t *epio, uint8_t block) |
| Get the current IRQ state bitmask for a PIO block. | |
| EPIO_EXPORT uint8_t | epio_peek_block_irq_num (epio_t *epio, uint8_t block, uint8_t irq_num) |
| Check if a specific IRQ flag is set for a PIO block. | |
| EPIO_EXPORT uint32_t | epio_peek_rx_fifo (epio_t *epio, uint8_t block, uint8_t sm, uint8_t entry) |
| Peek at an entry in the RX FIFO of a state machine without popping it. | |
| EPIO_EXPORT uint32_t | epio_peek_tx_fifo (epio_t *epio, uint8_t block, uint8_t sm, uint8_t entry) |
| Peek at an entry in the TX FIFO of a state machine without popping it. | |
Functions for reading internal state machine and block state for testing.
| EPIO_EXPORT uint32_t epio_peek_block_irq | ( | epio_t * | epio, |
| uint8_t | block | ||
| ) |
Get the current IRQ state bitmask for a PIO block.
Each PIO block has 8 IRQ flags (0-7) that can be set, cleared, and waited on by state machines. IRQs can be used for synchronization between state machines within a block or across blocks.
| epio | The epio instance. |
| block | PIO block index (0 to NUM_PIO_BLOCKS-1). |
| EPIO_EXPORT uint8_t epio_peek_block_irq_num | ( | epio_t * | epio, |
| uint8_t | block, | ||
| uint8_t | irq_num | ||
| ) |
Check if a specific IRQ flag is set for a PIO block.
Convenience function equivalent to checking the bit in epio_peek_block_irq().
| epio | The epio instance. |
| block | PIO block index (0 to NUM_PIO_BLOCKS-1). |
| irq_num | IRQ number to check (0 to NUM_IRQS_PER_BLOCK-1). |
| EPIO_EXPORT uint32_t epio_peek_rx_fifo | ( | epio_t * | epio, |
| uint8_t | block, | ||
| uint8_t | sm, | ||
| uint8_t | entry | ||
| ) |
Peek at an entry in the RX FIFO of a state machine without popping it.
Allows inspection of the contents of the RX FIFO without modifying it. The entry parameter specifies how far back in the FIFO to peek, with 0 being the next entry to be popped.
Asserts if entry is greater than or equal to the current RX FIFO depth.
| epio | The epio instance. |
| block | PIO block index (0 to NUM_PIO_BLOCKS-1). |
| sm | State machine index within the block (0 to NUM_SMS_PER_BLOCK-1). |
| entry | FIFO entry index to peek (0 = next to pop, up to depth-1). |
| EPIO_EXPORT uint8_t epio_peek_sm_delay | ( | epio_t * | epio, |
| uint8_t | block, | ||
| uint8_t | sm | ||
| ) |
Get the current delay counter for a state machine.
PIO instructions can include a delay field that causes the state machine to wait for 0-31 additional cycles before executing the next instruction. This returns the number of delay cycles remaining.
After the intruction that included the delay, but before any delay cycles have elapsed, this will return the full delay value. After all delay cycles have elapsed, this will return 0.
| epio | The epio instance. |
| block | PIO block index (0 to NUM_PIO_BLOCKS-1). |
| sm | State machine index within the block (0 to NUM_SMS_PER_BLOCK-1). |
| EPIO_EXPORT uint16_t epio_peek_sm_exec_instr | ( | epio_t * | epio, |
| uint8_t | block, | ||
| uint8_t | sm | ||
| ) |
Get the pending EXEC instruction for a state machine.
When OUT EXEC or MOV EXEC is executed, this returns the instruction that will be executed on the next cycle. Only valid when exec_pending is true.
| epio | The epio instance. |
| block | PIO block index (0 to NUM_PIO_BLOCKS-1). |
| sm | State machine index within the block (0 to NUM_SMS_PER_BLOCK-1). |
| EPIO_EXPORT uint8_t epio_peek_sm_exec_pending | ( | epio_t * | epio, |
| uint8_t | block, | ||
| uint8_t | sm | ||
| ) |
Check if a state machine has a pending EXEC instruction.
When OUT EXEC or MOV EXEC is executed, the state machine stores the instruction to execute on the next cycle rather than fetching from instruction memory. This returns whether such an instruction is pending.
| epio | The epio instance. |
| block | PIO block index (0 to NUM_PIO_BLOCKS-1). |
| sm | State machine index within the block (0 to NUM_SMS_PER_BLOCK-1). |
| EPIO_EXPORT uint32_t epio_peek_sm_isr | ( | epio_t * | epio, |
| uint8_t | block, | ||
| uint8_t | sm | ||
| ) |
Get the current Input Shift Register (ISR) value for a state machine.
The ISR accumulates data from IN instructions before being pushed to the RX FIFO.
| epio | The epio instance. |
| block | PIO block index (0 to NUM_PIO_BLOCKS-1). |
| sm | State machine index within the block (0 to NUM_SMS_PER_BLOCK-1). |
| EPIO_EXPORT uint8_t epio_peek_sm_isr_count | ( | epio_t * | epio, |
| uint8_t | block, | ||
| uint8_t | sm | ||
| ) |
Get the current ISR bit counter for a state machine.
Tracks how many bits have been shifted into the ISR since the last PUSH or autopush. Used to determine when autopush threshold is reached.
| epio | The epio instance. |
| block | PIO block index (0 to NUM_PIO_BLOCKS-1). |
| sm | State machine index within the block (0 to NUM_SMS_PER_BLOCK-1). |
| EPIO_EXPORT uint32_t epio_peek_sm_osr | ( | epio_t * | epio, |
| uint8_t | block, | ||
| uint8_t | sm | ||
| ) |
Get the current Output Shift Register (OSR) value for a state machine.
The OSR is loaded from the TX FIFO via PULL instructions and provides data to OUT instructions.
| epio | The epio instance. |
| block | PIO block index (0 to NUM_PIO_BLOCKS-1). |
| sm | State machine index within the block (0 to NUM_SMS_PER_BLOCK-1). |
| EPIO_EXPORT uint8_t epio_peek_sm_osr_count | ( | epio_t * | epio, |
| uint8_t | block, | ||
| uint8_t | sm | ||
| ) |
Get the current OSR bit counter for a state machine.
Tracks how many bits have been shifted out of the OSR since the last PULL or autopull. Used to determine when autopull threshold is reached.
OSR count indicates 32 when the OSR is empty (32 bits shifted out)
| epio | The epio instance. |
| block | PIO block index (0 to NUM_PIO_BLOCKS-1). |
| sm | State machine index within the block (0 to NUM_SMS_PER_BLOCK-1). |
| EPIO_EXPORT uint8_t epio_peek_sm_osr_empty | ( | epio_t * | epio, |
| uint8_t | block, | ||
| uint8_t | sm | ||
| ) |
Check whether the OSR is considered empty for a state machine.
Returns true if the OSR shift count has reached or exceeded the configured PULL_THRESH. This matches the condition used by JMP !OSRE and autopull.
| epio | The epio instance. |
| block | PIO block index (0 to NUM_PIO_BLOCKS-1). |
| sm | State machine index within the block (0 to NUM_SMS_PER_BLOCK-1). |
| EPIO_EXPORT uint8_t epio_peek_sm_pc | ( | epio_t * | epio, |
| uint8_t | block, | ||
| uint8_t | sm | ||
| ) |
Get the current program counter (PC) for a state machine.
Returns the instruction address that the state machine will execute next. The PC is automatically incremented after each instruction unless a jump or wrap occurs.
Remember that the PC is relative to the block's instruction memory, so it ranges from 0 to NUM_INSTRS_PER_BLOCK-1.
The PC is updated during at the end of the cycle when the previous instruction executed, if there is a delay, but not a stall. This is in line with the data sheet, which indicates that for a JMP, the delay happens after PC is updated.
| epio | The epio instance. |
| block | PIO block index (0 to NUM_PIO_BLOCKS-1). |
| sm | State machine index within the block (0 to NUM_SMS_PER_BLOCK-1). |
| EPIO_EXPORT uint8_t epio_peek_sm_stalled | ( | epio_t * | epio, |
| uint8_t | block, | ||
| uint8_t | sm | ||
| ) |
Check if a state machine is currently stalled.
A state machine stalls when waiting for a condition that hasn't been met, such as:
When stalled, the PC does not advance and the same instruction is re-evaluated each cycle until the stall condition clears.
| epio | The epio instance. |
| block | PIO block index (0 to NUM_PIO_BLOCKS-1). |
| sm | State machine index within the block (0 to NUM_SMS_PER_BLOCK-1). |
| EPIO_EXPORT uint32_t epio_peek_sm_x | ( | epio_t * | epio, |
| uint8_t | block, | ||
| uint8_t | sm | ||
| ) |
Get the current X register value for a state machine.
The X register is a general-purpose 32-bit scratch register that can be read and written by PIO instructions.
| epio | The epio instance. |
| block | PIO block index (0 to NUM_PIO_BLOCKS-1). |
| sm | State machine index within the block (0 to NUM_SMS_PER_BLOCK-1). |
| EPIO_EXPORT uint32_t epio_peek_sm_y | ( | epio_t * | epio, |
| uint8_t | block, | ||
| uint8_t | sm | ||
| ) |
Get the current Y register value for a state machine.
The Y register is a general-purpose 32-bit scratch register that can be read and written by PIO instructions.
| epio | The epio instance. |
| block | PIO block index (0 to NUM_PIO_BLOCKS-1). |
| sm | State machine index within the block (0 to NUM_SMS_PER_BLOCK-1). |
| EPIO_EXPORT uint32_t epio_peek_tx_fifo | ( | epio_t * | epio, |
| uint8_t | block, | ||
| uint8_t | sm, | ||
| uint8_t | entry | ||
| ) |
Peek at an entry in the TX FIFO of a state machine without popping it.
Allows inspection of the contents of the TX FIFO without modifying it. The entry parameter specifies how far back in the FIFO to peek, with 0 being the next entry to be popped by the SM.
Asserts if entry is greater than or equal to the current TX FIFO depth.
| epio | The epio instance. |
| block | PIO block index (0 to NUM_PIO_BLOCKS-1). |
| sm | State machine index within the block (0 to NUM_SMS_PER_BLOCK-1). |
| entry | FIFO entry index to peek (0 = next to pop, up to depth-1). |