From a373bf1613fef57bf3e6855e9897bc6d925765b1 Mon Sep 17 00:00:00 2001 From: Gwenhael Goavec-Merou Date: Fri, 20 Mar 2020 18:55:13 +0100 Subject: [PATCH] fsparser: use map provided by configBitstreamParser instead of a lot a variable. --- src/fsparser.cpp | 50 +++++++++--------------------------------------- src/fsparser.hpp | 10 ---------- 2 files changed, 9 insertions(+), 51 deletions(-) diff --git a/src/fsparser.cpp b/src/fsparser.cpp index a4ad0c6..0d3e3f8 100644 --- a/src/fsparser.cpp +++ b/src/fsparser.cpp @@ -15,11 +15,9 @@ * along with this program. If not, see . */ -#include -#include -#include #include #include +#include #include "fsparser.hpp" #include "display.hpp" @@ -28,10 +26,7 @@ using namespace std; FsParser::FsParser(string filename, bool reverseByte, bool verbose): ConfigBitstreamParser(filename, ConfigBitstreamParser::ASCII_MODE, - verbose), _reverseByte(reverseByte), _toolVersion(), _partNumber(), - _devicePackage(), _backgroundProgramming(false), _checksum(0), - _crcCheck(false), _compress(false), _encryption(false), - _securityBit(false), _jtagAsRegularIO(false), _date() + verbose), _reverseByte(reverseByte), _checksum(0) { } FsParser::~FsParser() @@ -58,42 +53,15 @@ int FsParser::parseHeader() else v2 = buffer.substr(pos+2) + '\0'; // ':' + ' ' - if (v1 == "GOWIN Version") - _toolVersion = v2; - if (v1 == "Part Number") - _partNumber = v2; - if (v1 == "Device-package") - _devicePackage = v2; - if (v1 == "BackgroundProgramming") - _backgroundProgramming = ((v2 == "OFF")?false:true); - if (v1 == "CheckSum") - sscanf(v2.c_str(), "0x%04hx", &_checksum); - if (v1 == "CRCCheck") - _crcCheck = ((v2 == "OFF")?false:true); - if (v1 == "Compress") - _compress = ((v2 == "OFF")?false:true); - if (v1 == "Encryption") - _encryption = ((v2 == "OFF")?false:true); - if (v1 == "SecurityBit") - _securityBit = ((v2 == "OFF")?false:true); - if (v1 == "JTAGAsRegularIO") - _jtagAsRegularIO = ((v2 == "OFF")?false:true); - if (v1 == "Created Time") - _date = v2; + _hdr[v1] = v2; } + + if (_hdr.find("CheckSum") != _hdr.end()) + sscanf(_hdr["CheckSum"].c_str(), "0x%04hx", &_checksum); + if (_verbose) { - printInfo("tool version: " + _toolVersion); - printInfo("Part number: " + _partNumber); - printInfo("Device package: " + _devicePackage); - printInfo("Background programming: " + - string((_backgroundProgramming)?"ON":"OFF")); - printInfo("Checksum: " + _checksum); - printInfo("CRC check: " + string((_crcCheck)?"ON":"OFF")); - printInfo("Compression: " + string((_compress)?"ON":"OFF")); - printInfo("Encryption: " + string((_encryption)?"ON":"OFF")); - printInfo("Security bit: " + string((_securityBit)?"ON":"OFF")); - printInfo("Jtag as regular IO: " + string((_jtagAsRegularIO)?"ON":"OFF")); - printInfo("Creation date: " + _date); + for (auto &&t: _hdr) + printInfo("x" + t.first + ": " + t.second); } return ret; diff --git a/src/fsparser.hpp b/src/fsparser.hpp index 41bee08..36e8315 100644 --- a/src/fsparser.hpp +++ b/src/fsparser.hpp @@ -35,17 +35,7 @@ class FsParser: public ConfigBitstreamParser { private: int parseHeader(); bool _reverseByte; - std::string _toolVersion; - std::string _partNumber; - std::string _devicePackage; - bool _backgroundProgramming; uint16_t _checksum; - bool _crcCheck; - bool _compress; - bool _encryption; - bool _securityBit; - bool _jtagAsRegularIO; - std::string _date; }; #endif // FSPARSER_HPP_