Porting MIPSfpga to Terasic DE1 board with Altera Cyclone II FPGA

Я получил запрос из крупного университета на Ближнем Востоке про использование MIPSfpga на плате Terasic DE1 с ПЛИС Altera Cyclone II. Хотя у меня нет этой платы на руках, я попробовал помочь преподавателю перенести MIPSfpga на эту плату, и я надеюсь, что университет сможет приспособить MIPSfpga для своей учебной программы. Ниже — фрагмент моей переписки с преподавателем:

I got a request from a large university in Near East about using MIPSfpga on Terasic DE1 board with Altera Cyclone II FPGA. While I do not have this particular board in my board collection, I tried to help the teacher to port MIPSfpga to this board and I hope the university can adopt MIPSfpga to their curriculum. Below is a fragment of my email conversation with the teacher.

Prof. XXX:

I was able to comfortably fit MIPSfpga into DE1 using my variation of MIPSfpga Getting Started / Fundamentals package. I can show you how you can reproduce my result and then how you can correct your own port of MIPSfpga Getting Started by borrowing some of the components I have created.

First, here is how to reproduce my result:

  1. Unzip MIPSfpga Getting Started to C:\MIPSfpga
  2. Get mipsfpgfa-plus into C:\github\mipsfpga-plus
  3. cd C:\github\mipsfpga-plus\boards\de1
  4. make_project.bat
  5. Run Altera Quartus II version 13.0 sp1
  6. Open project C:\github\mipsfpga-plus\boards\de1\project\de1.qpf
  7. Analyze/Synthesize/Place&Route/Assemble
  8. Open Device / Hardware Setup / ByteBlaster / Set file / ouput_files / de1.sof / Start

You should get the following:

Screenshot 2016-02-02 19.55.38

Note I do not have a DE1 board with me so I did not test running on the board. However I am confident it will run either immediately or after I adjust my clock divider.

Now how to correct your own port of DE1:

  1. First, I noticed that you have two versions of mipsfpga_ahb_const.vh with different sizes for ram and reset_ram. This is OK if you have a proper “set_global_assignment -name SEARCH_PATH” line in your .qsf file. Does Quartus pick the correct .vh file?
  2. I was able to fit the design comfortably by specifying 1KB reset_ram size and 1 KB user ram size. However the boot/reset sequence in the original MIPSfpga Getting Started does not fit into 1 KB because it is linked with crt0 from the standard C library. This crt0 code is totally unnecessary because its function is to setup C runtime in “big” operating systems before calling main() and most of it is not applicable for MIPSfpga. By omitting calling crt0 and setting up a stack pointer inside the boot sequence itself, it is possible to shrink the boot sequence to 1KB. You can get it here – https://github.com/MIPSfpga/mipsfpga-plus/blob/master/programs/00_counter/boot.S
  3. Now you may say that 1 KB for user ram is too small. Still, it is enough to do many lab exercises, and if you need more, it is possible to write an interface to the 8 MB SDRAM present on the DE1 board.
  4. Also, if you need more block ram, it is possible to eliminate EJTAG module and load the software program into your synthesized system via UART present in DE1 board.
  5. Options like “set_global_assignment -name ENABLE_ADVANCED_IO_TIMING ON” can bloat the design. If you use it, this would explain why you cannot fit. You can see my constraint file right here — https://github.com/MIPSfpga/mipsfpga-plus/tree/master/boards/de1
  6. I got Fmax 45.97 MHz on my synthesis so you may need to adjust PLL to divide 50 MHz clock.
  7. If necessary, I can sit with you over Skype and make sure you fit the MIPSfpga into DE1 and can run it. My Skype is yuri.panchul.

The whole thing is doable we just need to avoid the pitfalls I outlined (bloating options in constraint file, proper sizes for memories, compact bootloader, clock divider).

terasic_de1