* Another Ada/ARM Cortex M4F tutorial up, with some interesting results
@ 2014-09-22 5:51 Mike Silva
2014-09-22 12:14 ` G.B.
0 siblings, 1 reply; 2+ messages in thread
From: Mike Silva @ 2014-09-22 5:51 UTC (permalink / raw)
Sure wish I had this 20-30 years ago!
http://www.embeddedrelated.com/showarticle/625.php
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Another Ada/ARM Cortex M4F tutorial up, with some interesting results
2014-09-22 5:51 Another Ada/ARM Cortex M4F tutorial up, with some interesting results Mike Silva
@ 2014-09-22 12:14 ` G.B.
0 siblings, 0 replies; 2+ messages in thread
From: G.B. @ 2014-09-22 12:14 UTC (permalink / raw)
On 22.09.14 07:51, Mike Silva wrote:
> Sure wish I had this 20-30 years ago!
>
> http://www.embeddedrelated.com/showarticle/625.php
>
The source uses GNAT's own 'Enum_Rep, in part for use during
compile time checks. I wonder if the effect can be achieved
in portable Ada, at very little cost.
The following example code is set up to generate static
failures. Is there a way to reliably get rid of the entities
declared for testing only, as, I guess, they can potentially
make it to object code?
package Plain_Ada is
type Word is mod 2**16;
type Lights is new Word;
Red : constant Lights := 2#0001#;
Green : constant Lights := 2#0010#;
Blue : constant Lights := 2#0101#; -- deliberate
Yellow : constant Lights := 2#0100#;
Flashy : constant Lights := Red
or Green
or Blue
or Yellow;
private
package Compile_Time_Checks is
type Yes is new Boolean range True .. True;
Expected_Bits : constant Yes :=
Yes (Flashy = 2#0111#
and
(Blue or 1) /= 2#0000#);
No_Overlap : constant := (case 1 is
when Red or Green => 1,
when Red or Blue => 1,
when Red or Yellow => 1,
when Green or Blue => 1,
when Green or Yellow => 1,
when Blue or Yellow => 1,
when others => 1);
end Compile_Time_Checks;
end Plain_Ada;
One way not have traces of the tests in code is, I suppose,
to put the tests into some pramga that establishes Boolean
context, such as pragma Assert.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-09-22 12:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-22 5:51 Another Ada/ARM Cortex M4F tutorial up, with some interesting results Mike Silva
2014-09-22 12:14 ` G.B.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox