System Verilog Interview Questions With Answers
System Verilog Interview Questions With Answers
of systemverilog?
The basic difference between these two are evident from the nomenclature, i.e,
Initial block starts getting executed during simulation time t=0 while the Final block
gets executed when the simulation is completed.
Before getting into details, there is one similarity between these two sequential
block of codes, both of them gets executed only once during the simulation
Now getting back to the difference between Initial and Final blocks, Initial blocks can
contain some # delays or wait statements or some wait for events, but the Final
block should not contains any such things.
Final block should get executed with 0 simulation time. Ideally this is used for test
case status reporting or some display statements that have to be printed after the
test case execution is completed
environment
Build environment : Allocate and connect the testbench components based on the
configuration.
A testbench component is one that only exists in the testbench, as opposed to
physical components in the design that are built with RTL.
Reset the DUT
Configure the DUT : Based on the generated configuration from the first step, load
the DUT command registers
Run Phase
Start environment : Run the testbench components such as BFMs and stimulus
generators
Run the test : Start the test and then wait for it to complete. It is easy to tell when
a directed test has completed, but doing so can be complex for a random test. You
can use the testbench layers as a guide. Starting from the top, wait for layer to
drain all the inputs from the previous layer (if any), wait for the current layer to
become idle, and wait for the next lower layer. You should use time-out checkers to
make sure the DUT or testbench does not lock up.
Wrap-up Phase
Sweep : After the lowest layer completes, you need to wait for the final
transactions to drain out of the DUT.
Report : Once DUT is idle, sweep the testbench for lost data. Sometimes the
scoreboard holds the transactions which never came out, perhaps because they
were dropped by the DUT. Armed with this information, you can create the final
report on whether the test passed or failed. If it failed, be sure to delete any
functional coverage results, as they may not be correct.
class ASICwithAnkit ;
int a ;
function new (int a);
this.a = a;
endfunction : new
endclass : ASICwithAnkit
//Class instantiation and usage
ASICwithAnkit AwA = new (123);
$display ("AwA.a = %d,", AwA.a);
Alias
is system verilog coding technique to model bi-directional mapping for inout ports
or wires in a module. In particular, alias mapping is direct connection of one inout
port to other. In other way, its a short-circuit of wires
module tomap
(
inout [2:0] A, B;
);
// alias 1
alias B = {A[0], A[1], A[2]};
endmodule
Randomization
You first create a class to hold a group of related random variables, and then have
the random-solver fill them with random values.
In systemverilog which array type is preferred for memory declaration and why
Modeling memories larger than a few megabytes should be done with an
associative array. Note that each element in an associative array can take several
times more memory than a fixed-size or dynamic memory because of
pointer overhead.
As far as I can tell, a program block by itself only addresses two race conditions
between the testbench and DUT, both of which are covered by using a clocking
block by itself.
Erroneous use of blocking assignments for sequential logic. You have a race within
your DUT regardless of the race between your testbench and DUT.
Erroneous use of non-blocking assignments in combinational gated clock logic. You
may have a race within your DUT regardless of the race between your testbench
and DUT.
The idea of a program block is to create a clear separation between test and design
Today the opinion of usefulness of a program block is divided. From the last few
conventions I been to, the trend seems to be in favor of
abandoning program blocks. This is because the advantages can be achieved by
other methods. Scheduling in the Reactive region can be done with clockingblocks.
A mailbox, queue([$]), or associative array ([*]) can be used for intelligently
handling simulation terminate running multiple tests. Personally, I still like
using program blocks and use initial forever as an always equivalent when needed.
If you are planning to use UVM, then a non-program blocks test bench might work
better for you.
In the end, it really comes down to a methodology preference. It is best to evaluate
and try it on your own.
Let me turn the question around: Why should anyone use a program block for their
testbench, if everything works fine without them?
The developers of the AVM and OVM do not believe that program block solve timing
problems on their own. Numerous methodologies already in use by RTL designers
that eliminate races are sufficient for testbenches.
You can also add other non-random variables to the set of unique values which has
the effect of excluding the values of those variables from the set of unique values.
When randomized, this class generates a set of ten unique values excluding the
values 0, 7 and 15.
Shallow Copy:
Simply makes a copy of the reference to A into B. Think about it as a copy of A's
Address. So, the addresses of A and B will be the same i.e. they will be pointing to
the same memory location i.e. data contents.
Deep copy:
Simply makes a copy of all the members of A, allocates memory in a different
location for B and then assigns the copied members to B to achieve deep copy. In
this way, if A becomes non-existant B is still valid in the memory. The correct term
to use would be cloning, where you know that they both are totally the same, but
yet different (i.e. stored as two different entities in the memory space). You can also
provide your clone wrapper where you can decide via inclusion/exclusion list which
properties to select during deep copy.