Electronics > FPGA

C/C++ compiler for softcore CPU

(1/6) > >>

Anyone knows a very simple softcore CPU (let's say < 500 LUT) which has C++ or C compiler for it?

Also, let's suppose I design my own CPU. Is it hard to make a compiler for it?

PicoRV32 is advertised as 750-2000 LUT.  My very simple RISC-V core is about the same size (way less features, but also way easier to use) - https://github.com/ataradov/riscv .

And you get a real compiler that you won't have to maintain.

Making your own compiler from scratch is not trivial, but not impossible. But the only real reason to do it if you are explicitly interested in compiler creation. Otherwise it would be a huge pain.

There are lots of C51 cores out there supported by SDCC. But SDCC is pretty terrible.

I've seen people talking about using LLVM as a DIY compiler. Don't know if it's really easy to do or not

It is not at all. It is a huge mess of C++. If you have never worked on compilers, but know your way around programming and not afraid of megabytes of poorly documented code, I'd estimate 1-2 months of full time work to add completely new architecture to LLVM.

And then you have to maintain it. And LLVM is only the low level assembly. You would need to mess with Clang on top of that.

Unless compilers are your primary interest, it is not worth it.

TCC and SDCC are much easier to port, but they don't support C++, and even C support is spotty.

But generally it is easier to get already supported core, as FPGA part is way less effort.

As someone who implemented C parsers as a lab exercise in University, I tend to agree with @ataradov that implementing your own complier is not worth the trouble unless you are specifically interested in compilers.


[0] Message Index

[#] Next page

There was an error while thanking
Go to full version