Select Git revision
Forked from
Yong Sang Ho / SystemProgramming_MeBeforeYou
Source project has a limited visibility.
util.h 3.89 KiB
/***************************************************************/
/* */
/* MIPS-32 Instruction Level Simulator */
/* */
/* CSE561 Ajou University */
/* util.h */
/* Adapted from CS311@KAIST */
/* */
/***************************************************************/
#ifndef _UTIL_H_
#define _UTIL_H_
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#define FALSE 0
#define TRUE 1
/* Basic Information */
#define MEM_TEXT_START 0x00400000
#define MEM_TEXT_SIZE 0x00100000
#define MEM_DATA_START 0x10000000
#define MEM_DATA_SIZE 0x00100000
#define MIPS_REGS 32
#define BYTES_PER_WORD 4
#define PIPE_STAGE 5
typedef struct IF_ID_Struct {
instruction INSTR;
uint32_t NPC;
} IF_ID;
typedef struct ID_EX_Struct {
uint32_t NPC;
uint32_t REG1; // Register value 1
uint32_t REG2; // Register value 2
char RS;
char RD;
char RT;
uint32_t IMM; // Immediate Field
char SHAMT;
char DEST;
char ALUOp;
// 1: add (ADDIU, ADDU, LW, SW)
// 2: sub (SUBU, BEQ, BNE)
// 3: AND (AND, ANDI)
// 4: OR (OR, ORI, NOR)
// 5: Shift Left (SLL)
// 6: Shift Right (SRL)
// 7: Set Less Than (SLTIU, SLTU)
// 8: Shift Left 16 (LUI)
// 9: JAL (JAL)
char ALUSrc; // Second Operand from Immediate -> 1
char ALUNeg; // NOR or BNE -> 1
char Branch; // branch -> 1
char MemRead;
char MemWrite;
char RegWrite;
char MemtoReg;
char LoadUse;