43typedef enum : uint64_t {
59typedef enum : uint32_t {
67typedef enum : uint32_t {
74typedef enum : int32_t {
80typedef enum : uint32_t {
89typedef enum : uint32_t {
122 return s_pdm[ch].running &&
s_pdm[ch].read_enable;
148 const int32_t dither =
153 const int32_t sample = tri + dither;
168 const uint32_t n =
s_pdm[ch].samples;
173 (void)snprintf(ln,
sizeof(ln),
"PDM%u samples=%u (synth tone)", (
unsigned)ch, (
unsigned)n);
215 if (
s_pdm[i].running) {
239 const uint64_t off = addr - (uint64_t)
k_pdm_base;
247 uint64_t ch_off = 0U;
260 return (uint64_t)sample;
283 const uint64_t off = addr - (uint64_t)
k_pdm_base;
291 if (((uint32_t)value & (1U << i)) != 0U) {
292 s_pdm[i].running =
true;
299 if (((uint32_t)value & (1U << i)) != 0U) {
300 s_pdm[i].running =
false;
306 uint64_t ch_off = 0U;
325 for (uint32_t i = 0U; i < (uint32_t)
k_pdm_words; i++) {
341 if (
s_pdm[i].samples == 0U) {
344 (void)
priv_emu_io_errf(
" PDM ch%u : samples=%u run=%s read_en=%s (synth tone)\n",
347 s_pdm[i].running ?
"yes" :
"no",
348 s_pdm[i].read_enable ?
"yes" :
"no");
Multi-channel console log store backing the board view's tabbed console.
void board_console_push(board_console_ch_t ch, const char *line)
Append one completed line to a channel ring and the ALL ring.
@ k_board_console_ch_i2s
SSIE / I2S sample-block summaries.
Decentralized peripheral-block registry for the board emulator core.
void board_periph_register_block(const board_periph_block_t *block)
Register a peripheral block's descriptor with the core registry.
@ k_block_order_i2c
I3C/I2C + GT911 (no tick today).
static const board_periph_block_t s_k_pdm_block
This block's descriptor (static lifetime; the core keeps the pointer).
static RA8_INTERNAL uint32_t internal_pdm_next_sample(uint32_t ch)
Next 20-bit two's-complement PCM sample for a live channel.
static RA8_INTERNAL void internal_board_periph_pdm_register(void)
Self-register the PDM-IF block before main runs (decentralized).
static RA8_INTERNAL void internal_pdm_reset(void)
Clear all PDM channel + shadow state to power-on.
pdm_field_t
PDM-IF register field masks / bits (ra8_pdm_regs.h).
@ k_pdm_pddsr_num
PDDSR[7:0] FIFO fill count field.
@ k_pdm_pddrr_mask20
PDDRR[19:0] 20-bit two's-complement.
@ k_pdm_fifo_depth
Samples reported available when live.
@ k_pdm_pddrcr_datre
PDDRCR[0] data-read enable.
static RA8_INTERNAL uint64_t internal_pdm_read(uc_engine *uc, uint64_t addr, unsigned size)
MMIO read inside the PDM window.
static uint32_t s_pdm_reg[k_pdm_words]
Reflect-on-read shadow.
pdm_dither_t
Per-channel pseudo-random dither (window-to-window variety).
@ k_pdm_lcg_add
LCG increment (Numerical Recipes).
@ k_pdm_lcg_shift
Take the high bits (better spread).
@ k_pdm_lcg_mul
LCG multiplier (Numerical Recipes).
@ k_pdm_dither_mask
10-bit dither window (0..1023).
@ k_pdm_dither_half
Centre the dither at 0 (+-512).
static RA8_INTERNAL void internal_pdm_console_maybe(uint32_t ch)
Push an anti-flood "PDMn samples=.." line to the I2S/audio tab.
static RA8_INTERNAL bool internal_pdm_live(uint32_t ch)
True when channel ch is both started and read-enabled.
static RA8_INTERNAL void internal_pdm_write(uc_engine *uc, uint64_t addr, unsigned size, uint64_t value)
MMIO write inside the PDM window: latch, then update run/enable gates.
static RA8_INTERNAL bool internal_pdm_channel_at(uint64_t off, uint32_t *ch, uint64_t *ch_off)
Compute the channel index + in-bank offset for an in-window address.
static pdm_channel_t s_pdm[k_pdm_ch_count]
pdm_amp_t
Synthetic-tone amplitude / slope (20-bit signed, well below +-524288).
@ k_pdm_tone_amp
Triangle peak amplitude (+-).
@ k_pdm_tone_step
Per-sample slope = 2*amp / (period/2).
static RA8_INTERNAL uint32_t internal_pdm_read_csr(void)
PDCSR: one run bit per currently-started channel.
pdm_map_t
PDM-IF register-window geometry (ra8_pdm_regs.h).
@ k_pdm_base
PDM-IF block base (HUM Ch 49).
@ k_pdm_ch_pddrcr
CHn PDDRCR data-read control.
@ k_pdm_ch_pddsr
CHn PDDSR data status (fill count).
@ k_pdm_ch_stride
Bytes between channel banks.
@ k_pdm_off_cstptr
PDCSTPTR common stop trigger.
@ k_pdm_ch_count
PDM channels (CH0..CH2).
@ k_pdm_span
Common bank + 3 channel banks.
@ k_pdm_off_csr
PDCSR common channel status.
@ k_pdm_off_cstrtr
PDCSTRTR common start trigger.
@ k_pdm_ch_pddrr
CHn PDDRR 20-bit PCM data read.
@ k_pdm_words
Backing-store word count.
@ k_pdm_ch0_off
Offset of the first channel bank.
pdm_tone_t
Synthetic-tone shape constants (deterministic, integer-only).
@ k_pdm_tone_period
Samples per triangle cycle (power of two).
@ k_pdm_tone_half
period/2: rising-then-falling split point.
@ k_pdm_tone_qmask
period-1: phase wrap mask.
pdm_console_t
Console anti-flood cadence for the PDM (I2S/audio) tab.
@ k_pdm_console_line_cap
Max chars in a "PDM.. samples=.." line.
@ k_pdm_console_every
Push one line per N samples per channel.
static RA8_INTERNAL void internal_pdm_report(void)
Print one line per PDM channel the firmware captured from.
Bounded raw-descriptor I/O seam for the RA8 emulator.
emu_io_result_t priv_emu_io_errf(const char *format,...)
Format bounded text and write it to the injected error descriptor.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
A modelled peripheral block's self-description for the core registry.
One modelled PDM channel: run/enable gates + synthetic-tone state.
bool read_enable
PDDRCR.DATRE armed the data-read path.
uint32_t samples
Total PDDRR reads served (report + console).
uint32_t phase
Triangle-tone sample phase (advances on read).
bool running
A PDCSTRTR bit started this channel.
uint32_t lcg
Per-channel dither LCG state.