Home 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 :

» VMM Hackers Guide - Shutting Down Atomic Generators

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...

» To Do List 2010

Introducing Philip Americus - a new guest blogger here on Think Verification. Phil is an ASIC veteran who's worked with every phase of ASIC design - from initial concept to tapeout, with an emphasis on verification, including management of both HW...

» Get Hooked

Changing an existing eVC for new project requirements is a grueling task. It’s really painful for any eVC developer to witness his creation being torn apart by an end user, but a little prudence from the developer can result into longevity of eVC....

» The Big Picture

Great verification engineers know the secret - if they want to be successful they must also understand the essence of the entire chip design flow, from concept to working samples. Here are some great videos that will help you see the big picture a...

» My Story With Certitude

Long time no see. My website has been down for a while (technical issues - web experts contact me if you want to help) but now it's up again. And going through some of my old articles here (well, they're all old, I should probably do something about...

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.