aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorMiodrag Milanovic <mmicko@gmail.com>2019-06-01 15:52:32 +0200
committerMiodrag Milanovic <mmicko@gmail.com>2019-06-01 15:52:32 +0200
commitd5d8213871d8cb68b2e4ef9b3557879c80ff5b51 (patch)
tree03b1c06d747986941187e2b5d72cc2f93ac2702b /common
parentccbe2dd18d12d9d201afd5499e9e70ed8d2539de (diff)
downloadnextpnr-d5d8213871d8cb68b2e4ef9b3557879c80ff5b51.tar.gz
nextpnr-d5d8213871d8cb68b2e4ef9b3557879c80ff5b51.tar.bz2
nextpnr-d5d8213871d8cb68b2e4ef9b3557879c80ff5b51.zip
Added support for attributes/properties types
Diffstat (limited to 'common')
-rw-r--r--common/nextpnr.h39
-rw-r--r--common/pybindings.cc2
2 files changed, 38 insertions, 3 deletions
diff --git a/common/nextpnr.h b/common/nextpnr.h
index fc49300e..02201463 100644
--- a/common/nextpnr.h
+++ b/common/nextpnr.h
@@ -286,6 +286,41 @@ struct PipMap
PlaceStrength strength = STRENGTH_NONE;
};
+struct Property
+{
+ bool is_string;
+
+ std::string str;
+ int num;
+
+ std::string::iterator begin() { return str.begin(); }
+ std::string::iterator end() { return str.end(); }
+
+ bool isString() const { return is_string; }
+
+ void setNumber(int val) { is_string = false; num = val; str = std::to_string(val); }
+ void setString(std::string val) { is_string = true; str = val; }
+
+ const char * c_str() const { return str.c_str(); }
+ operator std::string () const { return str; }
+
+ bool operator==(const std::string other) const
+ {
+ return str == other;
+ }
+ bool operator!=(const std::string other) const
+ {
+ return str != other;
+ }
+
+ Property& operator=(std::string other)
+ {
+ is_string = true;
+ str = other;
+ return *this;
+ }
+};
+
struct ClockConstraint;
struct NetInfo : ArchNetInfo
@@ -295,7 +330,7 @@ struct NetInfo : ArchNetInfo
PortRef driver;
std::vector<PortRef> users;
- std::unordered_map<IdString, std::string> attrs;
+ std::unordered_map<IdString, Property> attrs;
// wire -> uphill_pip
std::unordered_map<WireId, PipMap> wires;
@@ -328,7 +363,7 @@ struct CellInfo : ArchCellInfo
int32_t udata;
std::unordered_map<IdString, PortInfo> ports;
- std::unordered_map<IdString, std::string> attrs, params;
+ std::unordered_map<IdString, Property> attrs, params;
BelId bel;
PlaceStrength belStrength = STRENGTH_NONE;
diff --git a/common/pybindings.cc b/common/pybindings.cc
index 60f87e27..52dd9717 100644
--- a/common/pybindings.cc
+++ b/common/pybindings.cc
@@ -122,7 +122,7 @@ BOOST_PYTHON_MODULE(MODULE_NAME)
.value("PORT_INOUT", PORT_INOUT)
.export_values();
- typedef std::unordered_map<IdString, std::string> AttrMap;
+ typedef std::unordered_map<IdString, Property> AttrMap;
typedef std::unordered_map<IdString, PortInfo> PortMap;
typedef std::unordered_map<IdString, IdString> PinMap;
typedef std::unordered_map<IdString, std::unique_ptr<Region>> RegionMap;