Comments (1)
Yeah, I think the @vsc_constraint decorator tries to override as many operators as possible to give you SV-like constraints, but just b/c you can put things in that function doesn't mean the decorator will handle it or execute as a normal function.
There aren't any examples in the docs for rand_list_t or randsz_list_t, but there is a sum property you can use to get the desired effect. Edit: My bad, there are examples. I was misreading the docs search bar results.
https://fvutils.github.io/pyvsc/reference.html#vsc.types.list_t
To give each element in rand_list_t a name like a,b,c,... I just assigned it in post_randomize. Maybe there's a clearer way to do it in the init, but I don't think the rand_list_t elements exist before calling randomize. The unit tests have more examples than the docs, so it can be a good to peruse.
https://github.com/fvutils/pyvsc/tree/master/ve/unit
Here's my take on your example. I left debug=True
on the randomize since it can be helpful knowing what constraints were actually generated.
import vsc
@vsc.randobj
class bist_constraints:
def __init__(self):
self.vars = vsc.rand_list_t(vsc.rand_bit_t(1), 6)
@vsc.constraint
def abc(self):
self.vars.sum < 2
def post_randomize(self):
self.a = self.vars[0]
self.b = self.vars[1]
self.c = self.vars[2]
self.d = self.vars[3]
self.e = self.vars[4]
self.f = self.vars[5]
def __repr__(self):
return self.__str__()
def __str__(self):
return f'{[self.a,self.b,self.c,self.d,self.e,self.f]}'
if __name__ == "__main__":
cfg=bist_constraints()
cfg.randomize(debug=True)
print(str(cfg))
print(cfg.a)
from pyvsc.
Related Issues (20)
- 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 HOT 1
- 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 HOT 1
- Unexpected behavior with unique rand_list_t HOT 4
- Cannot constrain attribute inside a rand_attr inside a rand_list HOT 12
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.