How to Randomize non-random variable in System Verilog


System Verilog is industry adopted very popular hardware descriptive language, most of the companies in industry have been using this language for complex SOC, ASIC design and verification.

System verilog has various ways you can randomize values and fields to generate random stimulus for complex system verification. Randomizing variables and fields which are declared as rand are easy to randomize with or without constraints. In system verilog you can just do object.randomize() and all variables and fields declared as rand will gets random values during the simulation. 

There could be different situation where one require to know how to generate random values for variables which are not declared as rand? The answer is scope randomize function (std::randomize())

std::randomize() is a scope randomize function that enables users to randomize data in the current scope. This method is also very useful if some variables required to be randomized are not part of a class. 

Lets understand this with simple example:

module my_module;

  bit [15:0] address;

  bit [31:0] data;

  function bit my_test ();

    bit pass;

    bit read_write;

    pass = std::randomize(address, data, read_write);

    return read_write;

  endfunction

endmodule

In this example, if you notice, we are using all these variables for scope randomize function. When you run this type of code usage, it std::randomize function will randomize all variables in its scope to generate random values without needing to use .randomize() method.

Now that we learn to randomize variable which are not rand in nature, you might have question what about constraints? How should we write constraints in this method. Good news is, you can. You can provide your constrains using "with" something like below:

pass = std::randomize(address, data, read_write) with {read_write -> address > 'h000F ;};

Hope you find this information useful. Stay tuned for more interesting stuffs about verification!

-ASIC With Ankit





My visit to DAC2022 at San Francisco!

Design Automation Conference was held at Moscone Centre in San Francisco from 10 Jul 2022 to 14 Jul 2022. Abiding by COVID safety protocols, it was great to see in-person participation!

The Design Automation Conference (DAC) is recognized as the premier conference for design and automation of electronic systems. The conference is devoted to Electronic Design Automation (EDA), Intellectual Property (IP), Embedded Systems and Software (ESS), IoT, Automotive Systems, Artificial Intelligence and Machine Learning (AI/ML), Security and Design on Cloud. 

This year, DAC focused a lot on Machine/Deep learning & AI techniques, EDA on cloud and security verification. It was an honor and privilege to share that I will be chairing Front End Design session at 59DAC at San Francisco. Are you attending 59DAC?

As demand for more application-specific chips increasing, the EDA community is relying on ML techniques. ML was discussed at the silicon level, where the industry is looking forward to developing more and more ML and neural networking processors and also discussed about using ML to optimize various aspects of the life cycle of semiconductor engineering.

Many technical presentations and tech talks also covered the ML, There were panels to discuss how ML and AI could be used in design verification and implementation domains. 

Security verification was one of the key topic for which I was given opportunity to chair the session. Great presentation from different companies and university. Session topic was "New Developments in security verification and controlling unpredictable behavior" For details on this session click here & here


Intel had Intel Foundry service booth at DAC too! Intel Foundry Services (IFS), have been engaging deeply with automotive OEMs to understand their foundry needs and how they can help support increasing demand and the industry’s transition to more compute-intensive applications. Intel Foundry Services (IFS) has also launched the Cloud Alliance, the newest addition to IFS Accelerator ecosystem. Through this alliance with key cloud providers and experts in electronic design automation EDA, Intel will ensure that manufacturing customers have a more secure and more efficient process to bring their products to life. Some pictures from IFS booth at Intel

Hon'ble Minister of Industries, Tamil Nadu, India. Mr. Thiru Thangam Thennarasu held a meeting with Dr. Randhir Thakur, President, Intel Foundry Services and discussed the opportunities in the emerging semiconductor segment.
Intel had great present at DAC, Bob Brennan, VP, GM, Intel Foundry Services, Customer Solutions Engineering had great presentation at Tech Talk DAC pavilion on "Open Architectures to Accelerate Industry Growth" Mr. Rahul Goyal, VP, VP, GM Intel Foundry Services was invited and participated in two successful event, DAC panel to discuss on important topic "Create Robust EDA & IP Ecosystems to strengthen the global semiconductor supply chain" and second one was Ansys Gold couch event, 1:1 interview with John Lee, GM and VP Ansys! Overall Great DAC2022!

I also got an opportunity to meet industry experts, share and learn lot of exciting stuffs from them. Best part of the DAC this year from networking was to got and opportunity to meet very well known experts in semiconductor industry, Mr Shiv Tasker, Global Vice President, Semiconductor at Capgemini, Mr. Nitin Dahad, Editor in Chief of www.embedded.com and corespondent for EETimes and my good friend Mr. Shankar Hemmady, Director at Intel Foundry Services. We had great chat at 39th floor at Marriot San Francisco. What a great meeting and conversation. Photo from our meet at Marriot, San Francisco. I like Nitin's post on LinkedIn, Click on the link to see what Nitin has to say about our meeting :) "Influencers at Design Automation Conference at the top of their game and on top of the world"

DAC is a place to meet your former colleagues. I had a great time catching up with them. It was also great to meet many engineers, customers, partners and industry experts. DAC also had interesting posters from young engineers from academic which was assuring that industry continue to evolve in safe hands. At DAC, I also met vendors! The vendors at their respective booths showed their new tools flows and methodologies (TFM), attracting audiences with their presentations, supporting talks, quizzes with some fun time and goodies :)

