More on my Homebrew CPU

I’ve mentioned the homebrew CPU on the Spartan 3 board I’ve been building for the last year. The internal architecture is sort of “old school” — internally there is a 16-bit bus connecting all the processor resources. Fixed logic handles all the operations (that is, it isn’t microcoded).

I call it Spartan Blue because it is very loosely based on “Blue” the CPU used as a learning tool in Caxton Foster’s excellent (but dated) Computer Architecture text book. However, Spartan Blue is a lot more advanced than Blue. My version incorporates indexing, a stack, conditional skips, and several other “advanced” features. All instructions complete in one “super cycle” or less (short instructions restart the super cycle; all of the original Blue’s instructions finished in one or two super cycles).

I don’t know if anyone ever built a real “Blue” machine — I know the book has a few errors in it. And my design is different enough that it isn’t really “Blue” at all. But you have to wonder if anyone ever made a faithful reproduction of Foster’s machine.

For the assembler I originally started writing it in awk. However, that proved too limiting so I had it autoconverted into Perl and then continued writing it in Perl. This allows for constant expressions and several other features. I recently “discovered” that Perl has long shipped with perlcc which lets you compile your Perl program to an executable. A shell script calls the C preprocessor before it launches the assembler, so overall it is a pretty powerful system without much work.

Here’s part of the monitor software:

call print_msgcr+CODEOFFSET
ds “Blue Monitor 0.4\xFF”

prompt: call print_msg+CODEOFFSET
ds “\r\r\nBLUE> \xFF”

call waitcharecho+CODEOFFSET


More later.

Update: You can see Blue in action:

Leave a Reply