hi all
i am new to ovm…i’ve just begun with a counter verification…my environment consists of a driver and a monitor only for the time being…
the problem i’m facing is that, ‘run’ task of monitor is executed before that of driver…
can anyone please help…
//-------------------------this is my code--------------------------
//-----------interface------------
interface intfCounter(input bit clk);
logic data, rst;
logic [2:0] count;
modport test(input count, output data, rst);
modport dut(output count, input data, rst);
endinterface
//--------------------top module------------------
module top;
logic clk=0;
initial begin
forever
#50 clk = ~clk;
end
intfCounter intfc(clk);
my_test t1;
count_ones cnt1(.clk(clk), .reset(intfc.rst), .data(intfc.data), .count(intfc.count));
initial begin
run_test("my_test");
end
endmodule
//-------------------test class--------------------
class my_test extends ovm_test;
`ovm_component_utils_begin(my_test)
`ovm_component_utils_end
my_env env;
virtual interface intfCounter intfc_t;
function new (string name = "my_test", ovm_component parent);
super.new(name, parent);
endfunction
function void build();
super.build();
env = my_env::type_id::create("env", this);
endfunction
virtual function void connect();
env.assign_vi(intfc_t);
endfunction
task run();
$display("--------enter test-------");
#500ns;
$display("----------exit test-------");
global_stop_request();
endtask: run
endclass: my_test
//------------------------environment---------------------------
class my_env extends ovm_env;
my_driver drv;
my_monitor mntr;
virtual interface intfCounter intfc;
`ovm_component_utils(my_env)
function new(string name = “my_env”, ovm_component parent);
super.new(name, parent);
endfunction: new
virtual function void build();
super.build();
drv = my_driver::type_id::create(“drv”, this);
mntr = my_monitor::type_id::create(“mntr”, this);
endfunction: build
function void assign_vi(virtual interface intfCounter intfc_e);
drv.assign_vi(intfc_e);
mntr.assign_vi(intfc_e);
endfunction
function void connect();
super.connect();
endfunction: connect
endclass
//-------------------driver----------------------
class my_driver extends ovm_driver();
virtual interface intfCounter intfc;
`ovm_component_utils (my_driver);
function new (string name = "my_driver", ovm_component parent = null);
super.new(name, parent);
endfunction: new
function void assign_vi(virtual interface intfCounter intfc);
this.intfc = intfc;
endfunction
function void build();
super.build();
endfunction: build
task reset_DUT();
$display("----enter reset_DUT task------");
intfc.rst = 1;
intfc.data = 0;
repeat(1) @(posedge intfc.clk);
intfc.rst=0;
$display("----exit reset_DUT taskt------");
endtask:reset_DUT
task run();
$display(“-------enter driver at time = %x\n--------”, intfc.clk);
reset_DUT();
fork
drive_dut();
join
$display(“-------exit driver--------”);
endtask: run
task drive_dut();
forever begin
@(posedge intfc.clk);
$display(“-------enter drive_dut task at time = %x\n--------”, intfc.clk);
intfc.data <= 1’b1;
end
endtask: drive_dut
endclass: my_driver
//-----------------monitor-------------------
class my_monitor extends ovm_monitor;
virtual interface intfCounter intfc;
`ovm_component_utils(my_monitor)
function new(string name, ovm_component parent);
super.new(name, parent);
endfunction: new
function void assign_vi(virtual interface intfCounter intfc);
this.intfc = intfc;
endfunction
function void build();
super.build();
endfunction: build
virtual task run();
$display("-------enter monitor---------");
fork
read_count();
join
endtask: run
task read_count();
bit [2:0] count_at_monitor;
forever begin
@(posedge intfc.clk);
count_at_monitor = intfc.count;
$display(“count = %b”, count_at_monitor);
$display(“-------exit monitor---------”);
end
endtask
endclass: my_monitor