Thank you, DAC! Thanks to all DAC committee members, organizer, sponsorers, contributors, partners and audience who participated to make this DAC a success ! Already waiting for DAC2023! 

Thanks,

Design Automation Conference 2022 (59DAC) at San Francisco - Lets meet, share, learn and network!

 


Its an honor and privilege to share that I will be chairing Front End Design session at 59DAC at San Francisco. Are you attending 59DAC? Let’s meet, share, learn and network. Details at LinkedIn post here 


Front Design Session for which I have given an opportunity to Chair @DAC

https://lnkd.in/gZNgGtxi 


DAC Conference website for more details


The Design Automation Conference (DAC) is recognized as the premier conference for design and automation of electronic systems. The conference is devoted to Electronic Design Automation (EDA), Intellectual Property (IP), Embedded Systems and Software (ESS), IoT, Automotive Systems, Artificial Intelligence and Machine Learning (AI/ML), Security and Design on Cloud. 

 

The 2022 Design Automation Conference (DAC 2022) will be held July 10–14 in San Francisco, CA, at the Moscone Center West.

 

If you are visiting DAC this year, please send me an email, I will be happy to meet, share and learn. Stay tuned for more details!  


Thanks,

ASIC With Ankit

System Verilog "ref" is a nice reference instead of "value"



Pass by reference is an interesting and very useful feature in system verilog. Very useful and importatn topic to understand and you might hit this as interview question in your next verification interview. This one is one of the very commonly asked interview question. Lets understand...

To begin, lets understand basic concept for pass by value vs pass by reference. In verilog, method arguments takes as pass by value (this is default). The inputs are copied when the method is called and the outputs are assigned  to relevant outputs when exiting the method. 

In system verilog, methods can also have "pass by reference". In this case, arguments passed by reference are not copied into subroutine area instead, a reference to the original arguments are passed to subroutine. In this case subroutines can access the arguments data via reference.  

This is very efficient way of passing arguments like class objects or arrays of objects. Scenario like these where you are dealing with class  objects and arrays of objects, if you use pass by value it would create a consume lot of memory on the stack because it has to copy the values and then use it for subroutine. Another advantage of using pass by reference is, since the caller and the function/tasks shares the same reference, any change done inside function using reference would also be visible to the caller. 

Example:

function automatic int my_crc (ref byte data [10:1]);

  for (int j =1; j<=10; j++) begin

    my_crc ^= data[j];

  end

endfunction

In this example, you can see data is declared with "ref" meaning, each call to CRC in for loop, my_crc function does to need to create a copy of the data on stack memory. Memory would have been consumed more if you would not use "ref" and use it as pass by value (because in that case as mentioned, every time my_crc function calls, it would need to create a copy on stack memory)

Now, an obvious question!

What if user wants to make sure that the ref argument is not modified by the function?

Answer to this question is "const ref"!! We need to use const key word if you want to make sure that ref argument is not modified by the function. 

For same example:

