Skip to content

Write a foreach constraint, and an inline randomize() with {} constraint

write-from-scratch

foreach (arr[i]) gives the constraint a loop variable i to index the array with. randomize() with { ... } adds a constraint for one call only, without changing the class.

Fix the class and function below.

Requirements

  1. Every element of lens stays in [1:100].
  2. tag_item() randomizes item so that tag equals the target argument.

Source on GitHub

foreach_with_basics.sv