Hello friends, sorry to ask very stupid question.
I am very new to this verification field.
I am posting my code below.
I have packet class, where i have defined all my FIELDS.
I have generator class, where those fields are being randomnized.
I have my driver class, where the fields which are randomized by generator class, are retrieved from mailbox.
But i am getting a list of error, saying that.
“Typedef ‘generator_t’ multiply defined.”
Can you please provide appropriate working solution for this.
I have referred to some documents, they asked to use PACKAGE CONCEPT.
But practically i didnt understood what they are trying to say in PACKAGE CONCEPT.
Please elabrote.
Thank you.
PACKET CLASS:
typedef enum bit [1:0] {IDLE,BUSY,NONSEQ,SEQ}ttype;
typedef enum bit [2:0] {BYTE,HALFWORD,WORD,DOUBLEWORD,
WORD4,WORD8,BIT_512,
BIT_1024} hsize;
typedef enum bit [2:0] {SINGLE,INCR,WRAP4,INCR4,
WRAP8,INCR8,WRAP16,INCR16} hburst;
typedef enum bit [3:0] {ONE,TWO,THREE,FOUR} hprot;
class packet;
rand bit [31:0] add;
rand bit [31:0] hwdata;
rand bit hwrite;
rand bit hmastlock;
rand ttype type1; // VARIABLE for ENUM
rand hsize size; // VARIABLE for ENUM
rand hburst burst; // VARIABLE for ENUM
rand hprot prot; //VAIRABLE FOR ENUM
constraint c1 {add dist{[0:1048]:=25,
[1049:2096]:=25,
[2097:3144]:=25,
[3145:4196]:=25};};
constraint c2 {prot > 2;prot<4;};
endclass: packet
--------------------------
GENERATOR CLASS
`include"packet_class.sv"
class generator_t;
packet p2rand;
packet p2send;
static int id;
mailbox #(packet) gen2drv;
function new();
this.p2rand=new();
this.gen2drv=new();
endfunction
function void disp123();
$display("\nSTART OF FIELDS DETIALS %0d\n",id);
$display("Address : %h",p2rand.add);
$display("Data : %h",p2rand.hwdata);
$display("HWRITE : %b",p2rand.hwrite);
$display("MASTER LOCK : %b",p2rand.hmastlock);
$display("transfer type : %s (%b)",p2rand.type1,p2rand.type1);
$display("transfer size : %s (%b)",p2rand.size,p2rand.size);
$display("burst transfer type : %s (%b)",p2rand.burst,p2rans.burst);
$display("Protection Level : %s (%b)",p2rand.prot,p2rand.prot);
$display("\nEND OF FIELDS DETIALS %0d\n",id);
$display("%p",p2rand);
$display("%p",p2send);
endfunction
function dorando();
if(p2rand.randomize())
id++;
p2send = new p2rand;
this.disp123();
endfunction
task mb_gen2dri();
this.gen2drv=new();
//this.p2dri=new();
begin
gen2drv.put(p2send);
end
p2rand.randomize();
endtask
endclass: generator_t
----------------------------
DRIVER CLASS
//`include"packet_class.sv"
`include"generator_class.sv"
class driver;
packet p2recv;
//packet p2intf;
mailbox #(packet) gen2dri;
function new(mailbox #(packet) gen2drv);
this.gen2drv = gen2drv;
endfunction
function void disp_drv();
$display("%p recieved packet",p2recv);
endfunction
virtual task doit();
begin
gen2drv.get(p2recv);
end
endtask
endclass
------------------------
PROGRAM BLOCK
`include"generator_class.sv"
`include"driver_class.sv"
program test1();
generator_t gen=new();
driver drv;
initial begin
drv = new(gen.gen2drv);
repeat(5)
begin
gen.dorando();
gen.mb_gen2dri();
drv.doit();
drv.disp_drv();
end
end
endprogram