3

I have a question about virtual sequencer in UVM. Let's think that I have N equal interfaces driven by N equal drivers, each one connected to its own sequencer. What I want to do is to have a transaction like:

    class my_transaction extends uvm_sequence_item;
         logic data;
         int num_if;
    endclass

that when executed with `uvm_do() is sent to the driver number num_if. My idea is that for this kind of work I need a virtual sequencer that "forward" the transaction to the right sequencer (the number num_if). Is this right? If yes, how it could be done? Thanks.

4

2 回答 2

4

虽然 Tudor 的答案在技术上有效,但从概念上讲,关于在哪个接口上运行 (num_if) 的决定是一个不属于事务的值,而是属于调用它的序列(当然也应该是随机的)。交易应该只包含从 A 到 B 的值的表示以及它为该协议传输的方式。A 和 B的规范通常不在事务的责任范围内。

在这种情况下,您的交易和 Tudor 序列的变化将如下所示:

class my_transaction extends uvm_sequence_item;
   rand logic data;
endclass

..和..

class some_virtual_sequence extends uvm_sequence;
  `uvm_declare_p_sequencer(virtual_seqr)
  rand int num_if; constraint.....
  task body();
    my_transaction trans = my_transaction::type_id::create("my_transaction");
    start_item(trans, , p_sequencer.seqrs[num_if]);
    trans.randomize(); // randomization should be done after start_item()
    finish_item(trans);
  endtask
endclass

..在虚拟音序器上运行,正如 Tudor 所说:

class virtual_seqr extends uvm_sequencer;
  my_sequencer seqrs[10];
endclass

上述方法还可以让随机化发生在正确的位置:在 start_item() 返回之后以及在调用完成序列项的 finish_item() 之前。

于 2014-11-13T05:42:19.183 回答
2

你对虚拟音序器是正确的。我将向您展示如何做到这一点的想法(所有伪代码,您必须自己处理细节)。

假设我们有一个虚拟定序器,其中包含所有总线定序器的数组:

class virtual_seqr extends uvm_sequencer;
  my_sequencer seqrs[10];
endclass

我们假设这些句柄被正确传递。在我们的虚拟序列中,我们可以创建一个事务,将其随机化,然后将其发送到适当的排序器。

class some_virtual_sequence extends uvm_sequence;
  `uvm_declare_p_sequencer(virtual_seqr)

  task body();
    my_transaction trans = my_transaction::type_id::create("my_transaction");
    my_transaction.randomize();
    start_item (my_transaction, , p_sequencer.seqrs[my_transaction.num_if]);
    finish_item(my_transaction);
  endtask
endclass

我们不能使用uvm_do,因为它不知道在哪里调度。我们也不能使用uvm_do_on,因为num_if字段必须随机化才能知道将项目发送到哪里。

于 2014-11-12T21:12:15.053 回答