-
|
@mballance or others, I want to use the
However, no example is provided. The code shown below fails while attempting to call In this simple example it is not technically necessary to use import vsc
@vsc.randobj
class IntData:
def __init__(self):
self.number = vsc.rand_bit_t(10)
intData = IntData()
intData.randomize()
print("intData = " + intData.number.get_val())
intData.number.set_val(4)
print("intData = " + intData.number.get_val()) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Hi @msmftc, pyvsc/ve/unit/test_field_standalone.py Lines 22 to 28 in eb6824c In order to call get_val/set_val directly, your code will need to work around the operator overloading. PyVSC provides something called pyvsc/ve/unit/test_rand_mode.py Lines 12 to 67 in 3053880 Do keep in mind that the operator overloading calls get_val(), so I'm not positive that calling get_val() will solve your issue. Lines 89 to 108 in 02302b4 Can you provide a bit more info on what isn't currently working right? It's possible a cast would get the desired results more-easily than directly invoking get_val. |
Beta Was this translation helpful? Give feedback.
-
|
@mballance, thank-you for explaining why my calls to |
Beta Was this translation helpful? Give feedback.
Hi @msmftc,
As you rightly point out, this situation isn't well-covered in the docs. I suppose that is because most use cases can make use of the Python operator overloading that allows getting/setting the field value simply by referencing it. The get_val()/set_val() methods are primarily used when creating fields outside a class context:
pyvsc/ve/unit/test_field_standalone.py
Lines 22 to 28 in eb6824c
In order to call get_val/set_val directly, your code will need to work around the operator …