// // globals.h // // Description: // Extern declarations of global variables for the AD-MIPS processor. // // Version: // $Id$ // // Revision: // $Log$ // // Author: // Brian J. Alliet // Jonathon W. Donaldson // #ifndef _GLOBALS_H #define _GLOBALS_H #include "includes.h" /****************************** *MIPS Architecture Components* ******************************/ /* Fetch */ extern Adder if_add; extern Constant if_4; extern Memory imem; /* Fetch/Decode */ extern StorageObject if_id_npc; extern StorageObject if_id_ir; extern Bus if_pc_bus; /* Decode */ extern Adder id_add; extern StorageObject* regs[32]; extern Bus id_reg_in_bus; extern Bus id_reg_rs_bus; extern Bus id_reg_rt_bus; extern Bus id_reg_jr_bus; extern SuperBus id_imm_bus; extern SuperBus id_branch_off_bus; extern SuperBus id_jump_target_bus; extern SuperBus id_shamt_bus; extern Bus id_ir_bus; extern Bus id_npc_bus; extern Bus id_onpc_bus; /* Decode/Execute */ extern StorageObject id_ex_onpc; extern StorageObject id_ex_rs; extern StorageObject id_ex_rt; extern StorageObject id_ex_imm; extern StorageObject id_ex_uimm; extern StorageObject id_ex_shamt; extern StorageObject id_ex_ir; /* Execute */ extern StorageObject ex_4; extern StorageObject ex_16; extern BusALU alu; extern Injector syscall_ret; extern Bus ex_rt_bus; extern Bus ex_ir_bus; /* Execute/Memory */ extern StorageObject ex_mem_rt; extern StorageObject ex_mem_ir; /* Memory */ extern Memory dmem; extern Bus mem_ir_bus; extern Bus mem_aluout_bus; /* Memory/Writeback */ extern StorageObject mem_wb_lmd; extern StorageObject mem_wb_aluout; extern StorageObject mem_wb_ir; /* Constants */ static const unsigned int WORD_SIZE = 32; // MIPS word size #ifdef mips static const unsigned int MEM_SIZE = 128*1024; // 128K Memory Space static const unsigned int STACK_SIZE = 8*1024; // 8K Stack Space #else static const unsigned int MEM_SIZE = 1024*1024; // 1MB Memory Space static const unsigned int STACK_SIZE = 64*1024; // 64K Stack Space #endif /***************************************** * AD-MIPS ISA OPCODES AND FUNCTION-CODES* *****************************************/ // R-type opcode is the same for *EVERY* instruction static const unsigned int R_ = 0x00; /* * ALU INSTRUCTIONS */ // R-TYPE instructions // 'F_' = Function-code for the specified instruction. static const unsigned int R_F_SLL = 0x00; static const unsigned int R_F_SRL = 0x02; static const unsigned int R_F_SRA = 0x03; static const unsigned int R_F_SLLV = 0x04; static const unsigned int R_F_SRLV = 0x06; static const unsigned int R_F_SRAV = 0x07; //static const unsigned int R_F_ADD = 0x20; //OVERFLOW TRAPPED not implemented static const unsigned int R_F_ADDU = 0x21; //static const unsigned int R_F_SUB = 0x22; //OVERFLOW TRAPPED not implemented static const unsigned int R_F_SUBU = 0x23; static const unsigned int R_F_AND = 0x24; static const unsigned int R_F_OR = 0x25; static const unsigned int R_F_XOR = 0x26; static const unsigned int R_F_NOR = 0x27; static const unsigned int R_F_SLT = 0x2A; static const unsigned int R_F_SLTU = 0x2B; // I-TYPE instructions // 'O_' = Opcode for the specified instruction. //static const unsigned int I_O_ADDI = 0x08; //OVERFLOW TRAPPED not implemented static const unsigned int I_O_ADDIU = 0x09; static const unsigned int I_O_SLTI = 0x0A; static const unsigned int I_O_SLTIU = 0x0B; static const unsigned int I_O_ANDI = 0x0C; static const unsigned int I_O_ORI = 0x0D; static const unsigned int I_O_XORI = 0x0E; /* * DATA TRANSFER INSTRUCTIONS */ // I-type instructions static const unsigned int I_O_LUI = 0x0F; static const unsigned int I_O_LB = 0x20; static const unsigned int I_O_LH = 0x21; static const unsigned int I_O_LWL = 0x22; static const unsigned int I_O_LW = 0x23; static const unsigned int I_O_LBU = 0x24; static const unsigned int I_O_LHU = 0x25; static const unsigned int I_O_LWR = 0x26; static const unsigned int I_O_SB = 0x28; static const unsigned int I_O_SH = 0x29; static const unsigned int I_O_SWL = 0x2A; static const unsigned int I_O_SW = 0x2B; static const unsigned int I_O_SWR = 0x2E; static const unsigned int I_O_LWC0 = 48; static const unsigned int I_O_SWC0 = 56; static const unsigned int I_O_LWC1 = 49; static const unsigned int I_O_SWC1 = 57; /* * CONTROL FLOW (Branch) INSTRUCTIONS */ // I-type instruction function-codes static const unsigned int I_F_BGEZ = 0x01; static const unsigned int I_F_BGEZAL = 0x11; //static const unsigned int I_F_BLTZAL = 0x10; //LINK instrux not implemented! static const unsigned int I_F_BLTZ = 0x00; static const unsigned int I_F_BLEZ = 0x00; static const unsigned int I_F_BGTZ = 0x00; //static const unsigned int I_F_BLEZAL = 0x00; //LINK instrux not implemented! // I-type instruction opcodes static const unsigned int I_O_COM_BRA = 0x01; // Common to BGEZ, BGEZAL, BLTZ, BLTZAL static const unsigned int I_O_BGEZ = 0x01; //static const unsigned int I_O_BGEZAL = 0x01; //LINK instrux not implemented! //static const unsigned int I_O_BLTZAL = 0x01; //LINK instrux not implemented! static const unsigned int I_O_BLTZ = 0x01; static const unsigned int I_O_BEQ = 0x04; static const unsigned int I_O_BNE = 0x05; static const unsigned int I_O_BLEZ = 0x06; static const unsigned int I_O_BGTZ = 0x07; //static const unsigned int I_BLEZAL = 0x16; //LINK instrux not implemented! /* * CONTROL FLOW (Jump) INSTRUCTIONS */ // I-type instruction opcodes static const unsigned int J_O_J = 0x02; static const unsigned int J_O_JAL = 0x03; // I-type instruction function-codes static const unsigned int R_F_JR = 0x08; static const unsigned int R_F_JALR = 0x09; /* * SYSCALL INSTRUCTIONS */ static const unsigned int R_F_SYSCALL = 0x0c; /* * Registers */ static const int ZERO = 0; static const int V0 = 2; static const int A0 = 4; static const int A1 = 5; static const int A2 = 6; static const int RA = 31; #endif