I’m always a bit frustrated that there isn’t more FPGA CPU design going on in the classroom. Don’t get me wrong. There is certainly some, but given how inexpensive FPGA hardware is now, I think learning about CPUs in this context is a great thing. First, it gives you great confidence in your ability to work with FPGAs. But even if you don’t do much with FPGAs ever again, it also gives you a deep insight into how CPUs work and I think there is great value in that.
There are two major problems. First, you have to have a CPU (or at least a part of one) that can be reasonably done in the classroom setting. It has to be simple enough to fit the time allotted. The other problem is building something with a reasonable toolset. Again, this is a matter of having the time to do it.
It would be easy to imagine a sequence of courses where you build a CPU, then you build an assembler, then you port GCC over to your new architecture. I haven’t seen anything that comprehensive and there are always logistic problems with that kind of class anyway. So you can build a toy CPU with no real tools, or copy an existing (and probably copyrighted) CPU and use tools meant for it. If you browse http://opencores.org you’ll see both approaches.
My Blue CPU,for example, has its own little assembler, but nothing special. The MCPU is very tiny and will fit on a ***a***CPLD but also lacks real tools and isn’t very representative as an example. But many other CPUs appear to be PICs, AVRs, 8051, or x86s. Tools for these CPUs are abundant, including C compilers.
Legal issues aside, though, both of these choices present another problem. Very few commercial CPUs document their instruction set architecture from the CPU designer’s point of view. They usually have a programmer in mind.
I’ve never seen anyone actually try this, but it has always been an idea in the back of my mind that the MIL-STD-1750A CPU would be ideal for teaching a class like this. You are probably either thinking “The what?” or “Dummy. That thing’s out of date.”
Let me address the first question first. Some time back, the U.S. Air Force decided that it could reduce the cost of developing embedded systems if it specified a common CPU. The military in general thought it was a good idea and MIL-STD-1750A was born. In addition to military use, the CPU found a home in NASA projects, European Space Agency projects, and other places.
As for the second question, well it is out of date. In 1996 the military declared the standard inactive, although Wikipedia says it is still in use in India and China. Yes, it is 16-bit but that means it fits easier in a smaller FPGA. Current GCC builds do not support 1750A, but version 3.1 and earlier do.
You can find a lot of info at http://is.gd/kPuujU, including a simulator, a C compiler, and the original specification. If I were making this a class project, I’d probably skip the floating point and the memory manager, but that should be harmless. I do know that Mississippi State University (a school I attended for awhile) did a VHDL 1750A CPU, but I couldn’t find the files anywhere on the Internet.
Granted, the 1750A is an older style of architecture and isn’t terribly practical. Depending on the goals you have for a class, there might be better choices. What CPUs have you seen used in an educational context? How did it work out? Leave a comment and let me know.