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
€36.72
List Price:  €137.84
You save:  €101.11
£31.26
List Price:  £117.33
You save:  £86.07
CA$54.44
List Price:  CA$204.35
You save:  CA$149.91
A$59.96
List Price:  A$225.08
You save:  A$165.11
S$53.84
List Price:  S$202.10
You save:  S$148.25
HK$312.04
List Price:  HK$1,171.22
You save:  HK$859.18
CHF 36.38
List Price:  CHF 136.56
You save:  CHF 100.18
NOK kr418.80
List Price:  NOK kr1,571.95
You save:  NOK kr1,153.15
DKK kr274.02
List Price:  DKK kr1,028.53
You save:  DKK kr754.50
NZ$64.86
List Price:  NZ$243.44
You save:  NZ$178.58
د.إ146.73
List Price:  د.إ550.76
You save:  د.إ404.02
৳4,687.10
List Price:  ৳17,592.78
You save:  ৳12,905.67
RM187.51
List Price:  RM703.83
You save:  RM516.31
₦59,224.27
List Price:  ₦222,294.87
You save:  ₦163,070.60
₨11,116.08
List Price:  ₨41,723.59
You save:  ₨30,607.50
฿1,463.58
List Price:  ฿5,493.49
You save:  ฿4,029.90
₺1,285.63
List Price:  ₺4,825.54
You save:  ₺3,539.91
B$206.68
List Price:  B$775.78
You save:  B$569.09
R734.46
List Price:  R2,756.77
You save:  R2,022.30
Лв71.82
List Price:  Лв269.60
You save:  Лв197.77
₩54,285.05
List Price:  ₩203,755.80
You save:  ₩149,470.74
₪146.87
List Price:  ₪551.28
You save:  ₪404.41
₱2,316.68
List Price:  ₱8,695.52
You save:  ₱6,378.84
¥6,266.80
List Price:  ¥23,522.08
You save:  ¥17,255.27
MX$666.43
List Price:  MX$2,501.42
You save:  MX$1,834.98
QR145.61
List Price:  QR546.54
You save:  QR400.92
P542.33
List Price:  P2,035.64
You save:  P1,493.30
KSh5,293.37
List Price:  KSh19,868.37
You save:  KSh14,575
E£1,898.02
List Price:  E£7,124.12
You save:  E£5,226.10
ብር2,277.96
List Price:  ብር8,550.20
You save:  ብር6,272.24
Kz34,031
List Price:  Kz127,733.40
You save:  Kz93,702.40
CLP$36,020.33
List Price:  CLP$135,200.23
You save:  CLP$99,179.89
CN¥284.01
List Price:  CN¥1,066.03
You save:  CN¥782.02
RD$2,352.24
List Price:  RD$8,829.03
You save:  RD$6,476.78
DA5,374.30
List Price:  DA20,172.12
You save:  DA14,797.82
FJ$89.01
List Price:  FJ$334.11
You save:  FJ$245.10
Q310.26
List Price:  Q1,164.57
You save:  Q854.30
GY$8,361.19
List Price:  GY$31,383.27
You save:  GY$23,022.07
ISK kr5,490.72
List Price:  ISK kr20,609.12
You save:  ISK kr15,118.40
DH396.63
List Price:  DH1,488.72
You save:  DH1,092.09
L707.52
List Price:  L2,655.64
You save:  L1,948.11
ден2,262.67
List Price:  ден8,492.81
You save:  ден6,230.14
MOP$321.26
List Price:  MOP$1,205.86
You save:  MOP$884.59
N$733.65
List Price:  N$2,753.72
You save:  N$2,020.06
C$1,470.20
List Price:  C$5,518.33
You save:  C$4,048.12
रु5,309.89
List Price:  रु19,930.39
You save:  रु14,620.49
S/149.51
List Price:  S/561.21
You save:  S/411.69
K155.32
List Price:  K582.99
You save:  K427.67
SAR149.83
List Price:  SAR562.40
You save:  SAR412.56
ZK1,069.47
List Price:  ZK4,014.20
You save:  ZK2,944.73
L182.73
List Price:  L685.87
You save:  L503.14
Kč905.47
List Price:  Kč3,398.63
You save:  Kč2,493.16
Ft14,088.74
List Price:  Ft52,881.26
You save:  Ft38,792.52
SEK kr420.92
List Price:  SEK kr1,579.90
You save:  SEK kr1,158.98
ARS$35,695.32
List Price:  ARS$133,980.32
You save:  ARS$98,285
Bs275.99
List Price:  Bs1,035.94
You save:  Bs759.94
COP$154,573.23
List Price:  COP$580,181.64
You save:  COP$425,608.41
₡20,540.35
List Price:  ₡77,097.01
You save:  ₡56,556.66
L987.04
List Price:  L3,704.82
You save:  L2,717.77
₲300,484.24
List Price:  ₲1,127,850.11
You save:  ₲827,365.86
$U1,537.98
List Price:  $U5,772.73
You save:  $U4,234.75
zł156.17
List Price:  zł586.17
You save:  zł430
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.