Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Constrain ten unique multiples of three

Hardware interview practice

Constrain ten unique multiples of three

EasyConstrained RandomSystemVerilog

Write SystemVerilog constraints for ten distinct randomized byte values, each inside 1 through 100 and divisible by three.

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 →
Starting point

Question code

class multiples_packet;
  rand bit [7:0] values[10];
endclass
Reviewed example

Work through one case

Input
Randomize values[10] under the range, modulo, and uniqueness constraints
Expected output
'{3, 6, 9, 12, 15, 18, 21, 24, 27, 30} is one legal result

Every element lies in 1 through 100, every remainder modulo three is zero, and no value repeats.

What to cover

Requirements

  1. Constrain every element to the inclusive range [1:100].
  2. Constrain every element to be divisible by 3.
  3. Require all ten elements to be unique.
  4. Show how the caller checks randomize() success.
Continue practicing

Related questions

Constrained RandomConstrain exactly five changed bit positions→Constrained RandomConstrain a nonzero 32-bit power of two→ConstraintsConstrain three disjoint child arrays→
asic.fyi · Learn silicon end to end.info@asic.fyi