# How to assert a bit sequence using concurrent assertions

**URL:** <https://verificationacademy.com/forums/t/how-to-assert-a-bit-sequence-using-concurrent-assertions/30553>\
**Category:** SystemVerilog\
**Tags:** SystemVerilog, assertion, concurrent-assertion\
**Created:** [April 16, 2015, 5:07am UTC](https://verificationacademy.com/forums/t/how-to-assert-a-bit-sequence-using-concurrent-assertions/30553 "2015-04-16T05:07:58Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![user49](https://verificationacademy.com/forums/user_avatar/verificationacademy.com/user49/32/4533_2.png) [@user49](https://verificationacademy.com/forums/u/user49)\
**Post date:** [April 16, 2015, 6:18pm UTC](https://verificationacademy.com/forums/t/how-to-assert-a-bit-sequence-using-concurrent-assertions/30553/7 "2015-04-16T18:18:42Z")

</div>

_In reply to [raku](https://verificationacademy.com/forums/t/how-to-assert-a-bit-sequence-using-concurrent-assertions/30553/6):_

1. I made a slight mistake, which I corrected above, I missed the “1” in  
(1, v\_collected[i]=serial, i=i-1’b1)

```verilog

 property p_data_lsb2msb; // Updated 
      bit[7:0] v_data, v_collected;
      bit[2:0] i;
      @(posedge clk)(sync, v_data=data, i=7) |=> // serial output is from msb to lsb 
          (1, v_collected[i]=serial, i=i-1'b1)[*8] ##1 v_collected==v_data; 
  endproperty 

```

> Please explain when or if sync is high thought 8 cycles does this assertion creates multiple threads or a single thread is created.Also if multiple thread are creates whether “i” value of assertion in each thread remains different from each or all will have same value

I assumed that sync was one pulse, indicating the start of the serial transmission, before the first bit of data, like the one in a UART. I don’t know your design, but if sync is high for all 8 bits, then you can do something like

```verilog

module par2ser;
  bit[7:0] data; 
  bit clk, sync, serial; 
  property p_data_msb2lsb; 
      bit[7:0] v_data, v_collected;
      bit[2:0] i;
      @(posedge clk)($rose(sync), v_data=data, i=0) |-> // serial output is from lsb to msb 
          (1, v_collected[i]=serial, i=i+1'b1)[*8] ##1 v_collected==v_data; 
  endproperty 
 
  property p_data_lsb2msb; 
      bit[7:0] v_data, v_collected;
      bit[2:0] i;
      @(posedge clk)($rose(sync), v_data=data, i=7) |-> // serial output is from msb to lsb 
          (1, v_collected[i]=serial, i=i-1'b1)[*8] ##1 v_collected==v_data; 
  endproperty 
 
  ap_data_msb2lsb: assert property(p_data_msb2lsb); 
  a_data_lsb2msb: assert property(_data_lsb2msb); 

```

In this case, there is one thread for the successful attempt. The $rose insures one successful attempt, and one thread. You have multiple threads in a successful attempt if you have in the antecedent the ORing of sequences, like

```verilog

a ##[1:4] b |-> c
a ##1 b[*1:4] |-> c
Here ypou would need a first_match() lile
first_match(a ##[1:4] b) |-> c
first_match(a ##1 b[*1:4]) |-> c 

```

Each local variable for each atteempt, when the assertion is first sampled and started, is independent of other previously threads started at previous attempts.  
Local variables are “local” to the property.  
Ben [SystemVerilog.us](http://SystemVerilog.us)

---

_[View the full topic](https://verificationacademy.com/forums/t/how-to-assert-a-bit-sequence-using-concurrent-assertions/30553)._
