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
€37.39
List Price:  €140.35
You save:  €102.95
£32.14
List Price:  £120.65
You save:  £88.51
CA$54.66
List Price:  CA$205.17
You save:  CA$150.51
A$61.46
List Price:  A$230.72
You save:  A$169.25
S$54.37
List Price:  S$204.11
You save:  S$149.73
HK$312.91
List Price:  HK$1,174.51
You save:  HK$861.59
CHF 36.52
List Price:  CHF 137.09
You save:  CHF 100.57
NOK kr437.63
List Price:  NOK kr1,642.62
You save:  NOK kr1,204.99
DKK kr278.85
List Price:  DKK kr1,046.65
You save:  DKK kr767.80
NZ$67.31
List Price:  NZ$252.67
You save:  NZ$185.35
د.إ146.73
List Price:  د.إ550.75
You save:  د.إ404.01
৳4,379.34
List Price:  ৳16,437.61
You save:  ৳12,058.27
RM190.86
List Price:  RM716.38
You save:  RM525.52
₦50,356.97
List Price:  ₦189,011.97
You save:  ₦138,655
₨11,078.47
List Price:  ₨41,582.42
You save:  ₨30,503.94
฿1,479.01
List Price:  ฿5,551.39
You save:  ฿4,072.38
₺1,299.17
List Price:  ₺4,876.37
You save:  ₺3,577.20
B$205.03
List Price:  B$769.58
You save:  B$564.55
R764.52
List Price:  R2,869.60
You save:  R2,105.07
Лв73.13
List Price:  Лв274.49
You save:  Лв201.36
₩54,936.80
List Price:  ₩206,202.11
You save:  ₩151,265.30
₪150.26
List Price:  ₪563.99
You save:  ₪413.73
₱2,300.82
List Price:  ₱8,635.99
You save:  ₱6,335.17
¥6,189.71
List Price:  ¥23,232.72
You save:  ¥17,043.01
MX$678.11
List Price:  MX$2,545.26
You save:  MX$1,867.15
QR144.95
List Price:  QR544.06
You save:  QR399.11
P554.20
List Price:  P2,080.19
You save:  P1,525.98
KSh5,373.27
List Price:  KSh20,168.27
You save:  KSh14,795
E£1,912.60
List Price:  E£7,178.85
You save:  E£5,266.25
ብር2,263.10
List Price:  ብር8,494.41
You save:  ብር6,231.31
Kz33,355.91
List Price:  Kz125,199.50
You save:  Kz91,843.58
CLP$38,100.31
List Price:  CLP$143,007.31
You save:  CLP$104,907
CN¥289.48
List Price:  CN¥1,086.55
You save:  CN¥797.07
RD$2,358.27
List Price:  RD$8,851.64
You save:  RD$6,493.36
DA5,369.66
List Price:  DA20,154.72
You save:  DA14,785.06
FJ$91.61
List Price:  FJ$343.85
You save:  FJ$252.24
Q310.23
List Price:  Q1,164.43
You save:  Q854.20
GY$8,348.16
List Price:  GY$31,334.33
You save:  GY$22,986.17
ISK kr5,619.76
List Price:  ISK kr21,093.46
You save:  ISK kr15,473.70
DH403.24
List Price:  DH1,513.54
You save:  DH1,110.30
L711.11
List Price:  L2,669.11
You save:  L1,958
ден2,300.75
List Price:  ден8,635.74
You save:  ден6,334.98
MOP$322.07
List Price:  MOP$1,208.89
You save:  MOP$886.82
N$764.41
List Price:  N$2,869.17
You save:  N$2,104.76
C$1,463.02
List Price:  C$5,491.39
You save:  C$4,028.36
रु5,322.32
List Price:  रु19,977.02
You save:  रु14,654.70
S/147.05
List Price:  S/551.96
You save:  S/404.90
K151.07
List Price:  K567.06
You save:  K415.98
SAR149.84
List Price:  SAR562.41
You save:  SAR412.57
ZK1,028.45
List Price:  ZK3,860.25
You save:  ZK2,831.79
L186.04
List Price:  L698.31
You save:  L512.27
Kč943.79
List Price:  Kč3,542.47
You save:  Kč2,598.68
Ft14,707.23
List Price:  Ft55,202.73
You save:  Ft40,495.50
SEK kr434.09
List Price:  SEK kr1,629.35
You save:  SEK kr1,195.26
ARS$34,866.52
List Price:  ARS$130,869.47
You save:  ARS$96,002.95
Bs274.66
List Price:  Bs1,030.94
You save:  Bs756.27
COP$155,927.93
List Price:  COP$585,266.43
You save:  COP$429,338.49
₡20,023.88
List Price:  ₡75,158.48
You save:  ₡55,134.59
L981.04
List Price:  L3,682.28
You save:  L2,701.24
₲294,922.92
List Price:  ₲1,106,976.03
You save:  ₲812,053.11
$U1,532.67
List Price:  $U5,752.80
You save:  $U4,220.12
zł161.60
List Price:  zł606.56
You save:  zł444.96
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.