Same function "my_crc" the argument can be declared as "const ref" to make sure the original data contents are not modified accidently by my_crc function. Very very useful feature to understand in the case where you want to make sure engineers don't modified original content accidently. 

function automatic int my_crc (const ref byte data [10:1]);

  for (int j =1; j<=10; j++) begin

    my_crc ^= data[j];

  end

endfunction


Now another obvious question!

Do we need to declare each arguments as "ref" if you have more than one argument in your task/function.

Answer is "NO". 

For example:

task my_task (ref int data[10], bit a, b)

In declaration like this, one needs to clearly understand each arguments to function/task can have direction which can be input, output or inout or ref. If no direction specified the default value of inputs are selected. If one argument is specifies the direction then all following arguments hold on to the same direction unless explicitly changed.

In above example, my_task, first argument is specifies "ref" direction and following variables does not explicitly specifies direction, a and b would be considered as pass by reference.

Hope this clears out some basic understanding of pass by value vs reference. 

Thanks,

ASIC With Ankit

ASIC With Ankit on AMIQ and testbench.in's recommended list of blogs

Thank you AMIQ  and Testbench.in for having ASIC With Ankit on recommended list of blogs.



Learning is Sharing and Sharing is Learning too! Lets all keep sharing and keep learning!

-ASICWithAnkit

System Verilog Array Randomization

System Verilog has different types of arrays that you can randomize to generate interesting scenario for the test bench you are working on. In SV we mainly have static array ,dynamic array and also queues that you can randomize, Lets deep dive in to each one of them to understand how you can use it with system Verilog:

Static Arrays:

class my_static_array;

   rand bit [3.0] my_array [8];

endclass

module my_testbench;

  my_static_array my_static_array_obj;

  initial begin

     my_static_array_obj = new ();

     my_static_array_obj.randomize();

     $display (“my randomize value =%p”, my_static_array_obj.my_array);

  end

endmodule

In above example, we have my_array declared as static array which is declared as rand so that you array will be randomize when you do class object.randomize in your module to generate random value for our static array, You can play around with this example by changing different seed to how it changes the random value w.r.t to different seed.

 

Dynamic Array:

As we know, Dynamic arrays are the array for which size will not be pre-determined during the declaration. Dynamic array declaration will have square bracket [ ]. Lest deep dive in to example to better understand its declaration and how you can randomize it:

 

class my_dynamic_array;

rand bit [7:0] my_array [] //dynamic array

//Adding some constraint to this array so we can constraint array during randomization

constraint c1 {my_array.size >2 ; my_array_size <=10;}

 

//Constraint each array index value to be equal to index+1

constraint c2 {foreach (my_array[i])

                          my_array[i] = i+1;

                            }

function void print_value ();

  foreach (my_array[i])

     $display(“my array value my_array[%0d] = 0x%0h”, i, my_array[i] );

endfunction

endclass

module my_testbench;

my_dynamic_array my_dynamic_array_obj;

initial begin

   my_dynamic_array_obj = new();  //create a memory for the class object

   my_dynamic_array_obj.randomize();  //randomize class with constraint provided

   my_dynamic_array_obj.print_value (); //calling function from class to print array value

end

endmodule

 

Try this example and play around by changing constraint for index value, array size and seed to see how it changes the value to create corner scenario.


Queue randomization

We can have a queue declared as rand and then later in test bench you can randomize the queue to create a random value generate from the queue elements, We can constraint and limit the queue size in the constraints. Lets deep dive in to the example to better understand declaration of the queue, how you can limit and constraint the size of the queue and how you can randomize the queue to generate random behavior for your test bench:

class my_queue_c;

rand bit [3:0] my_queue [$] // Queue declaration with rand to randomize it later

//constraint to limit the size of the queue

constraint c1 {my_queue.size() == 5;}

endclass

 

module my_testbench;

my_queue_c  my_queue_c_obj;

initial begin

   my_queue_c_obj = new ();

    my_queue_c_obj.randomize ();

   //Print values

  $display(“my queue value =%p”,   my_queue_c_obj.my_queue);

end

endmodule

Try this example and play around by changing constraint to change size of the queue and seed to see how it changes the value to create corner scenario.

