uvm_config_db::set一次能get多次吗?

本文详细介绍了在UVM(Universal Verification Methodology)环境中,如何通过`uvm_config_db`进行配置并实现在不同组件间传递int型变量。通过`comp1`和`comp2`组件的交互,展示了配置设置与获取的过程,并展示了在顶层`test`模块中创建和操作子组件的实践案例。
摘要由CSDN通过智能技术生成

以int型变量为例 

module test();
    
    import uvm_pkg::*;
    `include "uvm_macros.svh"

    
    class comp1 extends uvm_component;
        `uvm_component_utils(comp1)
        int t;
        function new(string name ="comp1",uvm_component parent);
            super.new(name,parent);
        endfunction 

        task get_config();
            uvm_config_db#(int)::get(this,"","t",t);
            $display("@%0t get the 1st,t = %0d",$time,t);
            #10;
            if(!uvm_config_db#(int)::get(this,"","t",t)) begin
                $display("@%0t Can't get 2nd!",$time);
                t = 99;
            end 
            else 
                $display("@%0t get the 2nd,t = %0d",$time,t);

        endtask
    endclass 

    class comp2 extends uvm_component;
        `uvm_component_utils(comp2)
        int t;
        function new(string name ="comp2",uvm_component parent);
            super.new(name,parent);
        endfunction 
    endclass 
    
    class test extends uvm_component;
        `uvm_component_utils(test)
        comp1 c1;
        comp2 c2;
        int t;
        function new(string name = "test",uvm_component parent);
            super.new(name,parent);
            t = 10;
            uvm_config_db #(int)::set(this,"c1","t",t);

            c1 = new("c1",this);
            c2 = new("c2",this);
        endfunction 

        function display;
            $display("\n\nc1.t = %0d",c1.t);
            $display("c2.t = %0d",c2.t);
        endfunction
    endclass 

    initial begin
        test t1;
        t1 = new("t1",null);
        t1.c1.get_config();
        t1.display();
    end 
endmodule

在顶层test 创建c1 和 c2 组件,test中set到c1一次int变量,c1 任务get两次。结果如下:

可以看到c1 get 的两次都成功了。 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值