Local Variables

SystemVerilog Assertions and Functional Coverage From Scratch Local Variables and Endpoint Sequence Methods
26 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$39.95
List Price:  $149.95
You save:  $110
₹1,480
List Price:  ₹9,995
You save:  ₹8,515
€38.34
List Price:  €143.93
You save:  €105.58
£31.88
List Price:  £119.66
You save:  £87.78
CA$56.05
List Price:  CA$210.41
You save:  CA$154.35
A$61.43
List Price:  A$230.58
You save:  A$169.15
S$53.79
List Price:  S$201.92
You save:  S$148.12
HK$310.98
List Price:  HK$1,167.27
You save:  HK$856.28
CHF 35.69
List Price:  CHF 133.99
You save:  CHF 98.29
NOK kr442.35
List Price:  NOK kr1,660.33
You save:  NOK kr1,217.98
DKK kr285.97
List Price:  DKK kr1,073.38
You save:  DKK kr787.41
NZ$68.47
List Price:  NZ$257
You save:  NZ$188.53
د.إ146.73
List Price:  د.إ550.76
You save:  د.إ404.03
৳4,772.75
List Price:  ৳17,914.27
You save:  ৳13,141.51
RM178.49
List Price:  RM669.97
You save:  RM491.48
₦67,630.68
List Price:  ₦253,847.82
You save:  ₦186,217.14
₨11,098.11
List Price:  ₨41,656.11
You save:  ₨30,558
฿1,376.92
List Price:  ฿5,168.19
You save:  ฿3,791.27
₺1,380.37
List Price:  ₺5,181.14
You save:  ₺3,800.77
B$231.74
List Price:  B$869.85
You save:  B$638.11
R725.31
List Price:  R2,722.44
You save:  R1,997.12
Лв74.97
List Price:  Лв281.42
You save:  Лв206.44
₩56,110.17
List Price:  ₩210,606.27
You save:  ₩154,496.10
₪148.41
List Price:  ₪557.07
You save:  ₪408.65
₱2,354.61
List Price:  ₱8,837.90
You save:  ₱6,483.29
¥6,183.06
List Price:  ¥23,207.76
You save:  ¥17,024.70
MX$816.11
List Price:  MX$3,063.25
You save:  MX$2,247.13
QR145.65
List Price:  QR546.72
You save:  QR401.06
P546.19
List Price:  P2,050.11
You save:  P1,503.92
KSh5,172.27
List Price:  KSh19,413.84
You save:  KSh14,241.56
E£1,983.52
List Price:  E£7,445.04
You save:  E£5,461.51
ብር4,889.44
List Price:  ብር18,352.22
You save:  ብር13,462.78
Kz36,474.35
List Price:  Kz136,904.35
You save:  Kz100,430
CLP$39,068.11
List Price:  CLP$146,639.90
You save:  CLP$107,571.78
CN¥289.35
List Price:  CN¥1,086.08
You save:  CN¥796.73
RD$2,407.08
List Price:  RD$9,034.84
You save:  RD$6,627.76
DA5,364.28
List Price:  DA20,134.53
You save:  DA14,770.25
FJ$90.92
List Price:  FJ$341.27
You save:  FJ$250.35
Q308.30
List Price:  Q1,157.20
You save:  Q848.89
GY$8,355.77
List Price:  GY$31,362.93
You save:  GY$23,007.15
ISK kr5,578.69
List Price:  ISK kr20,939.31
You save:  ISK kr15,360.61
DH401.79
List Price:  DH1,508.10
You save:  DH1,106.31
L727.95
List Price:  L2,732.33
You save:  L2,004.38
ден2,358.96
List Price:  ден8,854.23
You save:  ден6,495.27
MOP$320.22
List Price:  MOP$1,201.94
You save:  MOP$881.72
N$724.29
List Price:  N$2,718.59
You save:  N$1,994.30
C$1,469.63
List Price:  C$5,516.17
You save:  C$4,046.54
रु5,393.89
List Price:  रु20,245.66
You save:  रु14,851.77
S/151.44
List Price:  S/568.45
You save:  S/417
K160.80
List Price:  K603.57
You save:  K442.76
SAR149.98
List Price:  SAR562.97
You save:  SAR412.98
ZK1,104.44
List Price:  ZK4,145.47
You save:  ZK3,041.02
L190.88
List Price:  L716.49
You save:  L525.60
Kč971.83
List Price:  Kč3,647.71
You save:  Kč2,675.88
Ft15,780.25
List Price:  Ft59,230.25
You save:  Ft43,450
SEK kr440.89
List Price:  SEK kr1,654.87
You save:  SEK kr1,213.98
ARS$40,099.21
List Price:  ARS$150,510.06
You save:  ARS$110,410.85
Bs275.98
List Price:  Bs1,035.88
You save:  Bs759.90
COP$175,370.51
List Price:  COP$658,243
You save:  COP$482,872.49
₡20,344.02
List Price:  ₡76,360.13
You save:  ₡56,016.10
L1,009.30
List Price:  L3,788.36
You save:  L2,779.05
₲311,796.57
List Price:  ₲1,170,310.31
You save:  ₲858,513.73
$U1,702.76
List Price:  $U6,391.24
You save:  $U4,688.47
zł166.33
List Price:  zł624.31
You save:  zł457.98
Subscription
$149.95
$39.95
per week
Payment Plan
$149.96
$39.95
per week
4 payments
Already have an account? Log In

Transcript

Hello and welcome to lecture number 17. on local variables. local variable is a feature you're most likely to use very often. They can be used both in a sequence and a property. As the name suggests, and they are called local because they are indeed local to a sequence or a property and are not visible or available to other sequences or properties. But of course, there is a solution to this restriction which we will study further into the section. Figure 9.1 points out actually the most important element of a local var, which is that it allows multi threaded application and creates a new copy of the local variable with every instance of the sequence in which it is used.

In other words, the user does not know to worry about creating copies of local variables with each invocation of the sequence. Okay, let's look at this simple application here. And see what we mean by a local variables create a new copy of itself with every instance of the sequence or a property. And it's because of this reason that they are called dynamic variables compared to static variables. And in this application, at bondage of claw, every dried is high, it implies that we should hold the project. Now, sequence data check has a local variable called local data of type int declared and what we are doing in the sequences Based on the completion or based on the trueness of RTC, and RTC is another sequence.

If RTC holds which RTC basically says that within one to five clocks, after READ WRITE is asserted, that read is done on the completion of the sequence and if the sequence passes what we are doing is we are taking the read data because the read is done and assigning that read data or storing that read data into local data local data again being the local variable. And five talks later. After we do a write data, the data that we read we are writing out but we want to make sure that the right data is equal to read data which was stored in local data. Right data is equal to read data or local data plus hex FF. Now, Okay, so far it looks very straightforward. But now let's assume that before read is done, or when we are waiting for five clocks.

To check for the right data readwrite arrives again, it's pipelined behavior of read, write, read, write can keep coming to read data, while not waiting for the right data to go out. So let's read write arrives again and it being high, it means read. And we are still, let's say wait for a rating for the five clocks. What the local variable does it being a dynamic variable, it's simply going to create another copy of local data. So we are waiting for this but a new thread will start based on the completion of RTC and new read data. That we just got from the second thread of RDC that read data will be assigned to a new copy of local data.

So the first thread is continuing and to wait and check for write data. Second thread starts in what I call in a pipeline fashion when the first third is still executing, and more importantly, we don't need to worry about creating explicitly a copy of the local data. And so, the next read will also start a second thread, wait for five o'clock and compare right data. Now, this is a very important point. And without this facility what we used to do or all of us used to do in earlier days without such what I call pipeline, multi threaded behavior that is supported by the language, we will detect that we have When completed the first raid, then we will create an array of local data, for example, and each element of the array, we will explicitly be meaning the user, the coder, the programmer will create a new copy of local data, and then so on and so forth.

Here, you don't need to worry about that at all. So let's look at some more features. And it will become clear to you the semantic of this particular statement that you see here. So, as I just said, it's a new copy of local data that is created every instance of a project. few basic points that you need to know first of all, the local data can be initialized. Which makes sense.

But another point that you need to carefully understand is that if you notice, this is a repeat of the last Page. Before we assign anything to the local data, it must be assigned to an expressions as an expression or a sequence. Without this attachment, you cannot assign anything to the local data. assignment to local data must be attached to an expression or a sequence. And that was the reason why we had RDC. And I will show you well what if I don't have RDC?

I don't have any sequence of expression, then how do I assign local data and I'll show you that in just a second. So, do a repeat if you simply do this local data equal to read data without assigning it to or without attaching it to another sequence of expression, it will give you a compile time error and Another thing that may be confusing to many people is that when you compare the data, like in this case, right data needs to be equal to local data plus hex FF, it should not be attached to an expression. Rather, I shouldn't call is strange, but rather difficult to remember. Well, so that will give you an error. Now, that doesn't make me happy. So what is the solution?

How do we solve this problem? This is, this is what I want to do, but the language doesn't support it. So what we are going to do is, and this is something you'll probably use more or more very often. I don't have an expression or a sequence here, but I still want to assign the local data. All I'm going to do is use a one take B one, which is an expression, and it's always true. So every time we enter data, check sequence, these being always true.

