Transaction Class Compile error

Hi,

I wrote a quick SV testbench and my format generally follows many of the samples in EDA Playground (I looked a couple over to see if I had some syntax errors). Where I am getting stuck is on a couple errors in my driver.sv and generator.sv files where I define these class. The problem is with the compile in Questa.

The error in Questa says the line “rand transaction trans;” in the generator.sv is:
error summary: missing descriptor var and it expects a “;” near trans

This goes away if I add `include “transaction.sv” but that is already the environment.sv

I suspect this is a child/parent issue where the way I have things in my tool the generator class does not see understand the transaction class…driver has the same or similar issue when calling “transaction trans”

Am I missing something in my Questa setup to handle this? Do I need to set the project up in a manner where the classes are aware of each other?

======================================================================================================
class generator;

//declaring transaction class
rand transaction trans;

//mailbox, to generate and send the packet to driver
mailbox gen2driv;

//repeat count, to specify number of items to generate
int repeat_count;

//event, to indicate the end of transaction generation
event ended;

//constructor
function new(mailbox gen2driv,event ended);
//getting the mailbox handle from env, in order to share the transaction packet between the generator and driver, the same mailbox is shared between both.
this.gen2driv = gen2driv;
this.ended = ended;
endfunction

//main task, generates(create and randomizes) the repeat_count number of transaction packets and puts into mailbox
task main();
repeat(repeat_count) begin
trans = new();
if( !trans.randomize() ) $fatal(“Gen:: trans randomization failed”);
trans.display(“[ Generator ]”);
gen2driv.put(trans);
end
→ ended; //triggering indicates the end of generation
endtask

endclass

class transaction;

//declaring the transaction items
rand bit [63:0] inDataA; //Port A input data
rand bit [63:0] inDataB; //Port B input data
bit [255:0] outData; //output DDR Data
endclass

In reply to kvinacco:

This forum is not for discussing tool specific issues, but you will be much better off with any tool enviroment putting all your classes in a package, and then importing the package.

Also see http://go.mentor.com/package-import-versus-include