Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Predict and safely read a build-tag prefix service

Hardware interview practice

Predict and safely read a build-tag prefix service

MediumHardware-Software IntegrationSystemVerilog

Write the reference predictor and safe firmware transaction sequence for a memory-mapped I/O (MMIO) service that returns the longest common byte prefix of up to eight bounded build tags.

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 { LCP_OK, LCP_BAD_ARG, LCP_HW_ERROR, LCP_TIMEOUT } lcp_status_t;
lcp_status_t lcp_run(const char tag[8][16], const uint8_t len[8],
                     uint8_t count, char out[17], uint8_t *out_len);
// TAG_SEL, TAG_DATA, TAG_LEN[0:7], COUNT
// CMD{START,ABORT}, STATUS{BUSY,DONE,ERR}, RESULT_LEN, RESULT_DATA
Reviewed example

Work through one case

Input
tags=["asic-fyi","asic-flow","asic"], lengths=[8,9,4]
Expected output
RESULT_LEN=4; firmware output="asic\0"

All three byte strings match through index 3 and the shortest tag ends there; only firmware appends the terminator.

What to cover

Requirements

  1. Validate pointers, count 1 through 8, and active lengths 0 through 16 before any register access.
  2. Write each selected tag and length in order; START must snapshot the programmed inputs.
  3. Read exactly RESULT_LEN bytes, reject a result length above 16, and append one firmware-only terminator.
  4. Give ERR priority over DONE and preserve both caller outputs after hardware error, timeout, abort, or reset.
Continue practicing

Related questions

Reference ModelsMatch transactions in strict order→Reference ModelsMatch out-of-order packets by ID→Reference ModelsScoreboard a maximum-interval accelerator→
asic.fyi · Learn silicon end to end.info@asic.fyi