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.40
List Price:  €144.15
You save:  €105.75
£31.87
List Price:  £119.64
You save:  £87.76
CA$57.46
List Price:  CA$215.67
You save:  CA$158.21
A$64.10
List Price:  A$240.61
You save:  A$176.50
S$54.26
List Price:  S$203.67
You save:  S$149.41
HK$310.31
List Price:  HK$1,164.76
You save:  HK$854.44
CHF 35.93
List Price:  CHF 134.87
You save:  CHF 98.94
NOK kr454.39
List Price:  NOK kr1,705.56
You save:  NOK kr1,251.16
DKK kr286.51
List Price:  DKK kr1,075.42
You save:  DKK kr788.90
NZ$70.83
List Price:  NZ$265.87
You save:  NZ$195.03
د.إ146.73
List Price:  د.إ550.76
You save:  د.إ404.03
৳4,766.44
List Price:  ৳17,890.59
You save:  ৳13,124.14
RM178.53
List Price:  RM670.12
You save:  RM491.59
₦61,746.72
List Price:  ₦231,762.72
You save:  ₦170,016
₨11,104.31
List Price:  ₨41,679.41
You save:  ₨30,575.09
฿1,365.49
List Price:  ฿5,125.29
You save:  ฿3,759.80
₺1,408.70
List Price:  ₺5,287.50
You save:  ₺3,878.79
B$269.52
List Price:  B$1,011.65
You save:  B$742.12
R744.22
List Price:  R2,793.40
You save:  R2,049.17
Лв75.14
List Price:  Лв282.05
You save:  Лв206.91
₩58,527.63
List Price:  ₩219,680.06
You save:  ₩161,152.43
₪146.39
List Price:  ₪549.46
You save:  ₪403.07
₱2,315.72
List Price:  ₱8,691.92
You save:  ₱6,376.20
¥6,289.74
List Price:  ¥23,608.20
You save:  ¥17,318.45
MX$805.86
List Price:  MX$3,024.77
You save:  MX$2,218.90
QR145.06
List Price:  QR544.49
You save:  QR399.42
P553.96
List Price:  P2,079.26
You save:  P1,525.30
KSh5,155.14
List Price:  KSh19,349.54
You save:  KSh14,194.40
E£2,033.41
List Price:  E£7,632.32
You save:  E£5,598.90
ብር5,078.52
List Price:  ብር19,061.93
You save:  ብር13,983.41
Kz36,434.40
List Price:  Kz136,754.40
You save:  Kz100,320
CLP$39,554.45
List Price:  CLP$148,465.34
You save:  CLP$108,910.89
CN¥291.59
List Price:  CN¥1,094.47
You save:  CN¥802.87
RD$2,429.65
List Price:  RD$9,119.56
You save:  RD$6,689.91
DA5,402.27
List Price:  DA20,277.14
You save:  DA14,874.86
FJ$92.63
List Price:  FJ$347.68
You save:  FJ$255.05
Q307.23
List Price:  Q1,153.19
You save:  Q845.95
GY$8,344.93
List Price:  GY$31,322.21
You save:  GY$22,977.28
ISK kr5,572.22
List Price:  ISK kr20,915.02
You save:  ISK kr15,342.80
DH402.23
List Price:  DH1,509.75
You save:  DH1,107.52
L734.24
List Price:  L2,755.94
You save:  L2,021.69
ден2,364.09
List Price:  ден8,873.48
You save:  ден6,509.39
MOP$319.08
List Price:  MOP$1,197.67
You save:  MOP$878.58
N$741.65
List Price:  N$2,783.77
You save:  N$2,042.11
C$1,467.69
List Price:  C$5,508.89
You save:  C$4,041.20
रु5,432.30
List Price:  रु20,389.82
You save:  रु14,957.52
S/148.52
List Price:  S/557.48
You save:  S/408.95
K161.88
List Price:  K607.63
You save:  K445.74
SAR149.98
List Price:  SAR562.97
You save:  SAR412.98
ZK1,103.85
List Price:  ZK4,143.26
You save:  ZK3,039.40
L191.10
List Price:  L717.30
You save:  L526.19
Kč964.41
List Price:  Kč3,619.86
You save:  Kč2,655.45
Ft15,736.81
List Price:  Ft59,067.22
You save:  Ft43,330.41
SEK kr442.03
List Price:  SEK kr1,659.16
You save:  SEK kr1,217.12
ARS$40,962.17
List Price:  ARS$153,749.14
You save:  ARS$112,786.96
Bs275.61
List Price:  Bs1,034.52
You save:  Bs758.90
COP$176,459.02
List Price:  COP$662,328.69
You save:  COP$485,869.66
₡20,252.23
List Price:  ₡76,015.58
You save:  ₡55,763.35
L1,013.41
List Price:  L3,803.80
You save:  L2,790.38
₲311,072.84
List Price:  ₲1,167,593.83
You save:  ₲856,520.98
$U1,775.42
List Price:  $U6,663.96
You save:  $U4,888.53
zł163.81
List Price:  zł614.88
You save:  zł451.06
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.