Giter VIP home page Giter VIP logo

Comments (12)

mballance avatar mballance commented on May 27, 2024

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.

ShraddhaDevaiya avatar ShraddhaDevaiya commented on May 27, 2024

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.

mballance avatar mballance commented on May 27, 2024

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.

ShraddhaDevaiya avatar ShraddhaDevaiya commented on May 27, 2024

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.

ShraddhaDevaiya avatar ShraddhaDevaiya commented on May 27, 2024

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.

yashp0103 avatar yashp0103 commented on May 27, 2024

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.

mballance avatar mballance commented on May 27, 2024

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.

mballance avatar mballance commented on May 27, 2024

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.

yashp0103 avatar yashp0103 commented on May 27, 2024

Hi @mballance

Thanks for the updates. It will be a great help!

Regards,
Yash Patel

from pyvsc.

mballance avatar mballance commented on May 27, 2024

Hi Yash,
I've merged support for solve-ordering into PyVSC mainline. Here is an example of using the features:

@vsc.randobj
class my_c(object):
def __init__(self):
self.a = vsc.rand_bit_t()
self.b = vsc.rand_uint8_t()
@vsc.constraint
def ab_c(self):
vsc.solve_order(self.a, self.b)
self.a < self.b
with vsc.if_then(self.a == 0):
self.b < 10

I'll leave this issue open until you're able to confirm that it works for you.

Best Regards,
Matthew

from pyvsc.

yashp0103 avatar yashp0103 commented on May 27, 2024

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.

image

Can you look into this?

Regards,
Yash

from pyvsc.

mballance avatar mballance commented on May 27, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.