Closed aneels3 closed 4 years ago
Hi @aneels3, The current implementation throws an exception on randomization failure, so instead of if/else for detecting an error you should use try/catch. I realize that the use of exceptions is different than SystemVerilog, but would like to understand if it presents other use-model challenges.
Thanks, Matthew
Hi @mballance I was trying to implement the
assert(instance.randomize());
In this case I am assuming the assertions are turn on.
When assertion are turn off we can achieve the same with if else
but as per your suggestion we can achieve this by try except block as well.
May be we can implement this when we have support for assertion in PyVSC.
Hi @aneels3, There's another issue that will likely prevent us from ever having randomize return a boolean: the randomize_with pattern used by PyVSC doesn't allow us to return a value to the user. An exception is the only way to signal that something has gone wrong. For consistency, randomize() should behave the same.
Best Regards, Matthew
I think object.randomize() should return True (1) or False(0) on successful and unsuccessfull randomization respectively. Such that we can call the randomize() function with the class instance by checking it in the
if ... else
condition to check the possible randomization failure.