Home Articles SystemVerilog Method Manipulation In SV and e

Search

Method Manipulation In SV and e PDF Print E-mail
User Rating: / 5
PoorBest 
Thursday, 24 December 2009 16:46

If you're familiar with SystemVerilog and taking your first steps in e (or vice versa) you might find this useful. Here are some of the most common method manipulations that you''ll need to master and how you should go about implementing them in e and SV:

 

Before we dive in - here's the reference code for the examples we're going to show you.

// ** e **
struct my_struct {
 my_function() is {};
 my_task1()@sys.any is {};
 my_task2()@sys.any is {};
 };
// ** SystemVerilog **
class parent;
 // must be virtual
 virtual function my_function();
 endfunction
 virtual task my_task1();
 endtask
 virtual task my_task2();
 endtask
 endclass

OK, now let''s see how to implement the most common method manipulations in each language:


Extending methods - adding more functionality at the end:

// ** e **
 extend parent {
 my_function() is also {
 j++;
 };
 };
 
 // ** SV **
 class child extends parent;
 virtual function my_function();
 super.my_function();
 j++;
 endfunction;
 endclass


Extending methods - adding stuff to the beginning of a method:

// ** e **
 extend parent {
 my_function() is first {
 j++;
 };
 };
 
 // ** SV **
 class child extends parent;
 virtual function my_function();
 j++;
 super.my_function();
 endfunction;
 endclass


Overriding a method:

// ** e **
 extend parent {
 my_function() is only {
 j++;
 };
 };
 
 // ** SV **
 class child extends parent;
 virtual function my_function();
 j++;
 endfunction;
 endclass


Launching parallel threads - parent process not blocked:

// ** e ** 
 foo()@sys.any is {
 start my_task1();
 start my_task2();
 };
 
 // ** SV **
 task foo();
 fork begin 
 my_task1();
 my_task2();
 join_none; 
 endfunction


Launching parallel threads - parent process blocked until shortest thread completes:

// ** e ** 
 foo()@sys.any is {
 first of {
 { my_task1(); };
 { my_task2(); };
 };
 };
 
 // ** SV **
 function foo();
 fork begin 
 my_task1();
 my_task2();
 join_any;
 disable fork;    // remove if you don''t want to kill the longer task prematurely
 endfunction


Launching parallel threads - parent process blocked until all threads are finished:

// ** e ** 
 foo()@sys.any is {
 all of {
 { my_task1(); };
 { my_task2(); };
 };
 };
 
 // ** SV **
 function foo();
 fork begin 
 my_task1();
 my_task2();
 join;
 endfunction

 

 
More articles :

» How To Validate Type-Casting In OVM-e

Before type-casting an e variable ("as_a"), we often want to check the validity of the operation (this is quite similar in concept to $cast in SystenVerilog). The reason is simple, in case the casting operation failed we would end up with a fatal...

» UVM Users: Here Are Some Great Tips [Video]

A couple of years ago I wrote here about how the UVM was becoming the next big thing in the verification world.And guess what? I was right. Not that it was too hard to predict... but anyway, the industry has finally standardized on language (SV) and...

» Prepare For Your Next Job Interview

Succeeding at job interviews requires practice. If you're applying for a verification job you'd better get yourself well prepared both mentally and technically. Nevertheless, a great deal of tension could be avoided if you knew in advance what sort...

» Plug, Play and Reuse!

Time to talk about module-to-system reuse, a very important topic. If you plan your verification environment properly (using one of the common methodologies in the market today or your own) you’ll be able to easily build a system level...

» Educate Yourself - SystemVerilog 101

SystemVerilog emerged a few years ago and has gained phenomenal popularity ever since. Today this language is virtually ubiquitous and all 3 big EDA vendors keep pushing it forward. So if you consider yourself a modern verifier, you'd better get...

Comments  

 
0 #1 2010-04-17 16:43
Very simple and very informative article.
Quote
 

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.