/**************************************************************/ /* fpgaCfgTest.cpp Date: 2019/09/09 */ /* */ /* Copyright (c) 2019 GIS. All rights reserved. */ /* */ /**************************************************************/ #include #include "fpgaCfg5Test.h" // -------------------------------------------------- // FPGA configuration tests // -------------------------------------------------- int fpgaCfg5Test::fpga_cfg_test (CHmbFpgaCfg5Auto* pFpgaCfg, int node, int testGroup) { int error = 0; uint32_t status; bool foundError = false; VPrint("Starting FPGA configuration tests\n"); // =================================== // CPU mode // =================================== // Clear receiver clearRcvr(); // Set CPU mode pFpgaCfg->pControl->SetCpuMode(1); // Start FPGA configuration pFpgaCfg->pStart->SetStart(1); // Send data for (int blk = 0; blk < 3; blk++) { for (int idx = 0; idx < 32; idx++) { pFpgaCfg->pTxWord->SetTxWord(idx + 100 + blk*32); } // After two blocks written, check ok-to-write status is clear and wait for it to be processed // (3/4 of the total processing time) if (blk == 1) { if (pFpgaCfg->pStatus->GetOkToWrite()) { VPrint("**ERROR %03d : HMB FPGA OK to write status failure\n", testGroup + 0); error |= 1; } // Wait until it's okay to write the last block while(!pFpgaCfg->pStatus->GetOkToWrite()) { usleepSim(10); } } } // Wait for the interface to go idle while(pFpgaCfg->pStatus->GetBusy()) { usleepSim(10); } // Check the values in the CFG FPGA receiver foundError = false; for (int idx = 0; idx < 80; idx++) { status = readRxData(idx); if (status != idx+100) { if (!foundError) { VPrint("**ERROR %03d : HMB FPGA configuration failure from index %d (got %d exp %d)\n", testGroup + 1, idx, status, idx+100); foundError = true; } error |= 1; } } // =================================== // DMA test // =================================== // Clear receiver clearRcvr(); // Set DMA mode pFpgaCfg->pControl->SetCpuMode(0); // Fill the TB memory with a pattern for (int idx = 0; idx < 80; idx++) { uint32_t addr = memBaseAddr + idx*4; directWriteMem (addr, idx+200, false); } // Set start address for cfg data pFpgaCfg->pCfgAddr->SetCfgAddr(memBaseAddr); // Start FPGA configuration pFpgaCfg->pStart->SetStart(1); // Wait for the interface to go idle while(pFpgaCfg->pStatus->GetBusy()) { usleepSim(10); } // Check the values in the CFG FPGA receiver foundError = false; for (int idx = 0; idx < 80; idx++) { status = readRxData(idx); if (status != idx+200) { if (!foundError) { VPrint("**ERROR %03d : HMB FPGA configuration failure from index %d (got %d exp %d)\n",testGroup + 2, idx, status, idx+200); foundError = true; } error |= 1; } } return error; }