Comments (12)
Hi @pvipsyash,
Can you share an example of your use-case for solve-before? I'm assuming it's to control distribution across constraint-related variables. A testcase would also be very helpful to be able to validate any implementation.
This feature, unfortunately, is a fairly major one and will likely take some time. In the meantime, you might try using dist constraints if you just need to fix-up the distribution on some variables.
Best Regards,
Matthew
from pyvsc.
Hi @mballance ,
solve before is used inside the constraint block to specify the order of constraint solving. If the variables are dependent, due to the bidirectional nature of constraints value of one variable will influence the value of another variable.
Means if a = b + 5 and a,b are random variables, then constraint on B must solve first. So, for this we can write, b solve before a.
Thanks & Regards,
Shraddha Devaiya.
from pyvsc.
Hi @ShraddhaDevaiya,
Yes, I'm familiar with the construct and the description you quote:
https://verificationguide.com/systemverilog/systemverilog-solve-before-constraints/
My request was for a testcase or use-case example that we could use for validating the implementation, and possibly for finding a short-term alternative solution since solve-before is a somewhat-involved construct to implement. Do you have such a testcase?
Thanks,
Matthew
from pyvsc.
Hi @mballance ,
Sorry for misinterpreting it. I am working as per your inputs for solve before using weighted distribution and trying to produce the behavior. Will provide the use-case for this.
Thanks & Regards,
Shraddha Devaiya.
from pyvsc.
Hi @mballance, I was trying this code for solve before constraint using weighted distribution. Following is the code for it :
import vsc
@vsc.randobj
class my_s(object):
def __init__(self):
super().__init__()
self.a = vsc.rand_bit_t(8)
self.b = vsc.rand_bit_t(8)
@vsc.constraint
def ab_con(self):
vsc.dist(self.a, [
vsc.weight(1, 5),
vsc.weight(2,2),
vsc.weight(3,2)])
with vsc.implies(self.a == 1):
self.b == 1
item = my_s()
for i in range(10):
item.randomize()
print("A = ",item.a,", B = ",item.b)
And for this, output is like following :
A = 3 , B = 0
A = 1 , B = 1
A = 1 , B = 1
A = 1 , B = 1
A = 1 , B = 1
A = 3 , B = 7
A = 3 , B = 90
A = 1 , B = 1
A = 1 , B = 1
A = 1 , B = 1
Here, we get more occurrences of value a=1 , but it will not give any other values except specify in weighted distribution constraint. But temporary we can use this.
Thanks & Regards,
Shraddha Devaiya.
from pyvsc.
Hi @mballance
When can we expect support for solve before? without it, every time we need to find some workaround for dependency.
Thanks & Regards,
Yash Patel
from pyvsc.
Hi @pvipsyash,
Apologies for the delay in this, Yash. Supporting solve-before turned out to be a much larger project that I had originally thought. I'll try to get you an update this weekend when I have a bit more time to work on the project.
Best Regards,
Matthew
from pyvsc.
Hi @pvipsyash,
I was able to spend some time on this over the weekend, and believe I'm pretty close to having an implementation ready to release. I have a bit of cleanup still to do, but should be able to get something out this week.
Best Regards,
Matthew
from pyvsc.
Hi @mballance
Thanks for the updates. It will be a great help!
Regards,
Yash Patel
from pyvsc.
Hi Yash,
I've merged support for solve-ordering into PyVSC mainline. Here is an example of using the features:
pyvsc/ve/unit/test_constraint_solve_order.py
Lines 80 to 92 in 487620a
I'll leave this issue open until you're able to confirm that it works for you.
Best Regards,
Matthew
from pyvsc.
Hi @mballance
Thanks for adding this support. As we need to apply this constraint on list-type as well. I've tried a few examples but it is not giving proper output.
Can you look into this?
Regards,
Yash
from pyvsc.
Hi @pvipsyash,
Thanks for the testcase. Really helped in reproducing the core issue, which involved the unconstrained elements of the arrays not being properly randomized. The 0.2.5 release resolves this issue.
I'm closing this issue for now. Please open a new issue if you experience other trouble using the solve-order constraint.
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.