00001
00002 #include <iostream>
00003 #include <fstream>
00004 #include <sstream>
00005 #include <log4cpp/BasicConfigurator.hh>
00006 #include <log4cpp/Category.hh>
00007 #include <log4cpp/CategoryStream.hh>
00008
00009
00010 #include "pit_driver.h"
00011 #include "pit_def.h"
00012 #include "pit_comm.h"
00013 #include "pit_driver_optinBoard.h"
00014 #include "pit_driver_opticalLink.h"
00015 #include "pit_configuration.h"
00016 #include "pit_comm_exception.h"
00017
00018
00019 using namespace std;
00020
00021 pit_driver::pit_driver(){
00022
00023 logDriver = &(log4cpp::Category::getInstance("pitLog.driver"));
00024 logDriver->info("*************************** Starting DRIVER layer *****************************");
00025
00026
00027 commFEE = new pit_comm();
00028
00029
00030
00031
00032 try {
00033 readFpgaFirmwareVersion();
00034 logDriver->log(log4cpp::Priority::INFO, "pit_driver::pit_driver() - Firmware version read,hardware accessible." );
00035
00036 }
00037 catch(...) {
00038 logDriver->error("pit_driver::pit_driver() - Hardware access problem, check the hardware ");
00039 }
00040
00041 procFPGA = new pit_driver_procFpga( commFEE);
00042
00043 for(unsigned int i = 0; i < NUMBER_OPTIN; i++) {
00044 optinBoard[i] = new pit_driver_optinBoard(i, commFEE);
00045 }
00046
00047
00048
00049
00050
00051 cmdReturn = -1;
00052 commandGenericCmd = new DimCommand(GENERIC_CMD_NAME, "C");
00053
00054 serviceCmdAnswer= new DimService( GENERIC_CMD_SERVICE, cmdReturn);
00055 serviceCmdStatus= new DimService(GENERIC_CMD_STATUS_SERVICE, "NO_COMMAND");
00056
00057
00058 }
00059
00060
00061 pit_driver::~pit_driver(void){
00062 unsigned int i;
00063
00064
00065
00066 for(i = 0; i < NUMBER_OPTIN; i++) {
00067 delete optinBoard[i];
00068 }
00069 logDriver->info("(pit_driver::~pit_driver()) optinBoard instances deleted");
00070
00071
00072 delete commFEE;
00073 logDriver->info("(pit_driver::~pit_driver()) communication ojbject instance deleted");
00074
00075
00076 delete commandGenericCmd;
00077 delete serviceCmdAnswer;
00078 delete serviceCmdStatus;
00079 logDriver->info("(pit_driver::~pit_driver()) General DIM commands and services deleted");
00080
00081 logDriver->info("(pit_driver::~pit_driver()) PIT DRIVER down ***************************");
00082
00083 }
00084
00085 unsigned int pit_driver::readFpgaFirmwareVersion(){
00086
00087 fpgaFirmwareVersion = commFEE->PITGetVersion();
00088 return fpgaFirmwareVersion;
00089
00090 }
00091
00092
00093
00094 pit_driver_optinBoard & pit_driver::getOptinBoard(unsigned int optinBoardNumber){
00095 if (optinBoardNumber >= NUMBER_OPTIN){
00096 logDriver->crit("(getOptinBoard):out of range, optinBoardNumber %d", optinBoardNumber);
00097
00098 throw out_of_range("Exception from pit_driver::getOptinBoard, optinBoardNumber out of range");
00099 }
00100
00101 else return *optinBoard[optinBoardNumber];
00102 }
00103
00104
00105 int pit_driver::refresh(){
00106
00107 logDriver->info("refreshing the status of the driver");
00108
00109
00110 this->statusSIULink = commFEE->PITCheckCommStatus();
00111
00112 for (int optin = 0 ; optin< NUMBER_OPTIN ; optin ++){
00113 this->getOptinBoard(optin).refresh();
00114 }
00115
00116 return 0;
00117 }
00118
00119
00120
00121
00122 int pit_driver::executeCommand(const char *inStr ){
00123
00124 string command;
00125 cmdReturn=0;
00126
00127 try{
00128
00129
00130 stringstream inputStream(inStr);
00131
00132
00133 inputStream>> command;
00134
00135
00136 serviceCmdStatus->updateService(CMD_STATUS_EXECUTING);
00137
00138
00139 if (command == CMD_REFRESH_GLOBAL_STATUS){
00140 this->refresh();
00141 }
00142 else if (command==CMD_READ_WORD){
00143
00144
00145
00146 UInt32 address,dataIn;
00147 inputStream>> hex >> address;
00148
00149 commFEE->PITReadBlock( address,1 ,&dataIn );
00150 cmdReturn = (int) dataIn;
00151 logDriver->log(log4cpp::Priority::DEBUG,"(pit_driver::executeCommand()): Address read 0x%x, value 0x%x", address, cmdReturn);
00152 }
00153 else if (command==CMD_WRITE_WORD){
00154 UInt32 address, dataOut;
00155 inputStream >>hex >>address>> dataOut;
00156
00157 commFEE->PITWriteBlock(address,1 ,&dataOut);
00158 logDriver->log(log4cpp::Priority::DEBUG,"(pit_driver::executeCommand()): Address write 0x%x, value 0x%x", address, dataOut);
00159
00160 }
00161
00162 else if (command == CMD_CHECK_BOARD_PLUGGED){
00163 int boardNumber;
00164 inputStream>>dec >> boardNumber;
00165 pit_driver_optinBoard optinBoard = this->getOptinBoard(boardNumber);
00166 cmdReturn = optinBoard.IsBoardPlugged();
00167 }
00168 else if (command == CMD_LOAD_REQUIRED_CHANNELS_FILE){
00169 string filename;
00170 inputStream>> filename;
00171
00172 pit_configuration &conf = pit_configuration::getInstance();
00173 conf.openRequiredChannelsFile(filename.c_str());
00174
00175 this->refresh();
00176 }
00177 else if (command == CMD_RESET_SIU){
00178
00179 this->commFEE->PITrorcReset();
00180 }
00181
00182 else if (command == CMD_MEMORY_ACCESS_TEST ){
00183 unsigned int blockLength, initialAddress, finalAddres, repetitions, addressIncrement;
00184
00185 inputStream>>dec >> blockLength>>hex >>initialAddress>>hex >>finalAddres>> dec >>addressIncrement >> dec >> repetitions ;
00186
00187 cmdReturn = this->pitMemoryAccessTest(blockLength, initialAddress, finalAddres, repetitions, addressIncrement);
00188 }
00189
00190 else if (command == CMD_PROC_START_COUNTER){
00191 this->procFPGA->startCounter();
00192
00193 }
00194 else if(command ==CMD_PROC_STOP_COUNTER ){
00195 this->procFPGA->stopCounter();
00196 }
00197 else if (command == CMD_WRITE_PROC_CMD_REG){
00198 UInt32 value;
00199 inputStream >>hex >>value;
00200 this->procFPGA->writeCmdReg(value);
00201 }
00202 else if (command == CMD_READ_PROC_CMD_REG){
00203 cmdReturn = this->procFPGA->readCmdReg();
00204 }
00205 else if (command == CMD_READ_PROC_STATUS){
00206 int channel;
00207 inputStream >> channel;
00208 cmdReturn=this->procFPGA->readStatusRegister(channel);
00209 }
00210 else if (command == CMD_READ_PROC_SETTINGS_REGISTER){
00211 int channel;
00212 inputStream >> channel;
00213 cmdReturn=this->procFPGA->readSettingRegister( channel);
00214 }
00215 else if (command == CMD_WRITE_PROC_SETTINGS_REGISTER){
00216 int channel;
00217 UInt32 value;
00218 inputStream >> channel>> hex>>value;
00219 this->procFPGA->writeSettingRegister( channel, value);
00220
00221 }
00222 else if (command == CMD_READ_PROC_COUNTER){
00223 int channel;
00224 inputStream >> channel;
00225 cmdReturn=this->procFPGA->readCounter( channel);
00226 }
00227 else if (command == CMD_SET_PROC_TIMER_ENABLE){
00228 bool value;
00229 inputStream >> value;
00230 this->procFPGA->setTimerEnable( value);
00231 }
00232 else if (command==CDM_READ_PROC_TIMER_PERIOD){
00233
00234 cmdReturn = this->procFPGA->readTimerPeriod();
00235 }
00236 else if (command == CMD_WRITE_PROC_TIMER_PERIOD){
00237 UInt32 value;
00238 inputStream>>hex>>value;
00239 this->procFPGA->writeTimerPeriod(value);
00240
00241 }
00242 else if(command == CMD_READ_PROC_GEN_COUNTER){
00243 int counter, group;
00244 inputStream >>group>>counter;
00245 cmdReturn=this->procFPGA->readCounterInGroup(group, counter);
00246 }
00247 else if (command == CMD_READ_PROC_TIME_STAMP){
00248 int optin, timeStamp;
00249 inputStream>>optin>>timeStamp;
00250 cmdReturn=this->procFPGA->readTimeStamp(optin,timeStamp);
00251 }
00252 else if (command == CMD_READ_PROC_SIGNATURE){
00253 int signatureIndex;
00254 inputStream>> signatureIndex;
00255 cmdReturn=this->procFPGA->readSignature(signatureIndex);
00256 }
00257 else if (command == CMD_WRITE_PROC_SIGNATURE){
00258 int signatureIndex;
00259 UInt32 value;
00260 inputStream>> signatureIndex>>hex>> value;
00261 this->procFPGA->writeSignature(signatureIndex, value);
00262
00263 }
00264 else if (command == CMD_WRITE_PROC_TRIGGER_MODE){
00265 unsigned int output;
00266 string mode;
00267
00268 inputStream>> output>> mode;
00269
00270 this->procFPGA->writeTriggerMode(output, mode);
00271 }
00272 else if (command == CMD_READ_PROC_TRIGGER_MODE){
00273 unsigned int output;
00274 inputStream>> output;
00275
00276 cmdReturn = this->procFPGA->readTriggerMode(output);
00277 }
00278
00279
00280 else if (command == CMD_REFRESH_OPTIN_STATUS){
00281 pit_driver_optinBoard & optinBoard = this->getOptinBoardFromStream(inputStream);
00282 optinBoard.refresh();
00283 }
00284
00285 else if (command == CMD_READ_TIME_STAMP){
00286 pit_driver_optinBoard & optinBoard = this->getOptinBoardFromStream(inputStream);
00287 unsigned int timeStampNumber;
00288 inputStream>>timeStampNumber;
00289 cmdReturn =optinBoard.readTimeStamp(timeStampNumber);
00290 }
00291 else if (command == CMD_READ_MAX_FASTOR_COUNTS ){
00292 pit_driver_optinBoard & optinBoard = this->getOptinBoardFromStream(inputStream);
00293 unsigned int chip, layer;
00294 inputStream>>layer>> chip;
00295 cmdReturn=optinBoard.readMaxFastorCounts( layer, chip);
00296
00297 }
00298 else if (command == CMD_READ_MIN_FASTOR_COUNTS ){
00299 pit_driver_optinBoard & optinBoard = this->getOptinBoardFromStream(inputStream);
00300 unsigned int chip, layer;
00301 inputStream>> layer>> chip;
00302 cmdReturn=optinBoard.readMinFastorCounts(layer, chip);
00303
00304 }
00305 else if (command == CMD_WRITE_MAX_FASTOR_COUNTS ){
00306 pit_driver_optinBoard & optinBoard = this->getOptinBoardFromStream(inputStream);
00307 unsigned int chip, layer, value;
00308 inputStream>> layer>> chip>>value;
00309 cmdReturn=optinBoard.writeMaxFastorCounts(layer, chip, value);
00310
00311 }
00312 else if (command == CMD_WRITE_MIN_FASTOR_COUNTS){
00313 pit_driver_optinBoard & optinBoard = this->getOptinBoardFromStream(inputStream);
00314 unsigned int chip, layer, value;
00315 inputStream>> layer>> chip>>value;
00316 cmdReturn=optinBoard.writeMinFastorCounts(layer, chip, value);
00317
00318 }
00319
00320 else if (command == CMD_REFRESH_LINK_STATUS){
00321 pit_driver_opticalLink &opticalLink=getLinkFromStream(inputStream);
00322 opticalLink.refreshLinkStatus();
00323
00324 }
00325
00326 else if (command == CMD_READ_FO_MASK){
00327 pit_driver_opticalLink &opticalLink=getLinkFromStream(inputStream);
00328 cmdReturn = opticalLink.readFoMask();
00329
00330 }
00331 else if (command == CMD_READ_LINK_DELAY){
00332 pit_driver_opticalLink &opticalLink=getLinkFromStream(inputStream);
00333 cmdReturn= opticalLink.readLinkDelay();
00334 }
00335 else if (command == CMD_WRITE_LINK_DELAY) {
00336 int p_linkDelay = 0;
00337
00338 pit_driver_opticalLink &opticalLink=getLinkFromStream(inputStream);
00339
00340 inputStream >> p_linkDelay;
00341 cmdReturn = opticalLink.writeLinkDelay(p_linkDelay);
00342 }
00343 else if (command == CMD_READ_LINK_PHASE){
00344 pit_driver_opticalLink &opticalLink=getLinkFromStream(inputStream);
00345 cmdReturn= opticalLink.readLinkPhase();
00346 }
00347 else if (command == CMD_READ_ERROR_COUNTER){
00348 pit_driver_opticalLink &opticalLink=getLinkFromStream(inputStream);
00349 cmdReturn = opticalLink.readErrorCounter();
00350
00351 }
00352
00353
00354
00355
00356 else if (command == CMD_READ_UDF_ENABLE){
00357 pit_driver_opticalLink &opticalLink=getLinkFromStream(inputStream);
00358 cmdReturn = opticalLink.readEnUdFastors();
00359 }
00360 else if (command == CMD_WRITE_UDF_ENABLE){
00361
00362 bool udfEnable;
00363 pit_driver_opticalLink &opticalLink=getLinkFromStream(inputStream);
00364
00365 inputStream>> udfEnable;
00366 cmdReturn = opticalLink.writeEnUdFastors(udfEnable);
00367 }
00368
00369 else if (command == CMD_READ_FO_COUNTER){
00370 pit_driver_foChannel & foChannel=getFoChannelFromStream(inputStream);
00371 cmdReturn =(int)foChannel.readCounter();
00372 }
00373
00374 else if (command == CMD_ASSIGN_CHIP_FOMASK){
00375 pit_driver_foChannel & foChannel=getFoChannelFromStream(inputStream);
00376 bool chipMaskValue = false;
00377 inputStream >> chipMaskValue;
00378 foChannel.setMask(chipMaskValue);
00379 }
00380 else if (command == CMD_CLEAR_CHIP_FOMASK){
00381 pit_driver_foChannel & foChannel=getFoChannelFromStream(inputStream);
00382 foChannel.setMask(false);
00383 }
00384
00385 else if (command == CMD_FORCE_FO_CHANNEL){
00386
00387 pit_driver_foChannel & foChannel=getFoChannelFromStream(inputStream);
00388 bool force;
00389 inputStream >>force;
00390 foChannel.forceHigh(force);
00391 }
00392 else if (command == CMD_RELEASE_FO_CHANNEL){
00393 pit_driver_foChannel & foChannel=getFoChannelFromStream(inputStream);
00394 foChannel.forceHigh(false);
00395 }
00396
00397
00398 else{
00399 serviceCmdStatus->updateService(CMD_STATUS_FAILED);
00400 logDriver->error("(pit_driver::executeCommand()): unrecognized command %s", command.c_str());
00401 return -1;
00402 }
00403
00404 serviceCmdAnswer->updateService();
00405 serviceCmdStatus->updateService(CMD_STATUS_FINISHED);
00406 logDriver->info("(pit_driver::executeCommand()): executed command %s, last command answer: 0x%x", command.c_str(),cmdReturn);
00407 }
00408 catch(pit_comm_exception &commError){
00409 serviceCmdStatus->updateService(CMD_STATUS_FAILED);
00410 logDriver->error("(pit_driver::executeCommand()): execution failed for command %s. pit_comm_exception: %s", command.c_str(), commError.what());
00411
00412
00413 commFEE->PITCheckCommStatus();
00414
00415 return -1;
00416 }
00417
00418 catch(exception &commError){
00419 serviceCmdStatus->updateService(CMD_STATUS_FAILED);
00420 logDriver->error("(pit_driver::executeCommand()): execution failed for command %s, default exception: %s", command.c_str(), commError.what());
00421
00422
00423
00424
00425 return -1;
00426 }
00427
00428 catch(string & errorString){
00429 serviceCmdStatus->updateService(CMD_STATUS_FAILED);
00430 logDriver->error("(pit_driver::executeCommand()): execution failed for command %s, string exception: %s", command.c_str(), errorString.c_str());
00431 return -1;
00432 }
00433
00434 catch(...){
00435 serviceCmdStatus->updateService(CMD_STATUS_FAILED);
00436 logDriver->crit("(pit_driver::executeCommand()): execution failed for command %s, unknown exception", command.c_str());
00437
00438
00439
00440
00441 return -1;
00442 }
00443
00444 return 0;
00445 }
00446
00447 int pit_driver::checkDimCommands(){
00448
00449
00450 if (commandGenericCmd->getNext()){
00451
00452 char *cmd= commandGenericCmd->getString();
00453 this->executeCommand(cmd);
00454 }
00455
00456
00457
00458 return 0;
00459 }
00460
00461 pit_driver_foChannel & pit_driver::getFoChannelFromStream(stringstream & str){
00462
00463
00464
00465 int sector, channel, foNumber;
00466 char side ;
00467 unsigned int boardNumber, linkNumber;
00468
00469 str>> dec>> sector>>side>>channel>>foNumber;
00470
00471 pit_configuration &conf = pit_configuration::getInstance();
00472
00473 boardNumber= conf.getBoardNumber(side,sector,channel);
00474 linkNumber= conf.getLinkNumber(side,sector,channel);
00475
00476 pit_driver_opticalLink & opticalLink = this->getOptinBoard(boardNumber).getOpticalLink(linkNumber);
00477
00478 return opticalLink.getFoChannel(foNumber);
00479
00480
00481 }
00482
00483 pit_driver_opticalLink & pit_driver::getLinkFromStream(stringstream & str){
00484
00485
00486
00487 int sector, channel;
00488 char side ;
00489 unsigned int boardNumber, linkNumber;
00490
00491 str>> dec>> sector>>side>>channel;
00492
00493
00494 pit_configuration &conf = pit_configuration::getInstance();
00495
00496 boardNumber= conf.getBoardNumber(side,sector,channel);
00497 linkNumber= conf.getLinkNumber(side,sector,channel);
00498
00499
00500 return this->getOptinBoard(boardNumber).getOpticalLink(linkNumber);
00501
00502
00503 }
00504
00505 pit_driver_optinBoard & pit_driver::getOptinBoardFromStream(stringstream & str){
00506
00507
00508
00509 int sector, channel;
00510 char side ;
00511
00512 str>> dec>> sector>>side>>channel;
00513 unsigned int boardNumber, linkNumber;
00514
00515
00516 pit_configuration &conf = pit_configuration::getInstance();
00517
00518 boardNumber= conf.getBoardNumber(side,sector,channel);
00519 linkNumber = conf.getLinkNumber(side,sector,channel);
00520
00521 return this->getOptinBoard(boardNumber);
00522
00523
00524 }
00525
00526
00527 unsigned int pit_driver::pitMemoryAccessTest(unsigned int blockLength,
00528 unsigned int initialAddress,
00529 unsigned int finalAddress,
00530 unsigned int repetitions,
00531 unsigned int addressIncrement){
00532
00533 unsigned int bitErrors = 0;
00534 unsigned int readingErrors = 0;
00535 unsigned int writingErrors = 0;
00536 unsigned int undeterminedErrors = 0;
00537
00538
00539
00541 unsigned int bitErrorPositionHistogram[32] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
00542
00544 unsigned int* wordErrorPositionHistogram = new unsigned int[blockLength];
00545
00546 for (unsigned int i= 0; i< blockLength; i ++) {
00547 wordErrorPositionHistogram[i] = 0;
00548 }
00549
00550
00551
00552 if (addressIncrement == 0) addressIncrement=blockLength;
00553
00554
00555 UInt32 *writeData = new UInt32 [blockLength];
00556 UInt32 *readData = new UInt32 [blockLength];
00557 UInt32 tempData = 0;
00558
00559 float numberOfWords=0;
00560
00561
00562 this->logDriver->info("(pitMemoryAccessTest) starting memory access test: block length %d, initial address 0x%x, final address 0x%x, repetitions %d, address increment 0x%x", blockLength, initialAddress, finalAddress, repetitions, addressIncrement);
00563
00564
00565 try{
00566
00567 UInt32 testLength;
00568
00569
00570
00571
00572 for (unsigned int n = 0 ; n < repetitions ; n ++){
00573
00574 for (UInt28 address = initialAddress ; address <= finalAddress; address += addressIncrement){
00575
00576
00577 if ( (address + blockLength) <= finalAddress + 1) testLength = blockLength;
00578
00579 else testLength = finalAddress-address + 1;
00580
00581 numberOfWords += 1.0*testLength;
00582
00583 initializeWithRandom( writeData , testLength);
00584
00585
00586 commFEE->PITWriteBlock(address, testLength, writeData);
00587 commFEE->PITReadBlock(address, testLength, readData);
00588
00589 for(unsigned int index = 0 ; index < testLength ; index ++){
00590
00591 if (writeData[index] != readData[index]){
00592
00593
00594
00595 wordErrorPositionHistogram[index]++;
00596
00597
00598 bitErrors += chekBitErrorsNumber(writeData[index], readData[index], bitErrorPositionHistogram);
00599
00600
00601 commFEE->PITReadBlock(address+index, 1, &tempData);
00602
00603
00604 stringstream logMsg("");
00605 logMsg << "(pitMemoryAccessTest) word mismatch in block write/read operation, " <<
00606 "offset: " << index << ", " <<
00607 "written: " << hex << writeData[index] << ", " <<
00608 "read: " << hex << readData[index] << ", " <<
00609 "re-read: " << hex << tempData << ". ";
00610
00611 if (tempData == readData[index]) {
00612 logMsg << " Writing phase error." << endl;
00613 writingErrors++;
00614 }
00615 else if (tempData == writeData[index]) {
00616 logMsg << " Reading phase error." << endl;
00617 readingErrors++;
00618 }
00619 else {
00620 logMsg << " Undetermined error." << endl;
00621 undeterminedErrors++;
00622 }
00623
00624 this->logDriver->warn("%s", logMsg.str().c_str());
00625 }
00626 }
00627 }
00628 }
00629
00630
00631
00632
00633 this->logDriver->infoStream() << "(pitMemoryAccessTest)" <<
00634 "finished memory access test. " <<
00635 "Total number of words written/read = " << numberOfWords <<
00636 ", reading errors = " << readingErrors <<
00637 ", writing errors = " << writingErrors <<
00638 ", undetermined errors = " << undeterminedErrors <<
00639 ", total amount of bits written/read = " << 2*32*numberOfWords <<
00640 ", bit errors = " << bitErrors << "\n";
00641
00642
00643
00644
00645 stringstream wordErrorPositionLog;
00646 wordErrorPositionLog << "********* Histogram of word error position\n";
00647 wordErrorPositionLog << "| Word position\t| Errors\n";
00648 for (unsigned int i =0; i < blockLength ; i++) {
00649 wordErrorPositionLog << "| " << i << "\t| " << wordErrorPositionHistogram[i] <<"\t|\n";
00650 }
00651 wordErrorPositionLog << "********************************************";
00652 this->logDriver->info("%s", wordErrorPositionLog.str().c_str());
00653
00654
00655 stringstream histogramOutput;
00656 histogramOutput << endl << "********* Histogram of bit errors versus position" << endl << "| Position\t| Errors\t|" << endl;
00657 for (int i =0; i<32; i++) {
00658 histogramOutput << "| " << i << "\t| " << bitErrorPositionHistogram[i] <<"\t|" << endl;
00659 }
00660 this->logDriver->info("(pitMemoryAccessTest)\n%s", histogramOutput.str().c_str());
00661
00662 }
00663
00664 catch(pit_comm_exception &commError){
00665 delete [] writeData;
00666 delete [] readData;
00667 delete [] wordErrorPositionHistogram;
00668
00669 this->logDriver->error("(pitMemoryAccessTest) comunication problems encountered during the test, test not finalized");
00670 this->logDriver->warn("(pitMemoryAccessTest) test not completed");
00671
00672 throw (commError);
00673 }
00674 catch(exception & error){
00675 delete [] writeData;
00676 delete [] readData;
00677 delete [] wordErrorPositionHistogram;
00678
00679 this->logDriver->error("(pitMemoryAccessTest) exception encountered : %s", error.what());
00680 this->logDriver->warn("(pitMemoryAccessTest) test not completed");
00681 throw (error);
00682 }
00683 catch(...){
00684 delete [] writeData;
00685 delete [] readData;
00686 delete [] wordErrorPositionHistogram;
00687
00688 runtime_error error("(pitMemoryAccessTest) unknown problems encountered during the test, test not finalized");
00689
00690 this->logDriver->error("(pitMemoryAccessTest) unknow problems encountered during the test, test not finalized");
00691 this->logDriver->warn("test not finalized");
00692 throw(error);
00693 }
00694
00695 delete [] writeData;
00696 delete [] readData;
00697 delete [] wordErrorPositionHistogram;
00698
00699 return bitErrors;
00700
00701
00702 }
00703
00704
00705 void pit_driver::initializeWithRandom(UInt32 *dataBlock, unsigned int size){
00706
00707 srand(time (0) );
00708
00709 for (unsigned int address = 0 ; address < size ; address ++){
00710 dataBlock[address] = (unsigned int)rand();
00711 }
00712 }
00713
00714
00715
00716 UInt32 pit_driver::chekBitErrorsNumber( UInt32 data1, UInt32 data2, unsigned int* bitErrorPositionHistogram) {
00717
00718 unsigned int bitErrors = 0;
00719
00720
00721
00722 for (int bit = 0 ; bit < 32 ; bit++){
00723 if ( ((data1>> bit) & 0x1) != ((data2>> bit) & 0x1) ) {
00724 bitErrors ++;
00725 bitErrorPositionHistogram[bit]++;
00726 }
00727
00728 }
00729
00730 return bitErrors;
00731 }