Supplementing Generated Ada : Referencing Model Elements : Bit Arrays

Bit Arrays

Bit-arrays are stored in unsigned ints. Since unsigned ints can hold a maximum of 32 bits, bit-arrays larger than 32 bits are stored in arrays of unsigned ints. Arrays of bit-arrays are stored in two dimensional arrays of unsigned ints. Notice that multiple bit-arrays smaller than 32 bits are NOT packed into the unsigned int.

The examples below are of Rational Statemate elements and the resulting definitions found in the generated code and in the Rational Statemate Ada libraries.

Rational Statemate Elements:

BA1 is Array 1 to 10 of Bit-array 31 downto 0
BA2 is Array 1 to 10 of Bit-array 48 downto 0
BA3 is Array 1 to 10 of Bit-array 3 down to 0
 

In the Generated Code:

BA1 : u_ba32_arr(1..10) ;
BA2 : u_ba49_arr(1..10) ;
BA3 : u_ba4_arr(1..10) ;
 
type u_ba32_arr is array(natural rand <>) of u_ba32;
subtype u_ba32 is BITS_ARRAYS (1..1);
type u_ba49_arr is array (natural range <>) of u_ba49;
subtype u_ba49 is BIT_ARRAY (1..2);
type u_ba4 is array(natural range<>) of u_ba4;
subtype u_ba4 is BITS_ARRAY (1..1);

BITS_ARRAY is defined in the intrinsics package as follows:

type BITS_ARRAY is array(NATURAL range<>) of
INTERGER32;