aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/design.h4
-rw-r--r--common/design_utils.cc4
-rw-r--r--common/design_utils.h5
-rw-r--r--common/handle_error.cc5
-rw-r--r--common/log.cc4
-rw-r--r--common/log.h4
-rw-r--r--common/nextpnr.h40
-rw-r--r--common/place.cc4
-rw-r--r--common/place.h4
-rw-r--r--common/pybindings.cc5
-rw-r--r--common/pybindings.h9
-rw-r--r--common/pycontainers.h5
-rw-r--r--common/route.cc23
-rw-r--r--common/route.h4
-rw-r--r--common/rulecheck.cc4
15 files changed, 90 insertions, 34 deletions
diff --git a/common/design.h b/common/design.h
index ae2657f2..e763ed48 100644
--- a/common/design.h
+++ b/common/design.h
@@ -24,6 +24,8 @@
#error Include "design.h" via "nextpnr.h" only.
#endif
+NEXTPNR_NAMESPACE_BEGIN
+
struct CellInfo;
struct PortRef
@@ -81,4 +83,6 @@ struct Design
std::unordered_map<IdString, CellInfo *> cells;
};
+NEXTPNR_NAMESPACE_END
+
#endif
diff --git a/common/design_utils.cc b/common/design_utils.cc
index 8b52697b..85895a75 100644
--- a/common/design_utils.cc
+++ b/common/design_utils.cc
@@ -19,6 +19,8 @@
#include "design_utils.h"
+NEXTPNR_NAMESPACE_BEGIN
+
void replace_port(CellInfo *old_cell, IdString old_name, CellInfo *rep_cell,
IdString rep_name)
{
@@ -46,3 +48,5 @@ void replace_port(CellInfo *old_cell, IdString old_name, CellInfo *rep_cell,
assert(false);
}
}
+
+NEXTPNR_NAMESPACE_END
diff --git a/common/design_utils.h b/common/design_utils.h
index 9d027d58..2acc7d20 100644
--- a/common/design_utils.h
+++ b/common/design_utils.h
@@ -21,6 +21,9 @@
#ifndef DESIGN_UTILS_H
#define DESIGN_UTILS_H
+
+NEXTPNR_NAMESPACE_BEGIN
+
/*
Utilities for design manipulation, intended for use inside packing algorithms
*/
@@ -65,4 +68,6 @@ CellInfo *net_driven_by(NetInfo *net, F1 cell_pred, IdString port)
}
}
+NEXTPNR_NAMESPACE_END
+
#endif
diff --git a/common/handle_error.cc b/common/handle_error.cc
index 55ec75fb..7076c188 100644
--- a/common/handle_error.cc
+++ b/common/handle_error.cc
@@ -1,8 +1,11 @@
#include <Python.h>
#include <boost/python.hpp>
+#include "nextpnr.h"
namespace py = boost::python;
+NEXTPNR_NAMESPACE_BEGIN
+
// Parses the value of the active python exception
// NOTE SHOULD NOT BE CALLED IF NO EXCEPTION
std::string parse_python_exception()
@@ -56,3 +59,5 @@ std::string parse_python_exception()
}
return ret;
}
+
+NEXTPNR_NAMESPACE_END
diff --git a/common/log.cc b/common/log.cc
index e72633bc..cbd3c171 100644
--- a/common/log.cc
+++ b/common/log.cc
@@ -28,6 +28,8 @@
#include "log.h"
+NEXTPNR_NAMESPACE_BEGIN
+
std::vector<FILE *> log_files;
std::vector<std::ostream *> log_streams;
FILE *log_errfile = NULL;
@@ -233,3 +235,5 @@ void log_flush()
void log_cell(CellInfo *cell, std::string indent) {}
void log_net(NetInfo *net, std::string indent) {}
+
+NEXTPNR_NAMESPACE_END
diff --git a/common/log.h b/common/log.h
index 085f72ee..afe7a047 100644
--- a/common/log.h
+++ b/common/log.h
@@ -34,6 +34,8 @@
#define NXP_NORETURN
#define NXP_ATTRIBUTE(...) __attribute__((__VA_ARGS__))
+NEXTPNR_NAMESPACE_BEGIN
+
struct log_cmd_error_exception
{
};
@@ -99,4 +101,6 @@ static inline void log_assert_worker(bool cond, const char *expr,
#define log_ping() \
log("-- %s:%d %s --\n", __FILE__, __LINE__, __PRETTY_FUNCTION__)
+NEXTPNR_NAMESPACE_END
+
#endif
diff --git a/common/nextpnr.h b/common/nextpnr.h
index 453af496..0c74c1ad 100644
--- a/common/nextpnr.h
+++ b/common/nextpnr.h
@@ -27,42 +27,40 @@
#ifndef NEXTPNR_H
#define NEXTPNR_H
+#ifdef NEXTPNR_NAMESPACE
+#define NEXTPNR_NAMESPACE_PREFIX NEXTPNR_NAMESPACE::
+#define NEXTPNR_NAMESPACE_BEGIN namespace NEXTPNR_NAMESPACE {
+#define NEXTPNR_NAMESPACE_END }
+#define USING_NEXTPNR_NAMESPACE using namespace NEXTPNR_NAMESPACE;
+#else
+#define NEXTPNR_NAMESPACE_PREFIX
+#define NEXTPNR_NAMESPACE_BEGIN
+#define NEXTPNR_NAMESPACE_END
+#define USING_NEXTPNR_NAMESPACE
+#endif
+
+NEXTPNR_NAMESPACE_BEGIN
+
// replace with proper IdString later
typedef std::string IdString;
struct GraphicElement
{
- // This will control colour, and there should be separate
- // visibility controls in some cases also
- enum
- {
- // Wires entirely inside tiles, e.g. between switchbox and bels
- G_LOCAL_WIRES,
- // Standard inter-tile routing
- G_GENERAL_WIRES,
- // Special inter-tile wires, e.g. carry chains
- G_DEDICATED_WIRES,
- G_BEL_OUTLINE,
- G_SWITCHBOX_OUTLINE,
- G_TILE_OUTLINE,
- G_BEL_PINS,
- G_SWITCHBOX_PINS,
- G_BEL_MISC,
- G_TILE_MISC,
- } style;
-
enum
{
+ G_NONE,
G_LINE,
G_BOX,
G_CIRCLE,
G_LABEL
- } type;
+ } type = G_NONE;
- float x1, y1, x2, y2, z;
+ float x1 = 0, y1 = 0, x2 = 0, y2 = 0, z = 0;
std::string text;
};
+NEXTPNR_NAMESPACE_END
+
#include "chip.h"
#include "design.h"
diff --git a/common/place.cc b/common/place.cc
index b187b0f0..e8fadd16 100644
--- a/common/place.cc
+++ b/common/place.cc
@@ -32,6 +32,8 @@
#include "log.h"
#include "place.h"
+NEXTPNR_NAMESPACE_BEGIN
+
void place_design(Design *design)
{
std::set<IdString> types_used;
@@ -117,3 +119,5 @@ void place_design(Design *design)
}
}
}
+
+NEXTPNR_NAMESPACE_END
diff --git a/common/place.h b/common/place.h
index a8b86595..7df84873 100644
--- a/common/place.h
+++ b/common/place.h
@@ -21,6 +21,10 @@
#include "nextpnr.h"
+NEXTPNR_NAMESPACE_BEGIN
+
extern void place_design(Design *design);
+NEXTPNR_NAMESPACE_END
+
#endif // PLACE_H
diff --git a/common/pybindings.cc b/common/pybindings.cc
index d941436b..8aa831ca 100644
--- a/common/pybindings.cc
+++ b/common/pybindings.cc
@@ -25,6 +25,8 @@
#include <fstream>
+NEXTPNR_NAMESPACE_BEGIN
+
// Required to determine concatenated module name (which differs for different
// archs)
#define PASTER(x, y) x##_##y
@@ -64,7 +66,6 @@ Design load_design_shim(std::string filename, ChipArgs args)
BOOST_PYTHON_MODULE(MODULE_NAME)
{
class_<GraphicElement>("GraphicElement")
- .def_readwrite("style", &GraphicElement::style)
.def_readwrite("type", &GraphicElement::type)
.def_readwrite("x1", &GraphicElement::x1)
.def_readwrite("y1", &GraphicElement::y1)
@@ -178,3 +179,5 @@ void execute_python_file(const char *python_file)
std::cout << "Error in Python: " << perror_str << std::endl;
}
}
+
+NEXTPNR_NAMESPACE_END
diff --git a/common/pybindings.h b/common/pybindings.h
index bb060718..de6aa4c7 100644
--- a/common/pybindings.h
+++ b/common/pybindings.h
@@ -29,6 +29,11 @@
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#include <stdexcept>
#include <utility>
+
+#include "nextpnr.h"
+
+NEXTPNR_NAMESPACE_BEGIN
+
using namespace boost::python;
/*
@@ -110,8 +115,8 @@ void deinit_python();
void execute_python_file(const char *python_file);
-std::string parse_python_exception();
-
void arch_appendinittab();
+NEXTPNR_NAMESPACE_END
+
#endif /* end of include guard: COMMON_PYBINDINGS_HH */
diff --git a/common/pycontainers.h b/common/pycontainers.h
index 423e36f5..992d0de9 100644
--- a/common/pycontainers.h
+++ b/common/pycontainers.h
@@ -27,6 +27,9 @@
#include <stdexcept>
#include <type_traits>
#include <utility>
+#include "nextpnr.h"
+
+NEXTPNR_NAMESPACE_BEGIN
using namespace boost::python;
@@ -270,4 +273,6 @@ template <typename T> struct map_wrapper
map_wrapper<t>().wrap(#name, #name "KeyValue", #name "KeyValueIter", \
#name "Iterator")
+NEXTPNR_NAMESPACE_END
+
#endif
diff --git a/common/route.cc b/common/route.cc
index b98db259..ca76024f 100644
--- a/common/route.cc
+++ b/common/route.cc
@@ -22,22 +22,23 @@
#include "log.h"
#include "route.h"
+NEXTPNR_NAMESPACE_BEGIN
+
struct QueuedWire
{
WireId wire;
PipId pip;
DelayInfo delay;
-};
-namespace std {
-template <> struct greater<QueuedWire>
-{
- bool operator()(const QueuedWire &lhs, const QueuedWire &rhs) const noexcept
+ struct Greater
{
- return lhs.delay.avgDelay() > rhs.delay.avgDelay();
- }
+ bool operator()(const QueuedWire &lhs, const QueuedWire &rhs) const
+ noexcept
+ {
+ return lhs.delay.avgDelay() > rhs.delay.avgDelay();
+ }
+ };
};
-} // namespace std
void route_design(Design *design)
{
@@ -99,7 +100,7 @@ void route_design(Design *design)
std::unordered_map<WireId, QueuedWire> visited;
std::priority_queue<QueuedWire, std::vector<QueuedWire>,
- std::greater<QueuedWire>>
+ QueuedWire::Greater>
queue;
for (auto &it : src_wires) {
@@ -135,7 +136,7 @@ void route_design(Design *design)
if (next_qw.wire == dst_wire) {
std::priority_queue<QueuedWire, std::vector<QueuedWire>,
- std::greater<QueuedWire>>
+ QueuedWire::Greater>
empty_queue;
std::swap(queue, empty_queue);
break;
@@ -169,3 +170,5 @@ void route_design(Design *design)
}
}
}
+
+NEXTPNR_NAMESPACE_END
diff --git a/common/route.h b/common/route.h
index 5ecbd823..d9c240b3 100644
--- a/common/route.h
+++ b/common/route.h
@@ -22,6 +22,10 @@
#include "design.h"
+NEXTPNR_NAMESPACE_BEGIN
+
extern void route_design(Design *design);
+NEXTPNR_NAMESPACE_END
+
#endif // ROUTE_H
diff --git a/common/rulecheck.cc b/common/rulecheck.cc
index 4fc3f73a..c0139a85 100644
--- a/common/rulecheck.cc
+++ b/common/rulecheck.cc
@@ -3,6 +3,8 @@
#include "log.h"
#include "nextpnr.h"
+NEXTPNR_NAMESPACE_BEGIN
+
bool check_all_nets_driven(Design *design)
{
const bool debug = false;
@@ -70,3 +72,5 @@ bool check_all_nets_driven(Design *design)
log_info(" Verified!\n");
return true;
}
+
+NEXTPNR_NAMESPACE_END