Jump to content

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!

Link to comment
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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...