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

» Ignorance Is A Bliss

There is a rather confusing feature in Specman’s coverage engine that I would like to share with you today. I’ve met several people (including myself) who had been struggling to understand what was going on there and gave up Recently I was...

» The Cost Of Verification

We spend about one third of our lives in bed, right? doesn’t it make sense then to buy a good bed and not a cheap one? The same can be said for your verification tools as you spend so much of your project time on verification. Buying cheaper tools...

» Read/Write Registers From Everywhere

Here’s something for the less experienced verifiers out there. I’ve been asked to help with this issue several times in the past so I guess some of you will find it useful.

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

» Get On The Buss

Wow, it’s been a while since we last had a good old techie talk about Specman so why not now? Today I’d like to focus on applying reuse to Specman external ports. Very much like little caterpillars, DUTs often have tens or even hundreds of pins...

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.