mirror of
https://github.com/trabucayre/openFPGALoader.git
synced 2026-08-30 18:02:38 +02:00
32 lines
830 B
C++
32 lines
830 B
C++
// SPDX-License-Identifier: Apache-2.0
|
|||
|
|
/*
|
||
|
|
* Copyright (C) 2021 Gwenhael Goavec-Merou <[email protected]>
|
||
|
|
* Copyright (C) 2021 Cologne Chip AG <[email protected]>
|
||
|
|
*/
|
||
|
|
|
||
|
|
#include <sstream>
|
||
|
|
|
||
|
|
#include "colognechipCfgParser.hpp"
|
||
|
|
|
||
CologneChipCfgParser::CologneChipCfgParser(const std::string &filename):
|
|||
ConfigBitstreamParser(filename, ConfigBitstreamParser::ASCII_MODE,
|
|||
false)
|
|||
{}
|
|||
|
|
|
||
|
|
int CologneChipCfgParser::parse()
|
||
|
|
{
|
||
|
|
std::string buffer;
|
||
|
|
std::istringstream lineStream(_raw_data);
|
||
|
|
|
||
|
|
while (std::getline(lineStream, buffer, '\n')) {
|
||
|
|
std::string val = buffer.substr(0, buffer.find("//"));
|
||
|
|
val.erase(std::remove_if(val.begin(), val.end(), ::isspace), val.end());
|
||
|
|
if (val != "") {
|
||
_bit_data.push_back(std::stol(val, nullptr, 16));
|
|||
}
|
|||
|
|
}
|
||
|
|
_bit_length = _bit_data.size() * 8;
|
||
|
|
|
||
|
|
return EXIT_SUCCESS;
|
||
|
|
}
|