uvm_transaction,uvm_sequence

 1.uvm_transaction

1.在uvm环境中,所有组件之间的通信都是通过transaction类型连通;

 

2.是UVM中事务的基本类,继承uvm_object 的所有方法外,增加了timing和recording的接口

3.uvm_sequence_item – 用户定义的事务的基类,同时也是uvm_sequence的基类。提供了使用强大sequence机制的基本功能。

4.包含内容(成员变量、域的自动化、变量的约束、其他必要内容)

 

5.代码示例

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

class hello_transaction extends uvm_sequence_item;

    rand bit [47:0]    dmac;
    rand bit [47:0]    smac;
    rand bit [15:0]    ether_type;
    rand byte          pload[];
    rand bit [31:0]    crc;
//定义激励成员
    
    constraint cons_pload_size{
        pload.size >=46;
        pload.size <=1500;
    }
//约束项

    extern function new(string name="hello_transaction");

    `uvm_object_utils_begin(hello_transaction)
        `uvm_field_int(dmac,UVM_ALL_ON)
        `uvm_field_int(smac,UVM_ALL_ON)
        `uvm_field_int(ether_tpye,UVM_ALL_ON)
        `uvm_field_array_int(pload,UVM_ALL_ON)
        `uvm_field_int(crc,UVM_ALL_ON)
     `uvm_object_utils_end
endclass

function hello_transaction::new(string name="hello_transaction")
    super.new(name);
endfunction
//执行hello_transaction的构造函数


2.uvm_sequence 

1.uvm_sequence从uvm_sequence_base派生出来, 参数化的类,两个参数REQ, RSP,通常只给一个参数。

2.uvm_sequence_base提供sequence启动执行流程的方法及一些sequence之间调度的方法

3. sequence控制并产生一系列transaction;

一种sequence一般只用来产生一种类型的transaction,但可以产生多个;

sequence中对事务的控制和产生都是在body()任务中完成的;

sequence与sequence_item的关系:sequence启动后,按照body()任务的功能依次产生多个相同类型的事务对象,可以将sequence看做存储并管理一系列事务的仓库;

4.代码示例

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

class hello_sequence extends uvm_sequence#(hello_transaction);
    
    hello_transaction m_trans;
    
    extern virtual function new(string name,uvm_component parent);
    
    extern virtual task body();
        if(starting_phase != null)begin
            starting_phase.raise_objection(this);
            `uvm_info("my_sequence","after starting_phase.raise_objection,beforce repeat 100",UVM_LOW);
        end
    
        repeat(100)begin
            `uvm_do(my_trans);
            `uvm_info("my_sequence","uvm_do m_trans once time",UVM_LOW);
        end
        #100
        if(starting_phase != null)
            starting_phase.drop_objection(this);
        endtask
        `uvm_object_utils(hello_sequence)
endclass

   

function hello_sequence::new(string name="hello_sequence")
    super.new(name);
endfunction
//执行hello_sequence的new函数

3.总结

1.为什么transaction不继承于uvm_transaction,而要从uvm_sequence_item派生?

        uvm_sequence_item是用户定义的事务的基类,同时也是uvm_sequence的基类。提供了使用强大sequence机制的基本功能。

2.body是如何被执行的?

      每个sequence都有一个body任务。当一个sequence启动后,会自动执行sequence的body任务

3.starting_phase何时不为null?

       1.手工启动sequence时为starting_phase赋值

       2.将此sequence作为sequencer的某动态运行phase的default_phase时,starting_phase不为null。

        通俗一点,设置默认default_sequence时,会自动赋值phase给starting_phase,如果使用`uvm_do宏将sequence作为参数,则starting_phase为null。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值