【验证小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中。



相关文章
|
9月前
|
C++
【PTA】L1-016 验证身份(C++)
【PTA】L1-016 验证身份(C++)
107 0
【PTA】L1-016 验证身份(C++)
|
4月前
|
算法 API 数据安全/隐私保护
逆向学习crackme160题-007-reg 的 write up
逆向学习crackme160题-007-reg 的 write up
57 2
|
4月前
|
前端开发 安全 API
前端全栈之路Deno篇(三):一次性搞懂和学会用Deno 2.0 的权限系统详解和多种权限配置权限声明方式
本文深入解析了 Deno 2.0 的权限系统,涵盖主包和第三方包的权限控制机制,探讨了通过命令行参数、权限 API 和配置文件等多种权限授予方式,并提供了代码示例和运行指导,帮助开发者有效管理权限,提升应用安全性。
【验证小bai】利用verdi让所有环境force现身
【验证小bai】利用verdi让所有环境force现身
231 0
|
监控 网络协议 安全
eve-ng中模拟飞塔HA测试实验及理论
eve-ng中模拟飞塔HA测试实验及理论
414 1
eve-ng中模拟飞塔HA测试实验及理论
|
测试技术
软件测试面试题:lr自动关联和手动关联
软件测试面试题:lr自动关联和手动关联
132 0
|
中间件
【TP5.1】做了权限后,验证码不出来的问题
【TP5.1】做了权限后,验证码不出来的问题
106 0
【TP5.1】做了权限后,验证码不出来的问题
|
数据库
tp5.1关联预加载 -- 并再次解释模型的关联
tp5.1关联预加载 -- 并再次解释模型的关联
216 0
tp5.1关联预加载 -- 并再次解释模型的关联
tp5.1的模型操作
tp5.1的模型操作
121 0
|
数据库
【自然框架】之通用权限(九):权限的验证
继续,这是第九章了。本来这张应该好好写的,不过还是先简单介绍一下吧,以后有空再补上详细说明吧。 通用权限想要写的文章目录:(这是第九章)   1、 简介、数据库的总体结构2、 介绍人员表组3、 介绍组织结构表组4、 介绍角色表组5、 介绍“项目自我描述表组”6、 权限到节点7、 权限到...
801 0

热门文章

最新文章