在递归属性中使用队列

时间:2013-06-17 00:11:23

标签: verilog system-verilog verification assertions system-verilog-assertions

我有一些来自1位串行端口的数据,它有多个字节的变量长度,如下所示:

byte expected_1 [$] = {8'hBA, 8'hDD, 8'hC0, 8'hDE};
byte expected_2 [$] = {8'h01, 8'h23, 8'h45, 8'h67, 8'h89, 8'hAB, 8'hCD, 8'hEF};  

在每个正时钟边沿,发送一位。我需要testbench对序列的追求(将来可能有数千个),所以我想在系统verilog中使用断言自动化该过程。新的2012标准允许将队列传递给属性,但队列是否可以通过递归属性发送?我收到一些关于分层参考的错误。

这是我到目前为止(在@Greg here的帮助下):

default clocking sck @(posedge sck); endclocking : sck  

sequence seq_serial(logic signal, logic [7:0] expected); // check each bit
  byte idx = 7;
  (signal == expected[idx], idx--)[*8];
endsequence : seq_serial

property recurring_queue(bit en, logic data, byte data_e [$])
  int queue_size = data_e.size;
  logic [7:0] expected = data_e.pop_front(); 

  if(queue_size != 0) (
    !en throughout (seq_serial(data, expected) ##1 recurring_queue(en, data, data_e))
  );

endproperty : recurring_queue

`define ez_assert(exp)
   assert property (recurring_queue(en, data, exp))
   else $error("Bad Sequence @ time: %t. Info: %m", $time);

在我的测试平台中调用断言应该像这样简单:

A1 : `ez_assert(expected_1);

读取错误消息:

1) passing hierarchical ref to be used in another hierarchical ref is not supported 
2) Illegal SVA property in RHS of'##' expression 
3) Local variable queue_size referenced in expression before getting initialized

我对断言长可变长度序列序列的其他想法持开放态度。

1 个答案:

答案 0 :(得分:1)

尝试与seq_serial相同的策略:

sequence seq_queue_pattern(bit en, logic data, byte expt_queue [$]);
    int qidx = 0;
    ( !en throughout (seq_serial(data,expt_queue[qidx]), qidx++)[*] )
    ##1 (qidx==expt_queue.size);
endsequence : seq_queue_pattern

asrt_expected_1 : assert property ( $fell(en) |-> seq_queue_pattern(en,data,expected_1));
asrt_expected_2 : assert property ( $fell(en) |-> seq_queue_pattern(en,data,expected_2));

如果en为高或seq_serial链与预期不匹配,则此断言将失败。这个父亲位置不重要:

    最后en完成后,
  • seq_serial不关心一个时钟:
    • ( !en throughout (seq_serial(data,expt_queue[qidx]), qidx++)[*] ) ##1 (qidx==expt_queue.size)
  • 在最终en完成或错误后,
  • seq_serial必须低一个时钟,并且在此之后不关心
    • !en throughout ( (seq_serial(data,expt_queue[qidx]), qidx++)[*] ##1 (qidx==expt_queue.size) )
  • 在最终en完成后,
  • seq_serial必须低一个时钟,之后不关心
    • !en throughout ( (seq_serial(data,expt_queue[qidx]), qidx++)[*] ##1 (qidx==expt_queue.size) ) ##1 (qidx==expt_queue.size)

序列和属性中的队列是新的,所有模拟器可能都不完全支持。要解决此限制,请使用参数化宏为每个预期的队列流创建序列:

`define asrt_qpat(en,monitor, expt_queue) \
    sequence seq_queue_pattern__``expt_queue (bit en, logic data); \
        int qidx = 0; \
        (!en throughout (seq_serial(data,expt_queue[qidx]), qidx++)[*]) \
        ##1 (qidx==expt_queue.size); \
    endsequence : seq_queue_pattern__``expt_queue \
    \
    asrt_``expt_queue : assert property( @(posedge clk) \
        $fell(en) |=> seq_queue_pattern__``expt_queue (en,monitor) ) \
    else $error("Bad Sequence @ time: %t. Info: %m", $time);

`asrt_qpat(en,data[0],expected_1)
`asrt_qpat(en,data[1],expected_2)