aboutsummaryrefslogtreecommitdiffstats
path: root/generic/viaduct_helpers.h
diff options
context:
space:
mode:
authorgatecat <gatecat@ds0.me>2021-12-30 13:18:34 +0000
committergatecat <gatecat@ds0.me>2022-01-04 20:19:29 +0000
commite88bd34c02272ecdad6295123941d9040fa4f043 (patch)
tree2ff879a3a856d19f61cc0c0875e7a3aa7fba7ac1 /generic/viaduct_helpers.h
parent089ca8258e6f4dc93f8d39594c1109a8578cdc98 (diff)
downloadnextpnr-e88bd34c02272ecdad6295123941d9040fa4f043.tar.gz
nextpnr-e88bd34c02272ecdad6295123941d9040fa4f043.tar.bz2
nextpnr-e88bd34c02272ecdad6295123941d9040fa4f043.zip
Viaduct API for a hybrid between generic and full-custom arch
Signed-off-by: gatecat <gatecat@ds0.me>
Diffstat (limited to 'generic/viaduct_helpers.h')
-rw-r--r--generic/viaduct_helpers.h82
1 files changed, 82 insertions, 0 deletions
diff --git a/generic/viaduct_helpers.h b/generic/viaduct_helpers.h
new file mode 100644
index 00000000..8cba8411
--- /dev/null
+++ b/generic/viaduct_helpers.h
@@ -0,0 +1,82 @@
+/*
+ * nextpnr -- Next Generation Place and Route
+ *
+ * Copyright (C) 2021 gatecat <gatecat@ds0.me>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+
+#ifndef VIADUCT_HELPERS_H
+#define VIADUCT_HELPERS_H
+
+#include "nextpnr_namespaces.h"
+#include "nextpnr_types.h"
+
+NEXTPNR_NAMESPACE_BEGIN
+
+/*
+Viaduct -- a series of small arches
+
+See viaduct_api.h for more background.
+
+viaduct_helpers provides some features for building up arches using the viaduct API
+*/
+
+// Used to configure various generic pack functions
+struct CellTypePort
+{
+ CellTypePort() : cell_type(), port(){};
+ CellTypePort(IdString cell_type, IdString port) : cell_type(cell_type), port(port){};
+ explicit CellTypePort(const PortRef &net_port)
+ : cell_type(net_port.cell ? net_port.cell->type : IdString()), port(net_port.port){};
+ inline bool operator==(const CellTypePort &other) const
+ {
+ return cell_type == other.cell_type && port == other.port;
+ }
+ inline bool operator!=(const CellTypePort &other) const
+ {
+ return cell_type != other.cell_type || port != other.port;
+ }
+ inline unsigned hash() const { return mkhash(cell_type.hash(), port.hash()); }
+ IdString cell_type, port;
+};
+
+struct ViaductHelpers
+{
+ ViaductHelpers(){};
+ Context *ctx;
+ void init(Context *ctx) { this->ctx = ctx; }
+ // IdStringList components for x and y locations
+ std::vector<IdString> x_ids, y_ids;
+ void resize_ids(int x, int y);
+ // Get an IdStringList for a hierarchical ID
+ // Because this uses an IdStringList with seperate X and Y components; this will be much more efficient than
+ // creating unique strings for each object in each X and Y position
+ IdStringList xy_id(int x, int y, IdString base);
+ IdStringList xy_id(int x, int y, IdStringList base);
+ // Common packing functions
+ // Remove nextpnr-inserted IO buffers; where IO buffer insertion is done in synthesis
+ // expects a set of top-level port types
+ void remove_nextpnr_iobs(const pool<CellTypePort> &top_ports);
+ // Constrain cells with certain port connection patterns together with a fixed z-offset
+ int constrain_cell_pairs(const pool<CellTypePort> &src_ports, const pool<CellTypePort> &sink_ports, int delta_z);
+ // Replace constants with given driving cells
+ void replace_constants(CellTypePort vcc_driver, CellTypePort gnd_driver,
+ const dict<IdString, Property> &vcc_params = {},
+ const dict<IdString, Property> &gnd_params = {});
+};
+
+NEXTPNR_NAMESPACE_END
+
+#endif