Part 4 · Assertions (SVA) · Intermediate
Sampled Value Functions
Hub — $rose/$fell/$stable/$changed, $past with gating, counting functions, sampling edge cases, explicit clocking arguments, and building data-integrity checks.
Overview
Assertions never see your signals live. At every clocking event the simulator takes a snapshot of each expression in the Preponed region — the instant just before the edge, before any flip-flop updates — and the assertion evaluates against those snapshots. The sampled value functions are the tools that reason about that snapshot history: $rose and $fell detect edges between consecutive samples, $stable and $changed compare a full vector against its previous sample, $past reaches N samples back, and the counting functions ($countones, $onehot, $isunknown) classify a single sampled vector.
This topic is disproportionately interview-heavy because it is where most real SVA confusion lives. Candidates who can explain why an assertion fired one cycle later than the waveform seems to show, or what $past returns on cycle 1, or why $rose on a multi-bit bus only watches the LSB, demonstrate that they understand the sampling model rather than just the syntax. Every sub-lesson below pairs the semantics with cycle-by-cycle waveforms so you can replay the evaluation by hand.
Sub-topics
$rose, $fell, $stable, $changed — edge detection on sampled values, the LSB rule, X-transition table.
$past: Looking Backward — N-cycle history, the gating argument, first-cycle defaults, registered-output checks.
$countones, $onehot, $onehot0, $isunknown — vector classification, X handling, one-hot FSM and arbiter checks.
Sampled-Value Edge Cases — sampled vs procedural value mismatch, $sampled, glitch invisibility.
Sampled Functions with Clock & Gating Arguments — explicit clocking events, gated $past, valid-qualified pipelines.
Building Data-Integrity Checks — combining $past/$stable into FIFO, readback, and phase-matching checks.
SAMPLED VALUE FUNCTIONS — TOPIC MAP
Preponed-region snapshot stream
clk tick: 1 2 3 4 5
samples: s1 ──► s2 ──► s3 ──► s4 ──► s5
│ │ │ │ │
┌──────────────┴──────┴──────┴──────┴──────┴─────────────┐
│ │
▼ ▼ ▼
COMPARE TWO SAMPLES REACH N BACK CLASSIFY ONE SAMPLE
┌──────────────────┐ ┌──────────────────────┐ ┌──────────────────────┐
│ $rose (LSB →1) │ │ $past(e) = s-1 │ │ $countones(v) │
│ $fell (LSB →0) │ │ $past(e, N) = s-N │ │ $onehot(v) │
│ $stable (vector) │ │ $past(e,N,gd) gated │ │ $onehot0(v) │
│ $changed(vector) │ └──────────────────────┘ │ $isunknown(v) │
└──────────────────┘ └──────────────────────┘
│ │ │
└──────────────┬───────────┴─────────────────────────────┘
▼
building blocks for data-integrity checks:
dout == $past(din, LATENCY), stable-while-busy,
one-hot grants, X-free payloads, readback consistencyKey takeaways
All sampled value functions operate on Preponed-region snapshots — never on live procedural values.
$rose/$fell watch only the LSB of a multi-bit expression; $stable/$changed compare the whole vector.
$past has well-defined but dangerous start-up behavior — guard the first N cycles.
These functions are the raw material of every practical protocol and data-integrity assertion.