Chapter 10 – Test

At last, we needto create one more block: the test. This block will derive from the uvm_test classand it will have two purposes:

  • Create the env block
  • Connect the sequencer to the sequence

You might bewondering why are we connecting the sequencer and the sequence in this block,instead of the agent block or the sequence block.

The reason isvery simple: by specifying in the test class which sequence will be going to begenerated in the sequencer, we can easily change the kind of data istransmitted to the DUT without messing with the agent’s or sequence’s code.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

class simpleadder_test extends uvm_test;

     `uvm_component_utils(simpleadder_test)

 

     simpleadder_env sa_env;

 

     function new(string name, uvm_component parent);

          super.new(name, parent);

     endfunction: new

 

     function void build_phase(uvm_phase phase);

          super.build_phase(phase);

          sa_env = simpleadder_env::type_id::create(...

     endfunction: build_phase

 

     task run_phase(uvm_phase phase);

          simpleadder_sequence sa_seq;

 

          phase.raise_objection(.obj(this));

               sa_seq = simpleadder_sequence::type_id::create(...

               assert(sa_seq.randomize());

               sa_seq.start(sa_env.sa_agent.sa_seqr);

          phase.drop_objection(.obj(this));

     endtask: run_phase

endclass: simpleadder_test

Code 10.1– Code for the test class

Line 21 starts asequencer in the desired sequence for this test.

In Figure 10.1,it’s represented the current state of our testbench.



Our testbench isfinally ready, now it’s time to execute it and check the results.

The source ofthe test component can be found here:


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值