A tiny MIPS implementation for Terasic DE0/DEx and other Altera FPGA boards
- Calculating Fibonacci numbers: video
- Supports MIPS I instruction set with basic arithmetic ops, branches and other ops
- Runs MIPS I binary code generated from basic C program
- 32KB RAM (with Block RAM of Cyclone III)
- I/O: 7-seg LEDs for output, sw3 - sw0 for input
- Single clocked design (no pipeline)
- Does not support floating points, exceptions and etc
- No bus/cache/MMU support
- Consumes about 13k LEs, largely by dividers and multipliers generated by Quartus.
- May have some bugs :)
- Terasic DE0/DEx or Altera FPGA development environment, including Altera Quartus II Web edition on Windows
- (Alternatively, you could use ModelSim for simulation only purpose)
- Experience of basic Altera FPGA development
- Create a Quartus project named CPU32
- Copy /src and /conf folders under the project folder and add .v files to the project.
- Start Analysis & Elaboration for initial check. You would have errors on some .v files. Open property dialog and set language to "SystemVerilog" to resolve the errors
- Use Pin Planner for pin assignment of CPU32.v for clock, LEDs, switches and buttons
- Start Compilation for full build. This may takes several minutes
- Use Programmer for loading to DE0
- You will see fibonacci numbers displayed on the LED
- Write your C code. You can not use system calls, exceptions, and floating point operations. If you like to use LED display or switchies, refer to the Memory Mappings section below
- Install mips-gcc on Linux. Add mips-gcc/bin directory to your PATH
- Install Python runtime
- Use c2mif.py to compile the .c file and generate .mif file
> python c2mif.py fib.c
- Copy the mif file from the Linux to /conf folder in the Quartus project
- Edit bram.v file and replace "conf/fib.mif" with the path of your mif file
- Start Compilation on Quartus II and load it to the board
0x0000 -> : text
<- 0x7efc : stack
0x7f00 -- 0x7fff : global
0x7f00 : to display a value on LED
0x7ff0 : to input params from sw3 - sw0
The 7-seg LED displays $7f00, PC or registers, based on switch setting:
sw9: off = $7f00 on = PC or registers
sw8: off = PC on = reg
sw7: off = low bytes on = high bytes
sw6-5: not used
sw4-0: register address
- Apache License v2.0