i Tried the first method but it’s not working as mentioned.
link of the code : Edit code - EDA Playground
please help to find what I am mess it up with .
class sender extends uvm_component;
`uvm_component_utils(sender)
uvm_analysis_port#(int) send_port;
function new(string name=“sender”,uvm_component parent);
super.new(name,parent);
send_port=new(“send_port”,this);
endfunction
task run_phase(uvm_phase phase);
phase.raise_objection(this);
send_port.write(10);
send_port.write_BEFORE(34);
$display(“send the value from run_Phase”);
phase.drop_objection(this);
endtask
endclass
class receiver extends uvm_component;
`uvm_component_utils(receiver)
`uvm_analysis_imp_decl(_BEFORE)
uvm_analysis_imp#(int,receiver) rsv_port;
uvm_analysis_imp_BEFORE#(receiver) before_export;
function new(string name=“receiver”,uvm_component parent);
super.new(name,parent);
rsv_port=new(“rsv_port”,this);
before_export=new(“before_export”,this);
endfunction
function void write(int a);
$display(“value of a received=%0d”,a);
endfunction
function void write_BEFORE(int a);
$display(“value of a received=%0d”,a);
endfunction
endclass
class env extends uvm_env;
`uvm_component_utils(env)
sender sen;
receiver rsv;
function new(string name=“env”,uvm_component parent);
super.new(name,parent);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
sen=sender::type_id::create(“sen”,this);
rsv=receiver::type_id::create(“rsv”,this);
endfunction
function void connect_phase(uvm_phase phase);
sen.send_port.connect(rsv.rsv_port);
sen.send_port.connect(rsv.before_export);
endfunction
endclass
module top;
initial
run_test(“env”);
endmodule