Hope, this is useful simple example to understand randomization of arrays. Stay tuned for more simple but exciting post to learn System Verilog.

Keep reading and keep learning, stay tuned for more simple but exciting learning posts

-ASICWithAnkit

 

Future of 5G looks bright!


Dear Readers,

Hope everyone are doing great, staying safe and healthy in this challenging time! The whole world these days are covered with unexpected challenge, we are all in this together and will come out from this together. We are strong together. First of all I would like to express Thanks from bottom of my heart to all the Doctors, Nurses and medical staffs, Paramedics, Police officers, Home care workers, grocery store personnel, Delivery people, transit workers, Airline worker and anyone who works with the public and making everyone's life moving.

We all understand the typical and challenging situation around and we are together fighting strongly against and will come out from this too! We are together moving ahead with the new technologies like, IoT, Automotive, Artificial Intelligence, 5G networking, WiFi-6, Robotics, Health Care, Smart Cities, Connected Cars and many more technologies and applications. These days pretty much everything is very well accessed and in our palm through smart phones, internet and with 4G, LTE and 5G technology.

As 5G technologies have been continuously evolving, it will certainly change the way we spend our lives, our communications will be faster than you can imagine, When you imagine a future powered by 5G, connected factory devices that “talk” to each other, mobile internet-connected to multiple devices at the same time, different vehicles communicating with the roads they travel on, and accessibility of information at unprecedented speeds will come to mind.

Lot of companies are actively and aggressively working towards making 5G technology available for the world to connect quicker and faster. Once 5G is fully operational, there will no need for any kind of cable or wire to deliver entertainment or communications service to your mobile device, some companies have successfully introduced 5G-capable handsets, it might require more time for the proper availability of 5G. But it is expected that the maximum number of 5G connections would exist in the years to come. 5G is the future!! 

Thanks,
ASIC With Ankit

System Verilog Assertions (SVA) – Types, Usage, Advantages and Important Guidelines!

Dear Readers,


There was an article published by SmartPlay Technologies back in 2015 when I was working with them. It has very useful information to understand the usage, advantages, and guidelines about System Verilog Assertions (SVA).

ASICs continue to grow in size and complexities and in this case, traditional verification techniques are not sufficient to achieve verification confidence. In complex designs, debugging simulations is an ever-increasing challenge. To address these challenges assertion-based verification is found. Design and Verification engineers can place assertions in design or bind to design which will be useful to monitor, report and take action when incorrect behavior is detected. Assertions are playing a major role in test bench development which helps to achieve maximum confidence on bug-free design. Moreover, it can be used in simulations as well as in formal verification. It enables engineers to leverage the strength for block level, subsystem level and for chip level verification in order to reduce the overall effort and efficient verification closure. System Verilog Assertions are setting up a viable and effective standard in design and verification. An assertion adds an advantage in the debugging process and makes complex simulation debug easy.

The introduction of SVA added the ability to perform immediate and concurrent assertions for Design as well as for Verification. Assertions are used to validate design whether it is working correctly or not. Assertions can be useful to make sure ‘How good is the test case?’ Furthermore, it provides a means to measure the quality of the verification process through the creation of coverage using cover property feature of System Verilog assertion.
Questions are 


1. What type of System Verilog Assertions we have?
2. Where to put these assertions in our test bench development? 
3. How to implement these assertions?
4. Usage, Advantage
5. What are the important Guidelines for SVA implementation?

To find more details please read this blog post "System Verilog Assertions (SVA) Types, Usage Advantages and Important Guidelines" 

Thanks,
Ankit

Happy 2019!!


2019 has finally arrived like every new year. A new year always bring new challenges in many fields which will allow us to learn and grow even more!! Best wishes on this new year from us!

This time of the year is filled with moments of celebration, reflections, and resolutions- all of which are great for inspiration and making the necessary changes one has been thinking about in the past year. It is also the time to assess the year that has passed. So what happened during 2018 and what to do for a new year?

Lets all step back and self evaluate our self and list down all positive things that we think we are stronger and also list down weak points where we think we are lagging behind. Let's all try to focus on our weak areas and improve those. On this new year, let's all take some action items to work on and focus on improvements. I wish you all a happy new year, may this new year brings lots of energy to do more and more good things. 

