From: "Rego, P." <pvrego@gmail.com>
Subject: Best representation for spares
Date: Thu, 13 Feb 2014 17:07:05 -0800 (PST)
Date: 2014-02-13T17:07:05-08:00 [thread overview]
Message-ID: <215f6df2-a7ec-42f4-ac82-656d5b12bf61@googlegroups.com> (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.
next reply other threads:[~2014-02-14 1:07 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-14 1:07 Rego, P. [this message]
2014-02-14 9:19 ` Best representation for spares 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.
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox