Giter VIP home page Giter VIP logo

mips32-pipeline's Introduction

MIPS32 Pipeline

A naive 5-stage pipeline MIPS CPU.

Quick Start

Environment:

$ uname -a
Darwin MacBook-Pro.local 23.4.0 Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:41 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T8103 arm64

Set up the required toolchains:

$ brew install verilator llvm@17
$ echo 'export PATH="/opt/homebrew/opt/llvm@17/bin:$PATH"' >> ~/.zshrc

For better development experience, add the following two paths to the includePath in VSCode. Please note that the paths may vary based on your setup, but you should be able to locate the correct ones on your machine:

/opt/homebrew/Cellar/verilator/5.024/share/verilator/include
/opt/homebrew/Cellar/verilator/5.024/share/verilator/include/vltstd

Build Test Images

Set up the required toolchains based on the following list:

$ dpkg --list | grep mips
ii  binutils-mips-linux-gnu          2.38-1ubuntu1cross2                     amd64        GNU binary utilities, for mips-linux-gnu target
ii  cpp-10-mips-linux-gnu            10.3.0-1ubuntu1cross2                   amd64        GNU C preprocessor
ii  cpp-mips-linux-gnu               4:10.2.0-1                              amd64        GNU C preprocessor (cpp) for the mips architecture
ii  gcc-10-cross-base-mipsen         10.3.0-1ubuntu1cross2                   all          GCC, the GNU Compiler Collection (library base package)
ii  gcc-10-mips-linux-gnu            10.3.0-1ubuntu1cross2                   amd64        GNU C compiler (cross compiler for mips architecture)
ii  gcc-10-mips-linux-gnu-base:amd64 10.3.0-1ubuntu1cross2                   amd64        GCC, the GNU Compiler Collection (base package)
ii  gcc-mips-linux-gnu               4:10.2.0-1                              amd64        GNU C compiler for the mips architecture
ii  libatomic1-mips-cross            10.3.0-1ubuntu1cross2                   all          support library providing __atomic built-in functions
ii  libc6-dev-mips-cross             2.35-0ubuntu1cross1                     all          GNU C Library: Development Libraries and Header Files (for cross-compiling)
ii  libc6-mips-cross                 2.35-0ubuntu1cross1                     all          GNU C Library: Shared libraries (for cross-compiling)
ii  libgcc-10-dev-mips-cross         10.3.0-1ubuntu1cross2                   all          GCC support library (development files)
ii  libgcc-s1-mips-cross             10.3.0-1ubuntu1cross2                   all          GCC support library (mips)
ii  libgomp1-mips-cross              10.3.0-1ubuntu1cross2                   all          GCC OpenMP (GOMP) support library
ii  linux-libc-dev-mips-cross        5.15.0-18.18cross1                      all          Linux Kernel Headers for development (for cross-compiling)

To build the test images, navigate to ./tests and run:

make all

If you have all the required toolchains set up correctly, you will find *.bin files in the test case folders.

Run Tests

If everything goes well, you can run the tests with:

make test

and see the output:

[OK]            TEST1-JUMP.
[OK]            TEST2-BITWISE.
[OK]            TEST3-IMM.
[OK]            TEST4-OPs.
[OK]            TEST5-LOAD_STORE.
[OK]            TEST6-BRANCH.
[OK]            TEST7-LUI.
[OK]            TEST8-QSORT.
ACCEPTED.

To debug the CPU step by step, try:

make run

You can change the target image in the Makefile under the root folder.

Overview

The CPU is built from the following reference architecture, with some fixtures and modifications made by me, including memory access latencies, bitwise operations, data forwarding, and more.

MIPS-Pipeline

Some details of implementation can be found in the comments from the source code.

mips32-pipeline's People

Contributors

boreas618 avatar lsc2001 avatar

Stargazers

J3rry avatar

Watchers

 avatar

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.