Comments (2)
You can use try-except blocks to catch randomize_with()
failures. You can also run with solve_fail_debug=1
on the failure to see diagnostics for the failure.
import vsc
import random
@vsc.randobj
class my_item_c:
def __init__(self):
self.a = vsc.rand_uint8_t()
self.b = vsc.rand_uint8_t()
@vsc.constraint
def ab_c(self):
self.a + self.b < 10
my_item = my_item_c()
for _ in range(10):
v = random.randrange(0, 20)
try:
with my_item.randomize_with() as it:
it.a == v
print(f'(a == {v}) hit')
except:
print(f'(a == {v}) unsolvable')
try:
with my_item.randomize_with(solve_fail_debug=1) as it:
it.a == v
except:
pass
Output:
(a == 9) hit
Solve failure: set 'solve_fail_debug=1' for more details
(a == 14) unsolvable
Problem Set: 2 constraints
<unknown>:
((a + b) < 10);
<unknown>:
(a == 14);
(a == 3) hit
(a == 6) hit
(a == 1) hit
Solve failure: set 'solve_fail_debug=1' for more details
(a == 18) unsolvable
Problem Set: 2 constraints
<unknown>:
((a + b) < 10);
<unknown>:
(a == 18);
(a == 2) hit
(a == 0) hit
(a == 4) hit
Solve failure: set 'solve_fail_debug=1' for more details
(a == 18) unsolvable
Problem Set: 2 constraints
<unknown>:
((a + b) < 10);
<unknown>:
(a == 18);
from pyvsc.
There isn't currently a direct method for doing this, since the randomize allows the field values to be overwritten. Please file an enhancement request if this is functionality you need.
from pyvsc.
Related Issues (20)
- import error _boolector_add
- 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
- 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
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.