// Test whether PCIe is functional void test32( PCIE_HANDLE hPCIe, DWORD addr ) { BOOL bPass; DWORD testVal = 0xf; DWORD readVal; WORD i = 0; for (i = 0; i < 16 ; i++ ) { printf("Testing register %d at addr %x with value %x\n", i, addr, testVal); bPass = PCIE_Write32( hPCIe, pcie_bars[0], addr, testVal); if (!bPass) { printf("test FAILED: write did not return success\n"); return; } bPass = PCIE_Read32( hPCIe, pcie_bars[0], addr, &readVal); if (!bPass) { printf("test FAILED: read did not return success\n"); return; } if (testVal == readVal) { printf("Test PASSED: expected %x, received %x\n", testVal, readVal); } else { printf("Test FAILED: expected %x, received %x\n", testVal, readVal); } testVal = testVal + 1; addr = addr + 4; } return; }
BOOL TEST_BUTTON(PCIE_HANDLE hPCIe){ BOOL bPass = TRUE; DWORD Status; bPass = PCIE_Read32(hPCIe, DEMO_PCIE_USER_BAR, DEMO_PCIE_IO_BUTTON_ADDR,&Status); if (bPass) printf("Button status mask:=%xh\r\n", Status); else printf("Failed to read button status\r\n"); return bPass; }
DWORD Fpga::request(DWORD sensorId) { std::unique_lock<std::mutex>(this->lock); // Write request BOOL pass = PCIE_Write32(pcieHandle, PCIE_BAR0, 0x00, sensorId); if (!pass) { throw std::runtime_error("PCIE write failed"); } // Receive response DWORD input; pass = PCIE_Read32(pcieHandle, PCIE_BAR0, 0x20, &input); if (!pass) { throw std::runtime_error("PCIE write failed"); } return input; }
void launchGenius(PCIE_HANDLE hPCIe){ DWORD lista[101]; imagem(hPCIe, (DWORD)0,0, 0); for( int cont = 0; cont < 100; cont++){ lista[cont] = (0x1 << (rand() % 4))^0xf; for (int j = 0; j <= cont; j++){ imagem(hPCIe, (DWORD)lista[j] ^ 0xf, (DWORD)lista[j], cont); imagem(hPCIe, (DWORD) 0, 0, cont); } for (int j = 0; j <= cont; j++){ do{ PCIE_Read32(hPCIe, PCIE_BAR0, 0x20, &lista[100]); } while (lista[100] == 0xF); imagem(hPCIe, (DWORD)lista[100] ^ 0xf, lista[100], cont); imagem(hPCIe, (DWORD)0, 0, cont); if (lista[100] != lista[j]){ imagem(hPCIe, (DWORD)0,0, -1); return ; } } } imagem(hPCIe, (DWORD)0,0, -2); }