mirror of
https://github.com/YosysHQ/yosys
synced 2025-07-28 15:07:58 +00:00
bufnorm: my comments
This commit is contained in:
parent
f1038f20f6
commit
4c0380aa5d
1 changed files with 22 additions and 1 deletions
|
@ -3498,7 +3498,7 @@ void RTLIL::Design::bufNormalize(bool enable)
|
||||||
{
|
{
|
||||||
if (!flagBufferedNormalized)
|
if (!flagBufferedNormalized)
|
||||||
return;
|
return;
|
||||||
|
// Initialize
|
||||||
for (auto module : modules()) {
|
for (auto module : modules()) {
|
||||||
module->bufNormQueue.clear();
|
module->bufNormQueue.clear();
|
||||||
for (auto wire : module->wires()) {
|
for (auto wire : module->wires()) {
|
||||||
|
@ -3518,11 +3518,18 @@ void RTLIL::Design::bufNormalize(bool enable)
|
||||||
if (!cell->output(conn.first) || GetSize(conn.second) == 0)
|
if (!cell->output(conn.first) || GetSize(conn.second) == 0)
|
||||||
continue;
|
continue;
|
||||||
if (conn.second.is_wire()) {
|
if (conn.second.is_wire()) {
|
||||||
|
// Connection is constructed of a single wire,
|
||||||
|
// so we can normalize immediately
|
||||||
Wire *wire = conn.second.as_wire();
|
Wire *wire = conn.second.as_wire();
|
||||||
|
// TODO does this imply no tristate at this point?
|
||||||
log_assert(wire->driverCell == nullptr);
|
log_assert(wire->driverCell == nullptr);
|
||||||
wire->driverCell = cell;
|
wire->driverCell = cell;
|
||||||
wire->driverPort = conn.first;
|
wire->driverPort = conn.first;
|
||||||
} else {
|
} else {
|
||||||
|
// Multiple chunks or is const, queue this cell connection
|
||||||
|
// for per-module processing
|
||||||
|
// TODO when the connection is const, is it still
|
||||||
|
// advantageous to queue it?
|
||||||
pair<RTLIL::Cell*, RTLIL::IdString> key(cell, conn.first);
|
pair<RTLIL::Cell*, RTLIL::IdString> key(cell, conn.first);
|
||||||
module->bufNormQueue.insert(key);
|
module->bufNormQueue.insert(key);
|
||||||
}
|
}
|
||||||
|
@ -3543,15 +3550,24 @@ void RTLIL::Module::bufNormalize()
|
||||||
|
|
||||||
while (GetSize(bufNormQueue))
|
while (GetSize(bufNormQueue))
|
||||||
{
|
{
|
||||||
|
// TODO I'm pretty sure this isn't a loop
|
||||||
|
// Maybe it was expected that bufNormQueue will be
|
||||||
|
// pushed connections into as they get discovered?
|
||||||
|
|
||||||
|
// Pairs of cells and output ports
|
||||||
pool<pair<RTLIL::Cell*, RTLIL::IdString>> queue;
|
pool<pair<RTLIL::Cell*, RTLIL::IdString>> queue;
|
||||||
bufNormQueue.swap(queue);
|
bufNormQueue.swap(queue);
|
||||||
|
|
||||||
|
// Output wires that we will buffer
|
||||||
pool<Wire*> outWires;
|
pool<Wire*> outWires;
|
||||||
|
// We will buffer all non-const module connections
|
||||||
for (auto &conn : connections())
|
for (auto &conn : connections())
|
||||||
for (auto &chunk : conn.first.chunks())
|
for (auto &chunk : conn.first.chunks())
|
||||||
if (chunk.wire) outWires.insert(chunk.wire);
|
if (chunk.wire) outWires.insert(chunk.wire);
|
||||||
|
|
||||||
SigMap sigmap(this);
|
SigMap sigmap(this);
|
||||||
|
|
||||||
|
// After bufnormalize, there are no module connections needed
|
||||||
new_connections({});
|
new_connections({});
|
||||||
|
|
||||||
for (auto &key : queue)
|
for (auto &key : queue)
|
||||||
|
@ -3562,16 +3578,21 @@ void RTLIL::Module::bufNormalize()
|
||||||
if (GetSize(sig) == 0) continue;
|
if (GetSize(sig) == 0) continue;
|
||||||
|
|
||||||
if (sig.is_wire()) {
|
if (sig.is_wire()) {
|
||||||
|
// TODO I'm pretty sure this is unreachable
|
||||||
|
// due to the condition in Design::bufNormalize
|
||||||
Wire *wire = sig.as_wire();
|
Wire *wire = sig.as_wire();
|
||||||
log_assert(wire->driverCell == nullptr);
|
log_assert(wire->driverCell == nullptr);
|
||||||
|
// Let the wire know who its driver is
|
||||||
wire->driverCell = cell;
|
wire->driverCell = cell;
|
||||||
wire->driverPort = portname;
|
wire->driverPort = portname;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Each non-const chunk gets a buffer later
|
||||||
for (auto &chunk : sig.chunks())
|
for (auto &chunk : sig.chunks())
|
||||||
if (chunk.wire) outWires.insert(chunk.wire);
|
if (chunk.wire) outWires.insert(chunk.wire);
|
||||||
|
|
||||||
|
// Create wire for the driving signal
|
||||||
Wire *wire = addWire(NEW_ID, GetSize(sig));
|
Wire *wire = addWire(NEW_ID, GetSize(sig));
|
||||||
sigmap.add(sig, wire);
|
sigmap.add(sig, wire);
|
||||||
cell->setPort(portname, wire);
|
cell->setPort(portname, wire);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue