aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2015-02-16 09:08:00 +0100
committerClifford Wolf <clifford@clifford.at>2015-02-16 09:08:00 +0100
commit0748ef638d34bb5dd125271abc4fe051f95a790d (patch)
tree9cb4f26005f703674cf672c1a5a2c563f7ae35e8
parent162432a722039734743895b28fae5670ecdd0440 (diff)
downloadyosys-0748ef638d34bb5dd125271abc4fe051f95a790d.tar.gz
yosys-0748ef638d34bb5dd125271abc4fe051f95a790d.tar.bz2
yosys-0748ef638d34bb5dd125271abc4fe051f95a790d.zip
Bugfix in wreduce
-rw-r--r--passes/opt/wreduce.cc21
1 files changed, 14 insertions, 7 deletions
diff --git a/passes/opt/wreduce.cc b/passes/opt/wreduce.cc
index 1609a8be7..9a84dafe1 100644
--- a/passes/opt/wreduce.cc
+++ b/passes/opt/wreduce.cc
@@ -281,6 +281,10 @@ struct WreduceWorker
work_queue_cells.insert(port.cell);
}
+ pool<SigSpec> complete_wires;
+ for (auto w : module->wires())
+ complete_wires.insert(mi.sigmap(w));
+
for (auto w : module->selected_wires())
{
int unused_top_bits = 0;
@@ -296,13 +300,16 @@ struct WreduceWorker
unused_top_bits++;
}
- if (0 < unused_top_bits && unused_top_bits < GetSize(w)) {
- log("Removed top %d bits (of %d) from wire %s.%s.\n", unused_top_bits, GetSize(w), log_id(module), log_id(w));
- Wire *nw = module->addWire(NEW_ID, w);
- nw->width = GetSize(w) - unused_top_bits;
- module->connect(nw, SigSpec(w).extract(0, GetSize(nw)));
- module->swap_names(w, nw);
- }
+ if (unused_top_bits == 0 || unused_top_bits == GetSize(w))
+ continue;
+
+ if (complete_wires[mi.sigmap(w).extract(0, GetSize(w) - unused_top_bits)])
+ continue;
+
+ log("Removed top %d bits (of %d) from wire %s.%s.\n", unused_top_bits, GetSize(w), log_id(module), log_id(w));
+ Wire *nw = module->addWire(NEW_ID, GetSize(w) - unused_top_bits);
+ module->connect(nw, SigSpec(w).extract(0, GetSize(nw)));
+ module->swap_names(w, nw);
}
}
};