Local Variable Usage with 'and' and 'or' of Sequences

SystemVerilog Assertions and Functional Coverage From Scratch Local Variables and Endpoint Sequence Methods
7 minutes
Share the link to this page
You need to have access to the item to view this lesson.
One-time Fee
List Price:  $149.95
You save:  $110
List Price:  ₹9,995
You save:  ₹8,515
List Price:  €138.25
You save:  €101.41
List Price:  £117.84
You save:  £86.44
List Price:  CA$204.96
You save:  CA$150.35
List Price:  A$225.84
You save:  A$165.67
List Price:  S$202.34
You save:  S$148.43
List Price:  HK$1,170.83
You save:  HK$858.90
CHF 36.50
List Price:  CHF 137
You save:  CHF 100.50
NOK kr425.44
List Price:  NOK kr1,596.87
You save:  NOK kr1,171.43
DKK kr274.85
List Price:  DKK kr1,031.67
You save:  DKK kr756.81
List Price:  NZ$244.65
You save:  NZ$179.47
List Price:  د.إ550.76
You save:  د.إ404.03
List Price:  ৳17,586.25
You save:  ৳12,900.88
List Price:  RM705.43
You save:  RM517.49
List Price:  ₦217,052.62
You save:  ₦159,225
List Price:  ₨41,785.73
You save:  ₨30,653.08
List Price:  ฿5,477.82
You save:  ฿4,018.41
List Price:  ₺4,830.70
You save:  ₺3,543.69
List Price:  B$772.79
You save:  B$566.90
List Price:  R2,756.55
You save:  R2,022.14
List Price:  Лв270.43
You save:  Лв198.38
List Price:  ₩204,444.79
You save:  ₩149,976.17
List Price:  ₪550.62
You save:  ₪403.92
List Price:  ₱8,723.73
You save:  ₱6,399.53
List Price:  ¥23,492.32
You save:  ¥17,233.45
List Price:  MX$2,496.17
You save:  MX$1,831.13
List Price:  QR547.33
You save:  QR401.51
List Price:  P2,028.57
You save:  P1,488.12
List Price:  KSh19,868.37
You save:  KSh14,575
List Price:  E£7,062.64
You save:  E£5,181
List Price:  ብር8,624.46
You save:  ብር6,326.71
List Price:  Kz127,378.37
You save:  Kz93,441.95
List Price:  CLP$134,758.56
You save:  CLP$98,855.90
List Price:  CN¥1,066.23
You save:  CN¥782.16
List Price:  RD$8,809.46
You save:  RD$6,462.42
List Price:  DA20,174.87
You save:  DA14,799.84
List Price:  FJ$339.80
You save:  FJ$249.27
List Price:  Q1,166.47
You save:  Q855.69
List Price:  GY$31,407.88
You save:  GY$23,040.12
ISK kr5,529.08
List Price:  ISK kr20,753.08
You save:  ISK kr15,224
List Price:  DH1,486.40
You save:  DH1,090.39
List Price:  L2,651.18
You save:  L1,944.84
List Price:  ден8,524.55
You save:  ден6,253.42
List Price:  MOP$1,207.01
You save:  MOP$885.44
List Price:  N$2,728.31
You save:  N$2,001.42
List Price:  C$5,525.33
You save:  C$4,053.26
List Price:  रु19,997.53
You save:  रु14,669.74
List Price:  S/560.56
You save:  S/411.22
List Price:  K583.41
You save:  K427.98
List Price:  SAR562.40
You save:  SAR412.57
List Price:  ZK3,914.34
You save:  ZK2,871.47
List Price:  L687.88
You save:  L504.61
List Price:  Kč3,416.19
You save:  Kč2,506.04
List Price:  Ft53,514.39
You save:  Ft39,256.97
SEK kr427.07
List Price:  SEK kr1,603
You save:  SEK kr1,175.92
List Price:  ARS$133,452.42
You save:  ARS$97,897.74
List Price:  Bs1,037.36
You save:  Bs760.98
List Price:  COP$571,419.66
You save:  COP$419,180.81
List Price:  ₡76,972.73
You save:  ₡56,465.49
List Price:  L3,710.01
You save:  L2,721.58
List Price:  ₲1,129,468.37
You save:  ₲828,552.99
List Price:  $U5,743.98
You save:  $U4,213.65
List Price:  zł590.01
You save:  zł432.82
per week
Payment Plan
per week
4 payments
Already have an account? Log In


