Home Articles SystemVerilog VMM Hackers Guide - Shutting Down Atomic Generators

Search

VMM Hackers Guide - Shutting Down Atomic Generators PDF Print E-mail
User Rating: / 0
PoorBest 
Thursday, 24 December 2009 16:57

Everybody likes atomic generators. If you have a vmm_data class, all you have to do is add a quick macro line and you get a free VMM-compliant generator that you only need to instantiate in your environment. An atomic generator is a simple yet powerful means to create a continuous flow of random data items to your DUT (more accurately “ to your BFM). Once everything is hooked up, all you have to do in your test program is set the number of items you want to generate, or let it run endlessly.

 

For example, if you want to drive 100 items, do this:

program test;
 
 my_env.gen.stop_after_n_insts = 100;
 
 endprogram

And if you want the generator to work endlessly do this:

program test;
 ...
 my_env.gen.stop_after_n_insts = 0;
 ...
 endprogram

That’s right, it’s a zero up there, and it’s also the default. So if you don’t say anything, all of your atomic generators will work endlessly. So, one might ask, how do you turn it off? Well, seems like the only way to do this is to call the stop_xactor() method, but only if you call it immediately after vmm_env::start(). This means that if your test program looks like this, both generators will still work although stop_xactor() is called:

program test;
 
env = new();
env.build();
env.gen1.stop_after_n_insts = 100;
env.gen1.stop_xactor();
env.gen2.stop_after_n_insts = 0;
env.gen2.stop_xactor();
 
env.run();
 
endprogram

The generators will stop, however, if you place the stop_xactor() after explicitly calling the start() method:

program test;
 
env = new();
env.build();
env.gen1.stop_after_n_insts = 100;
env.gen2.stop_after_n_insts = 0;
 
env.start();
 
env.gen1.stop_xactor();
env.gen2.stop_xactor();
env.run();
 
endprogram

 

Now, although this is the recommended way by Synopsys we just couldn’t resist hacking the code to make stop_after_n_insts = 0 do NOTHING. Be careful though, this hack implies a minor paradigm shift - atomic generators are now off by default (rather than on and working endlessly).  With the hacked version, you can do this in your test, no need to stop_xactor():

program test;
 
// choose only one of the following:
my_env.gen1.stop_after_n_insts = 0; // shut down (default)
my_env.gen1.stop_after_n_insts = 100; // create 100 items and then stop
my_env.gen1.top_after_n_insts = -1; // work endlessly
 
endprogram

 


THE HACK


 

WARNING:

THIS IS FOR ADVANCED VMM USERS ONLY. USE AT YOUR OWN RISK!

KIDS, DON’T TRY THIS AT HOME.

  1. Locate the following line in the VMM source code:

    class `vmm_atomic_gen_(class_name)      extends `VMM_XACTOR; 



  2. About 100 lines down from there replace this line:

    while (this.stop_after_n_insts <= 0      ||


    with this one:


    while (this.stop_after_n_insts < 0      ||


  3. There’s a similar code line in the vmm_scenario class definition, make sure you haven’t ruined that one by mistake.
  4. Remember: This is only a small change, but it has a big impact.  Make sure you understand the paradigm shift.

 

 
More articles :

» VMM Hackers Guide - Default Behavior For Your BFM

Here's a short tutorial on how to implement a default behavior for your BFM using VMM. Some protocols require constant activity on their interface even when you don't have any data to transmit. This means you must have a mechanism that drives idle...

» About UVM And You

There’s been a lot of buzz about the lately and for a reason. The Universal Verification Methodology is about to change the rules of the game pretty soon, if not already. That is interesting because not too long ago verification engineers...

» Smart Constraints In SystemVerilog

Constraints are our best friends when it comes to random generation. They allow us to limit the range of possible scenarios/values as much as we like, from the level of "everything is allowed" down to the level of such heavy constraints that really...

» Cool Things You Can Do with Verdi

Wow it's been a while, but I'm back with a new series of YouTube videos. Hurray !!This time it's all about Verdi and all the cool things it can do for you.Since most of you guys already know it is the best debugger out there, my goal is to show you...

» We Hear Ya!

 During the last months we conducted a poll about what you guys would you like to read more about on ThinkVerification and here are the results: Verification Methodology - 41%SystemVerilog Tutorials - 31%e Tutorials - 13%Interviews - 12%...

Add comment


Security code
Refresh

Copyright © 2017 Think Verification - Tips & Insights on ASIC Verification. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.