Electronicdesign 24697 Ccg Adacore Promo

Ada Compiler Generates C Source

Nov. 17, 2018
AdaCore’s latest GNAT Pro Ada compiler can generate C source code, delivering portability to most platforms with a C compiler.

With AdaCore’s latest GNAT Pro Ada compiler, it’s now possible to generate C source code using its Common Code Generator (CCG). This is designed to provide portability to the vast majority of platforms that have a C compiler. It was originally done to support the popular 8-bit Microchip AVR that AdaCore doesn’t support with its native code support targeting platforms, such as the 32- and 64-bit x86, ARM, RISC-V, and Power architectures.

Using CCG is just a matter of a command-line option (see codelist below). It handles a subset of Ada, but this still includes features like fixed-point support and the minimal standard library. Features not supported are ones that would be hard to implement or those not supported by C compilers like overflow checks. This is one reason to use support for SPARK, a provable subset of Ada. CCG works with SPARK applications.

Compiling Ada/SPARK code into C like this is as easy as a command-line switch.

The ability to insert assembly code inline is also missing. However, it’s possible to edit generated C code to do this since the C compiler supports such a feature.

The Ada.Real_Time runtime package is supported if rts_monotonic_clock and rts_delay_until procedures are provided. The online documentation covers the details of everything that is and isn’t supported.

Support for 8-bit platforms is just one reason to use CCG. It can handle other platforms that don’t support Ada and SPARK compilers.

If you want a quick way to learn basic Ada and SPARK programming, then check out AdaCore’s online training tools. You can edit source code online and have it compiled and executed.

Sponsored Recommendations

What are the Important Considerations when Assessing Cobot Safety?

April 16, 2024
A review of the requirements of ISO/TS 15066 and how they fit in with ISO 10218-1 and 10218-2 a consideration the complexities of collaboration.

Wire & Cable Cutting Digi-Spool® Service

April 16, 2024
Explore DigiKey’s Digi-Spool® professional cutting service for efficient and precise wire and cable management. Custom-cut to your exact specifications for a variety of cable ...

DigiKey Factory Tomorrow Season 3: Sustainable Manufacturing

April 16, 2024
Industry 4.0 is helping manufacturers develop and integrate technologies such as AI, edge computing and connectivity for the factories of tomorrow. Learn more at DigiKey today...

Connectivity – The Backbone of Sustainable Automation

April 16, 2024
Advanced interfaces for signals, data, and electrical power are essential. They help save resources and costs when networking production equipment.

Comments

To join the conversation, and become an exclusive member of Electronic Design, create an account today!