DescriptionQ048
Q048FWDVASIC interview problem
Verify keypad expansion and FIFO draining
TechniquesFWDVMMIOFIFOCombinatorics
DifficultyMedium
TopicHardware-Software Integration
LanguageSystemVerilog
Requirements4 checkpoints
01
Problem
Write the ordered-string predictor and transaction plan for a memory-mapped keypad expander with a 16-entry first-in, first-out (FIFO) result queue.
Type declarationSystemVerilog
typedef enum { KP_OK, KP_BAD_ARG, KP_HW_ERROR, KP_TIMEOUT } kp_status_t;
kp_status_t keypad_expand(const char *digits, size_t len,
char (*out)[5], size_t out_cap, size_t *out_count,
uint32_t timeout_ticks);
// DIGITS,LENGTH,CONTROL.START,STATUS{BUSY,DONE,ERROR,FIFO_COUNT}
// RESULT_DATA,RESULT_LEN,IRQ_STATUS.DONE,IRQ_CLEARExample input and output
Use this case to check your interpretationInput
digits="23"Output
9 outputs in order: ["ad","ae","af","bd","be","bf","cd","ce","cf"]Explanation
The 3x3 Cartesian product follows keypad letter order, making the generated stream dictionary ordered.
02
Requirements (4)
- Validate one through four digits from 2 through 9 and calculate the exact output count before MMIO.
- Generate strings in dictionary order using abc through wxyz and drain the 16-entry FIFO while the job is still active.
- Pop exactly one result per accepted data read and publish out_count only after all expected entries and DONE are observed.
- Handle sticky status, busy START rejection, unsigned timer wrap, reset, timeout, and incomplete completion distinctly.
