I am trying to verify, in a serial bit stream, that a given pattern occurs only once. To check this I fed the serial input to a shift register and trying to poll the number of times the pattern was detected. The assertion that will check for the occurrence of the pattern at least once is working.
Could you suggest how to check the max repetitions w/o using the parallel data.
The pattern is 0xF within the stream of 30 bits
module ser_dut(input a, input start, input clk);
reg [3:0] pattern_reg;
bit [4:0] bits_in_frame;
bit [1:0] num_header;
bit toggle;
always @(posedge clk)
begin
if(start) begin
pattern_reg = {pattern_reg,a};
bits_in_frame = bits_in_frame +1;
if (pattern_reg==4'hF && bits_in_frame <30)
begin
num_header = num_header+1;
end
end
if(!start)
begin
num_header = 0;
bits_in_frame =0;
pattern_reg=0;
end
end
sequence allfour ;
a[*4];
endsequence
check_sva1: assert property(@(posedge clk) $rose(start) |-> allfour within 1[*30] ) $display("Assertion Min PASS at time %t", $time); else $display("Assert Min FAIL at time %t", $time);
check_sva2: assert property(@(posedge clk) $rose(start) |-> (num_header<=1) throughout 1[*30] ) $display("Assertion Max PASS at time %t", $time); else $display("Assert MAX FAIL at time %t", $time);
endmodule
Thanks, Ben. The solution works good but I am looking for some means to achieve it without parallelizing the data. There seems to be no way to use sequence repetition and goto operator together. The construct I wanted to use was something like this, for which the compiler fires errors.
The following works: AVOID the not opr. Intead check for the positive expected results. Here we’re looking that a[*4] occurs no more than once in 20 cycles.
Since the Non-consecutive repetition operator is a Booleaan (Boolean([=n]), we
can use the endpoints instead.