Monday, December 22, 2008

Beware of conditional constraints!!

I was impressed by conditional(implied) constraining of specman unit's fields. But that impression didn't last longer. It costed me ONE day and night to realise and convince myself about the issues with implied constraints.



C:\Documents and Settings\bkumar1\Untitled.html





1 unit xyz_u {
2
3 field_A: uint;
4 keep soft field_A in [1..4];
5
6 field_B: uint;
7 // ************* COMMENTS ***********************
8 // I wanted here fieldB to have 1 when fieldA =1;
9 // fieldB = fieldA/2 if fieldA != 1
10 // you know what, it yielded me results
11 // when filed_A = 4 it gave me field_B = 1
12 // that is becuase when field_A !=1,
13 // this could be becuase the constraining can
14 // happen both the ways RHS to LHS and vice-versa
15 // and also specman never assures that it will
16 // satisfy both the below conditions. Specman
17 // only **tries** to generate the value which
18 // satisfy below equations.
19 // It may not satisfy always.
20 keep field_A == 1 => field_B == 1;
21 // since this is implied constr. you can't use 'soft'
22 keep filed_A != 1 => field_B == field_A/2;
23 // this is very very dangerous
24 };
25





* what is the Real problem?
Specman doesn't give any hint or information as how it has generated and what conditions(equations) are really satisfied. It keeps the user in *dark* and doesnt really help the user to debug in anyway.

* what is the way out?
1. Look out for ways to avoid the conditional constraints.
2. Try to avoid negative way of implied constraining ( !=), it opens up the space for specman to play with the conditions.
3. Suppose if you can't get rid of the implied constraints. Try to break it up( I am not sure whether it works out well!!!)