RegisterLogin  
Update Profile
   
You are here: Forum  
Minimize 
SVUG Community Forum
Subject: Original Post: DM
Prev Next
You are not authorized to post a reply.

Author Messages
forumUser is Offline

Posts:0

04/27/2007 4:57 PM  

Hi,
I have some basic verilog tasks such as read & write. The higher level system verilog TB will have wrappers to these tasks & is to be called inside sv classes. How do I go about this.
1. Do I need to use import?
2. Do I need any extern definitions? & wrappers?
3. Or can i call verilog tasks directly inside sv classes

Please suggest?
DM

forumUser is Offline

Posts:0

04/27/2007 4:58 PM  

Hello DM,

My short answer to your question is: no, no, yes.
But let me elaborate a bit, since you have a number of options here, and without more details it would be difficult to suggest the one you're looking for.

Firstly, you should be able to call verilog tasks and functions directly inside SV classes thru absolute hierarchical referencing from the top level module. This may not be supported though by all simulators at this point. Note that an SV class cannot itself contain a module instance.

An alternative is to put the verilog tasks inside an SV interface instead of a module, and have a virtual interface in any class that needs access to the tasks. The virtual interface is essentially a handle to a concrete interface; it is assigned an instance of a concrete interface at run-time.

Another alternative, and perhaps the easiest, is to just put your tasks directly inside a class (copy-paste). In all likelihood they will compile and are usable with little or no modifications inside the class context. Just beware of the fact that tasks and functions inside modules and interfaces are static by default, while in a class context they are automatic by default. You can readily change this using the automatic/static keywords.

Hans

forumUser is Offline

Posts:0

04/27/2007 4:58 PM  

Deepa,
As I mentioned in the other forum as well the 2 choices are:

1. Move the tasks inside an interface and call it inside the class via virtual interface. However some vendors may not support this yet.
2. Use a trigger based WA as shown below for #1
3. Moving module task into class task is the easiest option. Infact since we have done this several times manually within CVC, I'm looking at developing a simple Perl script to do this.

Regards
Ajeetha, CVC
www.noveldv.com

interface my_if;
task my_task;
//

class my_c;
virtual my_if my_if_0;

task call_task();
my_if_0.my_task;

However I've seen tools not fully supporting this yet/premamture support. Till then you are better off with a WA like:

interface my_if;
task my_task; endtask

always @my_trigger begin
my_task;
end

Then trigger this "my_trigger" from within the class.

This was skeleton code.

forumUser is Offline

Posts:0

04/27/2007 4:58 PM  

Hello DM,

Addition to it, there is one bottle neck in porting legacy task into the class based structure. If your task are blocking then you will not be able to port it as blocking tasks are not supported inside dynamic testbench (like program, class etc). Either you have to make them non-blocking to port it inside class or keep them outside class structure (without making them non-blocking) and just have to access through hierarchical reference inside the class.

Thanks
Sachin

forumUser is Offline

Posts:0

04/27/2007 4:59 PM  

That last comment is not correct, or I do not understand the restriction you mention. Of course you can call a blocking task defined outside a class from within a class.

Dave

forumUser is Offline

Posts:0

04/27/2007 4:59 PM  

I do mention the same. In the last statement I just want to comment that you can call the blocking task defined outside a class from within a class.
If you don’t want to change the task to be non-blocking then you have to call the blocking task through hierarchical reference inside the class

Thanks
Sachin

You are not authorized to post a reply.



ActiveForums 3.7
  

 Copyright 2008 by SystemVerilog User Group Contact Us    Privacy Statement