Everybody expects life to have smooth way, nobody expects their life to have painful bumps like a 'ROLLER COASTER'! Things may go wrong in life, everything is up and down in life. Every year has new challenges and opportunities with lots of fun, learning !! Like every year this year was also an awesome year together. Let’s all step back for a few moments and think, list down all major good/bad events occurred to individual’s life. I must say… every event would teach you something to learn and accept a few things.. whether it is good or bad. Good events teach you how to share, celebrate and enjoy quality time while bad events teach you even more… like how to react, fight bad time, learn, accept and how to move forward with positivity. I strongly believe It’s a matter of how you look at it together.

Everyone has their own learning and experience from the past year and new thinking, the expectation from the new year! Like everyone we also learn many things nice way while some hard way….. but you learn in any case!

I wish new year would be 1000 time better than the past year for everyone! May this year brings lots of happiness and energy to do more and more good things for family, friends, and society.

Wishing you all very happy and healthy new year!!

With Love,
ASIC With Ankit

Happy Diwali & Prosperous New Year!


Diwali is the biggest and the brightest festivals celebrated by families around the world. Deepavali (actual name of Diwali) means "a row of lights." This auspicious day is also known as the "festival of lights. There is a saying “A Happiness can be found from darkest of dark if one knows how to switch on the light”! 

The evil need not necessarily come in the form of demons, it can come as depression, desperation, and frustration which can cause more damage. Diwali is a reminder to slay all that is negative to our life. 

There is so much happening during this whole week, people start preparing for Diwali, shops (e-shops J) are full of sales and there is light all over. People celebrate Diwali with many other things like firecrackers, visiting friends and family places and having lots of sweets! Well, I miss those days celebrating Diwali with lots of firecrackers and lights on streets with friends. A lot of regulation here, but still we manage to celebrate with some of the crackers in our patio J One of these years, I am going to take a vacation to celebrate Diwali back hometown to renew my Diwali spirit. On Diwali days, people use to do colorful rangoli at their house.

Diwali is one of the biggest and brightest festivals in India and we do celebrate it with full of enthusiasm and happiness. I would like to celebrate this Diwali by expressing thanks to all my friends, family members, near and dear ones! You all are awesome and I am lucky to have you all in my life. 

Diwali is the last day of Gujarati Year, Today, Vikram Samvat 2075 begins. So wishing you all a Happy New Gujarati Year. May this new year come with lots of happiness in your life.

May This Diwali be as bright as ever and brings joy, health, and wealth to you and your family. May this Diwali bring you the utmost in peace and prosperity. We wish you all a Happy Diwali and a prosperous new year!

Happy Diwali & Happy New Year!
ASIC With Ankit

System Verilog UVM Callbacks: Development and Usage

What is callback? If you know System Verilog, Easily explainable example is post_randomize() method which allows users to execute logic after an object has been randomized.
Callbacks are pre-defined hooks that allow users to influence a verification environment from outside the environment.

The UVM callbacks allow reusable environments to define our own hooks for our application needs. The main advantage of a callback is the ability to combine multiple extensions that are created by multiple teams into a single testbench.

How to Define Callbacks?

First thing, verification engineer to decide is to an interface to make available. Let’s take an example. Say for example you want to add a callback to modify a data packages after it is randomized. This can be implemented as below:


Second thing, we need to do is to register the callback type with the type that will use the callback. This registration enables UVM to do type checking when a user tries to add a callback to a specific object.


If you miss the registration, UVM issues a warning that the callback type was not registered with the object type.

Now, let’s understand how you insert the callback.
We will now insert a call to the callback functions in the code, UVM provides a utility macro to make the process very easy.


How to use Callback?

Now we have callback class defined and can be used as necessary in the testbench to modify the generated data before its driven on DUT. Now, let’s see how we use it in the test bench.


Once this is done, you need to attach the callback to a specific instance from your test case and then run a test. With this implementation when you run your simulation, this callbacks will update/modify randomized packets before driver drives it to the DUT signals.

This type of mechanism is useful in many places such as for error injection, data corruption, missed transaction etc…

