Jump to content

[virtual interface] Is is possible to pass one signal by task argument ?


Recommended Posts

Below (Example 1) shows that success of argument passing for whole virtual interface signals.

But (Example 2) cannot work that I intended.

I want to pass only one signal of virtual interface to certain task.

Is it possible or not?

Could you explain why ?

Thanks in advance …

------------------------------------------------------------------------------------------

interface aaa (input logic clk_a1, input logic clk_a2);

endinterface

(Example 1)

class private_sb extends uvm_scoreboard;

virtual interface aaa aaa_vif;

virtual task run ();

check_dut (aaa_vif);

endtask

virtual task check_dut (virtual interface aaa aaa_vif_dut)

repeat (10) @(posedge vif_dut.clk_a1)

endtask

endclass

(Example 2)

class private_sb extends uvm_scoreboard;

virtual interface aaa aaa_vif;

virtual task run ();

check_dut (aaa_vif.clk_a1.);

endtask

virtual task check_dut (logic aaa_logic_clk)

repeat (10) @(posedge aaa_logic_clk)

endtask

endclass

Link to comment
Share on other sites

The problem is that by default, task arguments are copied by value when you enter the task, and that argument is a local variable to the task. You should change your task argument to a ref.

virtual task check_dut (ref logic aaa_logic_clk)
        repeat (10) @(posedge aaa_logic_clk)
   endtask
Then the code inside the task will see value changes from the variable outside the task.

The reason that your example 1) works is because the value of a virtual interface variable is a handle, which is already a reference to an interface instance. So copying the handle value in a local virtual interface variable still points to the same interface instance.

Link to comment
Share on other sites

Dear dave_59,

Thank you for your kine response.

But, compilation error is occurred after modifying codes.

I modified codes below following your guide.

Compile error(exactly, elaboration error) is that

"invalid ref argument usage because actual argument is not a variable"

Is it not possible to use "ref" argument on interface signal which is connected to DUT?

Thanks in advance..

(Example 2)

interface aaa (input logic clk_a1, input logic clk_a2);
endinterface

class private_sb extends uvm_scoreboard;
  virtual interface aaa aaa_vif;

  virtual task run ();
    check_dut ([B]aaa_vif.clk_a1[/B]);  [U][B]// compiler points that this line has error[/B][/U]
  endtask

  virtual task check_dut ([B]ref[/B] logic aaa_logic_clk) // (old) virtual task check_dut (logic aaa_logic_clk)
    repeat (10) @(posedge aaa_logic_clk)
  endtask
endclass 
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...