Perhaps a somewhat philosophical question but I am wondering if mapping reserved fields in svd2ada is meaningful/useful for the clients of these packages.
Taking the RNG_CR register in the random number generator on a stm32f4 board, as a random example (apologies for the terrible pun) the svd2ada mapping is the following (taken directly from ADL):
type CR_Register is record
-- unspecified
Reserved_0_1 : HAL.UInt2 := 16#0#;
-- Random number generator enable
RNGEN : Boolean := False;
-- Interrupt enable
IE : Boolean := False;
-- unspecified
Reserved_4_31 : HAL.UInt28 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR_Register use record
Reserved_0_1 at 0 range 0 .. 1;
RNGEN at 0 range 2 .. 2;
IE at 0 range 3 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
However, as stipulated by the RM, these fields should not be meddled with and should be kept at reset value:
On one hand it can be argued that svd2ada simply maps what is parses on the file as this is what its job is and then it’s up to the clients (typically HAL implementers) to enforce any constraints/restrictions and that also these fields act as documentation aid. On the other hand, it could also be argued that these fields should not be modified at all and it would be safer to not expose them at all in the first place? That could also simplify the record interface that clients see (which could make the autocomplete list on the IDE’s a bit more readable) e.g.:
type CR_Register is record
-- Random number generator enable
RNGEN : Boolean := False;
-- Interrupt enable
IE : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR_Register use record
RNGEN at 0 range 2 .. 2;
IE at 0 range 3 .. 3;
end record;
And the correct sizes are naturally enforced by the Size aspect.
(I assume svd2ada has somehow the ability to tell which fields are reserved and which not or is that not how it works?)
Any thoughts?
