Computer Laboratory Home Page Search A-Z Directory Help
University of Cambridge Home Computer Laboratory
N-105
Computer Laboratory > Course material 2004-05 > ECAD + Architecture Main Page > N-105


  Optional Lab - Create new instructions for N-105

Introduction

Over the summer Rosemary Francis and Daniel Hulme designed a simple processor - N-105 - which lectured as part of Computer Design. The design is freely available for you to play with. Try adding your own instruction (e.g. integer multiply).

Download

The download is currently larger than is should be, but we've not had time to tidy it up yet.

N_105.zip (~2MB)

Documentation

The following documentation is available:

Getting Started

Thanks to Alban for preparing this Getting Started guide.

Programs used:

  • Quartus II
  • SOPC builder (can be loaded from Quartus II within Tools menu)
  • ModelSim v5.7e (can be found in the Start menu in the same location as Quartus II)

Below is information on the following uses of N_105:

  • Writing programs for N_105
  • Running the programs in simulation mode
  • Adding on your own custom instructions by editing the Verilog code

Writing programs for N_105

There are several example programs written in N_105 assembler located in Programs folder. You are encouraged to write programs of your own. They may be compiled using the assemblers Assembler_mif.java/Assembler_dat.java. Note that Assembler.java will not compile without Label.java. Java class files are also provided, therefore no need to compile anything. For accepted file format see the instructions at the top of Assembler_dat.java. The assembler produces a .dat file which can be read by ModelSim directly into the instruction memory. This file is usually...

_system_sim\_lane0.
eg
N_105\N_105_system_sim\onchip_rom_lane0.dat
N_105\onchip_rom_lane0.mif

The .dat and .mif files can be converted into other formats using a nios program called nios convert. The .dat file if used by ModelSim to fill the onchip memory when it is run and the .mif file is used by Quartus in compilation to set up the rom in the programming file (the .sof).

There are some code generators in programs\testing. These can generate a variety of large programs for testing instructions and can be easily adapted to test your own add on instructions.

Running the programs in simulation mode

  • Load the N_105 project in Quartus (File/Open project and select cpu.qpf in N_105 folder)
  • Load the SOPC builder
  • Go to System Generation pane and click on "Run ModelSim"
  • Overwrite the contents of the "N_105_system_sim\onchip_rom_lane0.dat" file with the dat file of your choice*
  • In the ModelSim command prompt, type the s command, followed by w and then the run 20us command
    • this should start the simulation and display the results of the simulation in the wave window

* Both project files are generated by SOPC Builder with blank contents so will need to be over written by the Assembler after each generation. This may seem like a really odd way of doing it but we are having problems with SOPC builder. We can't seem to get the memory contents option to work. :(

Adding on your own custom instructions by editing the Verilog code

If you want to change stuff please copy cpu.v and the uoccl_n105 folder to somewhere else and create a new project with that. You should create the system in SOPC Builder (you will need the .ptf in the uoccl directory in order to be able to add the N-105 processor). To create an SOPC system you need to add components given in the left side of the SOPC builder window (by selecting them and clicking "Add...") and then connecting all of them together in a bus (eg Avalon bus). Once you are finished with all configurations, press the Generate button to complete the system generation. After successfully generating the system, you need to open the system file in Quartus and create a symbol for the system. You can do this by going to File -> Create / Update -> Create Symbol Files for current file. After creating the symbol file you need to create a block diagram file and add the system as a symbol to it (try double clicking some to get the symbols dialogue up). You can then add pin symbols to make a wrapper for the system and connect these to the pins on the board in Settings->Pin assignments.