epio
A cycle-accurate RP2350 PIO emulator
Loading...
Searching...
No Matches
Functions
Execution API

Functions for loading instructions and stepping execution. More...

Functions

EPIO_EXPORT void epio_set_instr (epio_t *epio, uint8_t block, uint8_t instr_num, uint16_t instr)
 Write a PIO instruction into the instruction memory of a block.
 
EPIO_EXPORT uint16_t epio_get_instr (epio_t *epio, uint8_t block, uint8_t instr_num)
 Read a PIO instruction from the instruction memory of a block.
 
EPIO_EXPORT void epio_force_sm_instr (epio_t *epio, uint8_t block, uint8_t sm, uint16_t instr)
 Emulate a write to a state machine's SMx_INSTR register.
 
EPIO_EXPORT void epio_step_cycles (epio_t *epio, uint32_t cycles)
 Advance all enabled state machines by a number of clock cycles.
 
EPIO_EXPORT uint64_t epio_get_cycle_count (epio_t *epio)
 Return the total number of cycles executed since last reset.
 
EPIO_EXPORT void epio_reset_cycle_count (epio_t *epio)
 Reset the cycle counter to zero.
 

Detailed Description

Functions for loading instructions and stepping execution.

Function Documentation

◆ epio_force_sm_instr()

EPIO_EXPORT void epio_force_sm_instr ( epio_t *  epio,
uint8_t  block,
uint8_t  sm,
uint16_t  instr 
)

Emulate a write to a state machine's SMx_INSTR register.

The state machine's pending delay is kept and the instruction's own delay is ignored. A forced instruction that has to wait, for example a WAIT on a pin that is low, is skipped. On real hardware, the state machine waits until the instruction completes.

Parameters
epioThe epio instance.
blockPIO block index (0 to NUM_PIO_BLOCKS-1).
smState machine index within the block (0 to NUM_SMS_PER_BLOCK-1).
instrEncoded 16-bit PIO instruction.

◆ epio_get_cycle_count()

EPIO_EXPORT uint64_t epio_get_cycle_count ( epio_t *  epio)

Return the total number of cycles executed since last reset.

Parameters
epioThe epio instance.
Returns
Total cycle count.
See also
epio_reset_cycle_count()

◆ epio_get_instr()

EPIO_EXPORT uint16_t epio_get_instr ( epio_t *  epio,
uint8_t  block,
uint8_t  instr_num 
)

Read a PIO instruction from the instruction memory of a block.

Parameters
epioThe epio instance.
blockPIO block index (0 to NUM_PIO_BLOCKS-1).
instr_numInstruction slot (0 to NUM_INSTRS_PER_BLOCK-1).
Returns
The encoded 16-bit PIO instruction at that slot.
See also
epio_set_instr()

◆ epio_reset_cycle_count()

EPIO_EXPORT void epio_reset_cycle_count ( epio_t *  epio)

Reset the cycle counter to zero.

Parameters
epioThe epio instance.
See also
epio_get_cycle_count()

◆ epio_set_instr()

EPIO_EXPORT void epio_set_instr ( epio_t *  epio,
uint8_t  block,
uint8_t  instr_num,
uint16_t  instr 
)

Write a PIO instruction into the instruction memory of a block.

Parameters
epioThe epio instance.
blockPIO block index (0 to NUM_PIO_BLOCKS-1).
instr_numInstruction slot (0 to NUM_INSTRS_PER_BLOCK-1).
instrEncoded 16-bit PIO instruction.
See also
epio_get_instr()

◆ epio_step_cycles()

EPIO_EXPORT void epio_step_cycles ( epio_t *  epio,
uint32_t  cycles 
)

Advance all enabled state machines by a number of clock cycles.

Each enabled SM is stepped exactly cycles clock cycles. SMs stalled on a FIFO condition or IRQ consume cycles but make no forward progress. The global cycle count is incremented by cycles after each call.

Parameters
epioThe epio instance.
cyclesNumber of cycles to advance.
See also
epio_get_cycle_count()