SV Interview Question
SV Interview Question
System verilog
Basic Level
Questions
2
Both bit and byte are 2-state data types and can store 8-bit or 1-byte data. The difference
between them is that ‘bit’ is unsigned whereas ‘byte’ is a signed integer.
2. What is the difference between bit and logic?
A bit is a 2-state data type having values as 0 or 1 whereas logic is 4 state data type
having values as 0, 1, x, z.
3. Why logic is introduced in SV? Or Why reg and wires are not sufficient?
4. Difference between reg and logic?
Both are 4 state variables. Reg can be only used in procedural assignments whereas
logic can be used in both procedural and continuous assignments
Both can hold 32-bit signed integer values. The main difference between them is
integer – 4 state data type
int – 2 state data type
7. Difference between packed and unpacked arrays
Memory needs to be allocated before using it For bounded queues, the size needs to be allocated.
i.e. array size is required to be allocated first. For unbounded queue can store unlimited entries.
The size can be increased using a new [ ] For unbounded queues, the size of the queue expands
method to find out larger contiguous memory using push_back or push_front methods. The new
space and existing array elements get copied in data elements get added similar to linked list node
new space. addition.
initial begin
a = 2'd3;
b = 2'd2;
out = a**b;
4
A pass-by-reference argument passing mechanism does not copy arguments locally but
reference to the original arguments is passed. This also means that any change in values
for the argument inside the subroutine will affect the original values of the variables,
function int fn_multiply(ref int a, b);
0 0 1 1
1 1 1 1
0/1 x/z x 0
5
x x x 1
z z x 1
x z x 0
17. What are SystemVerilog interfaces and why are they introduced?
System Verilog provides an interface construct that simply contains a bundle of sets of
signals to communicate with design and testbench components.
Why are they introduced?
In Verilog for the addition of new signals, it has to be manually changed everywhere
that module has been instantiated. System Verilog made it easier to add new signals in
the interface block for existing connections.
Advantages:
1. It has increased re-usability across the projects.
2. A set of signals can be easily shared across the components bypassing its handle.
3. It provides directional information (mod ports) and timing information
(clocking blocks).
4. Interfaces can contain parameters, variables, functional coverage, assertions,
tasks, and functions.
5. Interfaces can contain procedural initial and always blocks and continuous
assign statements.
18. What is modport and clocking block?
The initial block executes at the start of a final block executes at the end of the
simulation at zero time units. simulation without any delays
6
Code coverage deals with covering design code metrics. It tells how many lines of code
have been exercised w.r.t. block, expression, FSM, signal toggling.
Functional coverage
Functional coverage deals with covering design functionality or feature metrics. It is a
user-defined metric that tells about how much design specification or functionality has
been exercised.
22. Different types of code coverage.
Code coverage deals with covering design code metrics. It tells how many lines of code
have been exercised w.r.t. block, expression, FSM, signal toggling.
23. Write rand constraint on a 3 bit variable with distribution 60% for 0 to 5 and 40% for
6,7. Write coverpoint for the same.
class rand_class;
covergroup c_group;
cp1: coverpoint value {bins b1= {[0:5]};
7
bins b2 = {[6:7]};
}
endgroup
endclass
2. Dynamic array in SystemVerilog: An array whose size can be changed during run
time simulation, is called dynamic array.
3. Associative array in SystemVerilog: An associate array is used where the size of a
collection is not known or data space is sparse.
8
Intermediate
level
questions
9
An array manipulation method find_index can be used for the indices of an associative
array.
2. Difference between fork-join, fork-join_any, and fork-join_none
In fork-join, all processes start simultaneously and join will wait for all processes to be
completed.
In fork-join_any, all processes start simultaneously and join_any will wait for any one
process to be completed.
In fork-join_none, all processes start simultaneously and join_none will not wait for any
process to be completed.
So, we can say that fork-join and fork-join_any is blocked due to process execution time,
whereas fork-join_none is not blocked due to any process.
3. Difference Between always_comb and always@(*)?
always_comb always@(*)
Structure Class
A structure can contain different Classes allow objects to create and delete
members of different data types. dynamically.
10
Data members of structure are visible to Data members of class can be protected and
everyone will not be visible outside of class.
new() – To create an object for the class, commonly known as ‘class constructor’.
class transaction;
// class properties and methods
endclass
Shallow Copy:
The shallow copy is used to copy
1. Class properties like integers, strings, instance handle, etc
2. Nested objects are not copied, only instance handles are copied which means
any changes are done in ‘nested copied object’ will also reflect in the ‘nested
original object’ or vice-versa.
Deep Copy:
The deep copy is the same as shallow copy except nested created objects are also copied
by writing a custom method. Unlike shallow copy, full or deep copy performs a
complete copy of an object.
8. How does the OOP concept add benefit in Verification?
Object Oriented Programming concept introduce concept of class and object in
SystemVerilog similar to other programming language like C++, Java, Python, etc that
provides following benefits
1. Inheritance: An Inheritance allows users to create an extended class from the
existing class. This promotes code reuse and can lead to more efficient
verification by having common functionality in the base class.
2. Polymorphism: Polymorphism means having many forms. A base class handle
can invoke methods of its child class which has the same name. Hence, an object
can take many forms.It uses virtual methods tha helps to override base class
attributes and methods.
3. Data Encapsulation and Hiding: Data encapsulation is a mechanism that
combines class properties and methods. Data hiding is a mechanism to hide
class members within the class. They are not accessible outside of class scope.
This avoids class member modification outside the class scope and its misuse. By
default, all class members are accessible with class handles in SystemVerilog. To
restrict access, access qualifiers are used.
4. Code Readability and Maintainability: The organized way of coding in OOPs
provides readable and maintainable code which allows verification engineers to
write tests and also build hierarchical verification testbench.
9. What is inheritance?
An Inheritance allows users to create an extended class from the existing class. The
existing class is commonly known as base class or parent class and the newly created
extended class is known as a derived class or child class or subclass. This promotes code
12
reuse and can lead to more efficient verification by having common functionality in the
base class.
2. Improves code readability and easy for code maintenance as common logic can
be placed in the base class itself.
3. Provides an encapsulation that allows objects to expose only required
functionality.
4. A new class can be added easily instead of modifying existing class functionality.
Thus it enablesflexibility.
12. What is a virtual function?
A virtual function or task from the base class can be overridden by a method of its child
class having the same signature (same method name and arguments).
In simple words, When a child class handle is assigned to its base class. On calling a
method using a base class handle, the base class method will be executed. On declaring
a method as a virtual method, a base class handle can call the method of its child class.
Usage:
A virtual function from the base class can A pure virtual function is a method that
be overridden by a method of its child makes it mandatory for methods to be
class having the same signature (same implemented in derived classes whose
function name and arguments). prototypes have been specified in an
abstract class.
Declared by using the keyword ‘virtual’ in Declared by using the keyword ‘pure
the base class. virtual’ in the base class.
:/ Operator
1. For specific value: Assign mentioned weight to that value
2. For range of values ([<range1>: <range2>]): Assigns weight/(number of value) to
each value in that range
:= operator
static casting is only applicable Dynamic casting is used to cast the assigned values to
to fixed data types. the variables that might not be ordinarily valid.
Example: The same memory location is accessed by two different cores. To avoid
unexpected results when cores try to write or read from the same memory location, a
semaphore can be used.
Assertions are used to check design rules or specifications and generate warnings or
errors in case of assertion failures.
Types of assertions:
1. Immediate assertions – An assertion that checks a condition at the current
simulation time is called immediate assertions.
2. Concurrent assertions – An assertion that checks the sequence of events spread
over multiple clock cycles is called a concurrent assertion.
33. Difference between $strobe, $monitor and $display
System
Description
tasks
To monitor signal values upon its changes and executes in the postpone
$monitor
region.
To display strings, variables, and expressions at the end of the current time
$strobe
slot i.e. in the postpone region.
Example:
covergroup c_group;
cp1: coverpoint addr {ignore_bins b1 = {1, 10, 12};
ignore_bins b2 = {2=>3=>9};
}
18
illegal_bins b4 = {2=>3=>9};
}
endgroup
Copy
36. How do you define callback?
Difficult level
questions
20
Local access qualifiers: If a class member is declared as a local, they will be available
to that class alone. The child classes will not have access to a local class member of their
parent class.
Protected access qualifiers: A protected class member can not be accessed outside
class scope except access by their child classes.
std::randomize(value) with {
value inside {5, 10, 15, 20};
};
Copy
21
8. How will you test the functionality of interrupts using functional coverage?
The functionality of interrupt getting raised and being serviced by the testbench can be
verified by writing ‘Sequence of transitions’ coverpoint as follows
covergroup c_group;
This allows testing interrupt is generated due to the stimulus and testbench is calling an
appropriate ISR to service the interrupt.
9. What is layered architecture in Verification?
Layered architecture involves structuring the verification environment into various
layers or levels that help to provide abstraction, scalability, reusability, etc.
Testbench Top and Test Layer: The testbench top is a top-level component that
includes interface and DUT instances. It connects the design with the test bench. The
reset, clock generation, and its connection with DUT is also done in testbench top.
The test is at the top of the hierarchy that initiates the environment component
construction and connection between them. It is also responsible for the testbench
configuration and stimulus generation process.
Based on the design feature verification, a directed or constrained random test is
written. The test case generates stimulus based on configurations or
coverage, and assertion coverage, providing insights into the verification completeness
and identifying any areas that require additional testing.
Advantages of the layered approach:
1. Improved Verification Efficiency: Abstraction and modularity accelerate the
verification process.
2. Enhanced Reusability: Verification components can be reused across multiple
projects.
3. Better Test Coverage: A modular approach facilitates comprehensive testing.
4. Improved Maintainability: Focused components make verification code easier to
maintain and update.
10. How can you establish communication between monitor and scoreboard in
SystemVerilog?
The monitor observes pin-level activity on the connected interface at the input and
output of the design. This pin-level activity is converted into a transaction packet and
sent to the scoreboard for checking purposes.
The scoreboard receives the transaction packet from the monitor and compares it with
the reference model. The reference module is written based on design specification
understanding and design behavior.
Both are used to verify the correctness of the design in the verification environment
component. They are connected using a mailbox in a SystemVerilog-based verification
environment.
11. Difference between class-based testbench and module-based testbench.
12. How will be your approach if code coverage is 100% but functional coverage is
too low?
This can be possible when
1. Functional coverage bins (may be auto bins) generated for wide variable range
which is not supported by design.
2. Cross check if code coverage exclusions are valid so that it should not give false
interpretation of 100% code coverage.
3. Functional coverage implemented for feature (were planned during initial
project phasing), but those are not supported by the design now.
13. How will be your approach if functional coverage is 100% but code coverage is
too low?
This can be possible when
property glitch_detection;
realtime first_change;
24