System Verilog interview questions with answers



Comments



Description

What is the difference between initial and final blockof 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 System verilog Simulation Environment Phases As one uses system verilog as a verification language, one needs to understand how to setup and control the simulation environment to get maximum reporting without generating erroneous reports. Here are some pointers from “System verilog for Verification” by Chris Spear that will enhance your understanding of the simulation phases for system verilog. Build Phase – Generate configuration : Randomize the configuration of the DUT and surrounding and wait for the next lower layer.0. You should use time-out checkers to make sure the DUT or testbench does not lock up.0.0. as they may not be correct.0.0. You can use the testbench layers as a guide.0. . wait for the current layer to become idle. – Reset the DUT – Configure the DUT : Based on the generated configuration from the first step. sweep the testbench for lost data. 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. Starting from the top. Sometimes the scoreboard holds the transactions which never came out. wait for layer to drain all the inputs from the previous layer (if any). as opposed to physical components in the design that are built with RTL. be sure to delete any functional coverage results. Armed with this information. // packed array bit [7:0] packed_array = 8'hAA. A testbench component is one that only exists in the testbench. – Report : Once DUT is idle.1}. The "this" keyword shall only used within a non-static class methods otherwise an error shall occur.environment – Build environment : Allocate and connect the testbench components based on the configuration. If it failed. Wrap-up Phase – Sweep : After the lowest layer completes. you can create the final report on whether the test passed or failed. you need to wait for the final transactions to drain out of the DUT. Packed Array and Unpacked Array System Verilog uses the term packed array to refer to the dimensions declared before the object name (what Verilog-2001 refers to as the vector width). perhaps because they were dropped by the DUT. It is easy to tell when a directed test has completed. but doing so can be complex for a random test. "This " keyword in systemverilog "this" is a key word in System Verilog used to unambiguously refer to class properties or methods of current object. The term unpacked array is used to refer to the dimensions declared after the object name. // unpacked array reg unpacked_array [7:0] = '{0. alias mapping is direct connection of one inout port to other. A[1]. int a .class ASICwithAnkit .a).a = %d. its a short-circuit of wires module tomap ( inout [2:0] A. Alias is system verilog coding technique to model bi-directional mapping for ‘inout’ ports or wires in a module. AwA. // alias 1 alias B = {A[0]. A[2]}. 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.".a = a. endmodule Randomization You first create a class to hold a group of related random variables. B. this. and then have the random-solver fill them with random values. How to avoid race round condition between DUT and test bench in systemverilog verification A race condition is a flaw in a system or process that is characterized by an output that exhibits an unexpected dependence on the relative timing or ordering of events. 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. In particular. ). In other way. . $display ("AwA. function new (int a). endfunction : new endclass : ASICwithAnkit //Class instantiation and usage ASICwithAnkit AwA = new (123). module instances. It is best to evaluate and try it on your own. You may have a race within your DUT regardless of the race between your testbench and DUT. or other programinstances. The simulation will terminate when all program instances have exited. then a non-program blocks test bench might work better for you. both of which are covered by using a clocking block by itself. You have a race within your DUT regardless of the race between your testbench and DUT. has an extra system task $exit. Scheduling in the Reactive region can be done with clockingblocks. it really comes down to a methodology preference. Erroneous use of blocking assignments for sequential logic. a program block: cannot cannot contain always procedures. 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. queue([$]). the trend seems to be in favor of abandoning program blocks.As far as I can tell. which terminates the program instances that calls it. In the end. I still like using program blocks and use initial forever as an always equivalent when needed. or associative array ([*]) can be used for intelligently handling simulation terminate running multiple tests. specifies scheduling in the Reactive region. This is because the advantages can be achieved by other methods. interface instanc es (virtual interface and port interface is allowed). Erroneous use of non-blocking assignments in combinational gated clock logic. What are the advantages of systemverilog program block In a short. is mostly like a module block except as stated above. a program block by itself only addresses two race conditions between the testbench and DUT. primitive instances. From the last few conventions I been to. Personally. . This prevents race conditions. incomplete summary. A mailbox. If you are planning to use UVM. Logic : System verilog added this additional datatype extends the rand eg type so it can be driven by a single driver such as gate or module. Wires are constantly assigned and regs are evaluated at particular points. but can lead to issues in case of having to drive x's to stimulate data corruption and recovery. Its not a actual hardware register but it can store values. The main difference between logic dataype and reg/wire is that a logic can be driven by both continuous assignment or blocking/non blocking assignment. The usage of bit and byte would be more common in testbench components. . What is the difference between logic and bit in systemverilog reg and wire were the original types. The type bit and byte have also been created that can only hold 2 states 0 or 1 no x or z. Wire : Wire data type is used in the continuous assignments or ports list. Using these types offers a small speed improvement but I would recommend not using them in RTL as your verification may miss uninitialized values or critical resets. This introduces logic which can be used in place of wire and reg. Numerous methodologies already in use by RTL designers that eliminate races are sufficient for testbenches. Explain the difference between data types logic and reg and wire : Wire are Reg are present in the verilog and system verilog adds one more data type called logic. the advantage here is for the simulator to make optimisations. It is treated as a wire So it can not hold a value. 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. . byteimplies bit [7:0].Let me turn the question around: Why should anyone use a program block for their testbench. The earlier optimisation for the simulator can be done through the context of its usage. Wires are used for connecting different modules. It can be driven and read. Reg : Reg is a date storage element in system verilog. Register retain there value until next assignment statement. A common mistake when learning Verilog is to assume the a reg type implies a register in hardware. class (or similar nonmodule entity in SystemVerilog). These are methods that must be overridden in in the extended class. along with their directions (via modports) and synchronization details (via clocking block). By abstracting the connectivity and functionality of a set of blocks.What is the need of virtual interface ? An interface encapsulate a group of inter-related wires. 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). Virtual interfaces provide a mechanism for separating abstract models and test programs from the actual signals that make up the design. Instead of referring to the actual set of signals directly. Java uses the keyword 'abstract'. The major usage of interface is to simplify the connection between modules. SystemVerilog re-used the keyword virtual so as not to reserve another keyword. Base class libraries like the UVM are full of abstract classes and have methods that you must override. An abstract class that only contains pure virtual methods is called an interface class and you can define an interface class that implements multiple interface classes. To solve this issue virtual interface concept was introduced in SV. but other languages like C++ do not have a specific keyword. But Interface can't be instantiated inside program block. This allows the same virtual interface to be used in different classes. users are able to manipulate a set of virtual signals. like a copy or print method. What is abstract class in systemverilog Yes. It is most often used in classes to provide a connection point to allow classes to access the signals in the interface through the virtual interface pointer. A virtual interface allows the same subprogram to operate on different portions of a design and to dynamically control the set of signals associated with the subprogram. An abstract class is simply one where the constructor is protected and you cannot construct it directly. you must extend the class first and you can construct a derived object. Virtual interfaces can be declared as class properties. But they needed to be driven from verification environment like class. It provides a mechanism for separating abstract models and test programs from the actual signals that make up the design. virtual interfaces promote code reuse. . Abstract classes allow another concept with is a pure virtual method. Another big advantage of virtual interface is that class can dynamically connect to different physical interfaces in run time. Changes to the underlying design do not require the code using virtual interfaces to be rewritten. A virtual interface is a pointer to an actual interface in SystemVerilog. which can be initialized procedurally or by an argument to new(). an abstract class in SystemVerilog is the same as a virtual class. 0. $monitor . (newly added in SV. Their names begin with a dollar sign ($) $display. Which programming language is actually used as the foreign language is transparent and irrelevant for the System-Verilog side of this interface. however. Unlike an assert statement. an expect statement starts only a single thread of evaluation. It comes out of the blocking mode only if the property succeeds or fails. Different programming languages can be used and supported with the same intact SystemVerilog layer. SystemC as well as others. z and x) System Tasks and Functions These are tasks and functions that are used to generate input and output during simulation. These Foreign languages can be C. Neither the SystemVerilog compiler nor the foreign language compiler is required to analyze the source code in the other’s language. C++. but it must occur within a procedural block (including initial or always blocks. Both the layers are isolated from each other. SystemVerilog defines a foreign language layer only for the C programming language.What is difference between $random() and $urandom() $random system function returns a 32-bit signed random number each time it is called $urandom system function returns a 32-bit unsigned random number each time it is called. For now. and is used to block the execution until the property succeeds. DPIs consist of two layers: A SystemVerilog Layer and a Foreign language layer. $strobe. not present in verilog) What is expect statements in assertions An expect statement is very similar to an assert statement. SystemVerilog DPI (Direct Programming Interface) is an interface which can be used to interface SystemVerilog with foreign languages. tasks and functions). all other will result in x) === tests 4-state logical equality (tests for 1. What is the difference between == and === == tests logical equality (tests for 1 and 0. width. When randomized. Its basically like templates in C++. this class generates a set of ten unique values from 0 to 15. how to generate array without randomisation in systemverilog The new unique constraint lets you use one statement to constrain a set of variables or array elements to have unique values.Separate static members for each different type Parameterized classes can be extended (inherited). In the system verilog you can parameterize the types also. and more With Verilog parameter notation Class type can also be a parameter .* implicit port connections. If the assertion module uses the same signal names as the target module.Define operations which can be used with different types Each different type parameter creates a different class declaration.What is systemverilog assertion binding and advantages of it Generally you create a SVA bind file and instantiate sva module with RTL module.Qualified with keyword type . the bind file port declarations are still required but the bind-instantiation can be done using the SystemVerilog . . Parameterized Classes in System Verilog : System verilog allows prameterized classes. SVA bind file requires assertions be wrapped in module that includes port declaration. If signal names are not exactly matching between target and bind file module then we need to expand the instantiation with respected port names. . 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. Like in classes can be parameterized for size. stored as two different entities in the memory space). whereas always @* is only sensitive to changes to the arguments of a function. Shallow Copy: Simply makes a copy of the reference to A into B. Here you can see the method name. parameter and return type are same but one method is in the parent class and another one in the child class.e.When randomized. Think about it as a copy of A's Address. What is the difference between always_comb() and always@(*) always_comb is sensitive to changes within the contents of a function. Here you can see the functions name are same but parameter type and number of parameters are different. 7 and 15.e. What is the difference between overriding and overloading Overloading When two or more methods (functions) in the same Class have the same name but different parameters is called method overloading. number of parameters. where you know that they both are totally the same. if A becomes non-existant B is still valid in the memory. You can also . and types of parameters as the method in the parent class is called method Overriding. they will be pointing to the same memory location i. In this way.e. the addresses of A and B will be the same i. The correct term to use would be cloning. So. this class generates a set of ten unique values excluding the values 0. allocates memory in a different location for B and then assigns the copied members to B to achieve deep copy. Deep copy: Simply makes a copy of all the members of A. Overriding When two or more methods (functions) have the exact same method name. but yet different (i. return type. data contents. provide your clone wrapper where you can decide via inclusion/exclusion list which properties to select during deep copy. .
Copyright © 2024 DOKUMEN.SITE Inc.