SV Interview Questions - ZishanManna/interview-prep-wiki GitHub Wiki
Click here to reveal the answer
-
initial
Block: Executes once at the start of the simulation and is used for setting up initial values. -
always
Block: Continuously repeats whenever the sensitivity list is active and is typically used for describing both combinational and sequential logic.
Click here to reveal the answer
-
wire
: Represents a continuous assignment, cannot hold a value. -
logic
: A SystemVerilog data type that can be used as a signal or variable and is compatible for both combinational and sequential logic.
Click here to reveal the answer
-
interface
: A construct used to group related signals together, making connections between modules easier. -
modport
: Defines specific access restrictions (read, write, or both) for signals in an interface.
Click here to reveal the answer
-
assert
: Checks a condition during simulation and throws an error if the condition is not met. -
assume
: Specifies a condition that should always hold true for formal verification tools, used to define constraints on inputs.
Click here to reveal the answer
-
unique
: Ensures that no twocase
items match at the same time. If no case item matches, it raises a warning. -
priority
: Indicates that higher-priority items should be evaluated first. If no case item matches, it doesn’t raise a warning.
Click here to reveal the answer
-
Blocking (
=
): Statements execute sequentially. The right-hand side value is immediately assigned to the left-hand side. -
Non-blocking (
<=
): The evaluation of the right-hand side occurs immediately, but the assignment to the left-hand side is postponed until the end of the time step.
Click here to reveal the answer
-
fork-join
: Executes all threads in parallel and waits for all of them to complete before proceeding. -
fork-join_none
: Executes all threads in parallel but does not wait for any of them to complete.
Click here to reveal the answer
- Covergroups are used for functional coverage analysis to track coverage points and ensure that various scenarios are tested.
Click here to reveal the answer
- Constraints are rules that control randomization, specifying conditions that the randomly generated values must meet.
Click here to reveal the answer
-
typedef
: Used to create an alias for a data type. -
enum
: Defines an enumerated data type with symbolic names representing integer values.
Click here to reveal the answer
-
parameter
: Used to define constants in a module that can be overridden during module instantiation.
Click here to reveal the answer
- A virtual interface is a reference to a physical interface, used primarily for passing interfaces to classes for testbenches and verification environments.
Click here to reveal the answer
-
randomize()
is used in SystemVerilog to generate random values for the variables within a class. You can apply constraints to control the randomization.
Click here to reveal the answer
-
Coverpoints can be of two types:
- Cross Coverage: Defines coverage points across multiple variables.
- Simple Coverage: Tracks values or conditions for a single variable.
Click here to reveal the answer
- Mailbox: A communication mechanism used for sending and receiving messages between parallel processes.
- Queue: A dynamic array that can be resized at runtime and used for storing ordered data.
Click here to reveal the answer
- A class is a user-defined data type that encapsulates variables and methods (functions and tasks). It supports object-oriented programming concepts.
Click here to reveal the answer
-
unique case
: Checks for mutually exclusive conditions. -
priority case
: Prioritizes checking of the case items in order.
Click here to reveal the answer
- A
uvm_component
is a base class in the UVM framework used for building verification components like drivers, monitors, and agents.
Click here to reveal the answer
-
Process control involves using constructs like
disable
,wait
,join
, andfork
to control the execution of processes in parallel and sequential code blocks.
Click here to reveal the answer
- Coverage refers to the analysis of how well the simulation tests cover various functional aspects, ensuring all scenarios are verified. It includes code coverage, functional coverage, and assertion coverage.
Click here to reveal the answer
-
Interface: Groups related signals and allows for easier connectivity between modules. It also supports advanced features like
modport
andclocking blocks
. - Struct: A composite data type used to bundle multiple variables of different types under a single name, useful for storing data rather than connectivity.
Click here to reveal the answer
-
typedef enum
: Allows defining a new enumerated type with symbolic names for each value. It's useful for state machines and defining symbolic states for better readability and code maintainability.
Click here to reveal the answer
- Define the states using
typedef enum
. - Use an
always_ff
block to implement state transitions. - Use another
always_comb
block to define the next state logic and output behavior.
Click here to reveal the answer
- The
bind
construct is used to associate external verification code (e.g., assertions or cover properties) with a module instance without modifying the module’s source code.
Click here to reveal the answer
- Program Block: Used in testbenches for sequential simulation. It’s event-driven and executes in the reactive region.
- Module Block: Represents hardware components and executes in the active region.
Click here to reveal the answer
- Clocking Blocks: Used to group related signals driven or sampled by a common clock in a testbench. They help synchronize between design and testbench signals and avoid race conditions.
Click here to reveal the answer
-
Wildcard Equality (
===
,!==
): Compares values with unknowns (x
orz
). It returnstrue
if unknowns match or if both operands havex
in the same position. -
Wildcard Case: Allows
case
statements to match patterns withx
andz
values.
Click here to reveal the answer
-
Properties: A high-level construct used in SystemVerilog Assertions (SVA) to describe temporal relationships between signals. They are used within
assert
andassume
statements.
Click here to reveal the answer
-
Task: Can include time-consuming statements (e.g.,
#
,@
). Can return zero or more values. - Function: Executes in zero simulation time and returns a single value. Cannot include time-consuming statements.
Click here to reveal the answer
- Static Variable: Retains its value between calls.
- Automatic Variable: Does not retain its value between calls. It is re-created every time the scope is entered, useful for reentrant tasks and functions.
Click here to reveal the answer
- Use the
randomize()
method on class variables. - Apply
constraint
blocks to limit the values. - Use the
void' randomize()
syntax to randomize inline variables.
Click here to reveal the answer
- Assertion Coverage: Tracks which assertions in the design have been triggered during simulation. It helps ensure that all expected conditions are verified.
Click here to reveal the answer
- The
uvm_sequence
class is a base class in UVM used to generate and manage stimulus for a testbench. Sequences define a series of transactions to be sent to a driver.
Click here to reveal the answer
- Call by Value: A copy of the actual value is passed, changes made in the called function do not affect the original variable.
- Call by Reference: A reference to the actual variable is passed, changes made in the called function affect the original variable.
Click here to reveal the answer
- The factory pattern allows for creating objects dynamically in UVM. It provides flexibility for changing the class type of objects in a testbench without modifying the source code.
Click here to reveal the answer
- In UVM, clocking blocks are used to control signal timing between the design and testbench, ensuring race-free signal sampling and driving in testbenches.
Click here to reveal the answer
- Cover Property: Focuses on checking specific temporal properties.
- Covergroup: Tracks values and transitions of variables to evaluate functional coverage.
Click here to reveal the answer
- Use
parameterized classes
by defining the parameters in the class header using theparameter
keyword.
Click here to reveal the answer
- A process is any
always
,initial
,fork
, orjoin
block in SystemVerilog. It represents a parallel thread of execution within a module or testbench.
Click here to reveal the answer
- The
constraint soft
keyword is used to define a constraint that can be overridden by other constraints. It provides flexibility in randomization by allowing other constraints to take precedence.
Click here to reveal the answer
-
solve
Constraint: Specifies the order in which random variables should be solved. For example,solve a before b
meansa
is solved first. -
soft
Constraint: Can be overridden by stronger constraints. If no conflicting constraints exist, the soft constraint is applied.
Click here to reveal the answer
-
rand
: Generates random values without considering previous values. -
randc
: Generates cyclic random values, ensuring that all possible values are produced before repeating any value.
Click here to reveal the answer
- Use the
constraint
keyword inside a class or struct and reference nested fields or parent class variables. - For example:
class A; rand int a; constraint a_c { a > 0; } endclass class B extends A; rand int b; constraint b_c { b > a; } // Hierarchical constraint endclass
Click here to reveal the answer
-
Implication Constraints are defined using the
->
operator and are used to express dependencies between variables. - For example:
This constraint means: If
constraint c { a == 1 -> b == 0; }
a
is1
, thenb
must be0
.
Click here to reveal the answer
-
foreach
constraints are used to apply a constraint on each element of an array. - For example:
This constraint ensures each element in the array is less than 5.
rand bit [3:0] array[5]; constraint c { foreach(array[i]) array[i] < 5; }
Click here to reveal the answer
- Use
inside
constraints for restricting the range or specific values:This constraint restrictsrand int x; constraint c { x inside {1, 3, 5, 7}; }
x
to the values1
,3
,5
, or7
.
Click here to reveal the answer
- Random Stability: Ensures that random values remain consistent across multiple simulations.
- It is achieved using the
srandom(seed)
method to set a specific seed value.
Click here to reveal the answer
-
disable soft
removes the effect of a soft constraint. It overrides the soft constraint temporarily in a local context.
Click here to reveal the answer
-
assert
: Checks a condition during simulation. If the condition fails, it triggers an error. -
assume
: Specifies assumptions for formal verification. Used to define constraints on inputs. -
cover
: Tracks specific points in the simulation to ensure coverage of particular scenarios.
Click here to reveal the answer
- Use
disable iff
to disable the assertion check when a specific condition is met. - For example:
This assertion is disabled whenever
assert property (@(posedge clk) disable iff (reset) (a == b));
reset
is high.
Click here to reveal the answer
- Use the
sequence
keyword to define a temporal sequence. - For example:
sequence seq_a; @(posedge clk) a ##1 b ##2 c; // Sequence defines that `a` occurs, followed by `b` 1 cycle later, and `c` 2 cycles later. endsequence
Click here to reveal the answer
-
Overlapping Implication (
|->
): Triggers the consequent expression at the same time as the antecedent. -
Non-Overlapping Implication (
|=>
): Triggers the consequent expression one clock cycle after the antecedent.
Click here to reveal the answer
-
Concurrent Assertions: Evaluate temporal conditions over multiple clock cycles. Defined using
property
,sequence
, andassert
blocks. They are triggered at specific simulation times.
Click here to reveal the answer
- Local variables in assertions are used to hold temporary values.
- For example:
property p1; int local_var; @(posedge clk) (a == 1) |-> (local_var = b); endproperty
Click here to reveal the answer
-
Covergroup: A group of
coverpoints
andcross
statements used to capture functional coverage. - Coverpoint: Monitors specific variables and tracks value hits.
Click here to reveal the answer
- A
cross
statement captures the relationship between two or morecoverpoints
. - For example:
covergroup cg; coverpoint a; coverpoint b; cross a, b; // Cross coverage between `a` and `b` endgroup
Click here to reveal the answer
-
Immediate Assertions: Use
assert
without temporal logic. They are evaluated immediately when encountered. - Example:
assert(a == b) else $fatal("Assertion failed: a != b");
Click here to reveal the answer
- Randomize using the
randomize()
function withforeach
constraints:rand int dyn_array[]; constraint size_c { dyn_array.size() == 10; } constraint val_c { foreach(dyn_array[i]) dyn_array[i] < 50; }
Click here to reveal the answer
-
Uniqueness Constraints ensure that multiple random variables are assigned unique values:
rand int a, b, c; constraint unique_c { unique {a, b, c}; }
Click here to reveal the answer
- Use
if
andinside
conditions in constraint blocks:rand int x, y; constraint c { if (y > 0) x inside {1, 2, 3}; }