Professional Documents
Culture Documents
? Master SV_ 200 Essential Interview Questions! ?️?
? Master SV_ 200 Essential Interview Questions! ?️?
System Verilog
Interview Handbook
DIFFERENT TOPICS
COVERED
200 Questions & Answers
By Gowtham Seela
System Verilog Basic & Fundamental Interview Questions
- Module: A basic building block in SystemVerilog used to define a hardware component. Modules can
contain ports, parameters, and instances of other modules.
- Interface: Used to group related signals and their associated logic, making the connections between
modules cleaner and more manageable. Interfaces can also include tasks, functions, and modports to
control access to their members.
Page 1 of 70
System Verilog Basic & Fundamental Interview Questions
Variables in SystemVerilog can be declared using various data types. Here's an example:
Page 2 of 70
System Verilog Basic & Fundamental Interview Questions
Arithmetic operations in SystemVerilog are similar to those in C/C++. Here are some examples:
- `logic`: A new data type introduced in SystemVerilog that can be used for both combinational
and sequential logic. It is more flexible than `reg`.
- `reg`: A legacy data type from Verilog used primarily for sequential logic (e.g., within `always`
blocks). In SystemVerilog, `logic` is preferred over `reg`.
Page 3 of 70
System Verilog Basic & Fundamental Interview Questions
`typedef` is used to create an alias for an existing data type, making code more readable and
easier to maintain.
A `struct` in SystemVerilog is a composite data type that groups different data types together:
Page 4 of 70
System Verilog Basic & Fundamental Interview Questions
- Packed arrays: a contiguous collection of bits treated as a single unit. They are used for
defining widths and bit slicing.
- Unpacked arrays:separatee elements, each of which can be accessed independently.
Page 5 of 70
System Verilog Basic & Fundamental Interview Questions
`const` is used to declare constants, which are variables whose value cannot be changed after
initialization:
Parameters are used to define constants within a module, which can be overridden during module
instantiation:
Page 6 of 70
System Verilog Basic & Fundamental Interview Questions
Page 7 of 70
System Verilog Data Types & Operators
- `bit`: A 2-state data type that can hold values 0 and 1. It is used for simple binary data.
- `logic`: A 4-state data type that can hold values 0, 1, X (unknown), and Z (high-impedance). It
is more versatile for representing digital logic where unknown and high-impedance states need to
be modeled.
A vector is an array of bits or logic types. Here’s how you declare it:
- `signed`: Indicates that a variable or vector is signed, meaning it can represent positive and
negative values.
- `unsigned`: Indicates that a variable or vector is unsigned, meaning it can only represent
non-negative values.
Bit-wise operations are performed using operators like `&`, `|`, `^`, and `~`.
Page 8 of 70
System Verilog Data Types & Operators
Page 9 of 70
System Verilog Data Types & Operators
The `?` operator is the conditional (ternary) operator, which selects one of two values based on a
condition.
The `case` statement is used to select one of several possible blocks of code to execute based on
the value of an expression.
- `case`: Performs exact matching and does not treat `x` and `z` as wildcards.
- `casex`: Treats `x` and `z` as wildcards, ignoring them during matching.
Page 10 of 70
System Verilog Data Types & Operators
The `else` clause is used to specify a block of code to execute if the `if` condition is false.
The `while` loop repeatedly executes a block of code as long as the condition is true.
Page 11 of 70
System Verilog Data Types & Operators
The `do-while` loop is similar to the `while` loop but guarantees at least one execution of the loop body
before checking the condition.
The `for` loop is used for iterative execution of a block of code with a counter.
Page 12 of 70
System Verilog Data Types & Operators
36. How do you use the `break` and `continue` statements in SystemVerilog?
Page 13 of 70
System Verilog Data Types & Operators
The `return` statement is used to exit a function or task and, optionally, return a value.
The `assert` statement is used for verification purposes to check if a condition is true. If the
condition is false, an error is reported.
The `assume` statement is used in formal verification to specify conditions that are assumed to
be true during analysis.
The `cover` statement is used to specify scenarios that should be covered during simulation or
formal verification, ensuring that all specified conditions occur.
Page 14 of 70
System Verilog Data Types & Operators
Page 15 of 70
System Verilog Classes & Objects
A class in SystemVerilog is a blueprint for creating objects that encapsulate data (properties) and
functions (methods). Classes support object-oriented programming features like inheritance,
polymorphism, and encapsulation.
The `new` keyword is used to create a new instance (object) of a class. It is also used to define a
constructor within the class.
You create an object by declaring a variable of the class type and using the `new` keyword.
Page 16 of 70
System Verilog Classes & Objects
- Static objects: Declared and instantiated at compile time. They have a fixed memory
allocation.
- Dynamic objects: Created at runtime using the `new` keyword. They provide flexibility and
are managed dynamically.
The `this` keyword is used to refer to the current instance of the class.
The `super` keyword is used to refer to the base class in a derived class. It is commonly used to
call the base class constructor or methods.
Page 17 of 70
System Verilog Classes & Objects
Inheritance is used to create a new class based on an existing class. The new class inherits
properties and methods from the existing class.
Polymorphism allows objects of different classes to be treated as objects of a common base class.
It enables methods to behave differently based on the object that invokes them.
Encapsulation is the concept of bundling data and methods that operate on the data within a
class, restricting direct access to some of the class’s components.
Page 18 of 70
System Verilog Classes & Objects
Abstraction allows you to hide complex implementation details and expose only the necessary
parts of an object or a system. This simplifies interaction and promotes reuse.
The `virtual` keyword is used to declare methods in a base class that can be overridden in derived classes.
It supports polymorphism.
In SystemVerilog, the term `pure` is not used explicitly. Instead, `pure virtual` functions are declared by
using `virtual` followed by the `;` without a method body, indicating the method must be overridden in
derived classes.
Page 19 of 70
System Verilog Classes & Objects
54. How do you use the `const` keyword with classes in SystemVerilog?
The `const` keyword is used to declare constants within a class, ensuring their values cannot be changed
after initialization.
55. What is the purpose of the `static` keyword with classes in SystemVerilog?
The `static` keyword is used to declare class members (variables or methods) that are shared among all
instances of the class. Static members belong to the class itself rather than any particular instance.
56. How do you use the `local` keyword with classes in SystemVerilog?
The `local` keyword restricts the visibility of class members to the class itself, preventing access from
derived classes or external entities.
Page 20 of 70
System Verilog Classes & Objects
The `protected` keyword restricts access to class members to the class itself and its derived classes. It
provides a level of encapsulation that allows inheritance but not external access.
58. How do you use the `private` keyword with classes in SystemVerilog?
The `private` keyword restricts access to class members to the class itself, preventing access from both
derived classes and external entities.
The `public` keyword allows access to class members from anywhere. Public members are accessible
from outside the class, derived classes, and any other part of the code.
Page 21 of 70
System Verilog Classes & Objects
60. How do you use the `interface` keyword with classes in SystemVerilog?
In SystemVerilog, `interface` is not used directly with classes. Instead, it is used to define signal groups
for modules. However, `virtual interfaces` can be used within classes to facilitate communication with
interfaces.
Page 22 of 70
SV Interfaces and Modports
An interface in SystemVerilog is a construct that bundles together signals and functionality that
multiple modules can share. It simplifies connectivity and enhances code modularity and
readability.
The `modport` keyword in SystemVerilog is used within an interface to define the direction
(input, output, or inout) of the signals for different modules that connect to the interface. It
allows for flexible and structured communication between modules.
You declare a modport inside an interface using the `modport` keyword. Here’s an example:
Page 23 of 70
SV Interfaces and Modports
A `clocking` block groups signals that are sampled or driven synchronously with a particular
clock. Here’s how you use it:
The `default` clocking block is a special clocking block that can be set as the default for
sampling or driving signals within a module or interface, simplifying the code by avoiding the
need to specify the clocking block every time.
68. How do you use the `input` and `output` keywords in SystemVerilog
interfaces?
The `input` and `output` keywords are used in modports and clocking blocks to specify the
direction of the signals.
Page 24 of 70
SV Interfaces and Modports
The `inout` keyword is used to declare bidirectional signals in an interface, meaning the signal
can be both read and written.
The `ref` keyword is used to pass arguments by reference to tasks or functions, allowing the
called function to modify the argument's value.
Page 25 of 70
SV Interfaces and Modports
The `const` keyword is used to declare constants within an interface, ensuring that their values cannot be
changed after initialization.
The `virtual` keyword is used to declare a virtual interface, which is a reference to an actual
interface instance. It allows classes to interact with interfaces.
SystemVerilog doesn't use the `pure` keyword explicitly. Instead, the concept of `pure` functions
is implied in `pure virtual` functions (abstract methods) declared using `virtual` followed by a `;`
in the base class.
Page 26 of 70
SV Interfaces and Modports
74. How do you use the `interface` keyword with modports in SystemVerilog?
Modports are defined within interfaces to specify signal directions for different roles.
The `modport` keyword defines roles for different modules that connect to the interface,
specifying the direction (input, output, or inout) of signals for each role.
76. How do you use the `import` keyword with interfaces in SystemVerilog?
The `import` keyword is used to bring tasks or functions from packages into an interface or module.
Page 27 of 70
SV Interfaces and Modports
The `export` keyword makes tasks or functions within an interface available to modules that connect to it.
78. How do you use the `interface` keyword with classes in SystemVerilog?
In SystemVerilog, you can use `virtual interfaces` within classes to facilitate interaction with
interfaces.
The `modport` keyword is not directly used with classes. However, classes can interact with
modports by using virtual interfaces to connect to specific modports.
Page 28 of 70
SV Interfaces and Modports
80. How do you use the `interface` keyword with modules in SystemVerilog?
Modules use interfaces to group and manage related signals, enhancing modularity and reducing
the complexity of signal declarations.
Page 29 of 70
SV Assertions and Coverage
An assertion in SystemVerilog is a statement used to check that certain conditions hold true in a
design. It helps verify the correctness of the design by catching errors during simulation or
formal verification.
Assertions are declared using the `assert` keyword. Here’s a basic example:
The `assert` keyword is used to check if a condition is true. If the condition is false, it triggers an
action, such as displaying an error message or halting the simulation.
The `assume` keyword is used to specify assumptions about the design's environment or inputs.
It is often used in formal verification to constrain the inputs.
The `cover` keyword is used to specify coverage points that monitor how often certain conditions
or events occur in a design, helping to measure the completeness of verification.
Page 30 of 70
SV Assertions and Coverage
The `cross` keyword is used within covergroups to define coverage points for combinations of
multiple variables or conditions, ensuring all possible combinations are exercised.
The `expect` keyword is used to specify expected behavior or values in a simulation. It can be
used for post-simulation analysis to ensure the design behaves as expected.
Page 31 of 70
SV Assertions and Coverage
The `prove` keyword is not a standard part of SystemVerilog. Instead, `prove` is a concept used
in formal verification tools to ensure that assertions hold under all possible conditions.
90. How do you use the `assert` keyword with classes in SystemVerilog?
Assertions can be used inside class methods to check the correctness of class behavior.
The `assume` keyword is used within class methods to specify assumptions about the class's
environment or inputs, aiding in formal verification.
92. How do you use the `cover` keyword with classes in SystemVerilog?
The `cover` keyword can be used within class methods to monitor the occurrence of specific
conditions or events related to the class’s data members.
Page 32 of 70
SV Assertions and Coverage
The `coverpoint` keyword within classes is used to define specific conditions or ranges for
coverage analysis, similar to how it is used in covergroups.
94. How do you use the `cross` keyword with classes in SystemVerilog?
The `cross` keyword within classes is used to define coverage for combinations of multiple data
members.
Page 33 of 70
SV Assertions and Coverage
The `expect` keyword is used within class methods to specify expected behavior or values for
post-simulation analysis.
96. How do you use the `prove` keyword with classes in SystemVerilog?
The `prove` keyword itself is not part of SystemVerilog, but formal verification tools use the
concept of proving assertions within classes to ensure correctness under all conditions.
Page 34 of 70
SV Assertions and Coverage
The `assert` keyword within interfaces ensures that the signals and behavior of the interface
comply with specified conditions.
98. How do you use the `assume` keyword with interfaces in SystemVerilog?
The `assume` keyword within interfaces specifies assumptions about the signals or environment
of the interface.
Page 35 of 70
SV Assertions and Coverage
The `cover` keyword within interfaces monitors the occurrence of specific conditions or events
to ensure comprehensive verification coverage.
The `coverpoint` keyword within interfaces defines specific conditions or ranges for coverage
analysis.
Page 36 of 70
System Verilog Randomization & Constraints
Randomization in SystemVerilog is the process of generating random values for variables within
constraints to thoroughly test and verify the design's behavior under various scenarios.
You declare a random variable using the `rand` or `randc` keyword inside a class.
The `rand` keyword designates a variable as a random variable, which can be randomized using
the `randomize` method.
The `randc` keyword is used for cyclic random variables, where values are generated without
repetition until all possible values are exhausted.
The `constraint` keyword is used to define rules and conditions that random variables must
satisfy during randomization.
Page 37 of 70
System Verilog Randomization & Constraints
The `solve` keyword specifies the order in which constraints are solved, helping to control
dependencies between variables during randomization.
The `randomize` method is used to generate random values for the variables in a class.
Page 38 of 70
System Verilog Randomization & Constraints
The `pre_randomize` function is called automatically before randomization, allowing for setup
operations or checks before the random values are generated.
The `random` function generates a random value for the variable it is called on. It’s part of the
`$urandom` and `$urandom_range` family of functions.
The `std::randomize` function is used to randomize variables in a standard way, typically within
a class.
Page 39 of 70
System Verilog Randomization & Constraints
The `std::uniform` function generates random numbers with a uniform distribution, providing a
random float between 0.0 and 1.0.
The `std::normal` function generates random numbers following a normal (Gaussian) distribution
with a specified mean and standard deviation.
Page 40 of 70
System Verilog Randomization & Constraints
The `std::poisson` function generates random numbers following a Poisson distribution with a
specified mean.
The `std::bernoulli` function generates random boolean values based on a specified probability of
success.
The `std::binomial` function generates random numbers following a binomial distribution with
specified number of trials and probability of success.
Page 41 of 70
System Verilog Randomization & Constraints
The `std::geometric` function generates random numbers following a geometric distribution with
a specified probability of success.
Page 42 of 70
SV Object-Oriented Programming
Inheritance in SystemVerilog is an object-oriented concept where a class (child class) can inherit
properties and methods from another class (parent class). This allows for code reuse and
extension of existing functionality.
You use inheritance by using the `extends` keyword to create a child class that inherits from a
parent class.
Page 43 of 70
SV Object-Oriented Programming
Polymorphism is achieved by using virtual methods and overriding them in derived classes.
Page 44 of 70
SV Object-Oriented Programming
Encapsulation is the bundling of data (variables) and methods (functions) that operate on the data
into a single unit, i.e., a class. It restricts direct access to some of the object's components, which
is a way of limiting and controlling access to the data.
Encapsulation is used by defining classes with private and public members, and using methods to
interact with the private data.
Abstraction in SystemVerilog is the process of hiding the complex implementation details and
showing only the essential features of an object. It allows the programmer to focus on
interactions at a higher level without worrying about the low-level details.
Page 45 of 70
SV Object-Oriented Programming
Abstraction is achieved by using abstract classes and methods (declared with the `virtual` and
`pure` keywords).
The `virtual` keyword is used to declare a method that can be overridden in a derived class. It
enables polymorphism by allowing methods to be defined in a base class but implemented in
derived classes.
The `pure` keyword is used in conjunction with `virtual` to declare a pure virtual method, which
must be overridden in a derived class.
Page 46 of 70
SV Object-Oriented Programming
SystemVerilog doesn't have an `abstract` keyword. Instead, abstract classes are created by
defining one or more pure virtual functions.
The `extends` keyword is used to derive a new class from an existing class, inheriting its
properties and methods.
SystemVerilog does not have an `implements` keyword. However, it supports interfaces and
virtual classes for similar functionality.
The `interface` keyword is used to define an interface, which can encapsulate signals and provide
a common connection between modules.
Page 47 of 70
SV Object-Oriented Programming
The `class` keyword is used to define a class, which is a blueprint for creating objects (instances)
with properties and methods.
The `struct` keyword is used to define a composite data type that groups multiple variables under
one name.
The `union` keyword is used to define a union, a data type that allows storing different data types
in the same memory location.
The `enum` keyword is used to define an enumeration, a user-defined data type consisting of a
set of named values.
Page 48 of 70
SV Object-Oriented Programming
The `typedef` keyword is used to create a new data type name for an existing data type, which
can improve code readability and maintainability.
The `alias` keyword is used to create an alias for a net or variable, allowing multiple names to
refer to the same data.
Page 49 of 70
SV Advanced Topics
Phasing is typically implemented using the UVM (Universal Verification Methodology) library,
which provides built-in phases like `build_phase`, `connect_phase`, `run_phase`, and more.
Clock domains refer to different sections of a design that operate on different clock signals.
Proper handling of clock domains is crucial for ensuring correct timing and synchronization
across the design.
Page 50 of 70
SV Advanced Topics
Clock domains are managed by defining separate clock signals and using appropriate
synchronizers for crossing clock domains.
Asynchronous FIFOs are used to transfer data between different clock domains. They allow for
safe data transfer between modules operating at different clock frequencies.
An asynchronous FIFO typically involves using dual-port memory and synchronizing the write
and read pointers between the clock domains.
Page 51 of 70
SV Advanced Topics
Synchronous FIFOs are used to buffer data within the same clock domain, allowing for
temporary storage and retrieval of data at the same clock frequency.
A synchronous FIFO is implemented using a single clock signal for both reading and writing
operations.
Page 52 of 70
SV Advanced Topics
A mailbox is created and used with the `mailbox` class, which provides methods like `put()` and
`get()` for sending and receiving data.
A semaphore is created and used with the `semaphore` class, which provides methods like `get()`
and `put()` for acquiring and releasing resources.
Page 53 of 70
SV Advanced Topics
An event in SystemVerilog is a synchronization primitive used to signal and wait for occurrences
of specific conditions. Events are used to coordinate the actions of multiple processes.
Events are declared using the `event` keyword and can be triggered with the `->` operator.
Processes can wait for events using the `@` operator.
Page 54 of 70
SV Advanced Topics
The `fork-join` construct in SystemVerilog allows parallel execution of multiple processes. All
processes within a `fork-join` block start executing concurrently and the join ensures that all
processes complete before proceeding.
Page 55 of 70
SV Advanced Topics
`disable fork` is used to terminate all processes within a `fork-join` block before they complete.
This can be useful in case of errors or when certain conditions are met.
You use `disable fork` to stop all concurrent processes in a `fork-join` block.
`wait fork` waits for all processes within a `fork-join` block to complete before proceeding. This
ensures that all concurrent operations have finished.
Page 56 of 70
SV Advanced Topics
You use `wait fork` to wait for the completion of all processes in a `fork-join` block.
Page 57 of 70
SystemVerilog for Verification
Verification in SystemVerilog involves checking that a design behaves as expected. This is done
using a combination of testbenches, assertions, and coverage to ensure that all parts of the design
are functioning correctly.
A testbench is a piece of code used to apply stimulus to the design under test (DUT) and check
its response. It is used to verify the functionality of the DUT.
A basic testbench involves instantiating the DUT, applying stimulus, and checking the output.
Page 58 of 70
SystemVerilog for Verification
Assertions are used to check if certain conditions hold true during simulation. They help in
identifying design errors early in the verification process.
Coverage is used to measure how thoroughly a design has been tested. It helps identify untested
parts of the design and ensures all functionality is verified.
Coverage is typically defined using covergroups, which specify what to cover and how to collect
coverage data.
Page 59 of 70
SystemVerilog for Verification
Constrained randomization involves generating random values for variables within specified
constraints. This helps in testing a wide range of scenarios automatically.
You use the `constraint` keyword to specify constraints on variables and the `randomize()`
method to generate random values.
Scenario-based verification involves testing the design with realistic and complex sequences of
operations that mimic actual use cases.
Scenario-based verification is implemented using sequences and transactions that define specific
scenarios to be tested.
Page 60 of 70
SystemVerilog for Verification
UVM is used by creating components like agents, drivers, monitors, and scoreboards, and
integrating them into a testbench.
Page 61 of 70
SystemVerilog for Verification
OVM is an earlier verification methodology that provides a framework for building modular,
reusable verification environments. It has since been replaced by UVM.
OVM is used similarly to UVM, with components like drivers, monitors, and scoreboards, but
using OVM base classes.
Page 62 of 70
SystemVerilog for Verification
VMM is a methodology developed by Synopsys for creating structured and reusable verification
environments. It provides guidelines and a set of base classes for building testbenches.
VMM uses base classes and guidelines to build verification components and testbenches.
Page 63 of 70
SystemVerilog for Verification
AVM focuses on using assertions to verify the correctness of a design. Assertions are embedded
in the design to check for specific conditions during simulation.
You use AVM by writing assertions that check for conditions in the design and integrating them
into the testbench.
Page 64 of 70
SV Miscellaneous
SystemVerilog is an extension of Verilog that includes additional features for design and
verification, such as advanced data types, object-oriented programming, assertions, and
coverage. Verilog is primarily focused on hardware description, whereas SystemVerilog adds
capabilities to support verification and complex modeling.
SystemVerilog can interface with other programming languages using the Direct Programming
Interface (DPI), allowing C/C++ functions to be called from SystemVerilog and vice versa.
DPI allows SystemVerilog to interface with C/C++ code, enabling the use of external functions
and procedures within a SystemVerilog environment.
To use DPI, you declare the external function or task in SystemVerilog and implement it in
C/C++.
Page 65 of 70
SV Miscellaneous
PLI is an older interface that allows Verilog/SystemVerilog code to interact with C/C++
programs, typically used for tasks such as file I/O and other system-level interactions.
PLI involves creating a C/C++ function, registering it with the simulator, and invoking it from
Verilog/SystemVerilog.
VPI is an interface for interacting with the Verilog simulation environment from C/C++
programs. It provides more control and capabilities compared to PLI.
VPI involves creating and registering C/C++ functions and calling them from SystemVerilog.
Page 66 of 70
SV Miscellaneous
FLI is an interface for interfacing with foreign languages (typically VHDL). It allows for
mixed-language simulation environments.
FLI usage is more common with VHDL simulators and requires specific tools and
methodologies provided by the simulator vendors.
Compiler directives in SystemVerilog are commands that control the compilation process, such
as defining macros or including files.
Page 67 of 70
SV Miscellaneous
Pragmas are special instructions to the compiler to alter its behavior or to provide additional
information.
Pragmas are typically vendor-specific and used for optimization or special processing.
Attributes are metadata annotations attached to language constructs that provide additional
information to tools.
Page 68 of 70
SV Miscellaneous
Macros in SystemVerilog are used to define reusable pieces of code that can be expanded inline
during compilation.
Macros are defined using `define` and used with the macro name.
File I/O in SystemVerilog allows reading from and writing to files, useful for testbenches and
logging.
You use the built-in file I/O system tasks like `$fopen`, `$fclose`, `$fwrite`, and `$fscanf`.
Page 69 of 70