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
00029
00035
00036 #ifndef _AC_STORAGE_H
00037 #define _AC_STORAGE_H
00038
00039 #include <stdio.h>
00040 #include <stdlib.h>
00041 #include <systemc.h>
00042 #include <list>
00043 #include <fstream>
00044 #include "archc.H"
00045 #include "ac_parms.H"
00046
00047 using std::string;
00048 using std::istringstream;
00049
00051
00052
00053 class ac_storage {
00054
00055 protected:
00056 char *Data;
00057 char *name;
00058 unsigned size;
00059
00060 #ifdef AC_UPDATE_LOG
00061 log_list changes;
00062 fstream update_file;
00063 #endif
00064
00065
00066 #ifdef AC_DELAY
00067 log_list delays;
00068 #endif
00069
00070 public:
00071
00073 virtual ac_word read( unsigned address );
00074
00076 virtual unsigned char read_byte( unsigned address );
00077
00079 virtual ac_Hword read_half( unsigned address );
00080
00081
00083 virtual void write( unsigned address, ac_word datum );
00084
00086 virtual void write_byte( unsigned address, unsigned char datum );
00087
00089 virtual void write_half( unsigned address, ac_Hword datum );
00090
00091 #ifdef AC_DELAY
00092
00093 virtual void write( unsigned address, ac_word datum, unsigned time );
00094
00096 virtual void write_byte( unsigned address, unsigned char datum, unsigned time );
00097
00099 virtual void write_half( unsigned address, ac_Hword datum, unsigned time );
00100 #endif
00101
00102 #ifdef AC_UPDATE_LOG
00103
00105 void reset_log();
00106
00108 int change_dump( ostream& output);
00109
00110
00112 void change_save( );
00113 #endif
00114
00116 ac_storage( char *n, unsigned s ){
00117
00118
00119 Data = (char*) new char[ s ];
00120 name = n;
00121 size = s;
00122
00123 #ifdef AC_UPDATE_LOG
00124
00125 char filename[strlen(n)+ 16];
00126
00127 sprintf(filename, "ac_storage.%s.log",n);
00128 update_file.open(filename, ios::out|ios::binary);
00129 #endif
00130
00131 }
00132
00134
00135 ac_storage( char *n ):name(n){};
00136
00138 virtual ~ac_storage(){
00139
00140 #ifdef AC_UPDATE_LOG
00141 update_file.close();
00142 #endif
00143
00144
00145 delete[] Data;
00146 }
00147
00149 ac_storage& operator =(ac_storage& src ){
00150
00151 Data = src.Data;
00152 name = src.name;
00153 size = src.size;
00154
00155 #ifdef AC_UPDATE_LOG
00156 changes = src.changes;
00157 #endif
00158 return *this;
00159 }
00160
00162 void initialize( char* n, unsigned s ){
00163 name = n;
00164 Data = (char*) new char[ s ];
00165 size = s;
00166 }
00167
00169 char* get_name( ){
00170 return name;
00171 }
00172
00174 unsigned get_size( ){
00175 return size;
00176 }
00177
00178 #ifdef AC_UPDATE_LOG
00179
00180 log_list* get_changes( ){
00181 return &changes;
00182 }
00183 #endif
00184
00186 void load( char* file );
00187
00189 void load_array( const unsigned char* d, const unsigned s );
00190
00191
00192 #ifdef AC_DELAY
00193
00195 virtual void commit_delays( double time );
00196
00197 #endif
00198
00199 };
00200
00201
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215 #endif