通过任务驱动虚拟接口信号的位片

Driving a bitslice of a virtual interface signal through a task

我正在尝试创建一个任务,负责设置一个向量的位并在一个时钟周期后将其清除。我的驱动程序代码附在下面:

class my_if_driver extends uvm_driver;
  `uvm_component_utils(my_if_driver)
 
  // Members
  // UVM stuff
  virtual my_if_interface vif;
 
  function new(string name="my_if_driver", uvm_component parent);
    super.new(name, parent);
  endfunction
 
  extern function void build_phase(uvm_phase phase);
  extern function void connect_phase(uvm_phase phase);
  extern task          run_phase(uvm_phase phase);
 
  extern task drive_my_if(my_if_transaction txn);
  extern task set_then_clear(ref logic signal);
endclass
 
function void my_if_driver::build_phase(uvm_phase phase);
endfunction
 
function void my_if_driver::connect_phase(uvm_phase phase);
endfunction
 
task my_if_driver::run_phase(uvm_phase phase);
  @(posedge vif.resetn);
  forever begin
    seq_item_port.get_next_item(req);
    fork
      drive_my_if(req);
    join_none
    seq_item_port.item_done(req);
  end
endtask

// NOTE: each 'command-signal' has bit for each tid (transaction ID)
task my_if_driver::drive_my_if(my_if_transaction txn);
  // Wait for delay
  repeat (txn.cycle_delay) @(posedge vif.clk);
  // Then drive appropriate signal
  if (txn.my_if_cmd == my_if_transaction::CMDA) begin
    set_then_clear(vif.my_if_cmd_a[txn.tid]);
  end
  else if (txn.my_if_cmd == my_if_transaction::CMDB) begin
    set_then_clear(vif.my_if_cmd_b[txn.tid]);
  end
  else if (txn.my_if_cmd == my_if_transaction::CMDC) begin
    set_then_clear(vif.my_if_cmd_c[txn.tid]);
  end
endtask
 
task my_if_driver::set_then_clear(ref logic signal);
  signal <= 1'b1;
  @(posedge vif.clk);
  signal <= 1'b0;
endtask

我收到以下错误 (Questa 10.6):

** Error: path_to_driver.svh(53): LHS in non-blocking assignment may not be an automatic variable

** Error: path_to_driver.svh(55): LHS in non-blocking assignment may not be an automatic variable

这些指向 set_then_clear 任务中对 'signal' 的非阻塞分配。有没有办法通过 ref 参数指向虚拟接口的位片?

LRM 说

Because a variable passed by reference may be an automatic variable, a ref argument shall not be used in any context forbidden for automatic variables.

并且您不能通过引用传递压缩变量的一点 select,只能传递整个变量。

如果不为每个 cmd 编写单独的任务,或者在 select 是您要分配的接口变量的信号任务中写一个大的 case 语句,就没有简单的方法可以做到这一点。