We will ask Find a local data with read data. And then the language itself will create a new copy of local data and do a fork of a second threat. So we don't need to worry about an explosion, the expression or sequence, if you do have it fine and good use that here and the title local data to it. Just like in our example, we had RDC. And now what about this roller where we cannot attach I want to check write data only on the completion of read RDC. So the simple solution to that is little pom pom file the advocate that's a requirement, we're simply going to say RDC and without advancing time, we are going to check for it.

This will do exactly what you were trying to do here. But if you do it this way, language won't accept it. If you do it this way, language up in that way. Be happy with it. So this particular RDC found ground zero, right data is equivalent to what you are trying to do here. Okay, let's see some more basic points.

So I think as I just said earlier, the local variables can be used both in sequence and property. In the property, you can have any implication operator. So what I'm showing here is, is the same example I'm waiting for one clock and I'm checking for raw data here I'm implying non overlapping, meaning the next clock check for the right data. This is rather straightforward. Let's look at some other finer points. If you're going to use local data as a formal in your sequence, then you cannot declare it as local In other words, if you have a local data, you cannot use it as form.

So that's the rule you need to remember. Now let's look at this particular rule that I mentioned earlier is that local variables declared in one sequence are not visible in the sequence where it gets instantiated. What does that mean? Let's look at this example. What we are doing here is we have a lower sequence I call l sequence, in that I have local variable data is a local variable, lb underscore data of type int. And I'm going to use the same RDC sequence and assign it read data.

Now, there is a higher sequence and I have some temporal domain associated with associativity here, and what I'm doing is I'm calling this L sequence which as you know, we can do you You can have a sequence use another sequence as a subsequence. And then since we are calling a sequence, we may think that I can use this lb data from the L sequence because I'm instantiating, that with everything that's in this sequence is visible in the higher sequence. Well, that's not quite true, because as we know, local data is local. It's not visible to a higher sequence. But what if I indeed want to do what I just showed here and not get a compiler? So what I've done number one, I have you I have created a form and as I just say, you cannot have a formal as local variable.

So I do not declare l data as a local variable. This is something I just showed you in the previous Slide. Now what I'm going to do is, so this is L data is a formal of sequence, Eleanor's course sequence. From the higher sequence, I'm going to create a local data. C note here that in the previous example, we had local data in the L sequence. And we could not use lb data into the higher sequence.

And I'm trying to solve that problem. So first of all, I don't declare it in the lower sequence because that's against the rule, but I declared it in the highest sequence. Now what I'm going to do is, I'm going to call l sequence with h data as the actual that gets assigned to or that gets equated to a data. And now I'm going to use h data when when l sequences instantiated here a data will be assigned to L data. We will go ahead and wait for our DC l data will get will be will store our data And this L data will be now assigned to the actual h data. So now we can compare right data equal to h data.

So there's a solution to this problem we had. Let's look at some more ways of using local data. So first of all, you can have multiple local data assignments you don't is not restricted to just one local data assignment, which is what we have seen so far. So on the completion of RDC, again, is the same sequence. What I'm going to do is I'm going to assign two local data and data one and data two to two different data. It could be anything.

Now I'm going to wait for five clocks. And there's another thing you can do is whatever data that you are assigning for example, data to guess retry data, you can increment or decrement, or you can use it in another expression in you can change the local data before you use it. And if you try to do right data equal to L data one, or compare right data for a data one and compare write retry data equal to add data to well, you cannot do multiple checks in the same sub expression. So this will give me an error, but assignment will not give you an error. And what we are doing here is, if this is a problem, just like I showed you in an earlier example, what if I do want to do multiple checks in a sub expression, I'm simply going to divide those with a bond bond zero meaning do not advance the time.

Just compare right data without data one right retry data with no data to This particular code will accomplish this exact thing. But this thing, this particular sub expression will give you an error. So let's look look at a very typical application, which I'm sure you will come across in your project. So the spec says that once a read has been issued, another read from the same read ID cannot be the issue until a read act with the same ID has returned. So once the read is issue, we wait for the read, redact. And if another read from the same read ID occurs again, then it's a problem and we need to catch it and the session should fail.

So let's start from the bottom. Here we are saying a cert property check read which is here. If it passes, don't do anything if it fails at this point. Right that it has failed. Let's look at chapter eight. In the property check rate, we declare a local variable called local ID.

Now we are saying once a read has been issued, and I have said this many times, choose your antecedent wisely. So here we're saying dollar rows read. Once read as an issue. What I'm going to do is I'm going to assign that read ID that is a show associated with this raid, and I'm going to store it in local ID. Now, let's look at this carefully. Just for the sake of argument for now put aside not once the rose dollar rose Reed has arrived, it implies starting next clock.

