2021-06-26 15:24:07 +02:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
2019-12-20 08:47:38 +01:00
|
|
|
/*
|
2022-11-26 12:06:24 +01:00
|
|
|
* Copyright (C) 2019-2022 Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
|
2019-12-20 08:47:38 +01:00
|
|
|
*/
|
2022-11-26 12:06:24 +01:00
|
|
|
#ifndef SRC_LATTICEBITPARSER_HPP_
|
|
|
|
|
#define SRC_LATTICEBITPARSER_HPP_
|
2019-12-20 08:47:38 +01:00
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <fstream>
|
|
|
|
|
#include <map>
|
|
|
|
|
#include <string>
|
2022-11-26 12:06:24 +01:00
|
|
|
#include <vector>
|
2019-12-20 08:47:38 +01:00
|
|
|
|
|
|
|
|
#include "configBitstreamParser.hpp"
|
|
|
|
|
|
|
|
|
|
class LatticeBitParser: public ConfigBitstreamParser {
|
|
|
|
|
public:
|
2022-11-26 12:06:24 +01:00
|
|
|
LatticeBitParser(const std::string &filename, bool machxo2,
|
|
|
|
|
bool verbose = false);
|
2019-12-20 08:47:38 +01:00
|
|
|
~LatticeBitParser();
|
|
|
|
|
int parse() override;
|
|
|
|
|
|
2022-11-26 12:06:24 +01:00
|
|
|
/*!
|
|
|
|
|
* \brief return configuration data with structure similar to jedec
|
|
|
|
|
* \return configuration data
|
|
|
|
|
*/
|
|
|
|
|
std::vector<std::string> getDataArray() {return _bit_array;}
|
|
|
|
|
|
2019-12-20 08:47:38 +01:00
|
|
|
private:
|
|
|
|
|
int parseHeader();
|
2022-11-26 12:06:24 +01:00
|
|
|
bool parseCfgData();
|
2021-02-24 06:36:48 +01:00
|
|
|
size_t _endHeader;
|
2022-11-26 12:06:24 +01:00
|
|
|
bool _is_machXO2;
|
|
|
|
|
/* data storage for machXO2 */
|
|
|
|
|
std::vector<std::string> _bit_array;
|
2019-12-20 08:47:38 +01:00
|
|
|
};
|
|
|
|
|
|
2022-11-26 12:06:24 +01:00
|
|
|
#endif // SRC_LATTICEBITPARSER_HPP_
|