Unions - overlaying bits & logic


Subject: Unions - overlaying bits & logic
From: Kevin Cameron (Kevin.Cameron@nsc.com)
Date: Fri Apr 05 2002 - 13:35:00 PST


Apart from endianess, there is an issue with size of data in unions. The types bit,char,integer etc. are
as in C, but types like "logic" do not have a defined bit representation - it could be:

 A: an enum (e.g. L0=0,L1=1,LX=2,LZ=3) - requires 2 bits (per node)
 B: value & strength (0,1,X) * (1,Z) - requires 3 bits
 C: value, strength and certainty (0,1) * (1,Z) * (1,X) - also 3 bits, but different coding

I think it is therfore impossible to sensibly overlay logic and bit types, unions should have
either all logic or all bit as the base type of all elements. The alternative is to store the
X & Z orthogonally so that only the bit value is overlayed (using representation C),
which has performance issues.

If a union of "structs" is declared, the the fields being overlayed should match in their
base type (rather than the whole struct).

[Note: 'logic' and 'reg' should probably be something other than 'integer_type' in the BNF]

Kev.



This archive was generated by hypermail 2b28 : Fri Apr 05 2002 - 13:39:55 PST