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
€37.87
List Price:  €142.15
You save:  €104.28
£31.55
List Price:  £118.43
You save:  £86.87
CA$55.89
List Price:  CA$209.78
You save:  CA$153.89
A$61.42
List Price:  A$230.55
You save:  A$169.12
S$53.66
List Price:  S$201.43
You save:  S$147.76
HK$310.94
List Price:  HK$1,167.12
You save:  HK$856.17
CHF 35.38
List Price:  CHF 132.82
You save:  CHF 97.44
NOK kr441.52
List Price:  NOK kr1,657.24
You save:  NOK kr1,215.71
DKK kr282.47
List Price:  DKK kr1,060.24
You save:  DKK kr777.77
NZ$67.94
List Price:  NZ$255.04
You save:  NZ$187.09
د.إ146.73
List Price:  د.إ550.76
You save:  د.إ404.02
৳4,757.02
List Price:  ৳17,855.20
You save:  ৳13,098.18
RM178.63
List Price:  RM670.50
You save:  RM491.86
₦66,908.65
List Price:  ₦251,137.75
You save:  ₦184,229.10
₨11,062.35
List Price:  ₨41,521.90
You save:  ₨30,459.55
฿1,386.54
List Price:  ฿5,204.31
You save:  ฿3,817.77
₺1,376.80
List Price:  ₺5,167.77
You save:  ₺3,790.96
B$231.20
List Price:  B$867.82
You save:  B$636.61
R723.37
List Price:  R2,715.16
You save:  R1,991.78
Лв74.05
List Price:  Лв277.95
You save:  Лв203.90
₩55,812.30
List Price:  ₩209,488.24
You save:  ₩153,675.93
₪149.29
List Price:  ₪560.37
You save:  ₪411.07
₱2,357.82
List Price:  ₱8,849.97
You save:  ₱6,492.14
¥6,222.78
List Price:  ¥23,356.84
You save:  ¥17,134.06
MX$807.25
List Price:  MX$3,029.98
You save:  MX$2,222.73
QR145.17
List Price:  QR544.90
You save:  QR399.73
P541.58
List Price:  P2,032.82
You save:  P1,491.23
KSh5,173.52
List Price:  KSh19,418.52
You save:  KSh14,245
E£1,985.51
List Price:  E£7,452.51
You save:  E£5,467
ብር4,899.40
List Price:  ብር18,389.63
You save:  ብር13,490.22
Kz36,460.79
List Price:  Kz136,853.46
You save:  Kz100,392.67
CLP$38,803.03
List Price:  CLP$145,644.93
You save:  CLP$106,841.90
CN¥289.50
List Price:  CN¥1,086.62
You save:  CN¥797.12
RD$2,397.37
List Price:  RD$8,998.41
You save:  RD$6,601.03
DA5,330.55
List Price:  DA20,007.92
You save:  DA14,677.37
FJ$90.71
List Price:  FJ$340.49
You save:  FJ$249.77
Q307.31
List Price:  Q1,153.47
You save:  Q846.16
GY$8,324.22
List Price:  GY$31,244.48
You save:  GY$22,920.25
ISK kr5,502.71
List Price:  ISK kr20,654.11
You save:  ISK kr15,151.40
DH397.72
List Price:  DH1,492.82
You save:  DH1,095.10
L727.09
List Price:  L2,729.10
You save:  L2,002.01
ден2,327.48
List Price:  ден8,736.06
You save:  ден6,408.58
MOP$319.12
List Price:  MOP$1,197.83
You save:  MOP$878.70
N$719.71
List Price:  N$2,701.40
You save:  N$1,981.69
C$1,464.95
List Price:  C$5,498.63
You save:  C$4,033.67
रु5,378.70
List Price:  रु20,188.64
You save:  रु14,809.94
S/151.06
List Price:  S/567.01
You save:  S/415.95
K160.17
List Price:  K601.21
You save:  K441.03
SAR149.98
List Price:  SAR562.94
You save:  SAR412.96
ZK1,099.68
List Price:  ZK4,127.58
You save:  ZK3,027.90
L188.46
List Price:  L707.37
You save:  L518.91
Kč957.21
List Price:  Kč3,592.84
You save:  Kč2,635.63
Ft15,518.42
List Price:  Ft58,247.49
You save:  Ft42,729.07
SEK kr439.39
List Price:  SEK kr1,649.23
You save:  SEK kr1,209.83
ARS$40,020.14
List Price:  ARS$150,213.28
You save:  ARS$110,193.13
Bs276.06
List Price:  Bs1,036.20
You save:  Bs760.13
COP$176,073.59
List Price:  COP$660,881.98
You save:  COP$484,808.38
₡20,235.05
List Price:  ₡75,951.09
You save:  ₡55,716.04
L1,005.80
List Price:  L3,775.23
You save:  L2,769.43
₲310,029.48
List Price:  ₲1,163,677.61
You save:  ₲853,648.13
$U1,707.86
List Price:  $U6,410.37
You save:  $U4,702.50
zł164.29
List Price:  zł616.68
You save:  zł452.38
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.