Skip to the selected question
ASIC.FYI

ASIC Question Bank

1,000+ hardware interview questions
DescriptionQ351
Page ↗
Q351DVMetaASIC interview problem

Random palindrome array constraint

TechniquesDVSystemVerilogDynamic arrayReduction
DifficultyMedium
TopicSystemVerilog Constraints
LanguageSystemVerilog
Requirements4 checkpoints
01

Problem

A sequence item needs a short digit array that reads the same forward and backward. Write constraints for size, digit range, full palindrome symmetry, and a bounded sum.

Class declarationSystemVerilog
class palindrome_item;
  rand int unsigned digits[];
endclass

Example input and output

Use this case to check your interpretation
Input
digits='{4,0,1,1,0,4}
Output
Legal; size=6 and sum=10
Explanation

Every element equals its mirror, every digit is 0..9, and the total is within 36.

02

Requirements (4)

  • Constrain digits.size() to be from 5 through 9 inclusive.
  • Constrain every element to the inclusive range 0 through 9.
  • For every valid index i, constrain digits[i] to equal digits[digits.size()-1-i].
  • Constrain the sum of all digits to be no greater than 36.