Search code examples
c++cembeddedverilog

Why does the chip control the language to choose


I've asked the question before what language should I learn for embedded development. Most embedded engineers said c and c++ are a must, but also pointed out that it depends on the chip.

Can someone clarify? Is it a compiler issue or what? Do chips come with their own specific compilers (like a c compiler or c++ compiler) and that's why you have to use the language the compiler knows? Is it not possible to code and compile it elsewhere, then burn it to the chip directly in its compiled state? (I think I heard an acquaintance say something to this effect)

I'm not sure how this works, as clearly I don't know much embedded systems or how they work. It's probably an easy answer for those of you who know.


Solution

  • It "depends on the chip" in three possible ways:

    1. Some very constrained architectures are not suited to C++, or at least C++ provides constructs not suited to such architectures so offers no benefit over C. Most 8 bit devices fall into this category, but by no means all; I have seen useful C++ code implemented on MegaAVR for example.

    2. Some devices are not supported by a C++ compiler. For example Microchip's dsPIC/PIC24 compiler is C only (third-party tools may have C++ support).

    3. The chip architecture is designed specifically for a particular language; for example INMOS Transputers invariably ran OCCAM.

    As well as C, C++, other possibilities are assembler, Forth, Ada, Pascal and many others, but C is almost ubiquitous; few chip vendors will release a new architecture or device without a C compiler being available from day-one. For other languages you will generally have to wait until a third-party decides to develop one, and that wait may be forever for a niche architecture.

    Is it not possible to code and compile it elsewhere, then burn it to the chip directly in its compiled state?

    That is called cross-compilation or cross-development, and is the usual development method for embedded systems. Most embedded systems lack the OS, filesystem, performance and memory resources to self-host a compiler, and most developers want the comfort of a sophisticated development environment with IDEs, debuggers etc. in a familiar user-oriented desktop OS.

    I'm not sure how this works, as clearly I don't know much embedded systems or how they work.

    Get up-to-speed with some of these: