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 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

Link to post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...