Do you want to build your CPU? It’s fun, but you don’t think it’s as tricky.
I have done many CPUs over the years, and there is no shortage of other custom CPUs, ranging from earnest endeavors to computers made from single chips to computers built with relays.
Not to minimize the effort, but the real problem is not the CPU, the real questions here are as follows;
1. What kind of infrastructure?
I think Holly Grill needs to bootstrap your custom CPU into a fully-fledged Linux system. That’s the proper thing to do, and it should end there.
Although you may be more productive than I am, you probably need a certain amount of sleep, so you may want to consider whether you can do it all at the right time.
Many custom CPUs, for example, do not run interactive operating systems (or any operating system for that matter).
In extreme cases, custom CPUs have no infrastructure, and you program them directly into machine code.
The machine code is error-prone, so you need an assembler. You will also need a linker if you are working on a large machine.
Assembly language coding becomes cumbersome, so you may need a C-compiler (or another language). A debugger? What about the operating system?
Each of these things is a severe project (at the top of the plan to build a reasonably capable CPU). If you have lots of free time or a big team, you must think about how to hew some shortcuts.
2. Getting Infrastructure?
The simplest way to get infrastructure is to steal it. But does this mean that your CPU is compatible with any other available CPU (such as OpenSparc or OpenRisc) and what fun is it? Still, the Internet is full of clone CPUs that work this way.
What makes a clone CPU suitable? Presumably, the designer wants to use this particular processor but intends to integrate it with other devices to build the system on the chip.
Of course, sometimes people want to mimic an old machine, which can be fun.
The appeal of developing your CPU is that you make it your own. You may want to experiment with weird instruction set architectures.
You probably know how to minimize processor stalls. Or you could be just like me and want a computer that suits you better than any commercial alternative.
If so, what do you do? You can try to port the infrastructure. It’s in the middle of stealing and building from scratch.
3. Portable options
There are plenty of options for portable assemblers. Assuming your processor doesn’t look too weird, and you don’t mind traditional assembler conventions about labels and symbols, you might consider TDASM or TASM. It is my change, AXASM, and I will discuss this shortly.
Assembly language is acceptable, but you want a high language level. Of course, your first thought would be on Port GCC, an excellent C and C ++ compiler (among other things).
There is good news, bad news, and bad news. The good news is that GCC is made portable if your architecture fits some default concepts (for example, at least 32-bit integers and flat address space). ).
The bad news is that seaports are challenging to navigate. The worst information is that there is a limited amount of documentation and much of it is outdated.
Still, it’s possible. There are three things you need to do to make a cross compiler.
- Machine description
- A machine header
- Some machine-specific functions
However, their construction is quite complex and uses lisp-like indicators that are not always intuitive.
If you want to deal with it, several documents are of interest. A review of a fantastic slideshow, ancient official papers, and some boy’s master’s thesis.
However, be prepared to read too much source code and experience. Then you might also want to port GDP, which is unusual.
Others are C compilers. llvm is ringing in the project, which you may find a little easier to port, though it is still not what I consider trivial.
The LCC compiler began in 1995 as a book. It uses iburg to generate code, and this tool may be helpful for some other targeting projects.
Although the vbcc compiler is not often updated, its backend documentation looks tremendous and seems one of the easiest compilers to port.
There is a portable C compiler, PCC, which is quite respectable. I’ve noticed that people port some “small” variations to a different CPU, even though they’re not standard C, so it’s only for limited use.
4. Management of memory
Remember that there is much more to porting GCC than just the C compiler.
You will need to specify your ABI (application binary interface; basically, how memory is managed and arguments are passed).
You’ll also need to provide at least some Bootstrap C libraries, although you may be able to reuse a lot of standard libraries after the compiler works.
So maybe the C compiler is a little bit. There are other ways to get high-quality language.
Developing a viable JVM (or another virtual machine) allows you to compile Java and perhaps less work overall.
Still, it’s not easy, and your JVM performance may not be close to what you set up. I find it easier to get to the fourth version. Jones on Forth is an excellent place to start if you get a backup copy of it.
If you cut the bullet and build the C compiler, the operating system is the next hurdle. Most Linux builds have advanced features like memory management.
There is a version, uClinux, which can be a little easier to port. You might be superior off looking at something like Contiki or FreeRTOS.
Final Thought
Creating a new CPU is not for the faint of heart and is probably not your best bet for the first FPGA project.
Sometimes, getting a decent front panel can be a challenge, regardless of the compilers and operating system.
Bootstrapping a new system on a complete Linux running monster would be a massive task for a hacker. It could be more suitable for a team of hackers.
However, just because you can’t build the next 128-bit superscale CPU over the weekend doesn’t mean you shouldn’t try to make a CPU. You will find out a lot, and who knows if you can invent something new?.
Related Article:
How Much Would It Take To Build My Own GPU and CPU?(Explained)