-
It is not clear to me how I am supposed to integrate vsc.randselect or vsc.distselect with a vsc class (@vsc.randobj class item_c(object):)? I would think it would be called when ci.randomize() is called but the example only shows it being used stand alone. Is there a simple example showing the preffered/intended use of the *select functions with an actual vsc.randobj? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I thought maybe you use it in the constraint but that does not seem to work for me: @vsc.randobj
class item_c(object):
def __init__(self):
self.a = vsc.rand_uint8_t()
self.b = vsc.rand_uint8_t()
@vsc.constraint
def a_dist_c(self):
self.a == vsc.distselect([1,1,10,10])
v3 = []
ci = iten_c()
for _ in range(100):
ci.randomize()
v3.append(ci.a)
# v3:
# 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 ...
|
Beta Was this translation helpful? Give feedback.
-
I believe |
Beta Was this translation helpful? Give feedback.
I believe
randselect
anddistselect
are meant as analogues torandcase
in SV, which you would use to randomize procedural code. There is a distribution constraint you can use within a constraint block/function here: https://fvutils.github.io/pyvsc/constraints.html#dist