On 18/01/11 11:06 PM, Sylvere Teissier wrote:

> But GHDL has about 100k line of code. It would take too much time to
> convert it to C++ :(

See http://adatoccpptranslator.free.fr/eg/index.html

 ...

      The aim of Adatoccpptranslator is to automate translation from Ada to
      C and C++ languages.

    Adatoccpptranslator doesn't translate all the code but tries to
    translate it as best as possible to obtain C/C++ code with the fewest
    bugs possible and whose execution is as near as possible to the
    original Ada program execution.

    The objective is to have no errors in the automatically translated part
    of the code so that the user doesn't need to check the translated code.
    So he just needs to translate the parts of the code which are not
    treated by Adatoccpptranslator.

    New software releases will allow the automatic translation rate to be
    increased to minimize the manual correction needed after automatic
    translation.

  ...

 --

It's licensed under the GPLv2.  The issue of course is having to debug the
translation, as well as manually deal with unsupported constructs and Ada's
runtime library (libgnat, plus exception handling immediately comes to mind).

The only other free converter I'm aware of is probably more limited, ada2c,
where the documentation isn't in English (somewhere I may have the start of
a translation from Romanian).  It dates from 2006 and appears to have been
written in 1995, while Adatoccpptranslator dates from 2005.  No license is
given in the source code for ada2c, you could inquire of the author.

http://www.idi.ntnu.no/~zoran/
http://www.idi.ntnu.no/~zoran/download/ada2c-src.tgz

You could alway 'improve' open source tools.   I can imagine writing little
tools for converting specific types of code snippets, but then I write C
programs to generate VHDL.  Both of these tools are based on parsers written
for Flex/Bison.

There are commercially available tools with likely lower error rates and
better coverage.  Some of them would require re-targeting the code
specifically from Windows build environments (e.g. ada2cc.com).  Some tools
integrate with host operating system abstractors (e.g. mapsoft.com).

Be forewarned the downloaded zip file dumps sub directories in the current
directory with unzip. Open it in an otherwise empty directory.  There are
ten files and subdirectories.  Some un-archiving tools will do the right thing.

This tool was released in 2005 and is written in C++, implying the
likelihood of having to debug a tool build.  When you find a tool frozen in
time there is a high probability the authors transferred their allegiance to
their own or some other commercial venture.

If you couldn't get Adatoccpptranslator to build easily, you could translate
ghdl source files one at a time entirely by hand in a mixed build
environment, which would likely require generating analogs for some Ada
constructs, also exception handling issues.  Even with a translator, one
source file at a time might be prudent, at least initially.  You can imagine
this infers a lot of regression type testing.

There's a section in the GNAT User's Guide, entitled "Linking a Mixed C++ &
Ada Program" as well as another - "Building Mixed Ada & C++ Programs".  A
mixed environment would likely be specific to gcc.  Note that the program
structure would be inherited from the Ada source in any event.

http://gcc.gnu.org/onlinedocs/gcc-4.3.4/gnat_ugn_unw.pdf

Googling "ADA to C++" can be educational.

I've always thought translating grt might be useful in jump starting
participation.  An interactive shell able to  peer into an elaborated and
loaded model while providing things like single stepping and break points
would be very encouraging.




_______________________________________________
Ghdl-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/ghdl-discuss

Reply via email to