DearTeam,
My generator code in my SV env goes like this …
`include "transaction.sv"
`define EOF 32'hFFFF_FFFF
`define NULL 0
class generator;
//declaring transaction class
rand transaction trans,tr;
//txn_count, to specify number of items to generate
// This section has declaration for declaring the other block
int txn_count;
bit[1:0] Opcodes;
integer file,r;
bit [31:0] price_rand;
bit [31:0] OrderId_rand;
//mailbox, to generate and send the packet to driver
mailbox gen2driv;
//event
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;
trans = new();
endfunction
//main task, generates(create and randomizes) the txn_count number of transaction packets and puts into mailbox
task main();
for (int i=0;i<txn_count;i++)
begin : file_block
Opcodes=trans.cmdcode;
OrderId_rand=trans.ORDER_BOOK.OrderNmbr;
price_rand=trans.newprice ;
file = $fopenr("rand_Inputs_generator.txt");
if (file == `NULL)
disable file_block;
while (!$feof(file))
begin
r = $fscanf(file, " %d %d %d \n", Opcodes, price_rand, OrderId_rand);
end // while not EOF
r = $fcloser(file);
end
tr = trans.do_copy();
gen2driv.put(tr);
end
-> ended;
endtask
endclass
my transaction class is 2086 bit and i am trying to configure a few fields(i.e Opcodes, price_rand, OrderId_rand ) of it from a text file(rand_Inputs_generator.txt) . The input text file is in the below format
///////////rand_Inputs_generator.txt////////////
0 1000 1
2 999 2
1 998 3
0 997 4
1 996 5
0 995 6
2 994 7
0 993 8
1 992 9
0 991 10
1 10 7
0 1000 1
2 999 2
1 998 3
0 997 4
1 996 5
0 995 6
2 994 7
0 993 8
1 992 9
0 991 10
1 10 7
0 997 4
1 996 5
/////////////
Need your help in understanding whats wrong with this code as i dont see any inputs applied to those 3 fields from this code…
Thanks in advance
Arjun