forked from trabucayre/openFPGALoader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjedParser.hpp
72 lines (63 loc) · 1.94 KB
/
jedParser.hpp
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// SPDX-License-Identifier: Apache-2.0
/*
* Copyright (C) 2019 Gwenhael Goavec-Merou <[email protected]>
*/
#ifndef JEDPARSER_HPP_
#define JEDPARSER_HPP_
#include <stdint.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include "configBitstreamParser.hpp"
class JedParser: public ConfigBitstreamParser {
private:
struct jed_data {
int offset;
std::vector<std::string> data;
int len;
std::string associatedPrevNote;
};
public:
JedParser(const std::string &filename, bool verbose = false);
int parse() override;
void displayHeader() override;
size_t nb_section() { return _data_list.size();}
size_t offset_for_section(int id) {return _data_list[id].offset;}
int len_for_section(int id) {return _data_list[id].len;}
std::string get_fuselist() {return fuselist;}
int get_fuse_count() {return _fuse_count;}
std::vector<std::string> data_for_section(int id) {
return _data_list[id].data;
}
std::string noteForSection(int id) {return _data_list[id].associatedPrevNote;}
uint32_t feabits() {return _feabits;}
uint64_t featuresRow() {return _featuresRow;}
private:
std::string readline();
std::vector<std::string>readJEDLine();
void buildDataArray(const std::string &content, struct jed_data &jed);
void buildDataArray(const std::vector<std::string> &content,
struct jed_data &jed);
void parseEField(const std::vector<std::string> &content);
void parseLField(const std::vector<std::string> &content);
std::vector<struct jed_data> _data_list;
int _fuse_count;
int _pin_count;
int _max_vect_test;
uint64_t _featuresRow;
uint16_t _feabits;
bool _has_feabits;
uint16_t _checksum;
uint16_t _compute_checksum;
uint32_t _userCode;
uint8_t _security_settings;
uint8_t _default_fuse_state;
std::istringstream _ss;
int _default_test_condition;
int _arch_code;
int _pinout_code;
std::string fuselist;
};
#endif // JEDPARSER_HPP_