From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: border1.nntp.dca3.giganews.com!backlog4.nntp.dca3.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!goblin3!goblin.stu.neva.ru!bolzen.all.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Best representation for spares Date: Sat, 15 Feb 2014 21:55:30 +0200 Organization: Tidorum Ltd Message-ID: References: <215f6df2-a7ec-42f4-ac82-656d5b12bf61@googlegroups.com> <8383f5d6-3f66-415b-ab3f-8801fa377a6b@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: individual.net m6gV+7ZI9Kgfbxb8WFFAJQBoiMSekBg9XWJUn0UNy8apxhHW2m Cancel-Lock: sha1:lltR2+3zxHEL53Xpt64d2XVI5Cs= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 In-Reply-To: <8383f5d6-3f66-415b-ab3f-8801fa377a6b@googlegroups.com> X-Original-Bytes: 2877 Xref: number.nntp.dca.giganews.com comp.lang.ada:184884 Date: 2014-02-15T21:55:30+02:00 List-Id: On 14-02-15 18:06 , Rego, P. wrote: > On Friday, February 14, 2014 7:19:20 AM UTC-2, Simon Wright wrote: >> I'd much prefer to fill this space. And, on the whole, better with zeros >> (unless, of course, 'unused' means 'don't even write to this bit'). >> Something like >> type Zero_Bit is range 0 .. 0; >> type Zero_Bits is array (Positive range <>) of Zero_Bit; >> for Zero_Bits'Component_Size use 1; >> type Auxiliary_Interrupt_Status_Type is >> record >> Mini_Uart_IRQ : Boolean; >> SPI_1_IRQ : Boolean; >> SPI_2_IRQ : Boolean; >> Spare : Zero_Bits (3 .. 31); >> end record; >> pragma Pack (Auxiliary_Interrupt_Status_Type); >> for Auxiliary_Interrupt_Status_Type'Size use 32; > > Great, I will use this. I wouldn't, not if the program will read the record from the HW. See below. > Even more that the datasheet says 'Reserved, write zero, "Write zero" implies, to me, that you definitely must declare record components for these bits, if you are going to write the record to the HW, and you must set the bits to zero before writing to HW. If you instead leave a gap in the record you have no way to control what values the bits in the gap have (except through Unchecked_Conversion, which would be a dirty trick). > read as don't care'. That implies, to me, that the bits read from the HW are not necessarily zero. If you declare these bits using the Zero_Bits type, and then read the record from the HW, you can get an "invalid" value -- any '1' bits will violate the constraint on Zero_Bit. This creates an inconsistency in the state of your program, which is IMO risky. I would declare these "reserved" bits with a type that can take any value that the HW can produce. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .