uvm config_db

1、uvm object 使用config_db。
1、uvm_object中通过config_db get得到变量

class my_config extends uvm_object;
    `uvm_object_utils(my_config)
    virtual my_if vif;
    function new(string name = "my_config");
        super.new(name);
        $display("%s", get_full_name());
        if(!uvm_config_db#(virtual my_if)::get(null, get_full_name(), "vif", vif))
        `uvm_fatal("my_config", "please set interface")
     //get函数原型中,第一个参数必须是一个component
所以这里不能使用this指针,只能使用null或者uvm_root

     //通过名字get_full_name()得到,即其实例化时指定的名字
     //使用null时,UVM会自动将其替换为uvm_root::get(),再加上第二个参数get_full_name() ,就可以完整地得到此object的路径 
endfunction
endclass

function void base_test::build_phase(uvm_phase phase);
    …
    cfg = new("cfg");
endfunction

module top_tb;
… 
initial begin
    uvm_config_db#(virtual my_if)::set(null, "cfg", "vif", input_if);
end
//所以,base_test中实例化cfg的名字要与top_tb中config_db::set的路径参数一致。

2、uvm_object中通过config_db set变量

class case0_sequence extends uvm_sequence #(my_transaction);
    …
    virtual task pre_body();
      if(uvm_config_db#(int)::get(null, get_full_name(), "count", count))
        `uvm_info("seq0", $sformatf("get count value %0d via config_db", count), UVM_MEDIUM)
      else
        `uvm_error("seq0", "can't get count value!")
      #10000;
      uvm_config_db#(bit)::set(uvm_root::get(), "uvm_test_top.env0.scb","cmp_en", 0);
    //可以set 到uvm_component中。

    ...
    void'(uvm_config_db#(bit)::get(uvm_root::get(), get_full_name(), "first_start", first_start)
    if(first_start)
    `uvm_info("drv0_seq", "this is the first start of the sequence", UVM_MEDIUM)
    else
    `uvm_info("drv0_seq", "this is not the first start of the sequence",UVM_MEDIUM)
    uvm_config_db#(bit)::set(uvm_root::get(), "uvm_test_top.v_sqr.*", "first_start", 0);
    //这个sequence向自己传递了一个参数:first_start。在一次仿真中,当此sequence第一次启动时,其first_start值为1
    //
当后面再次启动时,其first_start0。根据first_start值的不同,可以在body中有不同的行为。
    //由于此sequencevirtual sequence中被启动,所以其get_full_name的结果应该是uvm_test_top.v_sqr.*,而不
uvm_test_top.env0.i_agt.sqr.* 
    endtask
    …
endclass

2、uvm component 使用config_db。

 

转载于:https://www.cnblogs.com/littleMa/p/10688300.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值