From e88bd34c02272ecdad6295123941d9040fa4f043 Mon Sep 17 00:00:00 2001 From: gatecat Date: Thu, 30 Dec 2021 13:18:34 +0000 Subject: Viaduct API for a hybrid between generic and full-custom arch Signed-off-by: gatecat --- generic/viaduct_helpers.h | 82 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 generic/viaduct_helpers.h (limited to 'generic/viaduct_helpers.h') 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 + * + * 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 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 &top_ports); + // Constrain cells with certain port connection patterns together with a fixed z-offset + int constrain_cell_pairs(const pool &src_ports, const pool &sink_ports, int delta_z); + // Replace constants with given driving cells + void replace_constants(CellTypePort vcc_driver, CellTypePort gnd_driver, + const dict &vcc_params = {}, + const dict &gnd_params = {}); +}; + +NEXTPNR_NAMESPACE_END + +#endif -- cgit v1.2.3