comp.lang.ada
 help / color / mirror / Atom feed
* Best representation for spares
@ 2014-02-14  1:07 Rego, P.
  2014-02-14  9:19 ` Simon Wright
  0 siblings, 1 reply; 23+ messages in thread
From: Rego, P. @ 2014-02-14  1:07 UTC (permalink / raw)


When in a chip mapping, if we have spare (not used) bits, is it better to 'complete' the spaces, so now we have a contiguous type definition for all bits; or is it better to not complete the spaces, and do not consume more stack than necessary? I have seen both approaches, so still did not get a conclusion.

For example, using a Raspberry Pi bits definitions for auxiliary registers in BCM2835 chip:

   type Auxiliary_Interrupt_Status_Type is
      record
         Mini_Uart_IRQ : Boolean;
         SPI_1_IRQ     : Boolean;
         SPI_2_IRQ     : Boolean;
      end record;
   pragma Pack (Auxiliary_Interrupt_Status_Type);
   for Auxiliary_Interrupt_Status_Type'Size use 3;

   type Auxiliary_Enables_Type is
      record
         Mini_Uart_Enable : Boolean;
         SPI_1_Enable     : Boolean;
         SPI_2_Enable     : Boolean;
      end record;
   pragma Pack (Auxiliary_Enables_Type);
   for Auxiliary_Enables_Type'Size use 3;

   type Auxiliary_Peripherals_Register_Map_Type is
      record
         AUX_IRQ            : Auxiliary_Interrupt_Status_Type;
         AUX_ENABLES        : Auxiliary_Enables_Type;
      ... 
      end record;
   for Auxiliary_Peripherals_Register_Map_Type use
      record
         AUX_IRQ            at 16#00# range 00 .. 02;
         AUX_ENABLES        at 16#04# range 00 .. 02;
      end record;

using this kind of definitions, the compiler warns (correctly) me 
   warning: 29-bit gap before component "AUX_ENABLES" 

Would it be better if the definition were something like 

   type Auxiliary_Interrupt_Status_Type is
      record
         Mini_Uart_IRQ : Boolean;
         SPI_1_IRQ     : Boolean;
         SPI_2_IRQ     : Boolean;
         Spare         : Some_Type_With_29_Bits; 
      end record;
   pragma Pack (Auxiliary_Interrupt_Status_Type);
   for Auxiliary_Interrupt_Status_Type'Size use 32;

   ...
   for Auxiliary_Peripherals_Register_Map_Type use
      record
         AUX_IRQ            at 16#00# range 00 .. 32;
         AUX_ENABLES        at 16#04# range 00 .. 02;
      end record;

or just ignore the warning?

Regards,
Rego.


^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2014-02-16 18:50 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-14  1:07 Best representation for spares Rego, P.
2014-02-14  9:19 ` Simon Wright
2014-02-15 16:06   ` Rego, P.
2014-02-15 17:49     ` Jeffrey Carter
2014-02-15 20:21       ` Rego, P.
2014-02-15 19:55     ` Niklas Holsti
2014-02-15 20:25       ` Rego, P.
2014-02-15 21:35         ` Rego, P.
2014-02-16 10:02           ` Niklas Holsti
2014-02-16 13:40             ` Rego, P.
2014-02-16 16:26               ` Rego, P.
2014-02-16 18:50                 ` Niklas Holsti
2014-02-16 16:33               ` Niklas Holsti
2014-02-16 12:10           ` Simon Wright
2014-02-16 13:43             ` Rego, P.
2014-02-16 14:25               ` Robert A Duff
2014-02-16 16:21                 ` Rego, P.
2014-02-15 21:41         ` Jeffrey Carter
2014-02-15 22:37           ` Rego, P.
2014-02-15 22:41             ` Rego, P.
2014-02-16  0:39             ` Jeffrey Carter
2014-02-16 12:06         ` Simon Wright
2014-02-16 13:45           ` Rego, P.

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox