SystemVerilog 'class' Based Methodology

SystemVerilog Assertions and Functional Coverage From Scratch SystemVerilog Functional Coverage Language Features
24 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.44
List Price:  €144.28
You save:  €105.84
£31.93
List Price:  £119.86
You save:  £87.93
CA$57.45
List Price:  CA$215.64
You save:  CA$158.19
A$64.12
List Price:  A$240.67
You save:  A$176.55
S$54.27
List Price:  S$203.70
You save:  S$149.43
HK$310.47
List Price:  HK$1,165.34
You save:  HK$854.86
CHF 35.74
List Price:  CHF 134.15
You save:  CHF 98.41
NOK kr456.25
List Price:  NOK kr1,712.53
You save:  NOK kr1,256.27
DKK kr286.72
List Price:  DKK kr1,076.21
You save:  DKK kr789.48
NZ$70.92
List Price:  NZ$266.22
You save:  NZ$195.29
د.إ146.73
List Price:  د.إ550.75
You save:  د.إ404.02
৳4,792.38
List Price:  ৳17,987.92
You save:  ৳13,195.54
RM180.09
List Price:  RM675.97
You save:  RM495.88
₦62,179.77
List Price:  ₦233,388.17
You save:  ₦171,208.40
₨11,161.13
List Price:  ₨41,892.66
You save:  ₨30,731.52
฿1,376.19
List Price:  ฿5,165.47
You save:  ฿3,789.28
₺1,405.79
List Price:  ₺5,276.58
You save:  ₺3,870.78
B$246.73
List Price:  B$926.09
You save:  B$679.36
R734.27
List Price:  R2,756.05
You save:  R2,021.78
Лв75.23
List Price:  Лв282.40
You save:  Лв207.16
₩57,882.25
List Price:  ₩217,257.66
You save:  ₩159,375.41
₪145.78
List Price:  ₪547.21
You save:  ₪401.42
₱2,350.49
List Price:  ₱8,822.45
You save:  ₱6,471.96
¥6,261.91
List Price:  ¥23,503.72
You save:  ¥17,241.81
MX$810.63
List Price:  MX$3,042.66
You save:  MX$2,232.03
QR146.36
List Price:  QR549.38
You save:  QR403.02
P552.40
List Price:  P2,073.41
You save:  P1,521.01
KSh5,163.53
List Price:  KSh19,381.03
You save:  KSh14,217.50
E£2,034.16
List Price:  E£7,635.12
You save:  E£5,600.95
ብር5,099.95
List Price:  ብር19,142.37
You save:  ብር14,042.42
Kz36,674.10
List Price:  Kz137,654.10
You save:  Kz100,980
CLP$39,616.41
List Price:  CLP$148,697.91
You save:  CLP$109,081.50
CN¥291.59
List Price:  CN¥1,094.47
You save:  CN¥802.87
RD$2,439
List Price:  RD$9,154.65
You save:  RD$6,715.65
DA5,375.65
List Price:  DA20,177.19
You save:  DA14,801.54
FJ$92.73
List Price:  FJ$348.08
You save:  FJ$255.34
Q308.92
List Price:  Q1,159.54
You save:  Q850.61
GY$8,390.52
List Price:  GY$31,493.33
You save:  GY$23,102.81
ISK kr5,555.04
List Price:  ISK kr20,850.54
You save:  ISK kr15,295.50
DH402.49
List Price:  DH1,510.75
You save:  DH1,108.25
L735.86
List Price:  L2,762.03
You save:  L2,026.16
ден2,366.27
List Price:  ден8,881.68
You save:  ден6,515.40
MOP$320.99
List Price:  MOP$1,204.85
You save:  MOP$883.85
N$733.03
List Price:  N$2,751.42
You save:  N$2,018.38
C$1,476.03
List Price:  C$5,540.19
You save:  C$4,064.16
रु5,459.94
List Price:  रु20,493.58
You save:  रु15,033.64
S/149.71
List Price:  S/561.93
You save:  S/412.22
K162.56
List Price:  K610.15
You save:  K447.59
SAR150.11
List Price:  SAR563.45
You save:  SAR413.33
ZK1,109.90
List Price:  ZK4,165.96
You save:  ZK3,056.06
L191.30
List Price:  L718.05
You save:  L526.74
Kč966.19
List Price:  Kč3,626.54
You save:  Kč2,660.35
Ft15,901.88
List Price:  Ft59,686.78
You save:  Ft43,784.90
SEK kr440.95
List Price:  SEK kr1,655.10
You save:  SEK kr1,214.15
ARS$40,829.29
List Price:  ARS$153,250.37
You save:  ARS$112,421.08
Bs277.12
List Price:  Bs1,040.18
You save:  Bs763.05
COP$174,918.24
List Price:  COP$656,545.43
You save:  COP$481,627.19
₡20,168.90
List Price:  ₡75,702.82
You save:  ₡55,533.91
L1,018.04
List Price:  L3,821.16
You save:  L2,803.12
₲313,289.69
List Price:  ₲1,175,914.62
You save:  ₲862,624.93
$U1,782.11
List Price:  $U6,689.05
You save:  $U4,906.94
zł163.79
List Price:  zł614.79
You save:  zł451
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 10 on functional coverage. In this lecture, I'll basically go through some further nuances or cover group and cover point. And mainly I'll be covering embedded core group in a class. So let's start with a very simple example of how to embed a cover group in a class. I have a simple class called helper with two variables, same SIG, and address. And I have another class called my class in which I'm declaring a variable m object of type helper class.

Now within this class, I'm going to embed a color group called Co. And I'm going to access the properties or signals of class m underscore up. And here I'm accessing sync sake, which I'm using. It has A sampling edge for the core group. Similarly, I have a cover point that I am accessing address from the class helper. So not only can you embed a cover group in a class, but I'm also showing that you can access the properties of the instance of from the instance of another class. And this is quite powerful in the sense that you can have a class where you can go through many different types of variables and signals.

And then you can access those properties of the clause from different classes. And the only other thing I need to point out is that in the constructor of the class from noon, you have to instantiate helper class m object. Before you instantiate pick our group go otherwise Go group go does not have a handle ready to access the properties of class helper. If you declare our group because we knew before m object equal to new, then you will get a compile error. So this is a very simple example of embedding cover group in a class. Now, let's see that when you embed a cover group, you want to pass some arguments or parameters as I call them to that cover group.

So here I have a cover group in a class C one called CV, and it takes in one input parameter or a formal of dive aid called arc. And then in this cover group, I am covering integer x dollar point x. And as I have discussed in previous lectures, what I'm saying is create the maximum number of bins You need to create for this PowerPoint is based on the input argument called R. Now, when you construct this clause with the function new in the constructor of the class itself, I'm passing an input argument or a formal feeling of typing. Then I'm taking this formal and passing it to the instance of cover group CV. So the point is that when you like here, when you instantiate the class, you pass an argument to its constructor, which in turn will pass that argument to the instance of our group, you cannot pass parameters or the actual performance of a cover group that is embedded in a class directly.

So You can do it this way. And I'll show you a bit more interesting example, in the next slide in a upcoming slide, but before that, let me show you how to override a cover group that is embedded in a class. You know that whenever you extend a parent class, or or any class, that you can override the methods of that parent class. Similarly, you can override cover groups of the parent class. So here I have a class called parent. And I have declared p bike, which is of random type bike.

It's a random variable. And inside this class, I'm declaring a car group called Pico. And I'm saying our P bike. Now in this PowerPoint, I'm creating one begins, which is parent bands, but we This brackets it means that create as many explicit beans as required to cover the values on the right hand side. So we have 256 values on the right hand side so it will create 256 bins called parent parent beans. And then I am constructing the class and within the constructor of the class, I am instantiating our group Pico so far so good.

Now, let's create another class called child that extends parent. In this class also, I'm defining a cover group Pico. So what that means is these cover group Beco have child class is now going to override the Pico group or class parent. And in this cover group Pico here, I am simply again covering Beibei But I'm changing the definition of bins. Here, I'm creating a bin base called child base all in one with the 256 values on the right hand side. What that means is, if any of the 256 values that your test bench exercises that this beans will be considered covered here, you need to stimulate or 256 values to cover all beds.

And I'll tell you why I'm doing that basically to prove the point that when you override a covered rope in a child class, you can recreate his definition nav tree like and here in the constructor. I am instantiating Beco. Now let's see, let's prove that this overridden definition does work. So what I've created is a Simple module called test override. And in that I am declaring two variables p one of type parent class, and C one of child class. And then in the initial begin, I'm instantiating, both B one and C one.

And in a for loop, I'm basically saying that randomize all the variables or all the properties of P one, and randomize all the variables of C one, because just sort of fresh. The P by is the only variable but it's all tie brand, and you can randomize it. And that Ren v bi is also inherited here in child class. And then I'm explicitly calling the sample method that we have covered in previous lectures. So I'm basically saying that cover the Pico, which is the cover group, here and sample it for every iteration of the for loop explicit sample method call and then I'm displaying the instance coverage of Beco off the class class object p one and Pico instance of the class object c one which is the child class. And just to point out that you can get instance base coverage simply by calling the cover group dot get instance coverage and again, get his coverage from the class object see one.

Now the simulation log will show that P one dot Pico instance coverage is 25% while c one dot p coinsurance coverage is hundred percent. So this shows that the definition of Pico was overridden. redefined anti class that the reason for that is here in our group Pico, we needed 256 bins to cover or 256 values. Here you need any one of the 256 values to cover the bins. And with the randomization is so turned out that in the P one class Pico we did not hit all the 256 values, we only hit 25% of the values. But when Pico was overridden in child class, we definitely hit at least one of 256 values.

And so it was instant it had any it has an insurance coverage of hundred percent. So basically this proves that when you can indeed override a covered group in a child because that was defined in the parent class. Now, this is is a very interesting example. And I learned it, so to say, by mistake. So this shows a couple of things. One is, you will have cases where you will need to create a cover group for an array of variables or array of PowerPoints.

And either you can simply go in line by line saying change it for value one essentially for value two so on and so forth. I sometimes you can have an array of one K, and it's impossible to do it line by line. So you need to be able to create an array of instances. So, what I'm showing here is a class x class and this is a UVM type definition so it extends UVM component in that I'm doing Finding a variable of my end or an array of variables my end to end up typing. Now I come to this line in a second. Now in our group, my CG, I'm saying that cover my int, which is an array of 10 integers.

And then I'm declaring a couple of bins. In the constructor of the class, I'm basically saying now trying to create 10 different instances of our group my CG. So I'm saying for each value or each other value of my end, create a new instance of cover group my CG. So this little for loop will go through all values of it from a one to 10 but it If you do it this way, it will give you a compile time error. Because you cannot declare the my cG 10 different color group instances like the way I've shown here, because a cover group is defined inside the class and when it is defined in the class, it is considered an anonymous type. And you cannot create a create an array of anonymous type variable or enter new anonymous type color group.

And since we cannot do that what's happening here is in this slide we are trying to create we do not know the instance name of the cover group. So, the name of the cover group becomes the name of the instance variable. It sounds a little confusing. But look at this slide again and you will realize what's going on here now This should work as far as I'm concerned, but it does not. And so after investigating, I realized that it's currently and LRM research and currently meaning in December of 2018. So chances are that by the time you try this kind of example, that this limitation might have gone.

So what's the solution? The solution is very simple. Since covered rope is of type anonymous, when it is embedded inside a class, I simply removed the definition of our group and put it outside the class. So once I do that, now it is of type cover group, my CD cover group and I can create an array of instances of my CD class. And then similar to the constructor of the class, if I go through for each smiling, I create an instance of myself tg and create 10 instances this will work and simulator is happy with it. So, take this with a grain of salt, I prefer the all embedded definition of cover group within a class to keep it modular, but apparently right now, it is not working and hopefully by the time you hit this lecture that it is working.

So, let us see how to parameterize cover group which is which is embedded in a class. So, before I go there just is just a refresher slide that you can have a parameterised cover group with formal arguments and when you instantiate the cover group, you can pass that actual values to those formals and if you have a variable that you need to pass to The form and then it must be defined type ref. This is just a refresher, you have seen this in my previous slides. So now let's see how you can parameterize a cover rope in a class in so in this class, I'm defining our our group or construct been CG. And I'm saying cover variable x. And I have three different beans defined beans, lawyers say that it will be covered when the value is men.

Some input value of type integer is main base highest will be covered when the value is Max, and the beans middle will be covered and we'll create explicit number of beans based on the value of num beans that is passed on to this cover to. So during the construction of the class, what I'm doing is I'm only passing two and two parameters to this class called configurable c group class. Now inside the constructor, I can have any kind of expression. So anything as you know, so in this constructor of the class, I'm saying that max is equal to main plus weight minus one. And n underscore b is equal to weight minus two divided by four, some equation doesn't matter what. And then I'm instantiating this core group and passing it P values, min max the number of bins, so men and width came in as input to the class constructor.

From there, I derived Max and n bins. And now I'm passing min max and n Bayes to the cover group. And then when I instantiate the class because the code group has already been instantiated inside the class because it has to be that when I instantiate the class, I'm passing it to value 16 and 32 that will be taken in by men and break. The point is that if you want to pass values to the foremost offer career group, you need to pass it through and if the cover group is embedded in a class, you need to pass it through the class constructor. And this will help you understand how to parameterize a covered rope in a class. Now, this is a very important and interesting topic.

So far, what we have seen is when we declare CP, veins are any name any bins with explicit or implicit number of pins, we normally give it some values say zero colon 255. And whenever you hit the value zero colon 255 of the cover point that being will be considered covered. But what if you are interested only in certain values of dick our point here the PowerPoint is of type def enum statement, I want to cover all four states of the type def enum, Sagan. But I'm not really interested in all four states. Let's say I'm only interested in a few of the four states. So what you can do is instead of giving explicit values, you can actually call a function, and the function will determine what values need to be covered.

So this function says that a value is equal to zero. Return quiet because it's of type state M, which is of type F, and If valid and are not ready or equal to zero then return Bz. So if you notice here if valid is one and ready zero function will return nothing, basically saying that we are not interested in creating a bin or covering the value of state and when valid is one and ready zero. If you did not do this, for example, and you simply say, on the right hand side, quiet comma busy, then it will go on all four strings. And since you're not interested in valid equal to one red equal to zero, that also will go as part of your coverage report. And it may decrease your coverage percentage because it has included a state that you really don't care for.

So this is one way of filtering out values that you don't For So, this is a very powerful this this example is pretty trivial, but you can have a function with very complex logic in it. And based on that logic you determine what kind of beans will be created and that those need to be covered. So, similar to calling a function, another way of covering something where you are interested only in certain values. So, we take our point we normally say our point variable x or something, instead of that here, we are calling an expression. So, serial word is the variable that we want to cover. But I only want to cover those values of serial world where count ones that that is a count There are some ones in the serial world.

So let's say CDL word is a two bit variable, and 0110, and one one has once in them, and they will return some value of Count 101. Or sorry, one, two, or three. And I'm only interested in covering the values One, two and three have serial forward. If the value is 00, I don't care. And you can do that, that by using an expression here, this expression can be any expression. I'm showing a very simple one just to prove the point.

So this one just shows that you can have a bit more complex expression where I'm taking my variable plus your variable and taking a model for many cover only those values that is that are created by a model for of this audience. So, again, you're basically covering only those values of interest. Now, just like we saw that, you can instantiate a class in another class and access it the instance class properties from the class that is instantiated. Similarly, you can have a car group and you want to cover certain variables which are embedded or reach are hierarchically in different parts of the design. So, you can say government tap top doctors count or cover the variable address in the instance address generator within the top module. And so this is one way of accessing hierarchical very tables.

The other one I'm showing is I'm trying to formals address and data of type ref in their logic. And I want to pass the values to this parameters when I instantiate the cover group GC, and that also I can do with hierarchical instances. And that's what I've shown here. To be honest, I'm not a big fan of hierarchically referencing variables from different parts of the design in our group. There are better ways to do this, simply pass the variables are declared the variables, embed them in a class to keep the whole structure modular. And lastly, this one shows that you cannot PowerPoint PowerPoint So here I have a hierarchical pointer to a PowerPoint called CPA in the instance of a car group called cover group underscore ends.

And it makes sense you cannot go appoint a PowerPoint hierarchy equally or not hierarchically. So that is illegal just just to make sure that we know what can be hierarchically referenced. So that's pretty much it for this lecture. short and simple. Hopefully, you'll get a better feel for different nuances of embedding covered rope in a class. Thank you.

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.