00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00026
00027 #ifndef _FLIT_INC_
00028 #define _FLIT_INC_
00029
00030 #include "systemc.h"
00031 #include "../config/constants.h"
00032 #include <sys/stat.h>
00033 #include <sys/types.h>
00034 #include <string>
00035
00037 using namespace std;
00038
00042 struct source_hdr {
00043 UI route;
00044 };
00045
00051 struct rt_dst_hdr {
00052 UI dst;
00053 };
00054
00058 struct AntNet_hdr {
00059 UI dst;
00060 UI route;
00061 };
00062
00068 union routing_hdr {
00069 source_hdr sourcehdr;
00070 rt_dst_hdr dsthdr;
00071 AntNet_hdr AntNethdr;
00072 };
00073
00079 struct payload_hdr {
00080 int cmd;
00081 int data_int;
00082 const char *data_string;
00083 };
00084
00088 struct flit_head {
00089 routing_type rtalgo;
00090 routing_hdr rthdr;
00091 payload_hdr datahdr;
00092 };
00093
00097 struct flit_data {
00098 int cmd;
00099 int data_int;
00100 const char *data_string;
00101 };
00102
00106 union flit_hdr {
00107 flit_head header;
00108 flit_data payload;
00109 };
00110
00114 struct ant_hdr {
00115 public:
00116 ant_type anttype;
00117 routing_type rtalgo;
00118 routing_hdr rthdr;
00119
00120 };
00121
00125 struct noc_hdr {
00126 public:
00127 UI pktid;
00128 UI flitid;
00129 flit_type flittype;
00130 flit_hdr flithdr;
00131 };
00132
00136 union pkt_hdr {
00137 ant_hdr anthdr;
00138 noc_hdr nochdr;
00139 };
00140
00144 struct ECC {
00145 };
00146
00150 struct sim_hdr {
00151 sc_time gtime;
00152 sc_time atime;
00153 sc_time ctime;
00154 ULL gtimestamp;
00155 ULL atimestamp;
00156 ULL ICtimestamp;
00157 ULL num_waits;
00158 ULL num_sw;
00159 };
00160
00166 struct flit {
00167 pkt_type pkttype;
00168 sim_hdr simdata;
00169 pkt_hdr pkthdr;
00170 int vcid;
00171 UI src;
00172
00173
00174 inline bool operator == (const flit& temp) const {
00175 if(temp.pkttype != pkttype || temp.simdata.gtime != simdata.gtime || temp.simdata.atime != simdata.atime || temp.simdata.ctime != simdata.ctime || temp.src != src)
00176 return false;
00177 switch(temp.pkttype) {
00178 case ANT: break;
00179 case NOC:
00180 if(temp.pkthdr.nochdr.pktid != pkthdr.nochdr.pktid || temp.pkthdr.nochdr.flitid != pkthdr.nochdr.flitid || temp.pkthdr.nochdr.flittype != pkthdr.nochdr.flittype)
00181 return false;
00182 break;
00183 }
00184 return true;
00185 }
00186 };
00187
00188
00189 inline ostream&
00190 operator << ( ostream& os, const flit& temp ) {
00191 if(temp.pkttype == ANT)
00192 os<<"ANT PACKET";
00193 else if(temp.pkttype == NOC) {
00194 os<<"NOC PACKET, ";
00195 switch(temp.pkthdr.nochdr.flittype) {
00196 case HEAD: os<<"HEAD flit, "; break;
00197 case DATA: os<<"DATA flit, "; break;
00198 case TAIL: os<<"TAIL flit, "; break;
00199 case HDT: os<<"HDT flit, "; break;
00200 }
00201 os<<"src: "<<temp.src<<" pktid: "<<temp.pkthdr.nochdr.pktid<<" flitid: "<<temp.pkthdr.nochdr.flitid;
00202 }
00203 os<<endl;
00204 return os;
00205 }
00206
00207
00208 inline ostream&
00209 operator << ( ostream& os, const sim_hdr& temp ) {
00210 os<<"gtimestamp: "<<temp.gtimestamp<<" gtime: "<<temp.gtime;
00211 os<<"\natimestamp: "<<temp.atimestamp<<" atime: "<<temp.atime<<endl;
00212 return os;
00213 }
00214
00215
00216 inline void sc_trace( sc_trace_file*& tf, const flit& a, const std::string& name) {
00217
00218 sc_trace(tf, a.src, name+".src");
00219 sc_trace(tf, a.pkthdr.nochdr.pktid, name+".pktid");
00220 sc_trace(tf, a.pkthdr.nochdr.flitid, name+".flitid");
00221
00222 }
00223
00224 #endif