Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Constrain and cover an ASCII palindrome checker

Hardware interview practice

Constrain and cover an ASCII palindrome checker

HardConstraintsSystemVerilog

Create constrained-random stimulus, a software-style oracle, and a functional-coverage model for a checker that ignores non-alphanumeric ASCII, folds letter case, and tests the remaining sequence for a palindrome.

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 →
Reviewed example

Work through one case

Input
byte_count=32; raw ASCII bytes spell "A man, a plan, a canal: Panama!"
Expected output
request_error=0; filtered sequence=AMANAPLANACANALPANAMA; filtered_len=21; palindrome=1

Spaces and punctuation are removed and lowercase letters are folded to uppercase, leaving a case-insensitive palindrome.

What to cover

Requirements

  1. Retain only ASCII letters and digits, fold letters to one case, and classify an empty filtered sequence as a palindrome.
  2. Construct legal palindromes and targeted non-palindromes while also varying uppercase, lowercase, digits, punctuation, and nonprintable bytes.
  3. For byte_count above 32, predict request_error high and a zero palindrome result.
  4. Compare legal requests only at done and detect missing or duplicate completion pulses.
  5. Define coverpoints for raw and filtered length, result, character mix, parity, and punctuation-heavy case-insensitive matches; connecting and sampling the covergroup is a testbench follow-up.
Continue practicing

Related questions

ConstraintsGenerate opcode-bijection stimulus→ConstraintsGenerate ordered-signature matches→Verification UtilitiesRegress cross-transaction histogram leakage→
asic.fyi · Learn silicon end to end.info@asic.fyi