Comments (2)
Hi @aneels3,
I've completed support for rand_mode
on scalar fields. Support will be available in the 0.0.7 release. See the Constraints section for more information on how to use rand_mode
. You can also see a short example below:
@vsc.randobj
class my_cls(object):
def __init__(self):
self.a = vsc.rand_uint8_t()
self.b = vsc.rand_uint8_t()
# First, test that values vary
init_a = 0
init_b = 0
it = my_cls()
for i in range(20):
with it.randomize_with():
it.a != init_a
it.b != init_b
self.assertNotEqual(it.a, init_a)
self.assertNotEqual(it.b, init_b)
init_a = it.a
init_b = it.b
# Now, disable rand_mode for a
with vsc.raw_mode():
it.a.rand_mode = False
self.assertEqual(it.a.rand_mode, False)
self.assertEqual(it.b.rand_mode, True)
for i in range(20):
with it.randomize_with():
it.b != init_b
self.assertEqual(it.a, init_a)
self.assertNotEqual(it.b, init_b)
init_a = it.a
init_b = it.b
# Now, go back
with vsc.raw_mode():
it.a.rand_mode = True
self.assertEqual(it.a.rand_mode, True)
self.assertEqual(it.b.rand_mode, True)
for i in range(20):
with it.randomize_with():
it.a != init_a
it.b != init_b
self.assertNotEqual(it.a, init_a)
self.assertNotEqual(it.b, init_b)
init_a = it.a
init_b = it.b
from pyvsc.
Hi @aneels3,
Agreed, support for rand_mode makes sense and should be feasible. After a bit of investigation, I'm aware of one small user-interface difficulty. Because of the operator overloading that PyVSC provides that allows users to obtain the value of scalar fields directly, it's most likely that the user will need to switch to an explicit mode when changing the rand-mode of scalar fields. Something like the following:
with vsc.raw_mode():
it.a.rand_mode = False
I'm still looking at options to see if there is a better way to handle this. Thanks for the suggestion!
Best Regards,
Matthew
from pyvsc.
Related Issues (20)
- Enh: Support Default bin (How to write "default" in vsc.coverpoint ?)
- install error for latest version macos HOT 3
- support for function incur in constraint functions HOT 5
- constraint solver error HOT 1
- Installing pyvsc fails on pyboolector for python 3.11.5 on Linux (Arch) HOT 3
- Distributions have higher priority than soft constraints HOT 1
- I can't install pyvsc for pypy3.10! HOT 4
- not_inside constraint unexpectedly reducing output set significantly HOT 1
- Is there an example of pyvsc integrated with cocotb and SV RTL with a simulator? HOT 2
- Solve order of randsz_list_t size constraints within foreach incorrect [v0.8.8] HOT 5
- randsz_list_t: Placing the sum constraint before the size constraints can result in incorrect sums [v0.8.8]
- solve before is solve_order, but document marks it as not supported HOT 1
- Can't see vsc after installing pyvsc
- PyVSC to give exhaustive list of stimulus
- Set values on randobj and check if it satisfies the constraints HOT 2
- solve_order()'s after argument, when list is used, ends up in before_l list
- Is there a way to construct a logarithm constraint? HOT 2
- Key Error in adding constraints in the for loop
- Key error of ordinary for loop and TypeError of list indices in vsc.foreach
- constraint for one hot encoding.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyvsc.