首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >得到一个“.不是精化-时间常数”.但我不是已经定义过那个数组了吗?

得到一个“.不是精化-时间常数”.但我不是已经定义过那个数组了吗?
EN

Stack Overflow用户
提问于 2016-06-20 14:31:43
回答 1查看 450关注 0票数 1

在下面的代码片段中,我得到了以下错误:

资料来源:

x.datatheword = $urandom_range(0,255);'this‘不是精化时间常数。若要更正错误,可以将此const变量转换为参数或localparam。

数据记录的几何形状,只是一个内存,是在definition_pkg中声明的。数据记录对象是在Base_txn中创建的,我可以像这样直接访问它:

代码语言:javascript
运行
复制
x.data[0][7:0]  = x.frameID ;   

我不知道为什么我会得到一个精化时间错误,因为在for循环中所发生的一切(我认为)是我正在索引一个已经存在的对象。

对任何建议、解释或解决方案表示感谢。

definition_pkg.svh

代码语言:javascript
运行
复制
`define REC_DATAWIDTH 32  
`define REC_ROWS 16

typedef bit[`REC_DATAWIDTH-1:0] DataRec [`REC_ROWS]  ;

sequences.sv

代码语言:javascript
运行
复制
class Base_txn extends uvm_sequence_item;  

    rand DataRec data;  
    ...


class sequencethingy extends uvm_sequence#(Base_txn);  
    ...  
    int byte4val ;  
    int theword ;  
    int thebyteH ;  
    int thebyteL ;  

// -----------------------------------------------------------------------  
function void build_S (ref Base_txn x);  
   ...  
   x.data[0][7:0]  = x.frameID ;  
   ...  
   for (int i = 8 ; i <= (byte4val+8) ; i++)  // byte8 is the location of S[0]  
   begin  
   theword =  i/4 ;  
   thebyteL =  8*(i%4) ;  
   thebyteH =  thebyteL + 7  ;
   x.data[theword][thebyteH : thebyteL] = $urandom_range(0,255) ;  
   end  
 endfunction  

...  

task body();  
    Base_txn wd_tx;  
    ...  
    build_S(wd_tx) ; // give the processor some data  
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-06-20 14:38:46

把这个写成

代码语言:javascript
运行
复制
x.data[theword][thebyteL +:8] = $urandom_range(0,255) ;  

请参阅Indexing vectors and arrays with +:

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37925155

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档