Jump to content
Sign in to follow this  
ronyz

Mathematical constraints

Recommended Posts

Hi,

 

I have two problems:

1) I tried to implement multiplication constraint based on the one of the examples:

 
struct addr_constraint : public scv_constraint_base {
 
  scv_smart_ptr<int> row;
  scv_smart_ptr<int> col;
 
  SCV_CONSTRAINT_CTOR(addr_constraint) {
    SCV_CONSTRAINT( (row())*(col()) < 50);
    SCV_CONSTRAINT( col() > 0);
 
  }
};
 

When I try to randomize the values, the program keeps running and never stops.

What might be the problem?

 

2) Is there any way to define more complex mathematical constraints?

    constraints on the square, log, shift, division etc...?

    Where can I find a list of the supported mathematical operations?

 

Thanks!

Share this post


Link to post
Share on other sites

I think the problem is you have used int. This makes the constraint solver work very hard as you are asking it to search through combinations of 64 bits to find a solution.

 

Try this:

struct addr_constraint: public scv_constraint_base {

    scv_smart_ptr<sc_uint<8> > row;
    scv_smart_ptr<sc_uint<8> > col;
 
    SCV_CONSTRAINT_CTOR(addr_constraint) {
        SCV_CONSTRAINT( (row() *col()) < 50);
        SCV_CONSTRAINT( col() > 0 );
 
    }

};

Regarding the operators, refer to the document vwg_1_0e.pdf in the docs directory, at the bottom of page 34 and the top of page 35.

 

regards

Alan

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×