Professional Documents
Culture Documents
build
connect
end of elaboration
start of simulation
run
extract
check
report
4. Semaphores ?
Semaphore methods
Semaphore is a built-in class that provides the following methods,
rand: The attributes or data structures declared as rand are standard random variables and
their values are uniformly distributed over the range. Think of a rolling dice where each roll
could be a new value or repeat the current one.
1. class Packet;
2. rand bit [2:0] data; // keyword --> rand
3. endclass
4.
5. module tb;
6. initial begin
7. Packet pkt = new;
8. for (int i=0; i<7; i++) begin
9. pkt.randomize();
10. $display("ite = %0d data = 0x%0h", i , pkt.data);
11. end
12. end
13. endmodule
randc: In case of randc, it is random cyclic, so the random solver does not repeat a random
value until every possible value has been assigned. Think of dealing cards from a deck where
you deal out every card in the deck in random order, then shuffle the deck, and deal out the
cards in a different order.
1. class Packet;
2. randc bit [2:0] data; // keyword --> randc
3. endclass
4.
5. module tb;
6. initial begin
7. Packet pkt = new;
8. for (int i=0; i<7; i++) begin
9. pkt.randomize();
10. $display("ite = %0d data = 0x%0h", i , pkt.data);
11. end
12. end
13. endmodule
1. typedef struct {
2. int value = 0;
3. }num[N];
4. num numbers;
5.
6. int temp = 0;
7. // This loop needs to be run for a very long time. The time of
8. // the loop will be dependent on the random generator [Rand_Range]
9. // It will be generating for a very large number of times.
10.
11. for (int i=0; i<100; i++)
12. {
13. temp=Rand_Range(); // Random
Generation
14. if (number_check[temp].valid==0)
15. {
16. number_check[temp].valid=1;
17. numbers[i].value=temp;
18. }
19. }
randc : randomized cyclically over their range but randomization takes places in such a
way that no value is repeated until all the values in their range are assigned
randc are random cyclic that randomly iterates over all the values in the range and no value is repeated
with in an iteration until every possible value has been assigned.
6. Types of forks?
Fork Join None: The parent process continues to execute concurrently with all the processes spawned by
the fork. The spawned processes do not start executing until the parent thread executes a blocking
statement.
Fork Join Any: The parent process blocks until any one of the processes spawned by this fork completes.
For Join All: The parent process blocks until all the processes spawned by this fork complete.
Result = X - Y; //Line 2
Result = X + Y; //Line 4
end
end
Result = X - Y;
Result = X + Y;
end
end
You can create a truth table as follows for all possible cases of X, Y and Z that can
cause result to be true or false. The expression coverage gives a measure of if all
the rows of this truth table are covered.
5) Toggle coverage: Toggle coverage measures how well the signals and ports in
the design are toggled during the simulation run. It will also help in identifying
any unused signals that does not change value.
6) FSM coverage: FSM coverage measures whether all of the states and all
possible transitions or arcs in a given state machine are covered during a
simulation.
The UVM register model provides a way of tracking the register content of a DUT
and a convenience layer for accessing register and memory locations within the
DUT. The register model abstraction reflects the structure of the design
specification for registers which is a common reference for hardware and
software engineers working on the design.
Some other features of RAL include support for both front door and back door
initialization of registers and built in functional coverage support.
my_sequence_c seq;
seq = my_sequence_c::type_id::create(“my_seq“)
40. Factory
UCM Factory is used to manufacture (create) UVM objects and components. Apart from
creating the UVM objects and components the factory concept essentially means that you
can modify or substitute the nature of the components created by the factory without
making changes to the test bench.
For example, if you have written two driver classes, and the environment uses only one of
them. By registering both the drivers with the factory, you can ask the factory to substitute
the existing driver in environment with the other type. The code needed to achieve this is
minimal, and can be written in the test.
47. M-sequencer
When a sequence is started, it is always associated with a sequencer on
which it is started. The m_sequencer handle contains the reference to the
sequencer on which sequence is running. Using this handle, the sequence can
access any information and other resource handles in the UVM component
hierarchy.
48. About APB
49. Constraints for ascending order without system task
50. Polymorphism
Polymorphism is a generic term that means 'many shapes'. In C++ the simplest form of Polymorphism is
overloading of functions, for instance several functions called SortArray( arraytype ) where sortarray might be
an array of ints, or doubles.
::::::::::::::
shape.h
::::::::::::::
#ifndef SHAPE
#define SHAPE 1
class Shape {
public:
void setsize(int owbig);
virtual float getarea() {};
protected:
int givensize;
};
#endif
::::::::::::::
shape.cpp
::::::::::::::
#include "shape.h"
::::::::::::::
square.h
::::::::::::::
#include "shape.h"
float Square::getarea() {
float result = givensize * givensize;
return (result);
}
::::::::::::::
circle.h
::::::::::::::
#include "shape.h"
float Circle::getarea() {
float result = 3.14159265f * givensize;
return result;
}
::::::::::::::
polygon.cpp
::::::::::::::
#include
#include "circle.h"
#include "square.h"
main () {
int np = 10;
Shape *jigsaw[np];
return (0);
}
51. Interface
52. Modport
Modport restrict interface access within a module based on the direction declared. Directions of signals
are specified as seen from the module.
e.g.
interface intf (input clk);
logic read, enable,
logic [7:0] addr,data;
base class.
1) build_phase()
2) connect_phase()
3) end_of_elaboration()
2. Run time phases – These phases can consume time and this is where most of
the test execution happens.
1) start_of_simulation()
2) run_phase()
1) pre_reset
2) reset
3) post_reset
4) pre_configure
5) configure
6) post_configure
7) pre_main
8) main
9) post_main
10) pre_shutdown
11) shutdown
12) post_shutdown
3. Clean up phase – This phase execute after the test ends and is used to collect,
and report results and statistics from the test. This consists of following sub
phases:
1) extract()
2) check()
3) report()
4) final()
60. Config_db
61. Difference between function and task
62. What are blocking and non-blocking assignments
63. Function coverage-90% code coverage- 100%. How to improve
functional coverage?
Logic and wire are almost the same except wire can be driven by multiple sources. Logic can only driven by
single source.
1. A wire is a data type that can model physical wires to connect two
elements. Wires can only be driven by continuous assignment statement
and cannot hold onto value if not driven. Wires can hence only be used to
model combinational logic.
2. A reg is a data type that can model a storage element or a state. They need
to be driven by an always block and cannot be driven by continuous
assignment statement. A reg can be used to model both sequential and
combinational logic
3. A logic is a new data type in SystemVerilog that can be used to model both
wires and state information (reg). It also is a 4 state variable and hence can
hold 0, 1, x and z values. If a wire is declared as a logic (wire logic), then it
can be used to model multiple drivers and the last assignment will take the
value.
Following are some examples of system tasks and functions (categorized based
on functionality).
For a complete list, one should refer to LRM.
The Moore model contains the machines that have an entry The Mealy model only uses Input Actions, a
action, and the output depends only on the machine's state. the output depends on the state and t
previous inputs provided during the program
The Moore model is used to design the hardware systems. The Mealy model is used to design bo
hardware and software systems.
The output of the Moore machine depends only on the state The output of the Mealy machine is t
because the program is written in the state only. The output combination of both input and the state.
of the Mealy machine depends on the state as well as on the
input also.
When we make signal changes, the state variables also have The Moore machine doesn't have glitch
some delay. and its output is dependent only on stat
not on the input signal level.
endinterface: simple_bus
For example:
class B;
int
endclass
program main;
initial
begin
B b1;
B b2;
b1 = new();
b1.i = 123;
b2 = b1; // b1 and b2 point to the same memory. The properties did not get copied.
$display( b2.i );
end
endprogram
RESULTS:
123
RESULTS:
123
321
If the value of b1 change, it will also change the value of b1. It's because it's pointing to the same memory.
A deep copy copies all fields, and makes copies of dynamically allocated memory pointed to by the fields. To
make a deep copy, you must write a copy constructor and overload the assignment operator, otherwise the
copy will point to the original, with disasterous consequences.
EXAMPLE:
class A;
int i;
endclass
class B;
A a;
endclass
program main;
initial
begin
B b1;
B b2;
b1 = new();
b1.a = new();
b1.a.i = 123;
b2 = new b1;
b2.copy(b1.a);
$display( b1.a.i );
$display( b2.a.i );
b1.a.i = 321;
$display( b1.a.i );
$display( b2.a.i );
end
endprogram
RESULTS:
123
123
321
123
146. Polymorphism
Polymorphism allows an entity to take a variety of representations. Polymorphism means the ability to
request that the same Operations be performed by a wide range of different types of things. Effectively, this
means that you can ask many different objects to perform the same action. Override polymorphism is an
override of existing code. Subclasses of existing classes are given a "replacement method" for methods in the
superclass. Superclass objects may also use the replacement methods when dealing with objects of the
subtype. The replacement method that a subclass provides has exactly the same signature as the original
method in the superclass.
EXAMPLE: with virtual
class A ;
virtual task disp ();
$display(" This is class A ");
endtask
endclass
class EA extends A ;
task disp ();
$display(" This is Extended class A ");
endtask
endclass
program main ;
EA my_ea;
A my_a;
initial
begin
my_a = new();
my_a.disp();
my_ea = new();
my_a = my_ea;
my_a.disp();
end
endprogram
RESULTS
This is class A
This is Extended class A
An interface encapsulate a group of inter-related wires, along with their directions (via
modports) and synchronization details (via clocking block). The major usage of interface is
to simplify the connection between modules.
But Interface can't be instantiated inside program block, class (or similar non-module entity
in SystemVerilog). But they needed to be driven from verification environment like class. To
solve this issue virtual interface concept was introduced in SV.
Virtual interface is a data type (that implies it can be instantiated in a class) which hold
reference to an interface (that implies the class can drive the interface using the virtual
interface). It provides a mechanism for separating abstract models and test programs from
the actual signals that make up the design. Another big advantage of virtual interface is that
class can dynamically connect to different physical interfaces in run time.
148. Coverage’s
149. Phases in UVM
150. Ethernet explain
151. Difference between combinational and sequential circuit?
152. SV architecture and explain
153. Clocking block
1) What if design engineer and verification engineer do the same mistake in Test bench BFM(Bus Functional
Model) and RTL(DUT)? How can you able to detect errors?
2) If you got a failure from the customer, how do you debug this? How do you prevent it to happen again?
Answer: 1. First, try to reproduce the problem in your own environment. Try to get customer's vector, so you
can inject the same vector to create the problem in house.
2. If you confirm the problem and fix them, you should put the new assertion or test to catch the
problem again. Add this new test in the future test plan, so the problem will not happen again.