uvm-python icon indicating copy to clipboard operation
uvm-python copied to clipboard

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

Open sbhutada opened this issue 2 years ago • 1 comments

sbhutada avatar Jan 05 '24 19:01 sbhutada

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: https://github.com/tpoikela/uvm-python/blob/288b252228eedaa5967d552335f3692d3058cf3e/src/uvm/base/sv.py#L374

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.

tpoikela avatar Jan 06 '24 10:01 tpoikela