📄 common.h
字号:
/*************************************************************************** common.h - types de donn閑s du PowerPC ------------------- begin : Tue Feb 27 2001 copyright : (C) 2001 Universite Paris Sud and CEA author : Gilles Mouchard email : gilles.mouchard@cea.fr, mouchard@lri.fr ***************************************************************************/#ifndef __COMMON_H__#define __COMMON_H__#include <systemc.h>#include <ppcemul.h>#include <parms.h>#include <ostream.h>#include <string.h>#include <trace.h>typedef int UnitIdent;const UnitIdent IntegerUnitIdent = 0;const UnitIdent LoadStoreUnitIdent = 1;const UnitIdent BranchUnitIdent = 2;const UnitIdent SystemRegisterUnitIdent = 3;const UnitIdent FloatingPointUnitIdent = 4;typedef SInt8 tag_t;extern void sc_trace(sc_trace_file *tf, const UInt64& v, const sc_string& NAME);extern void sc_trace(sc_trace_file *tf, const SInt64& v, const sc_string& NAME);inline void WriteHex(ostream& os, UInt64 value){ static char hexChar[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; os << "0x"; os << hexChar[(value >> 60) & 15]; os << hexChar[(value >> 56) & 15]; os << hexChar[(value >> 52) & 15]; os << hexChar[(value >> 48) & 15]; os << hexChar[(value >> 44) & 15]; os << hexChar[(value >> 40) & 15]; os << hexChar[(value >> 36) & 15]; os << hexChar[(value >> 32) & 15]; os << hexChar[(value >> 28) & 15]; os << hexChar[(value >> 24) & 15]; os << hexChar[(value >> 20) & 15]; os << hexChar[(value >> 16) & 15]; os << hexChar[(value >> 12) & 15]; os << hexChar[(value >> 8) & 15]; os << hexChar[(value >> 4) & 15]; os << hexChar[value & 15];}inline void WriteHex(ostream& os, UInt32 value){ static char hexChar[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; os << "0x"; os << hexChar[(value >> 28) & 15]; os << hexChar[(value >> 24) & 15]; os << hexChar[(value >> 20) & 15]; os << hexChar[(value >> 16) & 15]; os << hexChar[(value >> 12) & 15]; os << hexChar[(value >> 8) & 15]; os << hexChar[(value >> 4) & 15]; os << hexChar[value & 15];}inline void WriteHex(ostream& os, UInt8 value){ static char hexChar[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; os << "0x"; os << hexChar[(value >> 4) & 15]; os << hexChar[value & 15];}/* Representations des registres (GPR, FP, CR, LR, CTR) pour appliquer Tomasulo's */struct Register64RSEntry{ tag_t tag; /* numero du registre de renommage */ BOOL valid; /* true ssi data est valide */ UInt64 data; /* valeur du registre */ Register64RSEntry() { tag = -1; valid = false; data = 0; }};struct IntegerRegisterRSEntry{ tag_t tag; /* numero du registre de renommage */ BOOL valid; /* true ssi data est valide */ UInt32 data; /* valeur du registre */ IntegerRegisterRSEntry() { tag = -1; valid = false; data = 0; }};struct ConditionRegisterRSEntry{ tag_t tag; /* numero du registre de renommage */ BOOL valid; /* true ssi condition est valide */ UInt8 crfield; /* CR[BI] */ ConditionRegisterRSEntry() { tag = -1; valid = false; crfield = 0; }};struct LinkRegisterRSEntry{ tag_t tag; /* numero du registre de renommage */ BOOL valid; /* true ssi data est valide */ UInt32 data; /* valeur du registre */ LinkRegisterRSEntry() { tag = -1; valid = false; data = 0; }};struct CountRegisterRSEntry{ tag_t tag; /* numero du registre de renommage */ BOOL valid; /* true ssi data est valide */ UInt32 data; /* valeur du registre */ CountRegisterRSEntry() { tag = -1; valid = false; data = 0; }};struct FloatingPointRegisterRSEntry{ tag_t tag; /* numero du registre de renommage */ BOOL valid; /* true ssi data est valide */ UInt64 data; /* valeur du registre */ FloatingPointRegisterRSEntry() { tag = -1; valid = false; data = 0; }};/* Operandes pour une instruction enti鑢e */struct IntegerOperands{ UInt32 data[2]; // Peut contenir un immediat IntegerOperands() { data[0] = data[1] = 0; } int operator == (const IntegerOperands& iop) const { return 0; } friend ostream& operator << (ostream& os, const IntegerOperands& iop) { os << "IntegerOperands("; WriteHex(os, iop.data[0]); os << ", "; WriteHex(os, iop.data[1]); os << ")"; return os; } operator bool () const { return true; }};extern void sc_trace(sc_trace_file *tf, const IntegerOperands& iop, const sc_string& NAME);/* Tags (registres de renommage) pour une instruction enti鑢e */struct IntegerTags{ tag_t tag; /* tag de l'instruction (numero dans le ROB) */ tag_t resultTag; /* tag du registre destination */ tag_t CRTag; /* tag du champ du registre CR */ int operator == (const IntegerTags& it) const { return 0; } friend ostream& operator << (ostream& os, const IntegerTags& it) { os << "IntegerTags(tag = " << (int) it.tag << ", resultTag = " << (int) it.resultTag << ", CRTag = " << (int) it.CRTag << ")" << endl; return os; } operator bool () const { return true; }};extern void sc_trace(sc_trace_file *tf, const IntegerTags& it, const sc_string& NAME);/* Operandes pour une instruction loadStore */struct LoadStoreOperands{ //UInt32 data[3]; // Peut contenir un immediat UInt64 data0; // entier 32 bits/flottant 32 bits/flottant 64 bits UInt32 data1; // entier 32 bits UInt32 data2; // entier 32 bits LoadStoreOperands() {// data[0] = data[1] = data[2] = 0; data0 = data1 = data2 = 0; } int operator == (const LoadStoreOperands& ldop) const { return 0; } friend ostream& operator << (ostream& os, const LoadStoreOperands& ldop) { os << "LoadStoreOperands("; WriteHex(os, ldop.data0); os << ", "; WriteHex(os, ldop.data1); os << ", "; WriteHex(os, ldop.data2); os << ")"; return os; } operator bool () const { return true; }};extern void sc_trace(sc_trace_file *tf, const LoadStoreOperands& lsop, const sc_string& NAME);/* Tags (registres de renommage) pour une instruction loadStore */struct LoadStoreTags{ tag_t tag; /* tag de l'instruction (numero dans le ROB) */ tag_t resultTags[2]; /* tag du registres destinations et du registre recevant l'adresse effective (pour un update) */ int operator == (const LoadStoreTags& ld) const { return 0; } friend ostream& operator << (ostream& os, const LoadStoreTags& ld) { os << "LoadStoreTags(tag = " << (int) ld.tag << ", resultTags = " << (int) ld.resultTags[0] << ", " << (int) ld.resultTags[1] << ")" << endl; return os; } operator bool () const { return true; }};extern void sc_trace(sc_trace_file *tf, const LoadStoreTags& lst, const sc_string& NAME);/* Op閞andes pour une instruction Branch */struct BranchOperands{ UInt32 immed; UInt32 pc; UInt8 crfield; UInt32 lr; UInt32 ctr; bool branchPredictedTaken; BranchOperands() { immed = pc = crfield = lr = ctr = 0; branchPredictedTaken = false; } int operator == (const BranchOperands& bro) const { return 0; } friend ostream& operator << (ostream& os, const BranchOperands& bro) { os << "BranchOperands(immed = "; WriteHex(os, bro.immed); os << ", pc = "; WriteHex(os, bro.pc); os << ", crfield = " << (int) bro.crfield; os << ", lr = "; WriteHex(os, bro.lr); os << ", ctr = "; WriteHex(os, bro.ctr); os << ", branchPredictedTaken = " << bro.branchPredictedTaken; os << ")"; return os; } operator bool () const { return true; }};extern void sc_trace(sc_trace_file *tf, const BranchOperands& brop, const sc_string& NAME);struct BranchTags{ tag_t tag; /* tag de l'instruction (numero dans le ROB), -1 s'il est n'est pas dans le ROB */ tag_t LRTag; /* tag du registre LR */ tag_t CTRTag; /* tag du registre CTR */ int operator == (const BranchTags& brt) const { return 0; } friend ostream& operator << (ostream& os, const BranchTags& brt) { os << "BranchTags(tag = " << (int) brt.tag << ", LRTag = " << (int) brt.LRTag << ", " << (int) brt.LRTag << ", CTRTag = " << (int) brt.CTRTag << ")"; return os; } operator bool () const { return true; }};extern void sc_trace(sc_trace_file *tf, const BranchTags& brt, const sc_string& NAME);struct SystemRegisterTags{ tag_t tag; /* tag de l'instruction (numero dans le ROB) */ tag_t resultTag; /* tag du registre g閚閞al */ tag_t CRTag; /* tag du registre CR */ tag_t LRTag; /* tag du registre LR */ tag_t CTRTag; /* tag du registre CTR */ int operator == (const SystemRegisterTags& srt) const { return 0; } friend ostream& operator << (ostream& os, const SystemRegisterTags& srt) { os << "SystemRegisterTags(tag = " << (int) srt.tag << ", resultTag = " << (int) srt.resultTag << ", CRTag = " << (int) srt.CRTag << ", LRTag = " << (int) srt.LRTag << ", CTRTag = " << (int) srt.CTRTag << ")"; return os; } operator bool () const { return true; }};extern void sc_trace(sc_trace_file *tf, const SystemRegisterTags& srt, const sc_string& NAME);struct FloatingPointOperands{ UInt64 data[3]; int operator == (const FloatingPointOperands& fpo) const { return 0; } double GetDouble(int i) { return *(double *) &data[i]; } float GetSingle(int i) { return *(float *) &data[i]; } friend ostream& operator << (ostream& os, const FloatingPointOperands& fpo) { os << "FloatingPointOperands("; WriteHex(os, fpo.data[0]); os << ", "; WriteHex(os, fpo.data[1]); os << ", "; WriteHex(os, fpo.data[2]); os << ")"; return os; } operator bool () const { return true; }};extern void sc_trace(sc_trace_file *tf, const FloatingPointOperands& fpop, const sc_string& NAME);struct FloatingPointTags{ tag_t tag; /* tag de l'instruction (numero dans le ROB) */ tag_t resultTag; /* tag du registre general */ tag_t CRTag; /* tag du registre CR */ int operator == (const FloatingPointTags& fpt) const { return 0; } friend ostream& operator << (ostream& os, const FloatingPointTags& fpt) { os << "FloatingPointTags(tag = " << (int) fpt.tag << ", resultTag = " << (int) fpt.resultTag << ", CRTag = " << (int) fpt.CRTag << ")"; return os; } operator bool () const { return true; }};extern void sc_trace(sc_trace_file *tf, const FloatingPointTags& fpt, const sc_string& NAME);/* structure pour 閏hanger des donn閑s entre l'unit
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -