Giter Club home page Giter Club logo

fum-mips's Introduction

FUM-MIPS

Overview

FUM-MIPS is a 5-stage CPU, that supports a subset of the MIPS Instruction Set. It is a 32-bit CPU with 32 general-purpose registers. The figure below shows an overview of the architecture.

overview of architecture

Supporting instructions are brought in the table below.

instructions

In this version, all data and control hazards are handled with stalls and there are no forwarding paths. My strategy for dealing with data hazards is to use a scoreboard for recognizing the pending registers.

Code Structure

Each of the 5 stages is implemented as a goroutine and stages pass messages using buffered channels. This is the most accurate simulation according to how CPU's pipeline works, as stages work asynchronously.

Application

The simulator gets a file to load the initial memory state and starts executing from the first line. To add an application, put your binary code in the "memory-initial-state" folder.
For validating the simulator I write an app "array-max-min.txt" that iterates through an array of size 10 and writes maximum and minimum elements in memory words. Assembly code is as below:

assebly

And its equivalent binary code is:

10001100000000010000000001100100
10001100000000100000000001101000
10001100000000110000000001101100
00110100000001000000000000000000
10001100000001010000000001110000
00010000100000010000000000001011
10001100101001100000000000000000
00000000010001100011100000101010
00010000000001110000000000000001
00000000000001100001000000100000
00000000110000110011100000101010
00010000000001110000000000000001
00000000000001100001100000100000
00100000100001000000000000000001
00100000101001010000000000000100
00001000000000000000000000000101

10101100000000100000000010011100
10101100000000110000000010100000






00000000000000000000000000001010
10000000000000000000000000000000
01111111111111111111111111111111
00000000000000000000000001110100
00000000000000000000000101000001
11111111111111111111111111110100
00000000000000000000000010000110
00000000000000000000000000000000
11111111110101111111000001110011
00000000000100110010110101001101
00000000000000000000000000000011
00000000000000000000000000000000
00000000000000000000000000001001
11111111111111111111111111101001

To see the result of excuting this code, go to results folder.

Run

Go to the project's directory and enter go build, then type ./mips-simulator -file=<filename.txt>. "filename" is composed of binary code of CPU instructions and data. Each of the 32-bit memory words must be on a new line. See attached example files.

fum-mips's People

Contributors

alabarjasteh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.