Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Co-verify a memory-mapped minimum stack

Hardware interview practice

Co-verify a memory-mapped minimum stack

MediumHardware-Software IntegrationSystemVerilog

Build the firmware wrapper and reference model for a signed 16-entry memory-mapped I/O (MMIO) stack supporting push, pop, top, and minimum.

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 enum { MSTACK_OK, MSTACK_BAD_ARG, MSTACK_HW_ERROR, MSTACK_TIMEOUT } mstack_status_t;
mstack_status_t mstack_exec(uint8_t op, int16_t arg,
                            int16_t *result, uint32_t timeout);
// WDATA, CMD{GO,OP}, RDATA
// STATUS{BUSY,DONE,EMPTY,FULL}, ERROR{UNDERFLOW,OVERFLOW}
// OP: PUSH=0, POP=1, TOP=2, MIN=3; depth=16
Reviewed example

Work through one case

Input
PUSH 5; PUSH 2; MIN; POP; MIN
Expected output
MIN returns 2; POP returns 2; final MIN returns 5

The auxiliary minimum state follows successful pushes and pops, while the read-only MIN operation leaves depth unchanged.

What to cover

Requirements

  1. Validate the operation and required result pointer before MMIO, write push data before GO, and clear stale completion state.
  2. Model only GO commands accepted while idle; TOP and MIN observe without changing depth.
  3. Underflow or overflow completes with an error while preserving stack contents and RDATA; error has priority over DONE.
  4. Keep sticky completion and error bits until write-one-to-clear, ignore GO while busy, and cancel visible state on reset.
Continue practicing

Related questions

Firmware AlgorithmsParse a bounded Roman board revision→Verification StrategyIdentify a specification-based negative test→
asic.fyi · Learn silicon end to end.info@asic.fyi