00001
00002
00003 #include "ac_verify.H"
00004
00005
00012 void ac_verify::add_log( log_list *pdevchg, unsigned address, unsigned datum, double time ) {
00013
00014 log_list::iterator itor;
00015
00016
00017 if( pdevchg->size() ) {
00018
00019
00020
00021
00022
00023 itor = pdevchg->begin();
00024 while( (itor != pdevchg->end()) &&
00025 !(itor->addr == address && itor->time == time) ){
00026 itor++;
00027 }
00028
00029 if(itor->addr == address && itor->time == time){
00030 itor->value = datum;
00031 }
00032 else{
00033 pdevchg->push_back( change_log(address, datum , time));
00034 }
00035 }
00036
00037 else{
00038 pdevchg->push_back( change_log(address, datum , time));
00039 }
00040 }
00041
00042
00043
00052 void ac_verify::match_logs( ac_storage *pbhvdevice,
00053 log_list *pdevchange,
00054 double time ) {
00055
00056 log_list *pbhvchange;
00057 log_list::iterator bhvitor;
00058 log_list::iterator devitor;
00059 bool flag = false;
00060
00061 pbhvchange = pbhvdevice->get_changes();
00062 bhvitor = pbhvchange->begin();
00063
00064 if( pbhvchange->size() && pdevchange->size())
00065
00066 while( bhvitor != pbhvchange->end() ){
00067
00068 devitor = pdevchange->begin();
00069 flag = false;
00070
00071 while( (bhvitor->time == devitor->time) && (devitor != pdevchange->end())){
00072
00073 if( bhvitor->addr == devitor->addr &&
00074 bhvitor->value == devitor->value ){
00075
00076 bhvitor = pbhvchange->erase( bhvitor );
00077 devitor = pdevchange->erase( devitor );
00078 flag = true;
00079 break;
00080 }
00081 devitor++;
00082 }
00083 if(!flag)
00084 bhvitor++;
00085
00086 }
00087 }
00088
00096 void ac_verify::check_final( ac_storage *pbhvdevice,
00097 log_list *pdevchange){
00098
00099 log_list *pbhvchange;
00100 log_list::iterator bhvitor;
00101 log_list::iterator devitor;
00102 bool flag;
00103
00104 pbhvchange = pbhvdevice->get_changes();
00105
00106
00107 if( pbhvchange->size() && pdevchange->size()){
00108
00109
00110 pbhvchange->sort();
00111 pdevchange->sort();
00112
00113 bhvitor = pbhvchange->begin();
00114 devitor = pdevchange->begin();
00115
00116
00117 while( (bhvitor != pbhvchange->end()) && (devitor != pdevchange->end()) ){
00118
00119 flag = false;
00120 if( bhvitor->addr == devitor->addr &&
00121 bhvitor->value == devitor->value ){
00122
00123 bhvitor = pbhvchange->erase( bhvitor );
00124 devitor = pdevchange->erase( devitor );
00125 flag = true;
00126 }
00127 if(!flag){
00128 bhvitor++;
00129 devitor++;
00130 }
00131 }
00132 }
00133
00134 if( pbhvchange->size() || pdevchange->size()){
00135 bhvitor = pbhvchange->begin();
00136 devitor = pdevchange->begin();
00137
00138 AC_ERROR( "Verification failed for device " << pbhvdevice->get_name() << "! See logs in ac_verification.log");
00139
00140 output << "************************************************************"<<endl;
00141 output << "* ArchC Storage Based Co-Verification ERROR Log *"<<endl;
00142 output << "************************************************************"<<endl;
00143 output << endl << "The following updates are inconsistent..."<<endl<<endl;
00144
00145 output << "------------------------------------------------------------\n";
00146 output << "=> Device: "<< pbhvdevice->get_name() <<endl;
00147 output << "------------------------------------------------------------\n";
00148 output<< " Address \t\tValue \t\tTime"<<endl;
00149 output<<"Behavioral: "<<endl;
00150 while(bhvitor != pbhvchange->end()){
00151 output << "\t\t"<< *bhvitor<< endl;
00152 bhvitor++;
00153 }
00154 output << "Structural: "<<endl;
00155 while(devitor != pdevchange->end()){
00156 output << "\t\t"<< *devitor<< endl;
00157 devitor++;
00158 }
00159 output << endl << endl;
00160 }
00161
00162 }