Constraints declare the legal stimulus space and the solver picks random points inside it. Coverage records which parts of that space were visited.
Topic | Lessons | Description | Time | Path |
|---|---|---|---|---|
6 | The solver call behind every random test: rand fields, hooks, nested objects and seeds. | 45 min | Required | |
4 | How inside, dist, implication, solve-before and soft shape the solver search space. | 30 min | Required | |
5 | Freeze fields, toggle blocks, tighten at call sites, and pick the right control layer. | 40 min | Required | |
5 | Variable-length payloads, ordered lists and transaction streams, described as constraints. | 40 min | Required | |
5 | How the solver picks values: solution sets, ordering, randc, speed, and guarantees. Senior depth. | 40 min | Optional | |
5 | Debug randomization failures: classify the symptom, isolate the cause, and harden the bench. | 40 min | Required | |
9 | Revision: write-the-constraint drills plus senior-level randomization Q&A with answers. | 70 min | Optional |
Path: Required is the core first pass for this part, Recommended is for most learners, and Optional is reference, specialist depth or revision.
A beginner who wants to write and debug constrained-random stimulus needs these twelve lessons, in this order. Each is labelled Required in its topic table.
Basics, then operators: you cannot write a useful constraint without both.
Dynamic control and array sizes: every real test freezes a field or randomizes a payload.
The failure taxonomy and contradiction finding, so a failed randomize() does not stop you.
How the Constraint Solver Works: senior depth, for when a result surprises you.
Random Stability and Seeding, once a regression result flips for no visible reason.
Interview Drills: revision practice, best after the first pass and the next parts.
pkt.randomize() without checking the result, and one call fails. What does the design receive?The previous packet again. A failed call returns 0 and changes nothing, so an unchecked call sends stale stimulus with no error anywhere.
Icarus 13 has no constraint support, so every runnable listing in this part runs on Verilator 5.048. Where Verilator's answer differs from the standard, the lesson says so; What the Open Simulators Run has the full list.
Five questions cover this part. Each answer names the lesson that teaches it.
t.randomize() and the call returns 0. What do the rand fields hold, and what must the test do?They keep their previous values, because a failed solve commits nothing. The test must check the return value and stop or report. Taught in The randomize() Call.
x dist { [1:5] :/ 10, 9 := 50 }: how often is x equal to 9?50 out of 60, about 83%. With :/ the range shares its weight of 10, so the total is 60. Taught in dist: Weighted Distributions.
small_mode is 0, what does small_mode -> len <= 8 say about len?Nothing. The rule only bites when small_mode is 1; the other arm stays fully open. Taught in Implication, if/else and solve...before.
A bound on data.size() and a foreach rule keeping each byte in [8'h20:8'h7E]. Taught in Constraining Array Size and foreach Constraints.
rand_mode(0) on the field, restored afterwards, and an inline randomize() with { ... } for the single call. Taught in rand_mode(): Freezing Fields and Inline Constraints.