Configuring a Test Environment(从Configuration_Configuration Objects开始

上一篇 / 下一篇  2018-12-17 09:06:28

   Configuration Objects  

       配置对象是用于组织配置变量的有效的可重用的机制。在典型的测试平台中,通常会有几个配置对象,每个配置对象都绑定到一个组件。它们被创建为uvm_object的子类,并将整个测试结构层次的给定分支的所有相关配置参数组合在一起。还可以有一个附加的单个的配置对象来单独保存全局配置参数。
       UVM配置数据库负责处理object的范围和存储。以下是agent的典型配置对象的代码。它有一个虚拟接口,用于指向代理连接的接口,且还拥有用于描述和控制该接口的许多变量。

       // configuration class
       class wb_config extends uvm_object;
         `uvm_object_utils( wb_config );

       // Configuration Parameters
         virtual wishbone_bus_syscon_if v_wb_bus_if; // virtual wb_bus_if
         int m_wb_id; // Wishbone bus ID
         int m_wb_master_id; // Wishbone bus master id for wishone agent
         int m_mac_id; // id of MAC WB master
         int unsigned m_mac_wb_base_addr; // Wishbone base address of MAC
         bit [47:0] m_mac_eth_addr; // Ethernet address of MAC
         bit [47:0] m_tb_eth_addr; // Ethernet address of testbench for sends/receives
         int m_mem_slave_size; // Size of slave memory in bytes
         int unsigned m_s_mem_wb_base_addr; // base address of wb memory for MAC frame. buffers
         int m_mem_slave_wb_id; // Wishbone ID of slave memory
         int m_wb_verbosity; // verbosity level for wishbone messages

         function new( string name = "" );
            super.new( name );
         endfunction

       endclass

    Using a Configuration Object

       任何需要配置的组件都应执行以下步骤:

  • 得到自己的配置;
  • 根据其配置创建自己的内部结构和行为;
  • 配置它的子类。

        作为顶层组件的测试组件从测试参数包或UVM配置数据库(例如虚拟接口句柄)获取其配置值。然后,它为环境中的组件设置特定的测试配置参数。

       class test_mac_simple_duplex extends uvm_test;
       ...

           wb_config wb_config_0; // config object for WISHBONE BUS
            ...

           function void set_wishbone_config_params();
                //set configuration info
                // NOTE The MAC is WISHBONE slave 0, mem_slave_0 is WISHBONE slave 1
                // MAC is WISHBONE master 0, wb_master is WISHBONE master 1
                wb_config_0 = new();

                if( !uvm_config_db #(virtual wishbone_bus_syscon_if)::get( this , "" , "WB_BUS_IF" , wb_config_0.v_wb_bus_if ) ) begin
                     `uvm_error(...)
                end

                wb_config_0.m_wb_id = 0; // WISHBONE 0
                wb_config_0.m_mac_id = 0; // the ID of the MAC master
                wb_config_0.m_mac_eth_addr = 48'h000BC0D0EF00;
                wb_config_0.m_mac_wb_base_addr = 32'h00100000;
                wb_config_0.m_wb_master_id = 1; // the ID of the wb master
                wb_config_0.m_tb_eth_addr = 48'h000203040506;
                wb_config_0.m_s_mem_wb_base_addr = 32'h00000000;
                wb_config_0.m_mem_slave_size = 32'h00100000; // 1 Mbyte
                wb_config_0.m_mem_slave_wb_id = 0; // the ID of slave mem
                wb_config_0.m_wb_verbosity = 350;

                uvm_config_db #( wb_config )::set( this , "*" , "wb_config" , wb_config_0 );
           endfunction

           ...
       

           function void build_phase( uvm_phase );
              super.build_phase( phase );

              set_wishbone_config_params();
              ...
           endfunction

           ...

       endclass

       使用配置对象的组件通过使用uvm_config_db :: get来获取它。在此示例中,driver从object获取虚拟接口句柄,ID和verbosity。

       class wb_m_bus_driver extends uvm_driver #(wb_txn, wb_txn);
       ...

          virtual wishbone_bus_syscon_if m_v_wb_bus_if;
          bit [2:0] m_id; // Wishbone bus master ID
          wb_config m_config;
          ...

          function void build_phase( uvm_phase phase );
             super.build_phase( phase );

             if( !uvm_config_db #( wb_config )::get( this , "" , "wb_config" , m_config ) ) begin
                `uvm_error(...)
             end
             m_id = m_config.m_wb_master_id;
             ...
          endfunction

          function void connect_phase( uvm_phase phase );
             super.connect_phase( phase );
             m_v_wb_bus_if = m_config.v_wb_bus_if; // set local virtual if property
          endfunction

          function void end_of_elaboration();
             set_report_verbosity_level_hier(m_config.m_wb_wb_verbosity);
          endfunction
          ...

       endclass

    Configuring sequences

        这里有一篇关于配置sequence的文章。

    Configuring DUT connections

        设置DUT-to-Testbench连接是一种始终需要的配置活动。SV模块(通常是顶层模块,但有时是ProtocolModules)必须在配置空间中添加虚拟接口。在测试平台上,测试组件从UVM config database获取虚拟接口句柄,并将其应用于适当的配置对象。

       class test_mac_simple_duplex extends uvm_test;
          ...

          function void set_wishbone_config_params();
             wb_config_0 = new();
             // Get the virtual interface handle that was set in the top module or protocol module
             if( !uvm_config_db #( virtual wishbone_bus_syscon_if )::get( this , "" , "WB_BUS_IF" , wb_config_0.v_wb_bus_if ) ) begin
                `uvm_error(...)
             end
             ...  

             uvm_config_db #( wb_config )::set( this , "*","wb_config",wb_config_0, 0); // put in config           endfunction

           ...

       endclass
             
       Example source code

       (在http://verificationacademy.com/uvm-ovm上在线下载源代码示例)。


TAG:

 

评分:0

我来说两句

显示全部

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

日历

« 2019-01-12  
  12345
6789101112
13141516171819
20212223242526
2728293031  

数据统计

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

RSS订阅

Open Toolbar
博聚网