>From: "Brad Pierce" <Brad.Pierce@synopsys.com> >In 4.10.4, the SV LRM says > > "Casting to an enum type shall cause a conversion of the expression >to its base type without checking the validity of the value" > >That's great if it's a 2-state base type, but if it's a 4-state >base-type wouldn't we want the result of the cast to be x's, so that x's >could propagate into any consumers of the bogus enum value? No, I don't think so. If you use a static cast, you are saying "Just do it." If you want a more expensive conversion that does a run-time check, you can always use $cast. >Why else would the user have declared the base type as 4-state? Several reasons. It causes the value to start at X, to allow simulation to tell them if they initialized the design properly. It allows enum values to be driven onto multi-driver busses, by allowing Z values from any drivers that are not actively driving. If there is driver contention, it allows representing that. It allows them to synthesize parts of the design into low-level hardware that operates on the bits of the enum, while other parts are still simulated at a higher level. Simulation of that lower- level part may produce X bits, and those can be propagated through the higher-level part. If the enum were 2-state, those X bits would look like 0 and you might not catch a design error. (Note that if all the bits of the enum were set to X on conversion as you suggest, the results would be excessively pessimistic. Some bits may be don't-cares.) Steven Sharp sharp@cadence.comReceived on Sat Oct 21 14:57:50 2006
This archive was generated by hypermail 2.1.8 : Sat Oct 21 2006 - 14:58:04 PDT