Skip to the selected question
ASIC.FYI

ASIC Question Bank

1,000+ hardware interview questions
DescriptionQ409
Page ↗
Q409DVASIC interview problem

Compile, program, and verify a bounded pattern matcher

TechniquesFirmwareUVMDynamic programming
DifficultyHard
TopicReference Models
LanguageSystemVerilog
Requirements4 checkpoints
01

Problem

Write the bounded pattern compiler, whole-record oracle, and transaction checks for literals, dot, and postfix star.

Type declarationSystemVerilog
typedef enum {
  PAT_OK, PAT_BAD_ARG, PAT_FULL, PAT_MMIO, PAT_TIMEOUT
} pat_status_t;
pat_status_t pat_program(const char *pattern, size_t length,
                         uint32_t timeout);

typedef struct packed {
  byte unsigned literal;
  bit any;
  bit star;
} pattern_token_t;

function automatic bit whole_record_match(
  input byte unsigned record[$],
  input pattern_token_t token[$]
);

Example input and output

Use this case to check your interpretation
Input
compile pattern="A.*B"; record="AXYB"
Output
shadow tokens=[literal A, dot-star, literal B]; whole-record match=1
Explanation

The star binds only to the preceding dot, which consumes XY while the leading A and trailing B anchor the entire record.

02

Requirements (4)

  • Reject a leading or repeated star, patterns above 48 bytes, and more than 24 compiled tokens before MMIO; an empty pattern is a valid committed program.
  • Use canonical token encoding, zero unused shadow slots, issue a release barrier, and preserve the active program after rejected commit, bus error, or timeout.
  • Build an independent prefix table for whole-record matching where star repeats only its preceding literal or dot zero or more times.
  • Enforce command and frame error priority, bounded responses, stable stalls, silent abort, and reset that clears both active and shadow configurations.