File: TileConfig.hpp

package info (click to toggle)
prjtrellis 1.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 83,000 kB
  • sloc: cpp: 20,813; python: 16,246; sh: 375; makefile: 262; asm: 80; ansic: 58
file content (91 lines) | stat: -rw-r--r-- 2,428 bytes parent folder | download
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#ifndef LIBTRELLIS_TILECONFIG_HPP
#define LIBTRELLIS_TILECONFIG_HPP

#include <string>
#include <cstdint>
#include <vector>
#include <map>
#include <iostream>

using namespace std;

namespace Trellis {
// This represents configuration at FASM level, in terms of routing arcs and non-routing configuration settings -
// either words or enums.

// A connection in a tile
struct ConfigArc {
    string sink;
    string source;
    inline bool operator==(const ConfigArc &other) const {
        return other.source == source && other.sink == sink;
    }
};

ostream &operator<<(ostream &out, const ConfigArc &arc);

istream &operator>>(istream &in, ConfigArc &arc);

// A configuration setting in a tile that takes one or more bits (such as LUT init)
struct ConfigWord {
    string name;
    vector<bool> value;
    inline bool operator==(const ConfigWord &other) const {
        return other.name == name && other.value == value;
    }
};

ostream &operator<<(ostream &out, const ConfigWord &cw);

istream &operator>>(istream &in, ConfigWord &cw);

// A configuration setting in a tile that takes an enumeration value (such as IO type)
struct ConfigEnum {
    string name;
    string value;
    inline bool operator==(const ConfigEnum &other) const {
        return other.name == name && other.value == value;
    }
};

ostream &operator<<(ostream &out, const ConfigEnum &ce);

istream &operator>>(istream &in, ConfigEnum &ce);

// An unknown bit, specified by position only
struct ConfigUnknown {
    int frame, bit;
    inline bool operator==(const ConfigUnknown &other) const {
        return other.frame == frame && other.bit == bit;
    }
};

ostream &operator<<(ostream &out, const ConfigUnknown &tc);

istream &operator>>(istream &in, ConfigUnknown &ce);

struct TileConfig {
    vector<ConfigArc> carcs;
    vector<ConfigWord> cwords;
    vector<ConfigEnum> cenums;
    vector<ConfigUnknown> cunknowns;
    int total_known_bits = 0;

    void add_arc(const string &sink, const string &source);
    void add_word(const string &name, const vector<bool> &value);
    void add_enum(const string &name, const string &value);
    void add_unknown(int frame, int bit);

    string to_string() const;
    static TileConfig from_string(const string &str);

    bool empty() const;
};

ostream &operator<<(ostream &out, const TileConfig &tc);

istream &operator>>(istream &in, TileConfig &ce);

}

#endif //LIBTRELLIS_TILECONFIG_HPP