tpoikela/uvm-python

Should we use PyVSC with UVM-Python to get constrained random and coverage working? Or, is there something similar already in the library?

Closed this issue · 1 comments

Should we use PyVSC with UVM-Python to get constrained random and coverage working? Or, is there something similar already in the library?

You can use cocotb-coverage https://cocotb-coverage.readthedocs.io/en/latest/

In uvm-python itself, you can use constrained random with UVMSequenceItems, and in any classes that inherit either from sv_obj (internal class) or from UVM classes.
Class sv_obj itself uses cocotb-coverage.crv:

class sv_obj(crv.Randomized):

To use constrained random, you can define class members in __init__ function like this:

self.start_addr = 0
self.rand('start_addr', range((1 << 12) - 1))

Then you can call obj.randomize() or obj.randomize_with(constraints) for instances of this class. pre_ and post_randomize should also work normally, if you define them in your class.