Ask Hackaday: Putting the C in CPU
I was once in a meeting where the facilitator asked us to introduce ourselves with the usual information, but also wanted us to share our favorite hobby. I spent a second trying to think of which hobby I could say to not sound like a total nerd. Then I realized it didn’t matter. All my hobbies are nerdy, including designing CPUs and their instruction sets.
I actually started sketching out an instruction set when I was a kid, back when no one had home computers. I am glad I lost that notebook: it would be painful to see today. The first CPU I put on an FPGA wasn’t of my own design, though. I implemented BLUE from Caxton Foster’s Computer Architecture book . I also extended it and modernized it a lot. I really wanted a C compiler for it.
C Compilation
That’s really the problem. C was once a simple language, but modern C is far from simple, and compilers are huge projects. I have looked before at porting GCC to a different architecture, and it looks daunting. There’s LLVM, which is a bit more modern, but also non-trivial to port. There are a few older compilers that ought to be easier, but they often aren’t quite modern enough. Plus, if your CPU were big enough, which BLUE isn’t, GCC or a similar modern compiler would be attractive because you could use it to get Linux going.
Keep in mind, though, I’m not talking about a C compiler that runs on BLUE. Just a cross-compiler. My OneDer CPU is 32-bit and could host a C compiler, though. That’s another reason to bite the bullet and do a “big” compiler port. Because even if BLUE isn’t that big, other CPUs are, and I’d love to have a GCC port under my belt.
Decisions
So… what do I do? I have a few ideas for you to consider, and of course I’m open to other suggestions. One of the biggest problems with BLUE is that it is a word-oriented machine. Address 0, for example, is a 16-bit word. Address 1 is another 16-bit word that does not overlap.
This is great until you get into strings: that is, character arrays. Should a ch




Comments
No comments yet. Be the first to share your thoughts.