Question bank · Design Verification Engineer
Design Verification interview questions
The 100 questions verification interviewers really ask, picked from recent interview reports at chip product companies and verification-service firms. Test planning, SystemVerilog and OOP traps, constraint writing, assertions from waveforms, coverage, UVM internals and bus protocols, each with a worked answer, working code, the likely follow-up and diagrams where they help.
How Design Verification interviews actually run
From recent interview reports at product companies and design-service firms in India and abroad. Rounds vary by company; this is the common shape.
- Online testCommon at service companies and campus drives. Digital electronics MCQs, Verilog and SystemVerilog output-prediction questions, aptitude, and sometimes C programming.
- Technical round 1SystemVerilog: OOP (polymorphism, virtual methods, deep copy), fork/join, mailbox and semaphore, data types. Expect 'what does this print' and 'write a constraint for...' on the spot.
- Technical round 2UVM: phases, factory, config_db, sequence/driver handshake, TLM, objections, RAL. Write assertions from a waveform, write a covergroup, and build a test plan for a FIFO, ALU or arbiter.
- Protocols and digital basicsAPB and AXI handshakes and bursts, I2C, SPI or UART at the level of the projects on your résumé. Digital design basics still come up: setup/hold, FIFO depth, CDC.
- CodingSome product companies add a C, C++ or Python round: linked lists, bit manipulation, string parsing. A few ask you to write a UVM sequence and driver live in a few minutes.
- Project deep dive and managersWalk through your testbench, the bugs you found and how you closed coverage. Then team-fit, deadlines and how you work with designers.
- Be able to write, without notes, a UVM driver loop, a sequence body, a covergroup with crosses, and five common SVA properties.
- Practise constraints until you can write one-hot, unique, sorted, sum-of-array and 'no two consecutive equal' in under a minute each.
- Have one test plan you can talk through end to end: features, stimulus, checkers, coverage, sign-off.
- Know the protocols on your résumé deeply, especially the handshake rules and corner cases.
Verification fundamentals and test planning
1What is the difference between directed testing and constrained-random verification? When do you use each?
Directed tests drive a specific, hand-written scenario and check a known result. They are quick to write for simple features and are the best way to hit one exact corner case (for example, write when the FIFO is exactly full).
Constrained-random testing generates many legal scenarios automatically from constraints, with self-checking (a scoreboard or assertions) and functional coverage to measure what was actually exercised. It finds bugs nobody thought of, which is why it is the default for complex blocks.
In practice you use both: constrained random for the bulk, and directed tests (or tightly constrained random tests) to close the coverage holes that random stimulus struggles to reach.
2What are the main components of a verification testbench, and what does each do?
- Generator / sequence: creates transactions (stimulus), usually randomised.
- Driver: converts transactions into pin-level activity on the DUT interface, following the protocol.
- Monitor: watches the pins passively and rebuilds transactions from them. It never drives.
- Scoreboard / checker: compares what the DUT did against expected results from a reference model.
- Coverage collector: records which scenarios and values were seen.
- Environment / test: builds and connects everything and chooses which stimulus to run.
The key idea interviewers want: the driver and the monitor are separate, so checking is based on what really happened on the pins, not on what the driver intended.
3How do you verify a 32-bit, two-input ALU? You cannot simulate every input combination.
Exhaustive simulation needs 2^64 combinations per operation, which would take far longer than the age of the universe. So:
- Plan by feature: each opcode, flags (carry, overflow, zero, negative), signed vs unsigned behaviour.
- Constrained-random stimulus with weights toward interesting values: 0, 1, all ones, max positive
0x7FFFFFFF, min negative0x80000000, values that carry across byte and word boundaries, equal operands. - A reference model (SystemVerilog function, or C through DPI) and a scoreboard comparing every result.
- Coverage: opcode × operand class (zero, max, min, random) crosses, flag values per opcode, back-to-back opcode transitions.
- Directed tests for any coverage holes, and formal equivalence or property checks on operations that are easy to specify (formal can effectively cover all 2^64 inputs).
- Check reset behaviour and pipeline effects if the ALU is pipelined.
4Write a test plan for a synchronous FIFO.
Features to verify
- Write and read in order, data integrity.
fullandemptyflags, andalmost_full/almost_emptythresholds if present.- Overflow and underflow protection (writes when full and reads when empty are ignored or flagged).
- Simultaneous read and write at empty, full and in between.
- Reset in the middle of traffic.
Stimulus: random mixes of read and write with varying rates, bursts that fill and drain completely, many pointer wrap-arounds.
Checking: a scoreboard using a SystemVerilog queue as a reference model; assertions such as full |-> !(wr_en && accepted), !(full && empty), count never above depth.
Coverage: fill level bins (0, 1, mid, depth−1, depth), read/write combinations crossed with fill level, flag transitions.
Sign-off: all tests pass on many seeds, 100% functional coverage, code coverage reviewed with waivers explained.
5What are the different types of code coverage? Does 100% code coverage mean the design is verified?
- Line (statement): every line executed.
- Branch: every
if/casebranch taken. - Condition / expression: every sub-condition of a boolean expression evaluated both true and false.
- Toggle: every bit went 0→1 and 1→0.
- FSM: every state and every transition visited.
100% code coverage does not mean the design is verified. It only says the code was executed, not that the results were checked, and it says nothing about features that are missing from the RTL (a feature that was never coded has no lines to miss). That is why functional coverage, written from the spec, and self-checking are needed as well.
6What is the difference between code coverage and functional coverage?
| Code coverage | Functional coverage | |
|---|---|---|
| Source | Generated automatically from the RTL | Written by the verification engineer from the spec |
| Answers | Was this code exercised? | Was this feature or scenario exercised? |
| Can find missing features | No | Yes, if the plan lists them |
| Effort | Free to collect, needs review | Must be designed and maintained |
You need both. Code coverage finds dead code and untested branches; functional coverage proves the scenarios in the verification plan really happened.
7What is a scoreboard? How do you handle a DUT that returns results out of order?
A scoreboard receives the expected transactions (from a reference model fed by the input monitor) and the actual transactions (from the output monitor), and compares them.
- In-order DUT: keep a queue of expected items; pop the front for each actual item and compare.
- Out-of-order DUT: match by a key, usually the transaction ID or address. Store expected items in an associative array indexed by ID (with a queue per ID if one ID can have several outstanding transactions) and look up each actual item by its ID.
At the end of the test, check that nothing is left in the expected storage. A leftover item means the DUT dropped a transaction, which is a bug that a compare-only scoreboard would miss.
8Why do we run gate-level simulation if RTL simulation and STA have passed?
Gate-level simulation (GLS) catches problems that RTL simulation and STA do not see:
- Reset and initialisation: flops without reset that come up as X, X-propagation that RTL simulation hid.
- Synthesis issues: simulation–synthesis mismatches, wrong
full_case, logic optimised away. - Timing exceptions: with SDF back-annotation, it checks that false paths and multicycle paths are really safe, and it exercises asynchronous paths and CDC synchronizers with real delays.
- DFT insertion: scan chains and test modes work, and functional mode is not broken.
- Power-up sequences and power-aware behaviour with the real netlist.
GLS is slow, so teams run a small set of reset, boot and key-scenario tests on it.
9What is formal verification? How is it different from simulation?
Simulation checks the design for the stimulus you give it. Formal verification uses mathematical solvers to prove that a property holds for all possible input sequences (up to a depth for bounded proofs), or to find a counterexample.
Main uses:
- Formal property verification: prove SVA assertions on a block (arbiters, FIFOs, protocol compliance).
- Equivalence checking (LEC): prove that RTL and the synthesised netlist are logically equivalent.
- Apps: connectivity checks, X-propagation, register access, unreachable code.
Formal is complete for what it proves but struggles with very large state spaces (deep datapaths, large memories), so it is used on control-heavy blocks alongside simulation.
10A test fails on one random seed but passes on others. How do you debug it?
- Reproduce with the same seed and the same build (the seed must be printed in the log for this to be possible).
- Find the first error message and its simulation time. Later errors are often consequences.
- Open waveforms around that time. Check the transaction the scoreboard complained about: what was sent, what the reference model expected, what the DUT produced.
- Decide whether it is a DUT bug, a testbench bug, or a spec ambiguity. Check the stimulus was legal under the protocol.
- Raise verbosity for the relevant components, or add a temporary assertion closer to the cause.
- Once understood, write a directed or constrained test that reproduces it reliably, so the fix can be checked and the scenario stays in regression.
Interviewers like to hear that you suspect your own testbench as readily as the RTL.
11What is the difference between verification, validation and testing in the chip industry?
- Verification (pre-silicon): proving the RTL matches the specification, by simulation, formal methods and emulation, before tape-out.
- Validation (post-silicon): checking the real chip works in a real system: software, boards, corner conditions, other chips.
- Manufacturing test (DFT/ATE): checking each manufactured die is free of fabrication defects, using scan patterns and BIST on testers.
A design-verification role is the first one. Mixing them up is a common fresher mistake.
12When is a block “verified”? What are typical sign-off criteria?
Verification is never complete in a mathematical sense, so teams agree on measurable criteria up front:
- Every item in the verification plan has a test, a checker and coverage linked to it.
- Functional coverage at 100%, or every hole reviewed and waived with a reason.
- Code coverage (line, branch, condition, toggle, FSM) reviewed, with exclusions documented.
- Regression passing across many seeds, with a stable or falling bug-discovery rate over the last weeks.
- All assertions enabled, with no failures and their cover properties hit.
- No open high-severity bugs; lower ones reviewed.
- Gate-level and power-aware simulation run on the agreed tests, if part of the flow.
Mentioning the bug discovery rate trend is a sign of real project experience.
13What is emulation, and why do teams use it as well as simulation?
An emulator (Cadence Palladium, Synopsys ZeBu, Siemens Veloce) maps the RTL onto special hardware so it runs thousands to millions of times faster than a software simulator. FPGA prototypes go faster still but take longer to bring up and are harder to debug.
Uses: booting an operating system, running real software and firmware, long scenarios (video frames, network traffic), and power analysis with real workloads, all before silicon exists. Simulation keeps the advantages of full visibility, fast compile and constrained-random testbenches, so the two are complementary.
SystemVerilog and OOP
14What does this print, and how do you fix it so it prints 0, 1, 2?
initial begin
for (int i = 0; i < 3; i++)
fork
$display("i = %0d", i);
join_none
end
It prints i = 3 three times. join_none lets the loop finish before any forked thread runs, and all three threads refer to the same loop variable i, which is 3 by then.
Fix: give each thread its own copy with an automatic variable declared inside the fork:
for (int i = 0; i < 3; i++)
fork
automatic int j = i;
$display("i = %0d", j);
join_none
This is one of the most frequently reported SystemVerilog interview questions.
15Explain fork-join, fork-join_any and fork-join_none. How do you stop the remaining threads?
fork ... join: the parent waits until all child threads finish.fork ... join_any: the parent continues as soon as any one child finishes; the others keep running.fork ... join_none: the parent continues immediately; children start when the parent blocks or finishes its current time step.
disable fork kills all child threads of the current process (careful: it kills all of them, not only the ones in the last fork, so wrap it in its own fork ... join if needed). wait fork waits for all child threads to finish.
A common pattern is a timeout: fork wait_for_response(); #1us; join_any disable fork;.
16What is polymorphism? Show it with a virtual method.
Polymorphism lets a base-class handle call the method of the actual object’s class at run time. It needs the method to be virtual.
class packet;
virtual function void show(); $display("packet"); endfunction
endclass
class bad_packet extends packet;
function void show(); $display("bad_packet"); endfunction
endclass
packet p; bad_packet b = new();
p = b; // base handle, derived object
p.show(); // prints "bad_packet" because show() is virtual
Without virtual, p.show() prints “packet”, because the call is chosen by the handle type at compile time. UVM relies on this everywhere: the factory hands you a derived object through a base handle, and your overridden methods run.
17What is the difference between a shallow copy and a deep copy?
class header; int id; endclass
class packet; int len; header h = new(); endclass
packet p1 = new();
packet p2 = new p1; // shallow copy
A shallow copy (new p1) copies the properties of p1, but for an object handle it copies only the handle. p1.h and p2.h point to the same header, so changing p2.h.id also changes p1.h.id.
A deep copy also creates new copies of the contained objects. You write it yourself (a copy() function that calls new for each member object and copies it), or in UVM implement do_copy() and call copy()/clone().
Also note: p2 = p1; copies no object at all; both handles point to the same packet.
18What is the difference between a virtual interface and an interface, and why do class-based testbenches need one?
An interface is a static, module-like bundle of signals that is instantiated in the hardware hierarchy and connected to the DUT.
Classes are dynamic: they are created at run time and cannot contain a static instance of an interface. A virtual interface is a handle (a pointer) to an interface instance. The top module creates the interface, passes it into the class world (in UVM, with uvm_config_db#(virtual my_if)::set), and the driver and monitor drive and sample signals through vif.signal.
This keeps the testbench classes reusable: the same driver can be pointed at any instance of the interface.
19What is a clocking block, and what problem does it solve?
A clocking block groups signals that are sampled and driven on a clock, with explicit input and output skews.
clocking cb @(posedge clk);
default input #1step output #2;
output req, data;
input ack;
endclocking
Inputs are sampled just before the clock edge (#1step, the value from the end of the previous time step), and outputs are driven a little after the edge. That removes the race between the testbench and the DUT on the same edge, which otherwise depends on the scheduler order. Drive with vif.cb.req <= 1; and wait with @(vif.cb);.
20Compare dynamic arrays, associative arrays and queues. When would you use each?
| Type | Size | Indexing | Good for |
|---|---|---|---|
Dynamic array int d[] |
Set at run time with new[n], then fixed until resized |
0 to n−1 | Payloads whose length is randomised |
Associative array int a[int] |
Grows as you write; stores only used entries | Any key (int, string, class handle) | Sparse memory models, lookup by ID or address |
Queue int q[$] |
Grows and shrinks at both ends | 0 to size−1 | FIFOs, scoreboards, expected-item lists |
A memory model for a 4 GB address space is the classic example for an associative array: you only store the addresses actually written.
21What are mailboxes and semaphores used for in SystemVerilog?
- A mailbox is a thread-safe FIFO for passing data (usually transaction handles) between processes.
put()blocks when a bounded mailbox is full;get()blocks when empty;try_get()andtry_put()do not block. Typical use: generator to driver in a non-UVM testbench. - A semaphore is a bucket of keys for mutual exclusion.
get(n)blocks until n keys are available,put(n)returns them. Typical use: two threads sharing one bus or one resource in a testbench. - An event is a synchronisation flag:
-> evtriggers it,@evorwait(ev.triggered)waits for it.wait(ev.triggered)avoids a race when the trigger and the wait happen in the same time step.
22What is the difference between bit and logic, and why can 2-state types hide bugs?
logic is a 4-state type (0, 1, X, Z). bit is 2-state (0, 1): any X or Z assigned to it becomes 0.
2-state types simulate faster and use less memory, so they are good for testbench variables and class properties. But if you sample a DUT output into a bit, an X caused by a missing reset becomes a quiet 0, and the bug disappears from your checks. Always sample DUT signals into 4-state types, and check for unknowns with $isunknown().
23What are static, local and protected members, and when is static useful in a testbench?
- A static property is shared by all objects of the class, and a static method can be called without an object (
packet::count). Typical use: a counter of packets created, giving each a unique ID, or a shared configuration. - local members are visible only inside the class itself, not in derived classes.
- protected members are visible in the class and its derived classes, but not from outside.
Also note: methods declared inside a class are automatic by default, while tasks and functions in modules are static by default, which matters when they are called from several threads at once.
24What is the difference between $cast and a direct assignment between class handles?
Assigning a derived-class handle to a base-class handle (upcast) is always legal: base_h = derived_h;.
Going the other way (downcast) is legal only if the object really is of the derived type, so it must be checked at run time with $cast:
if (!$cast(derived_h, base_h))
`uvm_fatal("CAST", "object is not a derived_pkt")
This is common in UVM: clone() returns a uvm_object handle, and you $cast it back to your transaction type before using its fields.
25What is an abstract class (virtual class) and a pure virtual method?
A virtual class cannot be instantiated with new; it exists to be extended. A pure virtual method has only a prototype in the base class and must be implemented by every non-abstract derived class.
virtual class shape;
pure virtual function real area();
endclass
class circle extends shape;
real r;
function real area(); return 3.14159 * r * r; endfunction
endclass
This forces a common API. UVM uses the same idea for base classes whose methods you are expected to override.
26Why are ref arguments used, and what does const ref add?
By default task and function arguments are passed by value (copied). With ref, the argument is passed by reference: no copy is made, and changes inside the subroutine are visible to the caller immediately, even while a task is still running.
Use it for large arrays (avoid copying) and for tasks that must see a variable change over time. const ref gives the speed of no copy while preventing the subroutine from modifying the argument. ref arguments need an automatic subroutine.
27What is the difference between a program block and a module, and do you still need program blocks?
A program block was added to separate testbench code from design code: its statements run in the reactive region, after the design has settled in the current time step, which avoids races between testbench and DUT. It cannot contain always blocks or instantiate modules.
In modern UVM testbenches, program blocks are rarely used. Clocking blocks and non-blocking drives already remove the race, and UVM itself runs from a module (initial run_test();). Knowing why they existed is still a common interview question.
28Explain the SystemVerilog event scheduler regions in simple terms.
Each simulation time step is processed in ordered regions. The main ones:
- Preponed: values are sampled for assertions and
#1stepclocking-block inputs. - Active: blocking assignments, continuous assignments,
$display, evaluation of non-blocking right-hand sides. - Inactive:
#0delayed statements. - NBA: non-blocking assignments update their left-hand sides. This can trigger more Active events.
- Observed: concurrent assertions are evaluated with the values sampled in Preponed.
- Reactive: program blocks and assertion action blocks run.
- Postponed:
$strobeand$monitorprint final values for the time step.
This ordering is why assertions see stable values, why $display and $strobe can print different values, and why the testbench does not race the design when written properly.
29How do you call C code from SystemVerilog, and why would you?
Use the Direct Programming Interface (DPI-C):
import "DPI-C" function int ref_crc(input int data, input int len);
The C function is compiled into a shared library and linked with the simulator. export "DPI-C" lets C call SystemVerilog tasks and functions.
Typical uses: reusing a C or C++ reference model from the architecture team (codecs, crypto, DSP), golden checkers, or talking to external software. Keep argument types simple (int, bit vectors, open arrays) and remember that a C function cannot consume simulation time unless it calls an exported task.
30What is the difference between a struct and a class in SystemVerilog?
| struct | class | |
|---|---|---|
| Storage | A value, stored where it is declared | An object on the heap, accessed through a handle |
| Assignment | Copies the data | Copies the handle only |
| Methods, inheritance, polymorphism | No | Yes |
| Randomisation | Only as a member of a class | rand properties and constraints |
| Synthesisable | Packed structs, yes | No |
Use structs for grouping signals (packed structs on ports), and classes for transactions and testbench components.
31What is a parameterised class, and where does UVM use them?
A class can take type or value parameters, like a module:
class fifo_model #(type T = int, int DEPTH = 16);
T q[$];
function bit push(T item); if (q.size() == DEPTH) return 0; q.push_back(item); return 1; endfunction
endclass
fifo_model #(my_pkt, 64) m = new();
UVM uses them all over: uvm_sequencer #(my_item), uvm_driver #(my_item), uvm_analysis_port #(my_item), uvm_config_db #(virtual my_if). Each specialisation is a separate type, so fifo_model#(int) and fifo_model#(byte) are not assignment-compatible.
Constraints and randomization
32Write a constraint so that only one bit of an 8-bit opcode is set (one-hot).
class instr;
rand bit [7:0] opcode;
constraint c_onehot { $countones(opcode) == 1; }
endclass
Other accepted answers: opcode inside {8'h01, 8'h02, 8'h04, ...}, or opcode != 0 && (opcode & (opcode - 1)) == 0.
Variants interviewers ask next: at most one bit set ($countones(opcode) <= 1), exactly three bits set, or no two adjacent bits set ((opcode & (opcode << 1)) == 0).
Likely follow-up: Now create a square 2D array whose size equals the index of the set bit (bit 4 set gives a 4×4 array).
Declare rand int arr[][] and constrain the sizes with an implication per bit: foreach (opcode[i]) opcode[i] -> arr.size() == i; and foreach (arr[j]) arr[j].size() == arr.size();. Size constraints on dynamic arrays are solved first, then the elements.
33Generate an array of 10 unique random values between 0 and 99.
class c;
rand int unsigned a[10];
constraint c_range { foreach (a[i]) a[i] < 100; }
constraint c_unique { unique {a}; }
endclass
Without the unique keyword (a common follow-up): foreach (a[i]) foreach (a[j]) if (i != j) a[i] != a[j];, or fill a queue with 0 to 99, shuffle() it and take the first 10. A randc variable also gives non-repeating values across successive randomize() calls of a single variable.
34Write constraints for a sorted array, an array with no two consecutive equal elements, and an array whose elements sum to 100.
rand int unsigned a[8];
constraint c_sorted { foreach (a[i]) if (i > 0) a[i] > a[i-1]; } // strictly ascending
constraint c_noadj { foreach (a[i]) if (i > 0) a[i] != a[i-1]; }
constraint c_sum { a.sum() with (int'(item)) == 100;
foreach (a[i]) a[i] <= 100; }
Two traps in the sum: sum() is computed in the element’s width, so with small element types (for example bit [3:0]) it overflows and the solver finds “wrong” solutions. Cast with with (int'(item)). With unsigned elements, also bound each element, otherwise wrap-around can make a sum of huge numbers equal 100 modulo 2^32.
35What is the difference between rand and randc?
rand picks each value independently (with a uniform distribution over the legal values), so values can repeat on the next call.
randc is random-cyclic: it goes through every legal value in a random order before repeating any. A 2-bit randc gives a permutation of 0, 1, 2, 3, then a new permutation.
randc is useful for covering every value of a small field quickly, such as opcodes or IDs. It is costly for wide fields because the solver tracks the cycle, so tools limit its width.
36What is the difference between dist with := and :/?
constraint c1 { x dist { 0 := 40, [1:3] := 60 }; }
constraint c2 { y dist { 0 :/ 40, [1:3] :/ 60 }; }
:=gives the weight to each value in a range. Inc1, value 0 has weight 40 and 1, 2, 3 each have 60, so the total is 220 and 0 is chosen 40/220 ≈ 18% of the time.:/divides the weight across the range. Inc2, 0 has weight 40 and 1, 2, 3 share 60 (20 each), so 0 is chosen 40% of the time.
dist is a soft preference on probability, not a hard rule; the value set is still a hard constraint.
37What does solve ... before do? Show when it matters.
By default the solver picks uniformly from all legal combinations of the random variables. Implications can make that very lopsided.
rand bit is_small;
rand bit [7:0] len;
constraint c { is_small -> len < 4; }
Legal combinations: 4 with is_small = 1, 256 with is_small = 0. So is_small is 1 only about 1.5% of the time.
Adding solve is_small before len; makes the solver choose is_small first (50/50), then len. It changes the distribution, not which values are legal. It cannot be used with randc variables.
38What are soft constraints and inline constraints? How do you turn constraints off?
- A soft constraint (
constraint c { soft len inside {[1:64]}; }) is a default that gives way if a stronger constraint conflicts, instead of causing a randomisation failure. It is how base sequences provide defaults that tests can override. - An inline constraint adds extra rules for one call:
assert(pkt.randomize() with { len == 8; }); pkt.c_len.constraint_mode(0);turns off one constraint block;pkt.len.rand_mode(0);stops one variable from being randomised (it keeps its current value).
Always check the return value of randomize(). If it fails, the variables keep their old values and the test silently continues with stale data.
39How do you randomize a variable that is not a class member, or only some members of a class?
std::randomize(x) with { x inside {[10:20]}; };randomizes local or module variables without a class.obj.randomize(len, addr);randomizes only the listed members; the otherrandmembers are treated as state (kept at their current values) for this call.obj.randomize(null)randomizes nothing but checks whether the current values satisfy all constraints, which is a handy check.
40What are pre_randomize() and post_randomize() used for?
They are callbacks that run automatically around randomize().
pre_randomize()runs before solving: set up state variables the constraints depend on, or switch constraint modes based on configuration.post_randomize()runs after a successful solve: compute derived fields that are hard to express as constraints, such as a CRC, parity or checksum over the randomized payload.
They are not called if randomization fails, and if you override them in a derived class, call super.pre_randomize() so base-class setup still runs.
41Constrain an AXI burst so it does not cross a 4 KB address boundary.
For an INCR burst, the bytes touched run from addr to addr + (len + 1) * (1 << size) − 1. They must all be in the same 4 KB page.
class axi_txn;
rand bit [31:0] addr;
rand bit [7:0] len; // beats - 1
rand bit [2:0] size; // bytes per beat = 2**size
constraint c_size { size <= 2; } // up to 4 bytes per beat for a 32-bit bus
constraint c_align { addr % (1 << size) == 0; } // aligned start
constraint c_4k { (addr % 4096) + ((len + 1) << size) <= 4096; }
endclass
Watch the arithmetic width: (len + 1) << size must not overflow in the expression width. Here everything is promoted to 32 bits because addr is 32 bits, so it is safe.
42Write a constraint that picks a prime number between 2 and 100.
Primality is hard to express directly as a constraint, and a function called inside a constraint is evaluated with the variable already chosen, so it cannot steer the solver. Compute the legal set first and constrain the variable to be inside it:
class prime_gen;
int primes[$];
rand int p;
function void pre_randomize();
primes.delete();
for (int n = 2; n <= 100; n++) begin
bit ok = 1;
for (int d = 2; d * d <= n; d++) if (n % d == 0) ok = 0;
if (ok) primes.push_back(n);
end
endfunction
constraint c { p inside {primes}; }
endclass
The same “precompute then inside” pattern works for any set that is easy to compute but awkward to constrain.
43Why might randomize() fail? How do you debug it?
It fails when the constraints are contradictory for the current state: for example an inline with { len == 100; } against a class constraint len < 64, or a constraint that depends on a non-random variable whose value makes it unsatisfiable.
Debug steps:
- Always check the return value (
if (!obj.randomize())uvm_error(…)`). - Most simulators print the conflicting constraints on failure; read the solver report.
- Turn constraint blocks off one at a time with
constraint_mode(0)to find the conflict. - Check state variables (non-rand members) used in the constraints.
- Prefer soft constraints for defaults so tests can override them without conflicts.
44How do you make randomization reproducible, and why does random stability matter?
A simulation run is reproducible when it is given the same seed (for example +ntb_random_seed=1234 or -sv_seed 1234, depending on the simulator) and the same code. Print the seed in every log.
Random stability means each thread and each object has its own random number generator, seeded from its parent. Adding a new random call in one component does not change the random values in unrelated components. That is what lets you reproduce a failure even after small testbench changes, and why you should create objects in a deterministic order (for example in build_phase) rather than from timing-dependent code.
45Generate a random 32-bit address that is 4-byte aligned and falls in one of two allowed regions.
class addr_gen;
rand bit [31:0] addr;
constraint c_align { addr[1:0] == 2'b00; }
constraint c_region { addr inside {[32'h0000_1000 : 32'h0000_1FFF],
[32'h8000_0000 : 32'h8000_FFFF]}; }
endclass
A common follow-up is to make one region more likely: replace inside with dist { [32'h0000_1000:32'h0000_1FFF] :/ 70, [32'h8000_0000:32'h8000_FFFF] :/ 30 }, keeping the alignment constraint as it is.
Assertions (SVA)
46What is the difference between |-> and |=>?
Both are implications: if the antecedent (left side) matches, the consequent (right side) must hold.
a |-> bis overlapping:bis checked in the same clock cycle whereamatched.a |=> bis non-overlapping:bis checked in the next clock cycle. It is the same asa |-> ##1 b.
If the antecedent does not match, the property passes vacuously, which is why an assertion can “pass” forever without ever checking anything. Pair important assertions with a cover property on the antecedent to prove it actually happened.
47Write an assertion that every request gets an acknowledge within 1 to 3 cycles.
property p_req_ack;
@(posedge clk) disable iff (!rst_n)
$rose(req) |-> ##[1:3] ack;
endproperty
a_req_ack: assert property (p_req_ack)
else `uvm_error("SVA", "ack did not arrive within 3 cycles of req")
$rose(req) makes it trigger once per request instead of on every cycle req stays high. disable iff turns the check off during reset.
Follow-ups: “and req must stay high until ack” → $rose(req) |-> req [*1:$] ##0 ack (or req until_with ack as a separate property), and “ack must not come without a request” → $rose(ack) |-> $past(req).
48Write an assertion that data must stay stable while valid is high and ready is low.
This is the core rule of a valid/ready (AXI-style) interface:
a_stable: assert property (@(posedge clk) disable iff (!rst_n)
valid && !ready |=> valid && $stable(data));
If the transfer did not happen this cycle (valid high, ready low), then next cycle valid must still be high and data unchanged. The non-overlapping |=> is what makes it compare across the two cycles.
49What do $rose, $fell, $stable and $past do?
They compare a signal’s sampled value now with its sampled value at the previous clock tick of the assertion’s clock:
$rose(s): was 0 (or X), now 1.$fell(s): was 1, now 0.$stable(s): unchanged.$changed(s): changed.$past(s, n): the value n clock ticks ago (default 1).
Example: wr_en |=> mem_count == $past(mem_count) + 1 checks that a write increments the count.
50What is the difference between the repetition operators [*n], [->n] and [=n]?
b[*3](consecutive):bis true on 3 consecutive cycles.b[->3](goto):bis true 3 times, not necessarily consecutive, and the sequence ends on the 3rd occurrence.b[=3](non-consecutive):bis true 3 times, not necessarily consecutive, and the sequence may continue for cycles after the 3rd occurrence wherebis false.
Example: start |-> data_valid[->4] ##1 done means done arrives exactly one cycle after the 4th valid beat. With [=4] instead, done may arrive any number of cycles after the 4th beat (as long as no 5th valid occurs).
51Write an assertion from this description: after start, busy must stay high for exactly 4 cycles and then done must pulse.
a_seq: assert property (@(posedge clk) disable iff (!rst_n)
$rose(start) |=> busy[*4] ##1 (done && !busy) ##1 !done);
Reading it: from the cycle after start rises, busy is high for 4 consecutive cycles; on the next cycle busy has dropped and done is high; and the cycle after, done is low again (a one-cycle pulse).
In interviews, draw the waveform first and number the cycles; then translate each cycle into the sequence. Interviewers care more about this method than the exact operators.
52What is the difference between immediate and concurrent assertions?
- An immediate assertion (
assert (expr) else ...;) is a procedural statement checked once, when that line executes, like anif. It has no clock. Use it in tasks, functions and class code, for example to checkrandomize()succeeded. - A concurrent assertion (
assert property (...)) is clocked and evaluated continuously on every clock tick. Its signals are sampled in the Preponed region, so it sees stable values, and it can describe behaviour across many cycles. It can be placed in modules, interfaces and programs, or connected withbind.
53Why do we use bind for assertions?
bind attaches a module or interface full of assertions to a design module without editing the RTL:
bind fifo fifo_sva #(.DEPTH(DEPTH)) u_sva (.*);
Every instance of fifo gets its own fifo_sva instance, connected to its internal signals. This keeps verification code out of the design files, lets the verification team own the checkers, and lets the same checkers be reused in simulation and formal verification.
54What is the difference between assert, assume and cover properties?
assert property: the design must satisfy this. In simulation it fires an error when violated; in formal it is a goal to prove.assume property: a rule about the inputs from the environment. Formal tools only consider input sequences that satisfy it; in simulation it acts like an assertion on your stimulus.cover property: a scenario you want to see happen. It reports how many times the sequence matched, proving the stimulus reached it.
A wrong assume is dangerous in formal: it can rule out the very input that would expose a bug (over-constraining).
55Write an assertion that the grant output of an arbiter is always one-hot or zero, and that every grant matches a request.
a_onehot: assert property (@(posedge clk) disable iff (!rst_n) $onehot0(gnt));
a_valid: assert property (@(posedge clk) disable iff (!rst_n) (gnt & ~req) == '0);
$onehot0 is true when at most one bit is set; $onehot when exactly one is. The second assertion says no requester gets a grant it did not ask for. A third, for fairness in a round-robin arbiter: a continuously asserted request is granted within N cycles, req[i] |-> ##[0:N-1] gnt[i] (written with a generate loop for each i).
56Write assertions for a FIFO’s flags.
// never write when full, never read when empty (if the design requires it)
a_no_ovf: assert property (@(posedge clk) disable iff (!rst_n) full |-> !wr_en);
a_no_udf: assert property (@(posedge clk) disable iff (!rst_n) empty |-> !rd_en);
// flags can never both be set
a_flags: assert property (@(posedge clk) disable iff (!rst_n) !(full && empty));
// a write with no read on a non-full FIFO clears empty next cycle
a_wr_ne: assert property (@(posedge clk) disable iff (!rst_n)
wr_en && !rd_en && !full |=> !empty);
// count tracks reads and writes
a_count: assert property (@(posedge clk) disable iff (!rst_n)
count == $past(count) + ($past(wr_en && !full) ? 1 : 0)
- ($past(rd_en && !empty) ? 1 : 0));
If the design is supposed to ignore a write when full rather than forbid it, the first two become checks that count does not change on such a write. Say which interpretation you assume; the spec decides.
57How do you check a clock’s period with an assertion?
Use a local variable to capture the time at one edge and compare it at the next:
property p_period(real exp_ns, real tol_ns);
realtime t;
@(posedge clk) (1, t = $realtime) |=> ($realtime - t >= exp_ns - tol_ns &&
$realtime - t <= exp_ns + tol_ns);
endproperty
a_clk100: assert property (p_period(10.0, 0.1));
Make sure the simulation time unit and precision are fine enough for the tolerance. Local variables like t are also how you check data integrity across a pipeline, for example capture data_in when valid_in and compare to data_out N cycles later.
58Why can an assertion pass even when the design is broken, and how do you guard against it?
- Vacuous success: the antecedent never matches, so the implication passes without checking anything. Check the assertion report for “vacuous” counts, and add a
cover propertyon the antecedent. disable iffstuck true: a wrong reset polarity disables the assertion for the whole test.- Wrong clock or sampling: asserting on a gated or wrong clock that rarely ticks.
- The assertion is not bound or not compiled in: check it appears in the assertion summary.
- Over-constrained assumptions in formal hide the failing input.
Good teams review assertion and cover hit counts as part of sign-off, not only the number of failures.
Functional coverage
59Write a covergroup for an ALU with opcode and operand bins, and a cross.
covergroup cg_alu @(posedge clk iff valid);
cp_op : coverpoint op; // one bin per enum value
cp_a : coverpoint a {
bins zero = {0};
bins max = {32'hFFFF_FFFF};
bins low = {[1 : 32'h0000_FFFF]};
bins high = {[32'h0001_0000 : 32'hFFFF_FFFE]};
}
cp_b : coverpoint b { bins zero = {0}; bins nonzero = {[1:$]}; }
x_op_a: cross cp_op, cp_a;
x_div0: cross cp_op, cp_b {
ignore_bins not_div = !binsof(cp_op) intersect {DIV} || binsof(cp_b.nonzero);
}
endcovergroup
Points to mention: bins come from the spec’s interesting classes (not one bin per value of a 32-bit field), iff samples only valid transactions, and the cross with ignore_bins focuses on the one combination that matters (divide by zero). Avoid default bins in coverpoints you want to cross: they are not counted in coverage and cannot be used in crosses.
60What are ignore_bins and illegal_bins?
ignore_bins: values or combinations that are excluded from coverage because they do not matter or cannot happen. They do not count against the coverage percentage.illegal_bins: values that must never occur. If one is sampled, the simulator reports an error. They also don’t count towards coverage.
Use illegal_bins with care: it mixes checking into coverage. Many teams prefer an assertion for illegal conditions and keep coverage purely for measuring progress.
61How do you cover transitions, such as an FSM going IDLE → BUSY → DONE?
Use transition bins:
coverpoint state {
bins start_run = (IDLE => BUSY);
bins full_cycle = (IDLE => BUSY => DONE => IDLE);
bins long_busy = (BUSY [*4:8]); // stayed busy 4 to 8 samples
bins back2back = (DONE => BUSY);
illegal_bins bad = (IDLE => DONE);
}
Transitions are sampled at each sampling event of the covergroup, so if you sample on every clock the [*4:8] counts clocks; if you sample per transaction it counts transactions.
62How does a covergroup get sampled? What is the difference between a clocking event and calling sample()?
- With a clocking event in the declaration (
covergroup cg @(posedge clk);), it samples automatically on every event. Simple, but it samples junk on idle cycles unless you addiff (valid). - With no event, you call
cg.sample()yourself, usually in a monitor or subscriber’swrite()method when a complete transaction arrives. This is the normal UVM style because transactions, not clocks, define what is interesting.
You can also define sample() with arguments (covergroup cg with function sample(my_item t);) to cover fields of an object passed in.
63Coverage is stuck at 92%. What do you do?
- Look at the holes: which bins and crosses are missing. Group them by cause.
- Check whether each hole is real: is the bin even reachable with this configuration? Unreachable bins should be excluded with a reviewed waiver, not hidden.
- For reachable holes, check the constraints: they may make the scenario unlikely or impossible (for example a
solve beforeproblem or a weight of zero). - Bias the stimulus: add a test or sequence with tighter constraints aimed at the hole, or a directed test.
- Check the coverage model itself: wrong bin boundaries or sampling at the wrong time can make bins impossible.
- For code coverage holes, talk to the designer: the code may be dead, or it may be a feature nobody tested.
Interviewers want to hear that closing coverage is analysis first, not running more seeds.
64What is the difference between a cover property and a covergroup?
cover propertychecks that a temporal sequence happened (for example, a write burst followed by a read to the same address within 10 cycles). It is good for protocol scenarios and is understood by formal tools.- A covergroup counts values and combinations of variables at sampling points (opcode × size × address region). It is good for data-oriented coverage and crosses.
Use cover properties for “did this sequence of events happen?” and covergroups for “did we see all these values together?”.
65How do you decide what goes into the coverage model?
Start from the verification plan, which comes from the specification:
- Every feature and configuration mode (from the spec and register map).
- Boundary values: minimum, maximum, zero, one below and above limits (FIFO depth, burst length, address boundaries).
- Interactions: crosses of features that can happen together (read during write, error during a burst, reset during traffic).
- Sequences: back-to-back transactions, transitions between modes.
- Error and corner cases: illegal inputs, timeouts, retries.
Avoid crossing everything with everything. Each cross should exist because a bug could hide in that combination. Review the plan with designers and architects.
66What do the covergroup options at_least, auto_bin_max and per_instance do?
option.at_least = 5;a bin counts as covered only after 5 hits (default 1). Useful when one hit is not convincing.option.auto_bin_max = 16;limits how many automatic bins are created when you do not define bins (default 64). Without it, a 32-bit coverpoint would be split into 64 wide ranges that are rarely meaningful.option.per_instance = 1;keeps separate coverage for each instance of the covergroup instead of merging them, for example one per port of a switch.option.weightsets how much a coverpoint contributes to the total percentage.
67Code coverage shows a branch is never hit. The designer says it is unreachable. What do you do?
Do not just exclude it. Ask why it is unreachable:
- If it is truly dead (for example a
defaultin a fully specifiedcase, or logic for a configuration this product never uses), get it reviewed and add a documented waiver, or ask the designer to remove the dead code. - If it is reachable in principle but your stimulus cannot get there, it is a stimulus hole: write a test.
- If it is reachable only through an error or reset scenario, it is often exactly where bugs hide.
Formal “unreachability” analysis can prove whether a branch can ever be hit, which gives a solid basis for the waiver.
68How do you merge coverage across many regression tests?
Each simulation writes a coverage database (UCDB for Siemens Questa, VDB for Synopsys VCS, UCD for Cadence Xcelium). After the regression, a merge tool combines them into one database, and a report or GUI shows the total and the holes.
Good practice: merge only passing tests (coverage from failing tests should not count), keep the coverage model identical across tests, and rank tests by unique contribution so the regression can be trimmed to the tests that add coverage.
UVM
69Draw a UVM testbench and explain each component.
- Test (
uvm_test): top of the class hierarchy. Configures the environment and starts sequences. - Environment (
uvm_env): holds agents, scoreboard and coverage, and connects them. - Agent (
uvm_agent): one per interface. An active agent has a sequencer, driver and monitor; a passive agent has only a monitor. - Sequencer: arbitrates between sequences and passes items to the driver.
- Driver: gets items and drives the DUT pins through the virtual interface.
- Monitor: samples pins, rebuilds transactions and broadcasts them through an analysis port.
- Scoreboard and coverage collector: subscribe to monitors’ analysis ports.
- Sequence and sequence item: objects, not components. Sequences generate items.
The top module instantiates the DUT and interfaces, puts the virtual interface in uvm_config_db, and calls run_test().
70What are the UVM phases? Which ones run top-down, and which are tasks?
In order: build, connect, end_of_elaboration, start_of_simulation, run (with optional run-time sub-phases reset, configure, main, shutdown and their pre/post versions), then extract, check, report, final.
- Only
run_phaseand its sub-phases are tasks that consume simulation time. All others are functions. build_phaseruns top-down, because a parent must create its children before they can build theirs.- The others run bottom-up, so that, for example, connections are made from the leaves up.
- All components’
run_phasetasks run in parallel.
71What is the UVM factory? What is the difference between create() and new()?
The factory is a central registry that creates objects and components by type, and allows a test to substitute a derived type without editing the code that creates it.
`uvm_component_utils(my_driver) // register with the factory
drv = my_driver::type_id::create("drv", this); // create through the factory
new() always builds exactly the class you name. type_id::create() asks the factory, which checks for overrides. A test can then do:
my_driver::type_id::set_type_override(err_driver::get_type());
and every driver created anywhere becomes an err_driver. set_inst_override replaces only at a specific hierarchy path. This is how error-injection tests reuse the whole environment.
72How does uvm_config_db work? How does the driver get the virtual interface?
uvm_config_db is a typed database keyed by hierarchy path and field name. A higher level sets a value; a component below gets it.
// top module
my_if vif(clk);
initial begin
uvm_config_db#(virtual my_if)::set(null, "uvm_test_top.env.agt*", "vif", vif);
run_test();
end
// driver build_phase
if (!uvm_config_db#(virtual my_if)::get(this, "", "vif", vif))
`uvm_fatal("NOVIF", "virtual interface not set")
Rules to know: the type parameter must match exactly on set and get, wildcards in the path decide who can see the value, a set from higher in the hierarchy wins during build, and always check the return value of get.
73Explain the handshake between sequence, sequencer and driver.
// sequence body()
req = my_item::type_id::create("req");
start_item(req); // wait for the sequencer to grant
if (!req.randomize() with { addr < 'h100; }) `uvm_error("RAND", "failed")
finish_item(req); // send it; returns after item_done
// driver run_phase()
forever begin
seq_item_port.get_next_item(req); // blocks until an item is available
drive(req); // wiggle the pins
seq_item_port.item_done(); // unblocks finish_item
end
Randomizing between start_item and finish_item is late randomization: the item is generated at the moment it will be driven, so it can depend on the current state. If the driver needs to send a response back, it calls item_done(rsp) or put_response(), and the sequence calls get_response().
74What is the difference between m_sequencer and p_sequencer?
m_sequenceris a handle of typeuvm_sequencer_basethat every sequence gets automatically when it is started. Enough to send items.p_sequenceris a handle of your specific sequencer type, created by the`uvm_declare_p_sequencer(my_sequencer)macro (which$castsm_sequencer). Use it when the sequence needs fields of that sequencer, such as handles to other sequencers in a virtual sequencer, or a configuration object.
Many teams avoid p_sequencer in reusable sequences, because it ties the sequence to one sequencer type; passing handles through config_db or sequence fields is more flexible.
75What are objections, and how does a UVM test end?
run_phase ends when no component has an objection raised. A test typically does:
task run_phase(uvm_phase phase);
phase.raise_objection(this);
seq.start(env.agt.sqr);
phase.drop_objection(this);
endtask
When the last objection drops, all run_phase tasks are killed and the cleanup phases run. If nobody raises an objection, the test ends at time 0. If an objection is never dropped, the test hangs until the global timeout.
A drain time (phase.phase_done.set_drain_time(this, 100ns)) keeps the phase alive a little after the last drop, so the last transactions can come out of the DUT and reach the scoreboard.
76Explain TLM ports, exports, imps and analysis ports.
TLM (transaction-level modelling) connects components by passing transaction handles through method calls instead of signals.
- A port is where a component calls a method (
put,get,write). - An imp (implementation) is where the method is implemented.
- An export passes a connection through a hierarchy level to an imp inside.
- A port → imp connection is one-to-one.
An analysis port is one-to-many and non-blocking: the monitor calls ap.write(t) once, and every connected subscriber’s write() runs (scoreboard, coverage, logger). The monitor does not know or care how many subscribers there are. uvm_tlm_analysis_fifo lets a component receive analysis traffic and consume it later with get().
77Write a minimal UVM sequence item, sequence and driver for a simple 32-bit memory interface.
class mem_item extends uvm_sequence_item;
rand bit we;
rand bit [31:0] addr, data;
constraint c_align { addr[1:0] == 0; }
`uvm_object_utils(mem_item)
function new(string name = "mem_item"); super.new(name); endfunction
endclass
class mem_wr_rd_seq extends uvm_sequence #(mem_item);
`uvm_object_utils(mem_wr_rd_seq)
function new(string name = "mem_wr_rd_seq"); super.new(name); endfunction
task body();
repeat (20) begin
req = mem_item::type_id::create("req");
start_item(req);
if (!req.randomize()) `uvm_error("RAND", "randomize failed")
finish_item(req);
end
endtask
endclass
class mem_driver extends uvm_driver #(mem_item);
`uvm_component_utils(mem_driver)
virtual mem_if vif;
function new(string name, uvm_component parent); super.new(name, parent); endfunction
function void build_phase(uvm_phase phase);
if (!uvm_config_db#(virtual mem_if)::get(this, "", "vif", vif))
`uvm_fatal("NOVIF", "no vif")
endfunction
task run_phase(uvm_phase phase);
vif.cb.en <= 0;
forever begin
seq_item_port.get_next_item(req);
@(vif.cb);
vif.cb.en <= 1; vif.cb.we <= req.we; vif.cb.addr <= req.addr; vif.cb.wdata <= req.data;
@(vif.cb);
vif.cb.en <= 0;
seq_item_port.item_done();
end
endtask
endclass
This “write it in five minutes” question is reported by candidates at large product companies. The points graded: factory registration, constructors with the right arguments, the driver loop, config_db for the interface, and checking randomize().
78What is a virtual sequence and a virtual sequencer?
A virtual sequence coordinates traffic on several interfaces at once, for example configuring registers over APB, then streaming data on AXI while a second agent injects interrupts. It does not generate items itself; it starts other sequences on the real sequencers of each agent.
A virtual sequencer is an optional component that holds handles to those agent sequencers, so the virtual sequence can reach them (through p_sequencer). The alternative style passes the sequencer handles directly into the virtual sequence and runs it with start(null).
79What is the UVM Register Abstraction Layer (RAL)? Explain frontdoor and backdoor access.
RAL is a class model of the DUT’s registers and memories (fields, addresses, access policies like RW, RO, W1C), usually generated from IP-XACT or a spreadsheet. Tests use it with names instead of addresses: regmodel.ctrl.enable.set(1); regmodel.ctrl.update(status);
- Frontdoor access goes through the real bus: RAL calls an adapter (
reg2bus/bus2reg) to turn the register operation into a bus transaction on an agent’s sequencer. It tests the bus logic too, but takes simulation time. - Backdoor access reads or writes the register directly through its HDL path, in zero time. Fast for setup and for checking, but it bypasses the bus logic.
RAL also keeps a mirror of expected values, updated by a predictor from monitored bus traffic, so mirror(status, UVM_CHECK) can compare the DUT against the model. Built-in sequences (reset value check, bit-bash) test the register block automatically.
80What is the difference between uvm_object and uvm_component?
| uvm_component | uvm_object | |
|---|---|---|
| Lifetime | Created in build_phase, lives for the whole test | Created and discarded at any time |
| Hierarchy | Has a parent and a full path name | No position in the hierarchy |
| Phases | Has phase methods (build, run, …) | No phases |
| Constructor | new(string name, uvm_component parent) |
new(string name = "...") |
| Examples | Driver, monitor, agent, env, test | Sequence items, sequences, config objects |
81How do you control messages in UVM? What do verbosity levels do?
Use the reporting macros: `uvm_info(ID, msg, verbosity), `uvm_warning, `uvm_error, `uvm_fatal.
An info message prints only if its verbosity is less than or equal to the component’s current threshold. Levels: UVM_NONE (always printed), UVM_LOW, UVM_MEDIUM (default threshold), UVM_HIGH, UVM_FULL, UVM_DEBUG.
Change the threshold from the command line with +UVM_VERBOSITY=UVM_HIGH, or per component with set_report_verbosity_level_hier(). You can also change actions per ID or severity, for example demote a known warning or make an error stop the test (+UVM_MAX_QUIT_COUNT).
82How is a test selected at run time, and what does run_test() do?
run_test() (called in the top module’s initial block) creates the test component through the factory, named uvm_test_top, and starts all phases.
The test name comes from the command line: +UVM_TESTNAME=my_err_test. This lets one compiled image run every test in the regression; only the run command changes. If run_test("name") is given an argument, the command-line option still overrides it.
83What are UVM callbacks, and when would you use them instead of the factory?
A callback is a hook a component provides at specific points (for example, “just before driving an item”). A test can register a callback object that runs extra code there, such as corrupting a field to inject an error, or counting events.
The factory replaces a whole class with a derived one. Callbacks add behaviour at defined points without replacing the class, and several can be stacked or switched on and off at run time. Callbacks need the component author to plan the hook points; the factory works on any registered class but needs a derived class for every variation.
84What do do_copy, do_compare and the field macros do? Why do some teams avoid field macros?
uvm_object provides copy(), clone(), compare(), print(), pack() and so on. They call user hooks do_copy(), do_compare(), do_print() that you implement for your fields.
The field macros (`uvm_field_int(addr, UVM_ALL_ON) inside `uvm_object_utils_begin) generate all of these automatically. They are convenient but expand into a lot of generic code that is slower in simulation and harder to debug. Many teams write the do_* methods by hand for transactions that are created millions of times.
85What are sequence arbitration, lock() and grab()?
When several sequences run on one sequencer, the sequencer arbitrates each time the driver asks for an item. Modes include FIFO (default), weighted random, strict priority and user-defined (set_arbitration()).
lock()requests exclusive access: it waits its turn in arbitration, then only this sequence’s items go through untilunlock().grab()takes exclusive access immediately, ahead of other waiting sequences, untilungrab().
Typical use: an interrupt-service sequence grabs the sequencer so its register accesses are not interleaved with background traffic.
86How do you write a reactive (slave/responder) agent in UVM?
A responder agent answers requests from the DUT, for example a memory model that responds to the DUT’s read requests.
- The monitor detects a request on the bus and sends it to the sequencer (through an analysis port to a TLM FIFO the sequencer or a sequence can read).
- A forever-running response sequence on that sequencer waits for a request (
p_sequencer.req_fifo.get(req)), computes the response (from a memory model), and sends a response item withstart_item/finish_item. - The driver drives the response onto the bus with the right timing.
The key difference from an initiator agent is that stimulus is driven by DUT activity, not by the test.
Protocols
87Explain an APB write transfer with a wait state.
APB transfers have two phases:
- Setup phase (one cycle): the requester drives
PADDR,PWRITE,PWDATAand assertsPSEL, withPENABLElow. - Access phase:
PENABLEgoes high. Address, data and controls must stay stable. The completer holdsPREADYlow to insert wait states, and the transfer completes on the clock edge wherePSEL,PENABLEandPREADYare all high.PSLVERRcan signal an error in that cycle.
APB is simple, unpipelined and low power, used for configuration registers. An APB transfer takes at least two cycles.
88Name the AXI channels and explain the VALID/READY handshake rules.
Five independent channels: AW (write address), W (write data), B (write response), AR (read address), R (read data and response).
Each channel uses a VALID/READY handshake: the source drives VALID and the information; the destination drives READY; a transfer happens on a rising edge where both are high.
Rules that interviewers check:
- Once VALID is asserted, it must stay high, with stable information, until the handshake completes.
- A source must not wait for READY before asserting VALID (that could deadlock).
- A destination may wait for VALID before asserting READY.
- The write response (B) can only be sent after the last write data beat (and, in AXI4, after the write address) has been accepted.
89What are the AXI burst types? Compute the addresses of a 4-beat WRAP burst of 4-byte beats starting at 0x34.
- FIXED: every beat uses the same address (for a FIFO-style peripheral).
- INCR: the address increments by the beat size each beat (normal memory access).
- WRAP: like INCR, but wraps at an aligned boundary of
beats × bytes per beat. Used for cache-line fills, so the critical word comes first.
For the WRAP example, the wrap boundary is 4 × 4 = 16 bytes, so the aligned block is 0x30 to 0x3F. Addresses: 0x34, 0x38, 0x3C, 0x30.
WRAP rules: the start address must be aligned to the beat size, and the length must be 2, 4, 8 or 16 beats.
90How does AXI support multiple outstanding and out-of-order transactions?
Because address and data are on separate channels, a requester can send several read or write addresses without waiting for the data of earlier ones (outstanding transactions).
Each transaction carries an ID (AWID, ARID, with matching BID, RID). Transactions with the same ID must complete in order. Transactions with different IDs may complete in any order, so a fast slave or a cache hit can return data before an older slow transaction. AXI4 removed write-data interleaving (no WID); read data with different IDs can still be interleaved.
For verification this means the scoreboard must match responses by ID, not by order, and the coverage must include out-of-order completion.
91Compare APB, AHB and AXI.
| APB | AHB | AXI | |
|---|---|---|---|
| Use | Low-speed peripherals, registers | Older high-performance buses | High-performance SoC interconnect |
| Pipelining | None | Address and data phases overlap | Separate channels, many outstanding transactions |
| Bursts | No | Yes | Yes (FIXED, INCR, WRAP), up to 256 beats in AXI4 INCR |
| Out-of-order | No | No | Yes, by ID |
| Read and write at once | No | No | Yes |
A typical SoC uses AXI in the main fabric, with an AXI-to-APB bridge to slow peripherals.
92Explain the I2C protocol. What are START and STOP conditions, and what is clock stretching?
I2C is a two-wire, open-drain bus (SCL clock, SDA data) with pull-up resistors, so any device can pull a line low and nobody drives it high.
- Data on SDA changes only while SCL is low. A change while SCL is high is a control condition: START is SDA falling while SCL is high; STOP is SDA rising while SCL is high.
- A transfer is START, a 7-bit address plus a read/write bit, an ACK (receiver pulls SDA low on the 9th clock), then data bytes each followed by ACK or NACK, then STOP (or a repeated START).
- Clock stretching: a slow slave holds SCL low to pause the master until it is ready.
- Arbitration: with several masters, a master that sends a 1 but sees a 0 on SDA knows it lost and backs off.
93What are the SPI modes (CPOL and CPHA)?
SPI uses SCLK, MOSI, MISO and a chip select per slave. Two settings define the timing:
- CPOL is the idle level of the clock (0 = idle low, 1 = idle high).
- CPHA chooses which clock edge samples data (0 = first edge after CS goes active, 1 = second edge).
| Mode | CPOL | CPHA | Sample on |
|---|---|---|---|
| 0 | 0 | 0 | Rising edge |
| 1 | 0 | 1 | Falling edge |
| 2 | 1 | 0 | Falling edge |
| 3 | 1 | 1 | Rising edge |
Master and slave must use the same mode. In a testbench, cover all four modes if the design supports them, and check the bit order (MSB or LSB first).
94How does a UART receiver find the middle of each bit without a clock line?
Both sides agree on the baud rate. The idle line is high; a frame is a start bit (0), 5 to 9 data bits (LSB first), an optional parity bit, and one or two stop bits (1).
The receiver runs an internal clock at typically 16× the baud rate. When it sees the falling edge of the start bit, it counts 8 ticks to reach the middle of the start bit, checks it is still 0 (to reject glitches), then samples every 16 ticks, at the middle of each following bit.
Verification corner cases: baud-rate mismatch of a few percent between sides, framing errors (stop bit = 0), parity errors, and break conditions (line held low).
Coding, debug and projects
95Reverse a singly linked list in C.
struct node { int val; struct node *next; };
struct node *reverse(struct node *head) {
struct node *prev = NULL;
while (head) {
struct node *next = head->next; // remember the rest
head->next = prev; // turn this link around
prev = head;
head = next;
}
return prev; // new head
}
O(n) time and O(1) extra space. Say the edge cases out loud: an empty list and a single node both work without special code. Product-company verification interviews often include one C, C++ or Python question like this.
96Count the number of set bits in a 32-bit value, in SystemVerilog and in C.
SystemVerilog has a built-in: $countones(x). If asked to write it yourself:
int popcount(unsigned int x) {
int n = 0;
while (x) {
x &= x - 1; // clears the lowest set bit
n++;
}
return n;
}
The x & (x − 1) trick loops once per set bit instead of once per bit. Follow-ups: check if a number is a power of two (x && !(x & (x - 1))), or find the position of the lowest set bit (x & -x).
97Find the elements that appear more than once in an array, in SystemVerilog.
Count occurrences in an associative array indexed by value:
function automatic void find_dups(int arr[], ref int dups[$]);
int cnt[int];
foreach (arr[i]) cnt[arr[i]]++;
foreach (cnt[v]) if (cnt[v] > 1) dups.push_back(v);
endfunction
Associative-array counting is O(n) and is the answer interviewers expect. Built-in array methods give another one-liner style: arr.unique() returns the distinct values, and arr.find(x) with (x == v) finds all matches of a value. Be ready to explain that foreach over an associative array walks the keys in ascending order.
98The simulation hangs and never finishes. What could cause it?
- An objection was raised and never dropped, so
run_phasenever ends. - A driver or monitor is waiting on a signal that never changes (
@(posedge vif.ack)when the DUT never acknowledges): add timeouts. - A zero-delay infinite loop: a
foreverloop without any time-consuming statement freezes simulation time. - A combinational loop in the RTL oscillating in zero time.
- The clock generator was never started, or stops.
- Mailbox
get()with no producer.
Use the global timeout (set_timeout() or +UVM_TIMEOUT) so hangs become clear failures, and add a watchdog per transaction.
99You find a mismatch between the scoreboard and the DUT. How do you decide whether it is a design bug or a testbench bug?
- Go back to the specification: what should happen for this exact input? Do not trust either the DUT or the reference model by default.
- Check that the stimulus was legal: does the input obey the protocol and the constraints in the spec?
- Check the monitors: did they capture the right values at the right time? Look at the waveform.
- Check the reference model for that case.
- If the spec is unclear, raise it with the designer and architect; the result may be a spec fix.
When you report a design bug, give a minimal reproducing test, the seed, the time, the waveform and the spec section. Verification engineers are judged by how quickly designers can act on their bug reports.
100How should you answer “Explain your verification project”?
Structure it like a verification plan:
- DUT in one sentence and its interfaces (for example, “an APB-programmable UART with TX and RX FIFOs”).
- Testbench architecture: draw it: agents, sequences, scoreboard, reference model, coverage.
- Verification plan: the features you listed and how each was tested.
- Checks: what the scoreboard compares, which assertions you wrote.
- Coverage: what the coverage model contained and the final numbers; how you closed the last holes.
- Bugs found: one or two concrete bugs, how you found and debugged them.
- What you would improve.
Expect detailed follow-ups on anything you mention. If you say “constrained random”, be ready to write one of your constraints; if you say “100% coverage”, be ready to say what was in the model.