00001 00023 #ifndef _genericPktGen_h_INC 00024 #define _genericPktGen_h_INC 00025 00026 #include <gsl/gsl_rng.h> 00027 #include <gsl/gsl_randist.h> 00028 #include "genericInterfaceNB.h" 00029 #include "../../../util/genericData.h" 00030 #include "../interfaces/processor.h" 00031 #include "../../data_types/impl/highLevelPacket.h" 00032 #include "../../../memctrl/request.h" 00033 #include "../../../memctrl/mshr.h" 00034 #include "../../../util/mc_constants.h" 00035 #include <math.h> 00036 #include <fstream> 00037 #include <deque> 00038 #include <string.h> 00039 #include <sys/time.h> 00040 00041 #define GSL_RNG_SEED 12345 00042 00043 #define DEFAULT_RAN_MAX_TIME 100 00044 #define MAX_ADDRESS 3 00045 00046 extern uint no_nodes; 00047 extern uint no_mcs; 00048 extern uint mean_irt; 00049 extern uint pkt_payload_length; 00050 extern message_class terminal_msg_class; 00051 extern bool do_request_reply_network; 00052 00053 00054 class GenericPktGen : public Processor 00055 { 00056 00057 private: 00058 uint vcs; 00059 uint no_nodes; 00060 ullint max_sim_time; 00061 uint irt; 00062 string out_filename; 00063 string trace_name; 00064 uint no_outstanding; 00065 ofstream out_file; 00066 ifstream *trace_filename; 00067 unsigned int last_vc; 00068 void handle_new_packet_event(IrisEvent* e); 00069 void handle_ready_event(IrisEvent* e); 00070 void handle_out_pull_event(IrisEvent* e); 00071 00072 public : 00073 GenericPktGen(); 00074 ~GenericPktGen(); 00075 /* stats variables */ 00076 unsigned int stat_packets_out; 00077 unsigned int stat_packets_in; 00078 double stat_min_pkt_latency; 00079 double stat_last_packet_out_cycle; 00080 double stat_last_packet_in_cycle; 00081 ullint stat_total_lat; 00082 ullint stat_hop_count; 00083 00084 vector< bool > ready; 00085 bool sending; 00086 ullint max_time; 00087 void setup(uint no_nodes, uint vcs, uint max_sim_time); 00088 void finish(); 00089 void process_event(IrisEvent* e); 00090 string toString() const; 00091 string print_stats() const; 00092 void set_trace_filename( string filename ); 00093 void set_no_vcs ( uint v ); 00094 void set_output_path( string outpath ); 00095 vector <uint> mc_node_ip; 00096 00097 /* for debugging.. break if not sending for too long */ 00098 ullint lastSentTime; 00099 00100 /* For statistical distrib */ 00101 const gsl_rng_type * T; 00102 gsl_rng * arate_gen; 00103 gsl_rng * dest_gen; 00104 gsl_rng * plen_gen; 00105 }; 00106 00107 00108 00109 #endif /* ----- #ifndef _genericPktGen_h_INC ----- */ 00110