Ask HN: did you ever implement a toy processor?
6 comments
I made a processor <edit> I emulated it </edit> in c++ in college. Started off with an abstract logic gate that had two inputs and an output, created an event queue to propagate outputs to inputs, created a couple of different buses, tristate and open drain I believe, and then created methods to link inputs and outputs as well some concrete logic gate classes to each other and also to the various bus end points.
The event queue even handled propagation delay.
I made it so that if a tristate bus was held to both high and low at the same time, then an exception would be thrown that told you you "let the blue smoke out" and ended the program.
Binary instructions were read from a static string buffer which were then interpreted by the logic to implement the functions of the cpu and alu.
In the end, I discovered that the cpu logic block that we had been told to emulate was missing a one clock cycle delay buffer and should not have functioned properly if anyone else implemented it accurately.
Wish I still had the code for that, it was super fun to make.
The event queue even handled propagation delay.
I made it so that if a tristate bus was held to both high and low at the same time, then an exception would be thrown that told you you "let the blue smoke out" and ended the program.
Binary instructions were read from a static string buffer which were then interpreted by the logic to implement the functions of the cpu and alu.
In the end, I discovered that the cpu logic block that we had been told to emulate was missing a one clock cycle delay buffer and should not have functioned properly if anyone else implemented it accurately.
Wish I still had the code for that, it was super fun to make.
This sounds like a really great way to get started without having to invest (time, money or both) in unfamiliar tools.
I architected an application-specific custom processor with about 25 instructions and implemented about 20% of it on an FPGA (the rest 80% was implemented by other team members). I also created software tools for this.
While this was not a toy processor per say (it was a part of a bigger project), I consider it toy-like because of the simple instruction set. Writing and debugging was not a major pain point in this case. Generally speaking though, I have been fairly satisfied with logic design tools for ASICs, though not as much for FPGAs.
I later discovered CAD tools built specifically for designing processors. Google ASIP [1] for more if interested.
Regarding this making me a better coder, well no, since I was already a good coder. :-) OK, I learned machine code at the age of 15 years, and so already had good insights into how stuff works inside when I learned C and C++.
[1] http://en.wikipedia.org/wiki/Application-specific_instructio...
While this was not a toy processor per say (it was a part of a bigger project), I consider it toy-like because of the simple instruction set. Writing and debugging was not a major pain point in this case. Generally speaking though, I have been fairly satisfied with logic design tools for ASICs, though not as much for FPGAs.
I later discovered CAD tools built specifically for designing processors. Google ASIP [1] for more if interested.
Regarding this making me a better coder, well no, since I was already a good coder. :-) OK, I learned machine code at the age of 15 years, and so already had good insights into how stuff works inside when I learned C and C++.
[1] http://en.wikipedia.org/wiki/Application-specific_instructio...
TKGate (http://www.tkgate.org/) is an awesome visual tool for discrete logic simulation, and comes with a toy processor as an example circuit. I implemented a simple 32-bit MIPS-like processor in TKGate as well as the DLX architecture from Hennessey and Patterson. I also designed and implemented my own microcoded 8-bit processor for variety. That project eventually included bootstrapped assemblers and disassemblers, and an emulator in C for faster simulations. Here's some of my TKGate work: http://xidus.xidus.net/mips
Check out TECS/NAND2Tetris to get started with VHDL and processor architecture: http://www.nand2tetris.org/ If you want a more academic approach, try Hennessey and Patterson's Computer Architecture: A Quantitative Approach.
Check out TECS/NAND2Tetris to get started with VHDL and processor architecture: http://www.nand2tetris.org/ If you want a more academic approach, try Hennessey and Patterson's Computer Architecture: A Quantitative Approach.
[deleted](1)
It's a nice project to implement a pipelined processor in logisim: http://ozark.hendrix.edu/~burch/logisim/
I'm asking this because I feel there isn't any easy way to write/debug and run fpga projects. I would like to change this, and I'm wondering if others feel the same?