Contact / Report an issue

Non blocking can_get method implementation

Nonblocking can_get method


NonBlocking Get Port Imp port
NonBlocking Get Port Imp port 
* Click on image for a better view

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

Before calling the trans_in.try_get() method comp_b checks for the comp_a status by calling trans_in.can_get() method. On calling trans_in.can_get() comp_a can respond with 1 if it's ready to send the transaction packet, otherwise 0.

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

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

if(trans_in.can_get) begin //{
    
  `uvm_info(get_type_name(),$sformatf(" component_a can send the transaction"),UVM_LOW)
  `uvm_info(get_type_name(),$sformatf(" Requesting transaction."),UVM_LOW)
  `uvm_info(get_type_name(),$sformatf(" Before calling port get method"),UVM_LOW)
  
  if(trans_in.try_get(trans)) begin //{
    `uvm_info(get_type_name(),$sformatf(" recived transaction 
                                          from get method"),UVM_LOW)
    `uvm_info(get_type_name(),$sformatf(" Printing trans, \n %s",
                                          trans.sprint()),UVM_LOW)
  end //} 
  else begin //{
    `uvm_info(get_type_name(),$sformatf(" Not recived transaction 
                                          from get method"),UVM_LOW)
  end //}
      
  `uvm_info(get_type_name(),$sformatf(" After  calling port get method"),UVM_LOW)

end //}
else begin //{
  `uvm_info(get_type_name(),$sformatf(" component_a is not ready to send 
                                        the transaction"),UVM_LOW)
end //}

2. Implement the can_get() method in comp_a

virtual function bit can_get();
  `uvm_info(get_type_name(),$sformatf(" component_b requested for status"),UVM_LOW)
  return 0;
endfunction




 Simulator Output  With can_get() return value 1.

UVM_INFO @ 0: reporter [RNTST] Running test basic_test...
------------------------------------------------------
Name Type Size Value
------------------------------------------------------
uvm_test_top basic_test - @335
env environment - @348
comp_a component_a - @357
trans_out uvm_nonblocking_get_imp - @366
comp_b component_b - @376
trans_in uvm_nonblocking_get_port - @385
------------------------------------------------------
UVM_INFO component_b.sv(26) @ 0: uvm_test_top.env.comp_b [component_b] Checking component_a status to get the transaction
UVM_INFO component_a.sv(40) @ 0: uvm_test_top.env.comp_a [component_a] component_b requested for status
UVM_INFO component_b.sv(29) @ 0: uvm_test_top.env.comp_b [component_b] component_a can send the transaction
UVM_INFO component_b.sv(30) @ 0: uvm_test_top.env.comp_b [component_b] Requesting transaction.
UVM_INFO component_b.sv(31) @ 0: uvm_test_top.env.comp_b [component_b] Before calling port get method
UVM_INFO component_a.sv(24) @ 0: uvm_test_top.env.comp_a [component_a] Recived transaction imp port get request
UVM_INFO component_a.sv(28) @ 0: uvm_test_top.env.comp_a [component_a] tranaction randomized
UVM_INFO component_a.sv(29) @ 0: uvm_test_top.env.comp_a [component_a] Printing trans,
---------------------------------
Name Type Size Value
---------------------------------
trans transaction - @418
addr integral 4 'h3
wr_rd integral 1 'h1
wdata integral 8 'h6
---------------------------------

UVM_INFO component_a.sv(31) @ 0: uvm_test_top.env.comp_a [component_a] Sendting trans packet
UVM_INFO component_b.sv(34) @ 0: uvm_test_top.env.comp_b [component_b] recived transaction from get method
UVM_INFO component_b.sv(35) @ 0: uvm_test_top.env.comp_b [component_b] Printing trans,
---------------------------------
Name Type Size Value
---------------------------------
trans transaction - @418
addr integral 4 'h3
wr_rd integral 1 'h1
wdata integral 8 'h6
---------------------------------

UVM_INFO component_b.sv(41) @ 0: uvm_test_top.env.comp_b [component_b] After calling port get method
UVM_INFO /apps/vcsmx/etc/uvm-1.2/src/base/uvm_objection.svh(1270) @ 0: reporter [TEST_DONE]
UVM_INFO /apps/vcsmx/etc/uvm-1.2/src/base/uvm_report_server.svh(847) @ 0: reporter [UVM/REPORT/SERVER]



 Simulator Output  With can_get() return value 0.

UVM_INFO @ 0: reporter [RNTST] Running test basic_test...
------------------------------------------------------
Name Type Size Value
------------------------------------------------------
uvm_test_top basic_test - @335
env environment - @348
comp_a component_a - @357
trans_out uvm_nonblocking_get_imp - @366
comp_b component_b - @376
trans_in uvm_nonblocking_get_port - @385
------------------------------------------------------
UVM_INFO component_b.sv(26) @ 0: uvm_test_top.env.comp_b [component_b] Checking component_a status to get the transaction
UVM_INFO component_a.sv(40) @ 0: uvm_test_top.env.comp_a [component_a] component_b requested for status
UVM_INFO component_b.sv(45) @ 0: uvm_test_top.env.comp_b [component_b] component_a is not ready to send the transaction
UVM_INFO /apps/vcsmx/etc/uvm-1.2/src/base/uvm_objection.svh(1270) @ 0: reporter [TEST_DONE]
UVM_INFO /apps/vcsmx/etc/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_a, uvm_infos before and after the try_get method of comp_b and uvm_infos inside try_get method of comp_a are not getting executed.