Happy Reading,

UVM Sequencer and Driver - Basic concept

A sequencer is an advanced stimulus generator that controls the items provided to the driver and then driver executes those items during the simulation.

Generator randomizes arrays of transactions and sequencer controls the generation of random stimulus by executing sequences. The sequence has the meaningful stream of transactions which can contain random data items, parameters and user can also add constraints. A user can combine sequences to create complex traffic streams.

Now, let’s understand UVM Sequencer with some more details from very simple picture given below:





Typically sequencer waits for get_next_item() call from a driver, randomize the item data and then sends the data item to the driver for execution.

How to create a sequencer?
  • Derive sequencer from the uvm_sequencer base class and specify request and response type prameters.
  • Use `uvm_component_utils and constructor

With these, you can define the baseline for sequencer, with built in sequencers behavior you can generate a constrained random data with synchronizing driver and sequencers.

Driver and sequencer are connected by way of TLM with driver’s seq_item_port connected to the sequencer’s seq_item_export. Sequencer produces data and sends them through se_item_export and driver consumes data itesm through its seq_item_port as shown in the figure above. A response is optional. Connections are made by components that contain instances of the driver and sequencers.

Handshake between Driver and Sequencer:


Basic handshake is done using the task get_next_tem() and item_done(). Driver requests a randomized item from sequencer and block waiting for the sequencer to have an item available. When sequencer has an item available, it will provide it and the get_next_item() task will return this item. Driver signals the sequencer that the item was processed using item_done() after sending it to DUT.

Simple Example:

class my_sequencer externs uvm_sequencer #(my_pkt_transfer);
 `uvm_component_utils (my_sequencer)
  
   function new (string name, uvm_component parent);
     super.new (name, parent);
   endfunction : new

end class : my_sequencer

Let's understand sequencer from example sudo code:

