Hello and welcome to this lecture where I will show you a how to model variable delay. As you know, and the bond bound delay delay can not be a variable, it must be constant. So there are a couple of ways you may attempt to make this delay variable, for example, and this property I'm showing a local variable. And then what I'm saying is whatever data delay that I pass, store it in the local variable Lv, and then wait from zero to that value stored in AD V and then go read data. Now, this will give you an elaboration time error combined will pass because during elaboration, the simulator needs to know the delay. And if he's variable, it does not know that delay.
So it has to be a function. So this will give you an The other way you may try to model days is by simply saying that, when read falls, wait for the read latency which I have passed into the property. And then to read data equal to expected, this also will give an error. Because read latency is a variable, and it must be a constant. This is what the semantic specify. So what if you do want variable delay?
Let's look at this example. This is an example from CPU system, where the level two cache can have different read latencies. So if the range is at the end of the queue, then the data will come with maximum latency. If the read is at the beginning of the read queue, data will arrive with minimum latency and anything in between. data will come with that in between latency Now we know that we cannot write a property where I can pass a variable latency and let it wait as long as it's supposed to wait. So, I mean, there are ways that you can handle this variable latency one is simply creating, you know, let's say there are 100, latencies hundred different properties, each with a constant delay from one to 100.
Would you do that? I don't think so. That's a that's not a clean solution at all. Or someone can say, Well, I don't care for in between latencies I will create a property with min latency and Max latency, when in mission critical applications. This will not work because in between latency also is just as important. So how would you solve this problem?
Well, local variable again comes to rescue and this is how it works. So what I'm doing is in Property read latency check, I passing it a variable latency real latency, then I'm creating a local variable called l delay, then I'm saying that every part of claw, whenever read falls, store the read latency that have passed in this property and stored it in the local variable l delay. Then at every clock, I'm going to decrement this latency and delay by doing this particular small sequence here, saying that always because it's always true, at every passage of claw decrement the local variable add delay, and keep repeating this keep recommending add delay at every claw, with the conjugative reputation operator meaning keep deleting, keep subtracting add delay forever. Until add delay is equal to zero. So for example, as every latency is three, and the next was edge of clock eight will become two, then at the next clock, it will become one, and then at the next law, it becomes zero, and this particular sequence will end.
So, this is the way you can easily create a small property where you can check for read data equal to expected data based on variable latency. This is a very good use of local variables. So, do visit this slide again. And make sure you understand this because this will be a very useful application when you can indeed how variable delays in system Verilog assertions. So, that's all for this lecture. Thank you