File: colognechipCfgParser.cpp

package info (click to toggle)
openfpgaloader 0.13.1-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 34,320 kB
  • sloc: cpp: 23,693; python: 555; makefile: 64; tcl: 62; xml: 41
file content (31 lines) | stat: -rw-r--r-- 830 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// SPDX-License-Identifier: Apache-2.0
/*
 * Copyright (C) 2021 Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
 * Copyright (C) 2021 Cologne Chip AG <support@colognechip.com>
 */

#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;
}