`uvm_component_utils macro is used to register sequencer with the common factory. In the class definition above, by default, the response type is the same as the request type. If you expect the different response, an optional second parameter must be specified for the uvm_sequencer.
something like...

class my_sequencer externs uvm_sequencer #(my_pkt_transfer, my_pkg_response);

These are basic things to understand sequencer and definition of the sequencer to use it with the driver. We will continue on this for driver part and communication with Driver.

Hope, this is useful and clears some basic facts about sequencer and its usage. Feel free to shoot me an email  asicwithankit@gmail.com for any question on this or would like to understand more on this.

Happy Reading,

System Verilog Assertion Binding - SVA Binding

Dear Readers,

As we all know SV has become so popular in verification industry with its very good features and constructs which helps us verify today's complex designs. Today, I am going to discuss about SVA binding that we use in test bench for SVA properties.

There are VHDL and Verilog model we use to deal with these days. Mostly verification engineers are not allowed to modified these modules. But still SVA addition to these modules are required and easy to verify lot of RTL functionality. How can you add SVA to these modules? 

Here is where system verilog ‘bind’ comes in picture. Generally you create a SVA bind file and instantiate sva module with RTL module.

SVA bind file requires assertions be wrapped in module that includes port declaration, So now lets understand this with a small example to understand basic things on  how to use SVA bind : 

click on below image to enlarge.. 



DUT_Module - Dummy RTL module to understand this example
SVA_Module - Dummy SVA module with implemented assertion property
TB_Module - Dummy test bench code to see how bind works with module instantiation 

Here, you could see there is DUT instantiation created DUT_u1 instance of DUT_Module. Now point of interest for us would be, how to bind DUT instance to SVA module.

To understand this take a look at line number 50 in image from TB_Module, where you could see 'bind' keyword used with DUT_Module module and SVA_Module. This is the place where we are binding DUT module with SVA module. Thus passing DUT signal information to SVA module. With this we could play around with DUT signal and can check assertion properties using DUT signals available through this instantiation.

If the assertion module uses the same signal names as the target module, the bind file port declarations are still required but the bind-instantiation can be done using the SystemVerilog .* implicit port connections. If signal names are not exactly matching between target and bind file module then we need to expand the instantiation with respected port names.

Hope, this information on SVA binding is useful, stay in touch with me and share your views !

Thanks,

System Verilog : Functional Coverage Guidelines

We have been implementing every possible checks to make sure design is verified but what have we done to check our test bench ? How do we make sure that our test bench has covered everything that needs to be covered w.r.t to specification and test plans ? Here is the place “Functional Coverage” and “SVA” comes in picture!

Before we start on few guidelines to follow while working with functional coverage, I would encourage you to refer various posts on functional coverage and assertions to get high level idea on architecture and usage. Click on 1, 2, 3!


Now, Basic questions can come to mind is, "what is the difference between code and functional coverage?". Let’s understand it at high level and then we will move forward to understand guidelines for functional coverage.


Sr No

Code Coverage

Functional Coverage  and SVA

1

Derived from design code with the help of simulation tools

It is user specified, controlled approach coverage by test bench

2

Evaluate design code to check whether structure is covered or not

Measures functionality part with the help of covergroup, cover point and bins (with the help of luxury feature of System Verilog J)

(With SVA you can capture functional coverage using cover property)

To conclude with few guidelines from various posts on functional coverage and assertions:

Functional coverage and code coverage both are contributing highly on sign off criteria for verification. Verification engineers have to make sure that their test plan and test environment is intelligent enough to satisfy the code/functional coverage closer. Code coverage is generated by tool with the help of the simulations generated by the test environment. So test environment should be random and intelligent enough to make sure design is covered as a part of code coverage and designer should be in agreement while code coverage review. There should be valid comments with reason for all exclusions for code coverage w.r.t to design specification. Functional coverage should be written such a way that it should be able to capture all identified functionality while defining the test plan. Coverage and assertions are very important entity in the verification process and there are few guidelines that would help in verification process.

Few guidelines while working with functional coverage
  1. Your test plan should be based on the functionality you want to verify w.r.t to specification
  2. You should have a coverage matrix with the list of cover point details w.r.t to your test plan scenario and there should be link of traceability between test scenario and cover point.
  3. Environment should have control mechanism for enabling or disabling coverage and assertions for better control ability in your environment
  4. Don’t enable functional coverage at the beginning of the verification to avoid simulation overhead in the starting phase of verification
  5. During the initial time of the verification bug ration is typically high, as you move forward to the verification bug ration would start to drop. Here is the time when you should enable coverage and analyze it
  6. Functional coverage plan needs to be updated as verification progresses
  7. As your knowledge of the design and corner case understanding increases, you should keep updating your functional coverage plan
  8. Make effective use of cover group “trigger” and sampling mechanism. (Stay tune for sampling mechanism on upcoming blog post !)
  9. Follow meaningful names of cover group and cover points. This will help when you in debug process
  10. Coverage should not be captured on failing simulations. Make sure to gathered coverage for only passing simulation. If few tests are not passing in regression first make sure to fix those issues before come to a conclusion on coverage achievement
  11. If your tests are keep exercising the same logic in design, start developing the new tests for uncovered coverage part of coverage (coverage holes)
For guidelines on SVA, please refer to this article !

Stay tuned to understand functional coverage sampling mechanism !

Thanks,
ASIC With Ankit

What a 'logic' you have System Verilog !!


Before we understand the “logic” data type for system Verilog, Lets understand verilog data types “reg” and “wire”. Wire is used to connect gates or modules and are physical wire in a circuit and it must be driven by a continues assignment statements. “Reg” in Verilog is a data object that holds its value from one procedural statement to next. When we say "reg (register datatype)" it does not mean the register in the hardware or a physical register in circuit. This is the common mistake or assumption mostly engineers thinks while learning Verilog.

In System Verilog, it improved the classic “reg” data type so that it can also be driven by continues assignments. The name they given for data type is “logic” in System Verilog. It is 4 state (1, 0, X, Z) System Verilog data type.

Let’s take an example to understand the usage of logic data type

Example :

module Asic_With_Ankit (input logic xyz);

   parameter DELAY;
   logic a, b, c;

 initial begin
    a = 0;
    forever #(DELAY/4) a = ~a
  end


  assign c = ~c;

 endmodule


In above example, you can see statement “a = 0” is procedural assignment while statement “assign c = ~c” is a continues assignment. So the important point to understand here is “SV allowed continuous assignments to logic variables, whereas in Verilog, you can’t use continuous assignments to “reg” variables”

“logic” signal can be used anywhere a “net” used but there is one exception to this, you can not drive logic variable from multiple driver. In these type of cases, variable needs to be a net type such as “wire” so that SV can resolve the multiple values.

Logic type can only have a single drive, it can’t allowed multiple driver. This means we can declare all signal as logic to find if is there any multiple driver issue. Because in this case you should be able to see compilation issue if there is any multiple driver by declaring all signal with type “logic”. Of course for the signal you would like to have multiple drivers shall be declared as net type such as “wire” or “tri”.

So, logic data type is identical to “reg” in every way except in SV it improved reg with logic so that it can also be driven by continues assignment and there would not be any confusion on “reg” data type w.r.t to physical register in hardware J

Enjoy,
ASIC With Ankit

System Verilog Class : No numbers for class name please !


Dear Readers,

Today I am going to share you one limitation with system Verilog class definition. We know Class is the basic feature to understand if we have to learn System Verilog. Class is the basic construct, data type in System Verilog. Some of the class feature I highlighted in my couple of previous blog posts can be found from here and here.

Methodological approach to name system Verilog class and major advantages

As a verification engineer with a mindset of methodological test bench architecture we prefer to name all data types, variables, blocks with meaningful names and their objects so that anybody with little understanding of that environment will be easily able to understand why is that class defined or what is the significant of adding this parameter? Let me give you a small example:

For example, a team of 3-5 engineers have developed a complex SoC or Block level verification environment using system Verilog. Environment is such complex that it has many classes defined to perform certain functional verification. Now with methodological approach usually engineers defined their test environment by classifying various configurable parameters and feature control and transaction based features and they will develop environment to accommodate these features in respected class called configuration class and transaction class respectively. They have given a names for cfg and transaction class to “rx_dma_cntrl_cfg” and “rx_dma_cntrl_tr”. Here “_cfg” represents configuration class while “_tr” represents transaction class which is quite common approach in today’s test bench developments.

Why do we need to follow these type of small-small things?

Well, answer to this question is “there are many advantage of following these type of approach while developing your test environment at the same time it does not cost you much”

Advantages:
  1. It helps in debugging the complex test environment as we all know “debugging is not free” and it always consumes amount of time and bandwidth in the verification cycles but we can always try to reduce the debugging efforts by following these small steps.
  2. Helps engineer to understand environment structure. This will be more helpful when new person joins in the team to work on this type of developed environment. It will surely reduce the reamp-up time for engineer and can easily pick up the tasks to update/modify/enhance such type of test bench environments.
  3. Helps in maintenance, enhancement and for re-usability

Limitation (while naming meaningful name to class)

We cannot name class starting with numeric number like 0,1,2 etc.. ! Class name is not allowed to have numbers as first character. Meaning you can’t give a class name called “8_bit_dma_env” or “8bit_dma_env”. Simulation will throw an error if you use this approach, instead it can be defined like “eight_bit_dma_env” or “dma8_bit_env” this is allowed because you are not using numeric number as first character of class name.

Let’s take an example of small exercises to understand :

program ASIC_With_Ankit;

   class 1_byte_display_test;

   int a;
   byte awa = 8'hA5;

   task display ();

      $display ("Byte value =%h", awa);

   endtask

endclass

initial begin
    1_byte_display_test  bdt;

     bdt = new ();
     bdt.display ();

end
endprogram


Solution :

In above example, you can see the class name uses first character as numberic number “1” which is not allowed in system Verilog and when you try compiling this code, you will see an error given below. But if you try the same example with changing a name to “one_byte_display_test” or “byte1_display_test”, you would be able to compile the same exercises without error

#################### ERROR ######################
-- Compiling program ASIC_With_Ankit
** Error: class.sv(3): near "1": syntax error, unexpected "INTEGER NUMBER", expecting "IDENTIFIER" or "TYPE_IDENTIFIER"
################################################


Hope this is useful information, keep reading “ASIC With Ankit” !

Enjoy !
ASIC With Ankit