aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2015-02-18 07:19:03 +0100
committerClifford Wolf <clifford@clifford.at>2015-02-18 07:19:03 +0100
commite4cf604ffda0033c0c0509421eeb6fb39bb975b5 (patch)
treeeb5242cf08492940438139b0f081376824cc405a
parent5f54be54b85c70beea5921a5042824d18a0f4c20 (diff)
parent024aa559e282347a08d5fe8e3f3cdccdd024a899 (diff)
downloadyosys-e4cf604ffda0033c0c0509421eeb6fb39bb975b5.tar.gz
yosys-e4cf604ffda0033c0c0509421eeb6fb39bb975b5.tar.bz2
yosys-e4cf604ffda0033c0c0509421eeb6fb39bb975b5.zip
Merge branch 'master' of github.com:cliffordwolf/yosys
-rw-r--r--CodingReadme35
-rw-r--r--passes/opt/wreduce.cc2
2 files changed, 36 insertions, 1 deletions
diff --git a/CodingReadme b/CodingReadme
index 1cee94e81..54ea368e7 100644
--- a/CodingReadme
+++ b/CodingReadme
@@ -154,6 +154,41 @@ only use one wire from such a group of connected wires. For example:
log("%d\n", sigmap(a) == sigmap(b)); // will print 1
+Using the RTLIL Netlist Format
+------------------------------
+
+In the RTLIL netlist format the cell ports contain SigSpecs that point to the
+Wires. There are no references in the other direction. This has two direct
+consequences:
+
+(1) It is very easy to go from cells to wires but hard to go in the other way.
+
+(2) There is no danger in removing cells from the netlists, but removing wires
+can break the netlist format when there are still references to the wire
+somewhere in the netlist.
+
+The solution to (1) is easy: Create custom indexes that allow you to make fast
+lookups for the wire-to-cell direction. You can either use existing generic
+index structures to do that (such as the ModIndex class) or write your own
+index. For many application it is simplest to construct a custom index. For
+example:
+
+ SigMap sigmap(module);
+ dict<SigBit, Cell*> sigbit_to_driver_index;
+
+ for (auto cell : module->cells())
+ for (auto &conn : cell->connections())
+ if (cell->output(conn.first))
+ for (auto bit : sigmap(conn.second))
+ sigbit_to_driver_index[bit] = cell;
+
+Regarding (2): There is a general theme in Yosys that you don't remove wires
+from the design. You can rename them, unconnect them, but you do not actually remove
+the Wire object from the module. Instead you let the "clean" command take care
+of the dangling wires. On the other hand it is safe to remove cells (as long as
+you make sure this does not invalidate a custom index you are using in your code).
+
+
Example Code
------------
diff --git a/passes/opt/wreduce.cc b/passes/opt/wreduce.cc
index 9a84dafe1..fc91f3689 100644
--- a/passes/opt/wreduce.cc
+++ b/passes/opt/wreduce.cc
@@ -315,7 +315,7 @@ struct WreduceWorker
};
struct WreducePass : public Pass {
- WreducePass() : Pass("wreduce", "reduce the word size of operations is possible") { }
+ WreducePass() : Pass("wreduce", "reduce the word size of operations if possible") { }
virtual void help()
{
// |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|