Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

randomize() function returns None #16

Closed
aneels3 opened this issue Jul 9, 2020 · 3 comments
Closed

randomize() function returns None #16

aneels3 opened this issue Jul 9, 2020 · 3 comments

Comments

@aneels3
Copy link
Contributor

aneels3 commented Jul 9, 2020

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.

@aneels3 aneels3 changed the title randimize() function returns None randomize() function returns None Jul 9, 2020
@mballance
Copy link
Member

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

@aneels3
Copy link
Contributor Author

aneels3 commented Jul 10, 2020

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.

@mballance
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants