00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _ARCHC_H
00029 #define _ARCHC_H
00030
00031 #include <systemc.h>
00032 #include <list>
00033 #include <iomanip>
00034 #include <iostream>
00035 #include <fstream>
00036 #include "ac_parms.H"
00037 #include "ac_log.H"
00038
00039 using std::list;
00040 using std::setw;
00041
00042 extern int ac_stop_flag;
00043 extern unsigned int ac_heap_ptr;
00044
00045 extern int ac_argc;
00046 extern char **ac_argv;
00047
00048
00049 void ac_init_opt( int ac, char* av[]);
00050 void ac_init_app( int ac, char* av[]);
00051
00052
00053
00055
00057
00058 #define ac_err stderr
00059 #define IDENT 0
00060
00061
00062 #define AC_ERROR( msg ) cerr<< "ArchC ERROR: " << msg <<'\n'
00063 #define AC_SAY( msg ) cerr<< "ArchC: " << msg <<'\n'
00064
00065 #define AC_RUN_ERROR( str, args...) \
00066 fprintf(stderr, "ArchC Runtime error (ac_pc=%#x; ac_instr_counter=%llu): " str, (int) ac_pc, ac_instr_counter, args);
00067 #define AC_RUN_MSG( str ) fprintf(stderr, str);
00068
00069 #define ac_trace( f ) extern ofstream trace_file; extern bool ac_do_trace; ac_do_trace = 1; trace_file.open( f )
00070 #define ac_close_trace trace_file.close
00071
00072 #ifndef AC_VERIFY
00073
00074 #define ac_init( processor) \
00075 extern char* appfilename; \
00076 ac_init_opt( ac, av);\
00077 ac_init_app( ac, av);\
00078 extern ac_storage* IMem; \
00079 IMem = processor.IM; \
00080 processor.APP_MEM->load(appfilename); \
00081 processor.time_step = clk.period().to_double() / (sc_get_default_time_unit()).to_double(); \
00082 processor.set_args(ac_argc, ac_argv);\
00083
00084 #else
00085
00086
00087 #define ac_init( processor) \
00088 extern char* appfilename; \
00089 ac_init_opt( ac, av);\
00090 ac_init_app( ac, av);\
00091 extern ac_storage* IMem; \
00092 IMem = processor.IM; \
00093 processor.APP_MEM->load(appfilename); \
00094 processor.time_step = clk.period().to_double() / (sc_get_default_time_unit()).to_double(); \
00095 processor.set_args(ac_argc, ac_argv);\
00096 processor.set_queue(av[0]);\
00097
00098 #endif
00099
00100
00102
00103
00105 class ac_instr{
00106
00107 unsigned instr[AC_DEC_FIELD_NUMBER];
00108
00109 public:
00110
00112 ac_instr( unsigned *im_instr ){
00113
00114 if( im_instr )
00115 for( int j =0; j<AC_DEC_FIELD_NUMBER; j++) {
00116 instr[j] = im_instr[j];
00117 }
00118 else
00119 for( int j =0; j<AC_DEC_FIELD_NUMBER; j++) {
00120 instr[j] = 0;
00121 }
00122 }
00123
00125 ac_instr(){
00126
00127 for( int j =0; j<AC_DEC_FIELD_NUMBER; j++) {
00128 instr[j] = 0;
00129 }
00130 }
00131
00133 ac_instr & operator= ( const ac_instr &i){
00134
00135 for( int j =0; j<AC_DEC_FIELD_NUMBER; j++){
00136 instr[j] = i.instr[j];
00137 }
00138 return *this;
00139 }
00140
00141 friend bool operator== (const ac_instr & i1,
00142 const ac_instr & i2){
00143 bool flag = true;
00144
00145 for( int j =0; j<AC_DEC_FIELD_NUMBER; j++) {
00146 flag = flag && (i1.instr[j] == i2.instr[j]);
00147 }
00148
00149 return flag;
00150 }
00151
00152
00153 void print (ostream & os) const{
00154 for( int j =0; j<AC_DEC_FIELD_NUMBER; j++)
00155 os << instr[j]<< ",";
00156 os << endl;
00157 }
00158
00159 friend ostream& operator<< (ostream &os,
00160 const ac_instr &i){
00161 i.print(os);
00162 return os;
00163 }
00164
00166 operator bool () const {return true;}
00167
00169 unsigned get( const int i ){ return instr[i]; }
00170
00172 void put(const unsigned data, const unsigned i ){ instr[i] = data; }
00173 };
00174
00175
00176 struct cache_item {
00177
00178 bool valid;
00179 ac_instr* instr_p;
00180 };
00181
00182
00183 void InitStat();
00184 void PrintStat();
00185
00186
00187 void ac_start(int argc=0, char *argv[]=0);
00188
00189
00190 void ac_stop(int status=0);
00191
00192
00193 #endif //_ARCHC_H