mirror of
https://github.com/YosysHQ/nextpnr.git
synced 2026-05-02 14:29:53 +00:00
ice40: Adding cell utilities for packing
Signed-off-by: David Shah <davey1576@gmail.com>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user