41

Can you recommend a readable and educational implementation of a CPU in VHDL or Verilog? Preferably something well documented.

P.S. I know I can look at opencores, but I'm specifically interested in stuff people have actually looked at and found interesting.

P.S.2. Sorry about the sucky tags, but as a new user I can't create new ones

endolith
  • 28,494
  • 23
  • 117
  • 181
Eli Bendersky
  • 566
  • 4
  • 7

7 Answers7

18

You may enjoy an article series I wrote on this long ago for Circuit Cellar magazine, Building a RISC System in an FPGA.

Happy hacking!

Jan Gray
  • 306
  • 2
  • 4
7

Get this book, I've got the first edition. A few years ago I implemented their CPU in a little Flex 10K10 FPGA on a PCB I designed, with a couple of push buttons and a single 7-segment display for entering data and displaying the results.

Leon Heller
  • 38,774
  • 2
  • 60
  • 96
7

A lot depends on what is your purpose of studying the code? In other words, what does interesting mean to you?

If you are doing it in order to see how much complexity can go into a CPU, you may be more interested in studying the source of OpenSPARC architectures. It will take a long time to dive in but you will get an appreciation for the overall big picture view of a complex microprocessor.

Then, if it is to study specific computer microarchitecture features, you will want to look at some straightforward RISC machines like the AEMB, a small and fast multi-threaded 32-bit RISC processor (shameless plug).

Then, if what you want is to learn good coding styles and conventions, the LEON2 design is a good place to learn good VHDL coding style.

However, if your purpose in studying a processor is to learn how to design one yourself, your best bet would be to start with one of the simple 8-bit machines (there are many AVR, 8051, PIC examples on the net).

sybreon
  • 1,591
  • 1
  • 12
  • 13
  • Shameless plug - [AEMB](http://github.com/aeste/aemb) - my own "littlest processor that could." – sybreon Sep 12 '11 at 12:13
5

You may try examining some Forth CPU designs. Forth is a simple programming language whose specification and implementation is defined by means of two stacks stack (one for data and one for return addresses).

Several small VHDL/Verilog processors are freely available:

Some more links can be found here:

PS. Despite Forth being a fairly old and obscure language many modern stack-based VMs (Java, fast JavaScript VMs) have similar low-level design so learning about it can be fruitful.

jpc
  • 5,302
  • 1
  • 24
  • 45
2

PicoBlaze is nice, however it is not available in vendor-independent VHDL.

Some other choices are:

  • A Picoblaze clone in Verilog (you should be able to find this easily). Not sure if it is maintained
  • Gumnut is a nice small core supported by a recent Ashenden book.
  • The tiny register machine/computer by Thacker (about 200 lines of Verilog)
  • Jan Gray's XSoC/XR16 (already mentioned here)

Also, if you are looking for a compiler for your CPU, it is most probable to get one for a 16-bit CPU. Once there was Poderico's compiler from a C-like language to Picoblaze but it has been taken off the web.

Earlz
  • 3,346
  • 15
  • 46
  • 66
1

You may have a look at the Xilinx PicoBlaze processor. It's a minimal 8-bit embedded microcontroller, and the source code should be available.

geschema
  • 433
  • 3
  • 12
1

Too late, however I provide a small answer.

There is a course named fromNand2Tetris from University of Jerusalem, this course is also present on coursera, I built the computer they created in that course. I implemented the language in scheme to be able to see myself how the computer works in the least detail. And I succeeded, the simulator they created in Java cannot do everything I wanted to see.

https://github.com/alinsoar/little-computer

alinsoar
  • 101
  • 3