Hello, and welcome to this lecture in this lecture, I will describe some obscure error messages that you may get. And these are related to the end and or of sequences where you use local variable. So let's start with a simple example. I have a sequence as one, but I have declared a local variable x. And then I'm doing an order of two sequences. This is sequence number one, and this is sequence number two.

In this sequence, I'm assigning some data part of your design or test bench to the local variable x. Then I'm ordering the sequence with another sequence where I'm not assigning any data or anything to the local variable x. When you do and then I will take the local data x and assign it to some other data If you go this particular order of sequences This way you will get an error. And the error will tell you this is from mentors question same that local variable accurate x reference in expression where it does not flow. I am not sure if this error message is understandable. And the alarm say that data does not flow out of the competent sequence, again a big obstacle.

So, let me explain what's going on here. In this sequence, we are assigning data to x. And this is an order of two sequences. So, let's say this sequence and, and first and then we assign data to x. Because this is an order as soon as one of the two sequences finishes, the control flows out of here, and then you assign the local variable to which you apply data to data one So, So far, so good, there is absolutely nothing wrong with it. But what if this sequence ends first, and then because this is an all again, the control will flow out.

And now when you try to assign X to data X has not been initialized, it is still in unknown state. So you cannot apply an unknown local data to any other variable. So, this is the reason why you get an error because of the order of two sequences where x is assigned only in one of the two sequences. So, this makes sense, and that's what the error message means. So, what's the solution? The simplest solution is that before you enter the order of sequences, you assign the data.

So, that way it does not matter which of the two sequences and first X has known data and then when you assign it to some other data It is okay. So this will pass. The other solution which I am not recommending it is not a clean solution, but it works. So for the sake of completeness I am showing it here. Here, basically what you do is in both sequences you apply, you apply the data to x, so that any again doesn't matter which sequence ends First, you will still have known data on x and then x will be assigned to another data. So, that's also fine and this works.

But more than often what you really need to do is what is shown here. In this sequence, I'm assigning at the end of this sequence, I'm saying x equal to data. And then I'm saying or at the end of this sequence x equal to beta two is a different data and in real life, the reason you Assign data in such a sequence is because at the end of a given sequence, you want to assign different data. So since this is an R, again, doesn't matter, the sequence ends First, there is some known data that is assigned to x. And so that when you assign X to data, one of the biggest wine, so the order of two sequences, where either the data is the same, all the data is different. The order of sequences with this kind of assignment or local data works.

Now we are going to look at and have two sequences. So I'm taking this particular example and I'm only changing or to end, like shown here. Now when you do this, you will get an error because this is an ad. So let's see what's going on here. Since this is an end of two sequences, both sequences must add. Let's say the sequence is first and then sequence ends.

So since this sequence ended later, x will be equal to data to, or but now let's say this sequence ends first, and, and this sequence and later than x to be equal to data. So once these two sequences are over and control flows out, you're going to say data when equal to x, but which x? Is it the data that was assigned or is it the data to assign? So that's an error. And again, the error message is obscure. So when you do an end of two sequences, and you assign two different data's, that's an error.

So again, the solution here is the same as the one for all is the same sequence and I'm assigning a data, same data. And then it doesn't matter which of the two sequences and first as soon as both and control throws out. And then you assign the data or manipulate the data and then assign it to something else. So the point here is that if you do need two different data to be assigned based on two different sequences, and n simply won't work, you'll have to call this in a totally different way. But this this kind of assignment of different data with an end does not work. And to complete the story, what I'm showing here is that this is the same sequence that I showed in the very first slide whether or not we replace or with an ad, and you're applying data in just one of the two sequences.

But in this case, because this is an end, war sequences must end. So as long as you assign data to x in one of the two sequences that will be unknown data, when the control flows out of sequence. Note that when we had a Or here, then this will give an error as I explained in the very first slide. So, these are some detailed nuances that will come in handy when you deep dive deep into usage of local variables. So, that's all thank you for attending the lecture.

Sign Up


Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.