Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Bounded MMIO command driver

Hardware interview practice

Bounded MMIO command driver

MediumFirmware & ValidationC

A test engine starts through one command register and reports DONE or ERROR in a status register. Write a C driver that issues one command and polls with a fixed bound.

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

enum rc { OK, BUSY, HWERR, TIMEOUT };
enum rc run_cmd(volatile uint32_t *cmd,
volatile uint32_t *status, uint32_t value);
// status bits: BUSY=1,DONE=2,ERROR=4; DONE/ERROR W1C
Reviewed example

Work through one case

Input
The first status-register read has BUSY set.
Expected output
Return BUSY with zero writes to cmd or status.

The driver checks the initial BUSY bit before clearing stale flags or issuing the command, so it exits without modifying MMIO.

What to cover

Requirements

  1. If the first status read has BUSY set, return BUSY without writing either register.
  2. Clear old DONE and ERROR by writing bits 2|4 to status, then write value to cmd exactly once.
  3. Read status at most 100 times; ERROR has priority over DONE if both are observed.
  4. Return HWERR on ERROR, OK on DONE, and TIMEOUT after 100 reads with neither; do no extra MMIO after returning.
Continue practicing

Related questions

Firmware & ValidationBounded byte-string palindrome check→Firmware & ValidationLocate the payload in an Ethernet frame→Firmware & ValidationCount errors in a build report→
asic.fyi · Learn silicon end to end.info@asic.fyi