aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/design_utils.cc34
-rw-r--r--common/design_utils.h8
2 files changed, 27 insertions, 15 deletions
diff --git a/common/design_utils.cc b/common/design_utils.cc
index a7298aec..8b52697b 100644
--- a/common/design_utils.cc
+++ b/common/design_utils.cc
@@ -19,22 +19,30 @@
#include "design_utils.h"
-void replace_port(CellInfo *old_cell, PortInfo *old, CellInfo *rep_cell,
- PortInfo *rep)
+void replace_port(CellInfo *old_cell, IdString old_name, CellInfo *rep_cell,
+ IdString rep_name)
{
- assert(old->type == rep->type);
+ PortInfo &old = old_cell->ports.at(old_name);
+ PortInfo &rep = rep_cell->ports.at(rep_name);
+ assert(old.type == rep.type);
- rep->net = old->net;
- old->net = nullptr;
- if (rep->type == PORT_OUT) {
- rep->net->driver.cell = rep_cell;
- rep->net->driver.port = rep->name;
- } else if (rep->type == PORT_IN) {
- for (PortRef &load : rep->net->users) {
- if (load.cell == old_cell && load.port == old->name) {
- load.cell = rep_cell;
- load.port = rep->name;
+ rep.net = old.net;
+ old.net = nullptr;
+ if (rep.type == PORT_OUT) {
+ if (rep.net != nullptr) {
+ rep.net->driver.cell = rep_cell;
+ rep.net->driver.port = rep_name;
+ }
+ } else if (rep.type == PORT_IN) {
+ if (rep.net != nullptr) {
+ for (PortRef &load : rep.net->users) {
+ if (load.cell == old_cell && load.port == old_name) {
+ load.cell = rep_cell;
+ load.port = rep_name;
+ }
}
}
+ } else {
+ assert(false);
}
}
diff --git a/common/design_utils.h b/common/design_utils.h
index 2faceddc..43ff180b 100644
--- a/common/design_utils.h
+++ b/common/design_utils.h
@@ -19,13 +19,15 @@
#include "nextpnr.h"
+#ifndef DESIGN_UTILS_H
+#define DESIGN_UTILS_H
/*
Utilities for design manipulation, intended for use inside packing algorithms
*/
// Disconnect a net (if connected) from old, and connect it to rep
-void replace_port(CellInfo *old_cell, PortInfo *old, CellInfo *rep_cell,
- PortInfo *rep);
+void replace_port(CellInfo *old_cell, IdString old_name, CellInfo *rep_cell,
+ IdString rep_name);
// If a net drives a given port of a cell matching a predicate (in many
// cases more than one cell type, e.g. SB_DFFxx so a predicate is used), return
@@ -58,3 +60,5 @@ CellInfo *net_driven_by(NetInfo *net, F1 cell_pred, IdString port)
return nullptr;
}
}
+
+#endif