DescriptionQ1050
Q1050FWDVASIC interview problem
Verify an in-place DMA merge transaction
TechniquesFWDVDMAArraysMemory safety
DifficultyEasy
TopicHardware-Software Integration
LanguageSystemVerilog
Requirements4 checkpoints
01
Problem
Write the merge oracle and transaction checks for firmware driving a direct memory access (DMA) engine that merges two sorted 16-bit arrays into reserved buffer A.
Type declarationSystemVerilog
typedef enum { DMA_OK, DMA_BAD_ARG, DMA_HW_ERROR, DMA_TIMEOUT } dma_status_t;
dma_status_t dma_merge_u16(uint32_t a, uint8_t m, uint8_t a_cap,
uint32_t b, uint8_t n, uint32_t timeout);
// A_ADDR, B_ADDR, M, N, A_CAP, CMD{START,ABORT}
// STATUS{BUSY,DONE,ERR,ERR_CODE}; ERR_CODE{BAD_DESC,READ_FAULT,WRITE_FAULT}Example input and output
Use this case to check your interpretationInput
A storage=[1,4,7,_,_,_], m=3, capacity=6; B=[2,4,9], n=3Output
A after DMA=[1,2,4,4,7,9]Explanation
The merge is sorted, preserves both copies of 4, and writes only inside the reserved six-element A destination.
02
Requirements (4)
- Validate lengths, destination capacity, alignment, address wrap, and nonoverlap before touching registers.
- Require A to be a valid destination whenever m+n is nonzero and B to be valid whenever n is nonzero.
- Snapshot both active inputs at accepted START and keep every write inside A[0:m+n).
- Stop after the first memory fault; map faults and timeout distinctly and suppress late completion after abort or reset.