The rows re should remain high. And the read ID should remain the same as the read ID that we got when dollar rolls read right if this does not hold and then should hold forever, continuously in the positive reputation semantics until you get the reader for the dollar rose read and it has the same redact the reader ID is the same as the read ID which is stored in local ID. If this does not happen, it is when we are waiting for the read with the same read ID until we get the read. If this does not happen, then we do or not have it, meaning fail if you indeed got a read with the same read ID and hence there is a knot here. So, again, the idea is you'll get continual or continuous reads. And with every invocation or check read.

We are going to create a new copy of local ID and store A new copy of read ID. So you can reverse rate read ID equal to one secondary to read ID equal to two, so on and so forth. And you don't need to worry about that. It's it's the nature of dynamic nature of local ID allows you what I call pipeline, multi threaded behavior. So carefully study this application. And it's, it's a very typical real life application that you may be directly able to use.

Now, I want to go back to this problem that I had posed in a previous lecture with delay range. Let me refresh your memory. So here's a property and we are saying that at pauses of clock, if ready is high, it implies that within the next five clause, block radius should arrive. Very straightforward. And here's the timing diagram for it. So let's say s one Which is the force ready?

First ready? starts here at S 112344 rocks later radio arrives, and everybody's happy because this thread has met its requirement. But let's say the very next clock radio arrives, okay? what's gonna happen is this radio is also going to wait from within one to five clocks, it waits for one to three sees the same radio that the first radio saw and said, Hey, I'm happy, I have already is going to also pass the simulator is going to give you only one pass indication. So you don't know if the radio arrived for the secondary or for the first three. What if radio never arrived for the secondary, you would not know.

And that's what I call a false positive. So let's look at this simulation log and after simulating the paper property. Here's the first already arrives. Then the secondary arrives at time 70. See what happens at time 90. Both these radio detects both readies and the property passes.

Again, you don't know this ready, right for the second ready or the first ready, and that's not good. You need to have a radio for each ready to make sure that the logic works. So this is what we are going to do we are going to use a local variable in your test bench. What you do is we have less than a sequence called ready actor. And we have declared a local variable called local data or type byte. And again, as I said, if you don't have any condition expression here, simply say it's always true.

What we are going to do is when the first Ready arrives, we are going to take the ready now and you assign the right in Amira testbench, we take the first ready name associated with the first ready and store it in local data. I just also want to point out that you can attach a sub routine like we have seen it many times before. And I use this idea of attaching a sub retain by displaying what's going on. And please use this little technique, which will tremendously help you in your debug process. So what I'm saying is, when this happens, enter a sequence. I have just ended the sequence and of assigning local data or local readiness equal to local data, which is basically a local array num readiness equal to readiness.

Then I'm going to wait for one to five clocks as required. Then when the radio arrives, I want I'm doing a logical and Meaning when ready act arrives, the ready act now should be equal to local data, which we had stored here with readiness. That means the force ready EQ corresponds to the first readiness. And then again, I attach a sub routine and I display the ready down ready economic zone and so forth, to help me with debug, as you will see in the log file, next page. So basically, for every ready that comes, we assign a readiness test by storing it here and then every time we're ready atoms, we make sure that this radio corresponds to the ready num that was stored. In the local data, let's look at the simulation log to solidify this behavior of the sequence.

So, at dine 50, we enter local sequence How do I know that again, because I would our display here the first already memorize first ready arrived, sorry first radio arrives and I assigned that ready num corresponding to the first ready for the one then I time 70 the the sequence or the property passes, because when the ready EQ arrives, the sequence checks to see that it's ready assigned in the Test Range corresponds to the first readiness as we just saw in the previous cycle page. So what we have made sure is that the ready yet that arrives, does indeed correspond to the ready, the first ready. So this radio is for the first ready. Now we move forward unless a second radio arrives. The second radio arrives before And it also says the radio check that game for the first ready. Okay, and local data is assigned the second ready now.

Now let's see what happens. It's a bit you may find this confusing, but study the law carefully and you will you will notice a behavior. Now when the radio arrives a sequence check to see that is right in that acronym corresponds to the second readiness. In other words we have made sure that every radiate that arrives is for a given ready again to emphasize in this example, without the local variable, we do not know that this radio is either for ready number two, already number one, as we saw in this particular law point, but with a local variable, we will create a new thread for every read We will create a new local data for every ready. And then when ready arise, we make sure with the local data that's stored ready numb that the radio corresponds to the ready that game before the radical right.

And that's what this log shows. This really shows you the power of local variable with this particular solution here again, you will not get a false positive as you would get here if you did not use the local variable. So that's pretty much it for the for the local variables. local variables are again dynamic in nature, and with every instance of a given sequence or a property, a new copy of the local variable is created. And that allows you what I call from a hardware point of view pipelined, multi threaded behavior. Thank you so much for attending this lecture and I will see you in the next lecture soon.

Sign Up

Share

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.