-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgenerator.sv
More file actions
37 lines (30 loc) · 1 KB
/
generator.sv
File metadata and controls
37 lines (30 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
`ifndef GENERATOR
`define GENERATOR
`include "transaction.sv"
class generator;
//declaring transaction class
rand transaction trans,tr;
//repeat count, to specify number of items to generate
int repeat_count;
//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 repeat_count number of transaction packets and puts into mailbox
task main();
repeat(repeat_count) begin
if( !trans.randomize() ) $fatal("Gen:: trans randomization failed");
tr = trans.do_copy();
gen2driv.put(tr);
end
-> ended;
endtask
endclass
`endif