openFPGALoader/src/efinixHexParser.cpp

32 lines
681 B
C++
Raw Normal View History

2021-06-26 15:24:07 +02:00
// SPDX-License-Identifier: Apache-2.0
2020-10-31 08:46:53 +01:00
/*
* Copyright (C) 2020 Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
*/
#include <sstream>
2020-10-31 08:46:53 +01:00
#include <stdexcept>
#include "configBitstreamParser.hpp"
#include "display.hpp"
#include "efinixHexParser.hpp"
using namespace std;
EfinixHexParser::EfinixHexParser(const string &filename):
2020-10-31 08:46:53 +01:00
ConfigBitstreamParser(filename, ConfigBitstreamParser::ASCII_MODE,
false)
2020-10-31 08:46:53 +01:00
{}
int EfinixHexParser::parse()
{
string buffer;
istringstream lineStream(_raw_data);
2020-10-31 08:46:53 +01:00
while (std::getline(lineStream, buffer, '\n')) {
2023-08-08 15:54:27 +02:00
_bit_data.push_back(std::stol(buffer, nullptr, 16));
2020-10-31 08:46:53 +01:00
}
_bit_length = _bit_data.size() * 8;
return EXIT_SUCCESS;
}