Here is an interesting project that I have finished this summer. I would like to share it with you so I can hear your opinions and suggestions

The mission of the project is to create a functional FPGA computer system consisting of a 6502-like processor, a display controller, a PS/2 controller for keyboard, a ROM to store the firmware, and a RAM. The computer was written in VHDL and installed on a Nexys-2 FPGA board.
NOTE: Click on any image to see it in full size.
1- The processor:
The processor is actually a 6502 clone, but with a totally new microarchitecture. The reasons why I used an ISA that already exists (and didn't design my own ISA) are:
- I already designed a customized ISA before, so it is time to study the ISAs of others (more specifically, the ISAs of the golden era of computing)
- 6502 is pretty interesting!
- I could use my 6502 implementation later to make a NES clone, for example.

No pipelining! No cache!


ALU has 8 operations (ADD, SUB, SHL, SHR, BIT, AND, ORA, and EOR); These ops are actually all the required operations to implement 6502 ISA. The control unit here is microprogrammed. I wrote the micro-program using my preferred text editor, wrote a micro-assembler to compile the microcode into binary, and used the micro-assembler along with GNU M4 to generate the microprogram ROM. The microprogram ROM is then converted into VHDL code as a block ram array. The combination of the VHDL logic + the microprogram ROM is an FSM that typically implements the 6502 instruction set.
2- Display controller:
Here I decided to replicate the design of the IBM VGA adaptor on a very small scale so that I could learn how the IBM VGA itself worked. I finally came up with this design:

After a lot of debugging on the real FGPA, it worked and the CRT screen showed something! I first implemented the CRT controller module, tested it until it worked, then the RAM blocks, then tests, then another module and so on. I am also grateful to this greate article on the wiki!
3- PS/2 controller:
This is a simple finite state machine that fetches signals on the PS/2 bus. The controller is connected to the NMI input of the CPU.
4- Memory controller:
This controller works as an interface between system bus and Nexys-2 on-board ROM and RAM chips. Whenever a CPU read/write cycle takes place, the controller generates signals that control the on-board ROM/RAM. The controller supports read/write operations from/to RAM, and read operation from ROM (no ROM programming).
5- The big picture:
Here is the design of the whole computer that shows how components interface each other:

Looking at the decoder, we can deduce that RAM appears at (0x0000-0x3FFF) memory region, the keyboard controller appears at (0x4000-0x5FFF), VGA at (0x6000-0x7FFF), and ROM at (0x8000-0xFFFF).
6- Software:
It was pretty interesting to design some hardware and then write some software to run on it

7- Emulator:
To test the operating system before uploading to the FPGA chip, I wrote a simple emulator in C. The real machine and the emulator use the same microcode binaries, so I could use the emulator to debug both the microcode and the OS.

8- Compiling and Uploading:
In order to synthesize the VHDL code and implement the design, one needs to have Xilinx ISE installed on a computer machine. I wrote a Makefile to automate the process, so I didn't have to use the messy GUI of ISE. Text editors win!

9- The final result:

Suggestions/questions are more than welcome

Project website, explains the whole story in more details.