From d5d8213871d8cb68b2e4ef9b3557879c80ff5b51 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sat, 1 Jun 2019 15:52:32 +0200 Subject: Added support for attributes/properties types --- common/nextpnr.h | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) (limited to 'common/nextpnr.h') 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 users; - std::unordered_map attrs; + std::unordered_map attrs; // wire -> uphill_pip std::unordered_map wires; @@ -328,7 +363,7 @@ struct CellInfo : ArchCellInfo int32_t udata; std::unordered_map ports; - std::unordered_map attrs, params; + std::unordered_map attrs, params; BelId bel; PlaceStrength belStrength = STRENGTH_NONE; -- cgit v1.2.3 From 1093d7e1228272ca73114bbc4415c48d6cba76ed Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 7 Jun 2019 11:48:15 +0200 Subject: WIP saving/loading attributes --- common/nextpnr.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'common/nextpnr.h') diff --git a/common/nextpnr.h b/common/nextpnr.h index 02201463..f7f135fb 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -681,6 +681,9 @@ struct BaseCtx // Workaround for lack of wrappable constructors DecalXY constructDecalXY(DecalId decal, float x, float y); + + void commonInfoToAttributes(); + void attributesToCommonInfo(); }; NEXTPNR_NAMESPACE_END -- cgit v1.2.3 From 78e6631f766194c078b6cd32d520146e6ab257a4 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 7 Jun 2019 13:49:19 +0200 Subject: Cleanup --- common/nextpnr.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'common/nextpnr.h') diff --git a/common/nextpnr.h b/common/nextpnr.h index f7f135fb..8e47dcda 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -682,8 +682,8 @@ struct BaseCtx // Workaround for lack of wrappable constructors DecalXY constructDecalXY(DecalId decal, float x, float y); - void commonInfoToAttributes(); - void attributesToCommonInfo(); + void archInfoToAttributes(); + void attributesToArchInfo(); }; NEXTPNR_NAMESPACE_END -- cgit v1.2.3 From d9b0bac248a12466cd2b62d02ec11b2e60d25019 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 7 Jun 2019 16:11:11 +0200 Subject: Save top level attrs and store current step --- common/nextpnr.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'common/nextpnr.h') diff --git a/common/nextpnr.h b/common/nextpnr.h index 8e47dcda..3b17920d 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -550,6 +550,9 @@ struct BaseCtx // Floorplanning regions std::unordered_map> region; + // Context meta data + std::unordered_map attrs; + BaseCtx() { idstring_str_to_idx = new std::unordered_map; -- cgit v1.2.3 From 856760599e51bd4c6da34112c993dc8bfb995f36 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Wed, 12 Jun 2019 18:34:34 +0200 Subject: Use properties for settings and save in json --- common/nextpnr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common/nextpnr.h') diff --git a/common/nextpnr.h b/common/nextpnr.h index 3b17920d..66134456 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -541,7 +541,7 @@ struct BaseCtx mutable std::vector *idstring_idx_to_str; // Project settings and config switches - std::unordered_map settings; + std::unordered_map settings; // Placed nets and cells. std::unordered_map> nets; -- cgit v1.2.3 From 95280060b869f266beaff023dd63d74905c39ef4 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sat, 15 Jun 2019 13:09:49 +0200 Subject: No need for settings class --- common/nextpnr.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'common/nextpnr.h') diff --git a/common/nextpnr.h b/common/nextpnr.h index 66134456..b796b8aa 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -32,6 +32,7 @@ #include #include +#include #ifndef NEXTPNR_H #define NEXTPNR_H @@ -724,6 +725,18 @@ struct Context : Arch, DeterministicRNG void check() const; void archcheck() const; + + template T setting(const char *name, T defaultValue) + { + IdString new_id = id(name); + if (settings.find(new_id) != settings.end()) + return boost::lexical_cast(settings.find(new_id)->second.str); + else + settings[id(name)] = std::to_string(defaultValue); + + return defaultValue; + } + }; NEXTPNR_NAMESPACE_END -- cgit v1.2.3 From 8d5724f4fd8e384ac59b8a94ec6979593239976c Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sat, 15 Jun 2019 15:23:51 +0200 Subject: moved some context variables to settings --- common/nextpnr.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'common/nextpnr.h') diff --git a/common/nextpnr.h b/common/nextpnr.h index b796b8aa..e4461cb4 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -701,10 +701,6 @@ struct Context : Arch, DeterministicRNG bool verbose = false; bool debug = false; bool force = false; - bool timing_driven = true; - float target_freq = 12e6; - bool auto_freq = false; - int slack_redist_iter = 0; Context(ArchArgs args) : Arch(args) {} @@ -733,10 +729,18 @@ struct Context : Arch, DeterministicRNG return boost::lexical_cast(settings.find(new_id)->second.str); else settings[id(name)] = std::to_string(defaultValue); - - return defaultValue; + + return defaultValue; + } + + template T setting(const char *name) const + { + IdString new_id = id(name); + if (settings.find(new_id) != settings.end()) + return boost::lexical_cast(settings.find(new_id)->second.str); + else + throw std::runtime_error("settings does not exists"); } - }; NEXTPNR_NAMESPACE_END -- cgit v1.2.3 From 92da4a91de0b602b0414754bd3ae05fdd70acbe7 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 21 Jun 2019 09:43:47 +0200 Subject: Preserve ports --- common/nextpnr.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'common/nextpnr.h') diff --git a/common/nextpnr.h b/common/nextpnr.h index e4461cb4..6950ac76 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -548,6 +548,9 @@ struct BaseCtx std::unordered_map> nets; std::unordered_map> cells; + // Top-level ports + std::unordered_map ports; + // Floorplanning regions std::unordered_map> region; -- cgit v1.2.3 From be47fc3e9a81a4890b05223ae18803cb07674dc9 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Tue, 25 Jun 2019 18:19:25 +0200 Subject: clangformat run --- common/nextpnr.h | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) (limited to 'common/nextpnr.h') diff --git a/common/nextpnr.h b/common/nextpnr.h index 6950ac76..3f434580 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -290,7 +290,7 @@ struct PipMap struct Property { bool is_string; - + std::string str; int num; @@ -299,22 +299,25 @@ struct Property 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 + void setNumber(int val) { - return str == other; - } - bool operator!=(const std::string other) const + is_string = false; + num = val; + str = std::to_string(val); + } + void setString(std::string val) { - return str != other; - } + 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) + Property &operator=(std::string other) { is_string = true; str = other; @@ -732,10 +735,10 @@ struct Context : Arch, DeterministicRNG return boost::lexical_cast(settings.find(new_id)->second.str); else settings[id(name)] = std::to_string(defaultValue); - - return defaultValue; + + return defaultValue; } - + template T setting(const char *name) const { IdString new_id = id(name); -- cgit v1.2.3