-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#pragma once | ||
|
||
#include "core.h" | ||
|
||
/* we need basic arithmetic operations like add, sub, mult, div | ||
* and logical operations | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#pragma once | ||
|
||
#include "core.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#pragma once | ||
|
||
#include "core.h" | ||
|
||
/* instruction decoder */ | ||
|
||
/* hazard detection */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#pragma once | ||
|
||
#include "core.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#pragma once | ||
|
||
#include "core.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* MIPS32 Register File */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#pragma once | ||
|
||
#include <stdio.h> | ||
#include "core.h" | ||
|
||
/* | ||
* Component Init | ||
**/ | ||
void init_simulator(MIPS32Simulator * sim) | ||
{ | ||
/* Memory Init */ | ||
for (int i = 0; i < MEM_SIZE; i++) | ||
sim->memory[i] = 0; | ||
|
||
/* GP Register Init */ | ||
for (int i = 0; i < GP_REG_SIZE; i++) | ||
sim->gp_registers[i] = 0; | ||
|
||
sim->pc = 0; /* PC Init */ | ||
} | ||
|
||
void run_simulator(MIPS32Simulator * sim) | ||
{ | ||
while(TRUE) | ||
{ | ||
int inst = sim -> memory[sim -> pc / 4]; /* Current Instruction */ | ||
sim -> pc += 4; /* Next Instruction */ | ||
|
||
int opcode = (inst >> 26) & 0x3F; | ||
int rs = (inst >> 21) & 0x1F; | ||
int rt = (inst >> 16) & 0x1F; | ||
int rd = (inst >> 11) & 0x1F; | ||
int imm = inst & 0xFFFF; | ||
} | ||
} | ||
|
||
int main() | ||
{ | ||
MIPS32Simulator sim; | ||
|
||
init_simulator(&sim); | ||
} |