Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Build an interrupt-safe sliding-maximum telemetry filter

Hardware interview practice

Build an interrupt-safe sliding-maximum telemetry filter

HardData StructuresC

Build a fixed-memory sliding maximum written by one interrupt service routine (ISR) and read by a task, with bounded retries, wrap-safe sequence ages, newest-equal tie behavior, and atomic publication.

Try it in the question bankReason first. Then compare.

Keep this exact question selected while you check your answer and review the full solution.

Practice this question →
Starting point

Question code

typedef struct { int32_t value; uint32_t seq; } tm_node_t;
typedef struct telemetry_max_ref telemetry_max_ref;

bool telemetry_max_configure(telemetry_max_ref *filter, uint32_t window);
void telemetry_max_isr_push(telemetry_max_ref *filter, int32_t value);
bool telemetry_max_read(const telemetry_max_ref *filter,
                        int32_t *maximum, uint32_t *maximum_seq);
Reviewed example

Work through one case

Input
window=3; ISR samples by sequence=[4,2,5,5]
Expected output
published maxima=[4,4,5,5]; newest equal maximum is the final 5

Removing older values less than or equal to each new sample keeps the deque decreasing and gives equal values newest-wins behavior.

What to cover

Requirements

  1. Initialization accepts windows 1 through 64, publishes window last, and leaves the object unchanged after invalid reconfiguration.
  2. Maintain a decreasing queue, remove older values less than or equal to the new sample, and expire by unsigned sequence age.
  3. Publish full, maximum, and sequence between odd and even generation values using release semantics.
  4. A reader uses acquire loads, accepts only the same even generation before and after, tries at most three snapshots, and preserves outputs on every failure.
asic.fyi · Learn silicon end to end.info@asic.fyi