Contact / Report an issue

Non blocking can_put method implementation

Nonblocking can_put method


nonblocking can_put method
can_put method

This example is a continuation of the previous example with the can_put method implemented.

Before calling the trans_out.try_put() method comp_a checks for the comp_b status by calling trans_out.can_put() method. On calling trans_out.can_put() comp_b can respond with 1 if it's ready to accept the transaction packet, otherwise 0.

In order to add can_put() method, there are two additional steps on top of steps followed in the previous example.

1. In comp_a before calling the try_put method, Call can_put() method and check for the comp_b status

    if(trans_out.can_put) begin //{
      `uvm_info(get_type_name(),$sformatf(" Before calling port put method"),UVM_LOW)
      trans_out.try_put(trans);
      `uvm_info(get_type_name(),$sformatf(" After  calling port put method"),UVM_LOW)
    end //}
    else 
      `uvm_info(get_type_name(),$sformatf(" component_b is not ready to accept the packet"),UVM_LOW)

2. Implement the can_put() method in comp_b

  virtual function bit can_put();
    `uvm_info(get_type_name(),$sformatf(" Inside can_put method"),UVM_LOW)
    `uvm_info(get_type_name(),$sformatf(" Sending can_put status as 1"),UVM_LOW)
    return 1;    
  endfunction 




 Simulator Output  With can_put() return value 1.

UVM_INFO @ 0: reporter [RNTST] Running test basic_test...
------------------------------------------------------
Name Type Size Value
------------------------------------------------------
uvm_test_top basic_test - @1839
env environment - @1908
comp_a component_a - @1940
trans_out uvm_nonblocking_put_port - @1975
comp_b component_b - @2008
trans_in uvm_nonblocking_put_imp - @2043
------------------------------------------------------
UVM_INFO component_a.sv(29) @ 0: uvm_test_top.env.comp_a [component_a] tranaction randomized
UVM_INFO component_a.sv(30) @ 0: uvm_test_top.env.comp_a [component_a] Printing trans,
---------------------------------
Name Type Size Value
---------------------------------
trans transaction - @1135
addr integral 4 'he
wr_rd integral 1 'h0
wdata integral 8 'h4
---------------------------------

UVM_INFO component_b.sv(33) @ 0: uvm_test_top.env.comp_b [component_b] Inside can_put method
UVM_INFO component_b.sv(34) @ 0: uvm_test_top.env.comp_b [component_b] Sending can_put status as 1
UVM_INFO component_a.sv(33) @ 0: uvm_test_top.env.comp_a [component_a] Before calling port put method
UVM_INFO component_b.sv(24) @ 0: uvm_test_top.env.comp_b [component_b] Inside try_put method
UVM_INFO component_b.sv(25) @ 0: uvm_test_top.env.comp_b [component_b] Recived trans On IMP Port
UVM_INFO component_b.sv(26) @ 0: uvm_test_top.env.comp_b [component_b] Printing trans,
---------------------------------
Name Type Size Value
---------------------------------
trans transaction - @1135
addr integral 4 'he
wr_rd integral 1 'h0
wdata integral 8 'h4
---------------------------------

UVM_INFO component_a.sv(35) @ 0: uvm_test_top.env.comp_a [component_a] After calling port put method
UVM_INFO /playground_lib/uvm-1.2/src/base/uvm_objection.svh(1271) @ 0: reporter [TEST_DONE]
UVM_INFO /playground_lib/uvm-1.2/src/base/uvm_report_server.svh(847) @ 0: reporter [UVM/REPORT/SERVER]

 Simulator Output  With can_put() return value 0.

UVM_INFO @ 0: reporter [RNTST] Running test basic_test...
------------------------------------------------------
Name Type Size Value
------------------------------------------------------
uvm_test_top basic_test - @1839
env environment - @1908
comp_a component_a - @1940
trans_out uvm_nonblocking_put_port - @1975
comp_b component_b - @2008
trans_in uvm_nonblocking_put_imp - @2043
------------------------------------------------------
UVM_INFO component_a.sv(29) @ 0: uvm_test_top.env.comp_a [component_a] tranaction randomized
UVM_INFO component_a.sv(30) @ 0: uvm_test_top.env.comp_a [component_a] Printing trans,
---------------------------------
Name Type Size Value
---------------------------------
trans transaction - @1135
addr integral 4 'he
wr_rd integral 1 'h0
wdata integral 8 'h4
---------------------------------

UVM_INFO component_b.sv(33) @ 0: uvm_test_top.env.comp_b [component_b] Inside can_put method
UVM_INFO component_b.sv(34) @ 0: uvm_test_top.env.comp_b [component_b] Sending can_put status as 1
UVM_INFO component_a.sv(38) @ 0: uvm_test_top.env.comp_a [component_a] component_b is not ready to accept the packet
UVM_INFO /playground_lib/uvm-1.2/src/base/uvm_objection.svh(1271) @ 0: reporter [TEST_DONE]
UVM_INFO /playground_lib/uvm-1.2/src/base/uvm_report_server.svh(847) @ 0: reporter [UVM/REPORT/SERVER]

Execute the above code on 




 Output Analysis 

In the second output with the return value set to '0', we can see that as the return value is '0' from comp_b, uvm_infos before and after the try_put method of comp_a and uvm_infos inside try_put method of comp_b are not getting executed.