Connections to DUT Interfaces(从Connect/AbstractConcreteConfigDB开始)

上一篇 / 下一篇  2018-09-29 09:44:12

       Connect/AbstractConcreteConfigDB

      Abstract Class 

       Abstract类被定义为测试平台中agent的一部分,并包含在agent package中。下面是一个名为wb_bus_abs_c的示例抽象类的代码。请注意定义此类的公共接口的纯虚methods。作为公共接口的一部分,也是表示时钟的上升沿的事件。另请注意,抽象类继承自uvm_component,因此继承了phase methods等。       

       // Abstract class for abstract/concrete class wishbone bus communication
       //----------------------------------------------
       virtual class wb_bus_abs_c extends uvm_component;

           function new(string name, uvm_component parent);
                super.new(name,parent);
           endfunction

           // API methods
           //WRITE 1 or more write cycles
           pure virtual task wb_write_cycle(wb_txn req_txn, bit [2:0] m_id);

           //READ 1 or more cycles
           pure virtual task wb_read_cycle(wb_txn req_txn, bit [2:0] m_id, output wb_txn rsp_txn);

           // wait for an interrupt
           pure virtual task wb_irq(wb_txn req_txn, output wb_txn rsp_txn);

           //Get a wb transaction from the bus
           pure virtual task monitor(output wb_txn txn);

           event pos_edge_clk;
       endclass

       Concrete Class

       具体类派生自抽象类。需要重载任何纯虚methods,提供实现。它还可以提供编写/读取从抽象类继承的变量的代码。此类在包含BFM实例的包装器模块内定义。因为它是在包装器模块中定义的,因此具体类的范围是整个包装器模块,因此它的method可以访问包装器模块内部定义的任何东西,包括端口,变量,类句柄,函数,任务,特别是BFM 模块实例。

       【此处需一副图】

       这是具体类wb_bus_concr_c的代码。它在包装器模块wb_bus_protocol_module中定义,此模块是一个协议模块。请注意,此类继承自抽象类并提供method的具体实现。这些methods很简单,因为它们是简单地调用BFM内部相应method的“中介”method。例如,具体的driver class wb_write_cycle()task调用BFM中的wb_write_cycle()task。在wb_bus_protocol_module的底部是BFM(wishbone_bus_syscon_bfm)的实例(wb_bfm)。

        module wb_bus_protocol_module #(int WB_ID = 0, int num_masters = 8, int num_slaves = 8,
                                                                      int data_width = 32, int addr_width = 32)
               (
               // Port declarations
               // WISHBONE common signals
               output logic clk,
               output logic rst,
               ...
               );
               ...

               // Concrete class declaration
               class wb_bus_concr_c #(int ID = WB_ID) extends wb_bus_abs_c;

                    function new(string name = "", uvm_component parent = null);
                         super.new(name,parent);
                    endfunction

                    // API methods
                    // simply call corresponding BFM methods
                    //WRITE 1 or more write cycles
                    task wb_write_cycle(wb_txn req_txn, bit [2:0] m_id);
                        wb_bfm.wb_write_cycle(req_txn, m_id);
                    endtask

                    //READ 1 or more cycles
                    task wb_read_cycle(wb_txn req_txn, bit [2:0] m_id, output wb_txn rsp_txn);
                         wb_bfm.wb_read_cycle(req_txn, m_id, rsp_txn);
                    endtask

                    // wait for an interrupt
                    task wb_irq(wb_txn req_txn, output wb_txn rsp_txn);
                         wb_bfm.wb_irq(req_txn, rsp_txn);
                    endtask

                    task monitor(output wb_txn txn);
                        wb_bfm.monitor(txn);
                    endtask

                    task run_phase(uvm_phase phase);
                         forever @ (posedge clk)
                             -> pos_edge_clk;
                    endtask : run_phase

              endclass
              ...
              // WISHBONE BFM instance
              wishbone_bus_syscon_bfm wb_bfm(
                   .clk( clk ),
                   .rst( rst ),
                    ...
               );

        endmodule


TAG:

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

日历

« 2019-01-19  
  12345
6789101112
13141516171819
20212223242526
2728293031  

数据统计

  • 访问量: 19986
  • 日志数: 75
  • 建立时间: 2018-09-03
  • 更新时间: 2018-12-29

RSS订阅

Open Toolbar