Using sequence to capture protocol violations

Hi all,

I created this interface with an assert that checks that a valid e1_num is a periodic counter range in [0:N-1]:


interface e1_if #(parameter N = 5)(input clock);
	logic [7:0] 			data;
	logic				valid;
	logic [common::log2(N)-1:0]	e1_num;
	// this 2 lines exists just to support the assert below
	logic [common::log2(N)-1:0]		prev_e1_num = 0;
	always @(posedge clock) if(valid) 	prev_e1_num <= e1_num;

	property non_consequtive_e1_num;
		@(posedge clock) valid |-> if (e1_num != 0) (e1_num - prev_e1_num == 1)
			else (e1_num - prev_e1_num == -(N-1));
	endproperty

	ERROR_non_consequtive_e1_num: assert property (non_consequtive_e1_num);
endinterface

I want to use sequence block to describe the expected behavior instead of using the support signal prev_e1_num. Any idea how to write it?
I want to write a sequence that describe two consequtive valid with e1_num incremented by 1.

In reply to yakirmishli:

I want to use sequence block to describe the expected behavior instead of using the support signal prev_e1_num. Any idea how to write it?

What’s wrong in using support logic, as long as your assertion is correct?

I want to write a sequence that describes two consecutive valid with e1_num incremented by 1.


logic				valid;
logic [common::log2(N)-1:0]	e1_num;
sequence q_really_consecutive; 
 valid[*2] ##0 e1_num==$past(e1_num -1'b1);
endsequence

sequence q_sparcely_consecutive; 
  logic [common::log2(N)-1:0]	v_e1;
  (valid, v_e1==e1_num) ##1 valid[->1] ##0 e1_num==v_e1 -1'b1);
endsequence 
 

Ben Cohen
http://www.systemverilog.us/ ben@systemverilog.us

  • SVA Handbook 4th Edition, 2016 ISBN 978-1518681448
    // For 10% discount, use code 45KJT5GN @
  • A Pragmatic Approach to VMM Adoption 2006 ISBN 0-9705394-9-5
  • Using PSL/SUGAR for Formal and Dynamic Verification 2nd Edition, 2004, ISBN 0-9705394-6-0
  • Real Chip Design and Verification Using Verilog and VHDL, 2002 isbn 0-9705394-2-8
  • Component Design by Example ", 2001 ISBN 0-9705394-0-1
  • VHDL Coding Styles and Methodologies, 2nd Edition, 1999 ISBN 0-7923-8474-1
  • VHDL Answers to Frequently Asked Questions, 2nd Edition ISBN 0-7923-8115

In reply to ben@SystemVerilog.us:

What’s wrong in using support logic, as long as your assertion is correct?

Nothing. I just started to learn the sequence style and wanted to use it. I want to believe that when I be skilled enough it will be more productive than RTL logic for debug.

Thanks for the example - exactly what I tried to do :-)