comp.lang.ada
 help / color / mirror / Atom feed
From: "Frédéric Praca" <frederic.praca@free.fr>
Subject: Re: Representation clauses and side-efects on STM32F411 ravenscar runtime
Date: 02 Aug 2015 20:27:51 GMT
Date: 2015-08-02T22:27:51+02:00	[thread overview]
Message-ID: <55be7d47$0$3323$426a34cc@news.free.fr> (raw)
In-Reply-To: 87egjlla7z.fsf@theworld.com

Le Sun, 02 Aug 2015 16:13:52 -0400, Bob Duff a écrit :

> Frédéric Praca <frederic.praca@free.fr> writes:
> 
>> Le Sun, 02 Aug 2015 15:54:50 -0400, Bob Duff a écrit :
>>
>>> "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org> writes:
>>> 
>>>> On 08/02/2015 01:59 AM, Frédéric Praca wrote:
>>>>> 
>>>>>    type Mantissa is range 0 .. 2**12 - 1 with Size => 12;
>>>>>    type Fraction is range 0 .. 2**4 - 1 with Size => 4;
>>> 
>>> Note that the Sizes will be 12 and 4 by default.
>>> 
>>>> Wouldn't modular types be better for these?
>>> 
>>> Why would you want wraparound arithmetic for these?  Seems like it
>>> would just hide bugs.
>>
>> I fully agree. Mantissa and Fraction don't have to use wraparound
>> arithmetic. In fact, these two variables together represent a fixed
>> point type and the magic must be inside the functions which calculates
>> these variables according to the bus frequency and by the way must take
>> care of the carry and possible overflow.
> 
> Then would a fixed-point type work?
> 
>     type Baud_Rate is delta 1.0/16 range ...;
>     for Baud_Rate'Small use 1.0/16;
Maybe. I have to try this but this is tightly coupled to my example and 
don't explain the side effects I also have on other records with 
representation clauses :)
Anyway, it could be a better way to represent things I need to 
investigate.

> - Bob
Fred

  reply	other threads:[~2015-08-02 20:27 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-02  8:59 Representation clauses and side-efects on STM32F411 ravenscar runtime Frédéric Praca
2015-08-02  9:40 ` Simon Wright
2015-08-02 10:22   ` Simon Wright
2015-08-02 14:53     ` Frédéric Praca
2015-08-02 14:52   ` Frédéric Praca
2015-08-02 15:19     ` Simon Wright
2015-08-02 19:23 ` Jeffrey R. Carter
2015-08-02 19:54   ` Bob Duff
2015-08-02 20:01     ` Frédéric Praca
2015-08-02 20:13       ` Bob Duff
2015-08-02 20:27         ` Frédéric Praca [this message]
2015-08-02 20:31     ` Jeffrey R. Carter
2015-08-03 11:08 ` Simon Clubley
2015-08-15 14:22   ` Frédéric Praca
2015-08-15 15:33     ` Simon Clubley
2015-08-15 17:17       ` Frédéric Praca
replies disabled

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