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!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!news.snarked.org!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: Best representation for spares Date: Sat, 15 Feb 2014 10:49:21 -0700 Organization: Also freenews.netfront.net; news.tornevall.net 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; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 15 Feb 2014 17:49:23 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="6bab1dce10a849dba13303bd95a0f77d"; logging-data="22225"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19NDJsJZQFZmopb8pm9KCz7uPmhmZlZggs=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 In-Reply-To: <8383f5d6-3f66-415b-ab3f-8801fa377a6b@googlegroups.com> Cancel-Lock: sha1:EIyxZs315AGngzx7WYDzVnhiQns= X-Original-Bytes: 2987 Xref: number.nntp.dca.giganews.com comp.lang.ada:184880 Date: 2014-02-15T10:49:21-07:00 List-Id: On 02/15/2014 09:06 AM, 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. Even more that the datasheet says 'Reserved, write zero, read as don't care'. Thanks. Note that this does not guarantee that the contents of Spare are zeroes. Uninitialized objects, other than access objects, contain "stack junk", whatever happens to be in the memory that the object occupies. As a result, they may contain invalid values. To force Spare to contain zeroes, you have to initialize it: type Auxiliary_Interrupt_Status_Type is record Mini_Uart_IRQ : Boolean; SPI_1_IRQ : Boolean; SPI_2_IRQ : Boolean; Spare : Zero_Bits (3 .. 31) := (3 .. 31 => 0); end record; for Auxiliary_Interrupt_Status_Type'Size use 32; -- Jeff Carter "In the frozen land of Nador they were forced to eat Robin's minstrels, and there was much rejoicing." Monty Python & the Holy Grail 70