Giter Club home page Giter Club logo

mips-pipeline-processor's Introduction

MIPS-pipeline-processor

Thanks for visiting this repository!

Developed during the Fall 2017 Computer Architecture Laboratory course at the University of Tehran, this project is an implementation of a pipelined MIPS processor featuring hazard detection as well as forwarding. This implementation is based on a limited ISA, the details for which are present in docs/MIPS_ISA.png. This code is synthesizable and can be run on an FPGA. We used Altera DE2 units for testing purposes. The implemtation has been verified using a relatively complex test program (found in instructions/example_source_code.txt).

MIPS pipelened processor

Getting Started

Download or clone the project, write your machine code to run (there already exists a default test program in the instruction memory), compile the Verilog files and and run testbench.v in a Verilog simulation environment such as ModelSim from Mentor Graphics.

Instruction format

Instructions should be provided to the instruction memory in reset time. We avoided the readmemb and readmemh functions to keep the code synthesizable. The instruction memory cells are 8 bits long, whereas each instruction is 32 bits long. Therefore, each instruction takes up four memory cells, as shown bellow.

For example, an add instruction: 10000000001000000000000000001010 or Addi r1,r0,10 will need to be given as

instMem[0] <= 8'b10000000;
instMem[1] <= 8'b00100000;
instMem[2] <= 8'b00000000;
instMem[3] <= 8'b00001010;

Converting your raw machine codes

A python script is provided under the instructions/rearrange_instructions.py directory which simply takes your machine code (in a specified format) and converts it to the format illustrated above.

Enable/disable forwarding

An instance of the top-level circuit is taken in testbench.v. The inputs of the MIPS_Processor include clk, rst, and forwarding_EN. Forwarding will be enabled if forwarding_EN is set to 1, and disabled otherwise.

Under the hood

There are five pipeline stages:

  1. Instruction Fetch
  2. Instruction Decode
  3. Execution
  4. Memory
  5. Write Back

Modular design

All modules are organized under the modules directory. The top level description can be found under topLevelCircuit.v. It contains a modular design of the processor and encompasses five pipe stages and four pipe registers, the description for which are present under modules/pipeStages and modules/pipeRegisters respectively. The register file, the hazard detection and the forwarding units are also instantiated in topLevelCircuit.v. Pipe stages are made of and encapsulate other supporting modules.

Constants

defines.v contains project-wide constants for opcodes, execution commands, and branch condition commands. It also contains constants for wire widths and memory specifications. You can change memory size values to suit your needs.

Wire naming convention

To maintain conformity, most wire names follow the format {wire description}_{wire stage}, where the second part describes the stage where the wire is located. For example, MEM_W_EN_ID is the memory write enable signal present in the instruction decode stage.

Contributions

Contributions are welcomed, both general improvements as well as new features such as a more realistic memory heirarchy or branch prediction. However, please follow the coding styles and the naming convention. Another useful contribution would be more comprehensive testing and verification and bug report.

mips-pipeline-processor's People

Contributors

mhyousefi avatar mohsen-zare avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

mips-pipeline-processor's Issues

Little typo and some questions on the code?


  1. Should it be an output? Reference here:

  2. In the comment there's a little typo, "of" should be changed to "or" :

    mux #(.LENGTH(`WORD_LEN)) mux_val2 ( // determins whether val2 is from the reg file of the immediate value

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.