【验证小bai】randomize中的this.指的是哪个this呢

简介: 【验证小bai】randomize中的this.指的是哪个this呢

为啥小白是标题中的禁止词呢,有点摸不着头脑啊。


今天一精神小伙突然发现一个问题,简化讲就是在seq中对某一transaction进行randomize时,this的含义竟然指的不是这个seq中的值,而是transaction中的值!


示意代码如下:

class my_transaction extends uvm_sequence_item;
  rand bit [8-1:0] data;
  rand bit       par_err;
    bit [8 -1:0] test_value = 8'hFF;
endclass
class sanity_case_seq extends my_sequence;
  extern function new(string name = "sanity_case_seq");
  extern virtual task body();
    bit [8 -1:0] test_value = 8'hAA;
  `uvm_object_utils(sanity_case_seq)
endclass: sanity_case_seq
function sanity_case_seq::new(string name = "sanity_case_seq");
  super.new(name);
endfunction: new
task sanity_case_seq::body();
    bit [8 -1:0] test_value = 8'hBB;
  repeat(1) begin
    `uvm_do_with(my_tr, {my_tr.par_err == 0; my_tr.data == this.test_value;})
  end
  #100;
endtask: body


其中,

`uvm_do_with(my_tr, {my_tr.par_err == 0; my_tr.data == this.test_value;})

这个this.test_value指的是哪个值呢?没错,指的是class my_transaction中的test_value = 8'hFF,看下波形也能知道:



我当时大感惊奇,这this难道不是应该指的seq里的量么?后来下班路上我才想明白,这不就是相当于我在class my_transaction里做约束吗?my_transaction里constraint中的this一定是指的本身内部的值,这里也一定是呀!


这实验做得就有一点没有意义了哈哈哈


当然了,如果transaction内没有this.test_value这个值,那么此时会取哪个值呢?答案是会取class sanity_case_seq中的bit [8 -1:0] test_value = 8'hAA,如波形:



当然,此时VCS会给你告警,告诉你是他往外扩大了范围去找的:

Warning-[ETLIIC] Extended this/super lookup
../tc/sanity_case.sv, 21
"\this .test_value"
  A member 'test_value' is not found in the randomized object. It is present 
  in the class of the method containing the randomize-with call.In inline 
  constraints, this/super refers to the object being randomized. VCS supports 
  an extended lookup in the class of the method, where randomize call is 
  present, for backwards compatibility. This may be removed in the future.
  If you intend to access the this/super of the containing method in a 
  portable way, you may want to create a local object aliased to this/super. 
  To promote this warning to error, use '-error=ETLIIC'.

那么要怎么取到body()函数中的bit [8 -1:0] test_value = 8'hBB呢?需要把this去掉:

`uvm_do_with(my_tr, {my_tr.par_err == 0; my_tr.data == test_value;})

此时就是取值函数内的值:



还有一点,就是如果transaction和seq类内都没有这个值,只在function内有的话,VCS是会报error的,this必须是类内的变量,不能只在function中。



相关文章
|
3月前
|
C++
【PTA】L1-016 验证身份(C++)
【PTA】L1-016 验证身份(C++)
66 0
【PTA】L1-016 验证身份(C++)
|
2月前
|
人工智能
技术心得记录:关于自补图的认识和构造(无证明)
技术心得记录:关于自补图的认识和构造(无证明)
18 0
|
10月前
|
移动开发
【验证小bai】关于多个声明域变量名重名时如何取用的问题——还是以随机约束为例
【验证小bai】关于多个声明域变量名重名时如何取用的问题——还是以随机约束为例
|
3月前
|
数据安全/隐私保护
HJ20 密码验证合格程序
HJ20 密码验证合格程序
33 0
|
10月前
【验证小bai】利用verdi让所有环境force现身
【验证小bai】利用verdi让所有环境force现身
113 0
整数值比较判断登录系统用户
整数值比较判断登录系统用户
39 0
|
人工智能
CF1556D. Take a Guess(交互 性质)
CF1556D. Take a Guess(交互 性质)
76 0
CF1556D. Take a Guess(交互 性质)
|
数据安全/隐私保护
PTA 1081 检查密码 (15 分)
本题要求你帮助某网站的用户注册模块写一个密码合法性检查的小功能。该网站要求用户设置的密码必须由不少于6个字符组成,并且只能有英文字母、数字和小数点 .,还必须既有字母也有数字。
393 0
|
PHP
tp自动验证流程和返回空数组的问题
tp自动验证流程和返回空数组的问题
102 0
7-158 验证“哥德巴赫猜想” (20 分)
7-158 验证“哥德巴赫猜想” (20 分)
600 0