UVM糖果爱好者教程 - 31.provides_responses?

这是一篇关于何时应设置寄存器适配器的provides_responses位的简短文章。

原始Jelly Bean Driver

这是Register Abstraction中使用的原始jelly_bean_driver。驱动程序使用get_next_item(第23行)获取请求,然后更新请求本身以存储来自DUT的响应(第33行)。最后,它调用item_done(第35行)。由于驱动程序不会返回单独的响应,因此我们将jelly_bean_reg_adapter的provides_responses设置为零。

class jelly_bean_driver extends uvm_driver#( jelly_bean_transaction );
   `uvm_component_utils( jelly_bean_driver )
 
   virtual jelly_bean_if jb_if;
 
   function new( string name, uvm_component parent );
      super.new( name, parent );
   endfunction: new
 
   function void build_phase( uvm_phase phase );
      super.build_phase( phase );
   endfunction: build_phase
 
   task main_phase( uvm_phase phase );
      jelly_bean_transaction jb_tx;
 
      forever begin
         @jb_if.master_cb;
         jb_if.master_cb.command < = jelly_bean_types::NO_OP;
         jb_if.master_cb.color   <= jelly_bean_types::NO_COLOR;
         jb_if.master_cb.flavor  <= jelly_bean_types::NO_FLAVOR;
 
         seq_item_port.get_next_item( jb_tx ); // get the request
         @jb_if.master_cb;
         jb_if.master_cb.command <= jb_tx.command;
         if ( jb_tx.command == jelly_bean_types::WRITE ) begin
            jb_if.master_cb.flavor     <= jb_tx.flavor;
            jb_if.master_cb.color      <= jb_tx.color;
            jb_if.master_cb.sugar_free <= jb_tx.sugar_free;
            jb_if.master_cb.sour       <= jb_tx.sour;
         end else if ( jb_tx.command == jelly_bean_types::READ ) begin
            @jb_if.master_cb;
            jb_tx.taste = jelly_bean_types::taste_e'( jb_if.master_cb.taste ); // update the request itself
         end
         seq_item_port.item_done();
      end
   endtask: main_phase
endclass: jelly_bean_driver

返回单独的响应的driver

如果provide_responses是1,我会按如下方式重写driver。 (通常这是另一种方式;如果driver提供单独的响应,那么我们将provide_responses设置为1。)

class jelly_bean_driver extends uvm_driver#( jelly_bean_transaction );
   `uvm_component_utils( jelly_bean_driver )
 
   virtual jelly_bean_if jb_if;
 
   function new( string name, uvm_component parent );
      super.new( name, parent );
   endfunction: new
 
   function void build_phase( uvm_phase phase );
      super.build_phase( phase );
   endfunction: build_phase
 
   task main_phase( uvm_phase phase );
      jelly_bean_transaction jb_tx;
      jelly_bean_transaction jb_rsp;
 
      forever begin
         @jb_if.master_cb;
         jb_if.master_cb.command < = jelly_bean_types::NO_OP;
         jb_if.master_cb.color   <= jelly_bean_types::NO_COLOR;
         jb_if.master_cb.flavor  <= jelly_bean_types::NO_FLAVOR;
 
         seq_item_port.get( jb_tx );     // get the request
         $cast( jb_rsp, jb_tx.clone() ); // create a response
         jb_rsp.set_id_info( jb_tx );    // copy the sequence_id and the transaction_id
 
         @jb_if.master_cb;
         jb_if.master_cb.command <= jb_tx.command;
         if ( jb_tx.command == jelly_bean_types::WRITE ) begin
            jb_if.master_cb.flavor     <= jb_tx.flavor;
            jb_if.master_cb.color      <= jb_tx.color;
            jb_if.master_cb.sugar_free <= jb_tx.sugar_free;
            jb_if.master_cb.sour       <= jb_tx.sour;
         end else if ( jb_tx.command == jelly_bean_types::READ ) begin
            @jb_if.master_cb;
            jb_rsp.taste = jelly_bean_types::taste_e'( jb_if.master_cb.taste ); // update the response
         end
         seq_item_port.put( jb_rsp ); // return the response
      end
   endtask: main_phase
endclass: jelly_bean_driver
driver使用get(第24行)获取请求,然后克隆请求以创建单独的响应(第25和26行)。 set_id_info函数将请求中的一些ID复制到响应中,以便sequencer可以将响应路由回原始序列。最后,driver更新响应(第37行)并将其返回到sequencer(第39行)。希望这可以帮助。

猜你喜欢

转载自blog.csdn.net/zhajio/article/details/80842001