jedParser: fix checksum for xc9500
This commit is contained in:
parent
caf7710e68
commit
db5d4e75d9
|
|
@ -87,15 +87,14 @@ void JedParser::buildDataArray(const string &content, struct jed_data &jed)
|
||||||
{
|
{
|
||||||
size_t data_len = content.size();
|
size_t data_len = content.size();
|
||||||
string tmp_buff;
|
string tmp_buff;
|
||||||
uint8_t data = 0;
|
fuselist += content;
|
||||||
for (size_t i = 0; i < content.size(); i+=8) {
|
for (size_t i = 0; i < content.size(); i+=8) {
|
||||||
data = 0;
|
uint8_t data = 0;
|
||||||
for (int ii = 0; ii < 8; ii++) {
|
for (int ii = 0; ii < 8; ii++) {
|
||||||
uint8_t val = (content[i+ii] == '1'?1:0);
|
uint8_t val = (content[i+ii] == '1'?1:0);
|
||||||
data |= val << ii;
|
data |= val << ii;
|
||||||
}
|
}
|
||||||
tmp_buff += data;
|
tmp_buff += data;
|
||||||
_compute_checksum += data;
|
|
||||||
}
|
}
|
||||||
jed.data.push_back(std::move(tmp_buff));
|
jed.data.push_back(std::move(tmp_buff));
|
||||||
jed.len += data_len;
|
jed.len += data_len;
|
||||||
|
|
@ -113,6 +112,7 @@ void JedParser::buildDataArray(const vector<string> &content,
|
||||||
for (size_t i = 0; i < content.size(); i++) {
|
for (size_t i = 0; i < content.size(); i++) {
|
||||||
uint8_t data = 0;
|
uint8_t data = 0;
|
||||||
data_len += content[i].size();
|
data_len += content[i].size();
|
||||||
|
fuselist += content[i];
|
||||||
for (size_t ii = 0; ii < content[i].size(); ii++) {
|
for (size_t ii = 0; ii < content[i].size(); ii++) {
|
||||||
uint8_t val = (content[i][ii] == '1'?1:0);
|
uint8_t val = (content[i][ii] == '1'?1:0);
|
||||||
data |= val << ii;
|
data |= val << ii;
|
||||||
|
|
@ -221,16 +221,6 @@ void JedParser::parseLField(const vector<string> &content)
|
||||||
|
|
||||||
myList.erase(myList.begin());
|
myList.erase(myList.begin());
|
||||||
|
|
||||||
/* merge all to compute checksum by 8bits */
|
|
||||||
std::stringstream imploded;
|
|
||||||
std::copy(myList.begin(), myList.end(),
|
|
||||||
std::ostream_iterator<std::string>(imploded, ""));
|
|
||||||
string t = imploded.str();
|
|
||||||
|
|
||||||
for (size_t i = 0; i < t.size(); i+=8)
|
|
||||||
_compute_checksum += reverseByte(std::stoi(t.substr(i, 8),
|
|
||||||
nullptr, 2));
|
|
||||||
|
|
||||||
buildDataArray(myList, d);
|
buildDataArray(myList, d);
|
||||||
}
|
}
|
||||||
_data_list.push_back(std::move(d));
|
_data_list.push_back(std::move(d));
|
||||||
|
|
@ -355,6 +345,10 @@ int JedParser::parse()
|
||||||
size += _data_list[area].len;
|
size += _data_list[area].len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < fuselist.size(); i+=8)
|
||||||
|
_compute_checksum += reverseByte(std::stoi(fuselist.substr(i, 8),
|
||||||
|
nullptr, 2));
|
||||||
|
|
||||||
if (_verbose)
|
if (_verbose)
|
||||||
printf("theorical checksum %x -> %x\n", _checksum, _compute_checksum);
|
printf("theorical checksum %x -> %x\n", _checksum, _compute_checksum);
|
||||||
if (_checksum != _compute_checksum) {
|
if (_checksum != _compute_checksum) {
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ class JedParser: public ConfigBitstreamParser {
|
||||||
int _default_test_condition;
|
int _default_test_condition;
|
||||||
int _arch_code;
|
int _arch_code;
|
||||||
int _pinout_code;
|
int _pinout_code;
|
||||||
|
std::string fuselist;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // JEDPARSER_HPP_
|
#endif // JEDPARSER_HPP_
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue