Ben Morgan wrote: > In a course at my university (Universität Würzburg, Germany) we have created > a 32-bit RISC CPU architecture -- the HaDesXI-CPU -- (in VHDL) which we then > play onto a FPGA (the Xilinx Spartan-3AN) to use. So far if we want to do > anything with it, we have to write the assembly code ourselves.
You have already ported binutils and gdb if I understand correctly? > How much work would it be to write a HadesXI backend for GCC? (The idea is > to use this as a possible bachelor thesis.) It's not the idea of your Betreuer, I hope. If so, it's unfair to propose this as a bachelor thesis. Besides that the pure implementation will take several months for an experienced GCC developer (others already commented on this), you will have to author and write corresponding paperwork. Porting GCC is "only filling in hooks", yes, but the internals linked below are often misleading and hard to read for newcomers, likewise intuition from programming experience is often misleading and wrong. Without an experienced GCC developer / backend guy as tutor I'd strongly discourage to pick this topic, and even with an experienced tutor it's a *very* ambitious project, and bugs and shortcoming of the implementation and the resulting gcc executables are likely to diminish you grading in an unfair way. > Where would be a good place to start; what are the prerequisites for > undertaking a project like this other than knowing the CPU architecture > inside out? One basis is a reasonable assembler like GNU as. If the tools after GCC are not "mighty" enough, e.g. if you cannot express things by means of respective relocations or expression modifiers and such as needed, the assembler is not much help. And such a port will be hard without a debugger and a simulator. Many things are easier with a simulator than on silicon. For a start with GCC, it's the internals, see http://gcc.gnu.org/onlinedocs/gccint/ and in particular chapters 10 RTL Representation 16 Machine Descriptions 17 Target Description Macros and Functions 19.1 Target Makefile Fragments Besides that it's reading existing backends. Avoid overly complicated ones like x86 and rs6000. s390 is nicely documented and it can be helpful to consult backends even if the hardware is not similar to your hardware. The more orthogonal the instruction set is, the easier will be the backend. Similar for register set and addressing modes. > > Thanks for your advice, Ben Morgan > Johann