uvm_driver,uvm_sequencer,uvm_monitor

目录

1.uvm_driver

1.uvm_driver内有两个参数,但一般只需要声明REQ即可

2.主要方法

3.代码示例

2.uvm_sequencer

 1.sequence不能自启动,必须通过相关联的sqr启动并自动执行其中的body方法,在某一环境中sqr管理多个sequence,仲裁某一个时刻传递哪个sequence的数据。

2.sqr从uvm_sequencer派生,定义时要指定传递的transaction类型;

3.代码示例

3.uvm_monitor

1.monitor 将信号转化为transaction级的数据包,可以在其中进行function coverage的收集,通过TLM-port机制与其他组件相连。

2.代码分析

4.总结

1.建议所以phase都使用super.phase去调用父类的phase方法,虽然目前除了build_phase大部分都没有区别,但是不保证之后的uvm版本中不会更新,建议养成代码规范;

2.monitor与driver相似,driver将transaction级转化为signal级,monitor与其相反,二者都与vif之间有紧密的联系。通常二者中的main_phase都放在一个while(1)中的死循环。


1.uvm_driver

class uvm_driver #(
    type REQ = uvm_sequenve_item,
    type RSP = REQ
) extends uvm_component

1.uvm_driver内有两个参数,但一般只需要声明REQ即可

2.主要方法

get_next_item

try_next_item

通过以上两个方法之一,实现driver向sqr的请求。driver为initiator,sqr为target。

get为阻塞方法,try为非阻塞。

当driver内除了获取数据还需要进行其他处理,例如未获取数据时将接口初始化,则必须使用try

item_done

3.代码示例

`ifndef _GUARD_HELLO_DRIVER_SV_
`define _GUARD_HELLO_DRIVER_SV_        //两句连用,防止重复编译(C语言内容)

class hello_driver extends uvm_driver #(hello_transaction)
    virtual hello_if vif;
    
    `uvm_component_utils(hello_driver)    //uvm 工厂机制 宏注册

    extern function new(string name,uvm_component parent);
    extern virtual function void build_phase(uvm_phase phase);
    extern virtual task main_phase(uvm_phase phase);

    //new、build_phase、main_phase是一个component必须的    
    
    extern task xxx
    //不同的component里面有各自完成独特功能的函数,属于用户自定义

endclass

function hello_driver::new(string name,uvm_component parent)
    super.new(name,parent);
endfunction
//执行uvm_driver的new函数

function hello_driver::build_phase(uvm_phase phase)
    super.build_phase(phase);
    if(!uvm_config_db#(virtual hello_if)::get(this,"","vif",vif))begin
        `uvm_fatal(get_full_name(),"Error in Geting interface");
    end
endfunction
//interface只在top中实例化.软件域中均使用vif

task hello_driver::main_phase(uvm_phase phase);
    hello_transaction req;
    super.main_phase(phase);
    
    vif.data <= 0;
    vif.valid<= 1'b0;
//初始化

    while(!vif.rst_n)
        @(posedge vif.clk)
    
    while(1) begin
        seq_item_port.get_next_item(req);    //通过driver与sqr之间的port,获取一个req
        
        drive_one_pkt(req);       //用户自定义函数,通常用来处理transaction并驱动DUT

        seq_tiem_port.item_done();           //通知sqr该transaction已经处理完毕
    end
endtask


2.uvm_sequencer

 1.sequence不能自启动,必须通过相关联的sqr启动并自动执行其中的body方法,在某一环境中sqr管理多个sequence,仲裁某一个时刻传递哪个sequence的数据。

2.sqr从uvm_sequencer派生,定义时要指定传递的transaction类型;

3.代码示例

`ifndef _GUARD_HELLO_DRIVER_SV_
`define _GUARD_HELLO_DRIVER_SV_        //两句连用,防止重复编译(C语言内容)

class hello_sequencer extends uvm_sequencer #(hello_transaction)
    
    `uvm_component_utils(hello_driver)    //uvm 工厂机制 宏注册

    extern function new(string name,uvm_component parent);
    extern function void build_phase(uvm_phase phase);
    
    //new、build_phase、main_phase是一个component必须的    
endclass

function hello_sequencer::new(string name,uvm_component parent)
    super.new(name,parent);
endfunction
//执行uvm_sequencer的new函数

function void hello_sequencer::build_phase(uvm_phase phase)
    super.build_phase(phase);
endfunction

3.uvm_monitor

\

1.monitor 将信号转化为transaction级的数据包,可以在其中进行function coverage的收集,通过TLM-port机制与其他组件相连。

2.代码分析

`ifndef _GUARD_HELLO_MONITOR_SV_
`define _GUARD_HELLO_MONITOR_SV_        //两句连用,防止重复编译(C语言内容)

class hello_driver extends uvm_monitor #(hello_transaction)
    virtual hello_if vif;
    
    uvm_analysis_port #(hello_transaction) ap;

    `uvm_component_utils(hello_monitor)    //uvm 工厂机制 宏注册

    extern function new(string name,uvm_component parent);
    extern virtual function void build_phase(uvm_phase phase);
    extern virtual task main_phase(uvm_phase phase);

    //new、build_phase、main_phase是一个component必须的    
    
    extern task xxx
    //不同的component里面有各自完成独特功能的函数,属于用户自定义

endclass

function hello_monitor::new(string name,uvm_component parent)
    super.new(name,parent);
endfunction
//执行uvm_driver的new函数

function void hello_driver::build_phase(uvm_phase phase)
    super.build_phase(phase);
    if(!uvm_config_db#(virtual hello_if)::get(this,"","vif",vif))begin
        `uvm_fatal(get_full_name(),"Error in Geting interface");
    end
    
    ap = new("ap",this);
endfunction
//interface只在top中实例化.软件域中均使用vif

task hello_monitiro::main_phase(uvm_phase phase);
    logic valid;
    logic [7:0] data;

    hello_transaction tr;
    super.main_phase(phase);
    
    while(1) begin
        tr = new();
        receive_one_pkt(tr);
        ap.write(tr);
    end
endtask




4.总结

1.建议所以phase都使用super.phase去调用父类的phase方法,虽然目前除了build_phase大部分都没有区别,但是不保证之后的uvm版本中不会更新,建议养成代码规范;

2.monitor与driver相似,driver将transaction级转化为signal级,monitor与其相反,二者都与vif之间有紧密的联系。通常二者中的main_phase都放在一个while(1)中的死循环。

  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值