lattice: check matching idcode between bitstream and FPGA

This commit is contained in:
Gwenhael Goavec-Merou 2021-11-20 17:01:40 +01:00
parent ab43af7f0e
commit 2e2e325a9b
1 changed files with 14 additions and 2 deletions

View File

@ -271,9 +271,14 @@ bool Lattice::program_mem()
if (_verbose)
_bit.displayHeader();
/* read ID Code 0xE0 */
/* read ID Code 0xE0 and compare to bitstream */
uint32_t bit_idcode = std::stoul(_bit.getHeaderVal("idcode").c_str(), NULL, 16);
uint32_t idcode = idCode();
if (idcode != bit_idcode)
throw std::runtime_error("mismatch between target's idcode and bitstream idcode");
if (_verbose) {
printf("IDCode : %x\n", idCode());
printf("IDCode : %x\n", idcode);
displayReadReg(readStatusReg());
}
@ -521,6 +526,13 @@ bool Lattice::program_extFlash(unsigned int offset)
if (_verbose)
_bit->displayHeader();
if (_file_extension == "bit") {
uint32_t bit_idcode = std::stoul(_bit->getHeaderVal("idcode").c_str(), NULL, 16);
uint32_t idcode = idCode();
if (idcode != bit_idcode)
throw std::runtime_error("mismatch between target's idcode and bitstream idcode");
}
/*IR = 0h3A, DR=0hFE,0h68. Enter RUNTESTIDLE.
* thank @GregDavill
* https://twitter.com/GregDavill/status/1251786406441086977