Thanks Dave and Srini for your replies.
I cannot use an ovm_sequence object for this as it is a configuration object (for which I was thinking of having such an override). So using `ovm_do* macros are not possible I think.
Normally configuration objects within an environment are static in nature and hence they are more suited as ovm_component (is what i thought). And many a times, you may want some randomization of some variable within a configuration object, but there has to be a way to disable/override the randomization from within a test. For e.g. :
class C;
rand bit var; //0 = 8 bit PCIE lane, 1 = 16bit PCIE lane
endclass
and if you have a C.randomize() call somewhere within your testbench sequencing, then every test will come up with a random value of “var”. But if you want some directed test to come up with 8bit configuration only, then you can :
-
potentially extend class C inside the test and then have a factory override in the test for that class. But this would mean redefining code for every such class (may be in class E,F,G etc.) where you need to constrain randomization, right.
-
Else, we can just have a call similar to set_config* and set the bit as well as disable randomization, and that would have ensured that even if somebody gave a call to C.randomize() from within the testbench sequence (which is not known to test writer) , “var” will still hold a value of 0. This will be just a one line code from user and will be neat too. For e.g.
function void end_of_elaboration();
set_config_whatever(var,0); //arbitrary non-OVM code for illustration
endfunction
can be inside the test.
So, (2) really was my question, and looks like OVM does not support it directly as of now.
I am a new user to OVM, so any more comments/suggestions also welcome.
Now to the nit-picking :)
Not really - basically var will be left in its initial value/prev value with no randomization done. You are simply assigning a value (not “constrained”).
Well, as I explained above, this will be equivalent to overriding the randomization without rewriting constraints or using ‘randomize() with’ constructs. Remember that this “overide” is before somebody in testbench will give a call to C.randomize(). Only thing is that some care needs to be taken so as to select legal values for such an override. Whenever somebody in testbench does call the C.randomize(), constraint solver will correctly compute value of other variables based on this (overriden) value of “var”. Another way of achieving the same is to do this “override” in post_randomize, but then if I have multiple variables being overriden in test code at different places, it may not work.
And yes, i do remember the ACL validation times with you Srini :)
-Ujjal