aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/celltypes.h
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2016-06-17 13:46:01 +0200
committerClifford Wolf <clifford@clifford.at>2016-06-17 13:50:09 +0200
commit52bb1b968d4bfbbbd84eca88f0e80c486cc1a16e (patch)
tree59a78b1ea866b90e23c757bdba2c5c2680b9d636 /kernel/celltypes.h
parentc3365034e9db8b6450db578daefd860276d5071f (diff)
downloadyosys-52bb1b968d4bfbbbd84eca88f0e80c486cc1a16e.tar.gz
yosys-52bb1b968d4bfbbbd84eca88f0e80c486cc1a16e.tar.bz2
yosys-52bb1b968d4bfbbbd84eca88f0e80c486cc1a16e.zip
Added $sop cell type and "abc -sop"
Diffstat (limited to 'kernel/celltypes.h')
-rw-r--r--kernel/celltypes.h28
1 files changed, 27 insertions, 1 deletions
diff --git a/kernel/celltypes.h b/kernel/celltypes.h
index 40fdca36e..41dd51ed8 100644
--- a/kernel/celltypes.h
+++ b/kernel/celltypes.h
@@ -85,7 +85,7 @@ struct CellTypes
std::vector<RTLIL::IdString> unary_ops = {
"$not", "$pos", "$neg",
"$reduce_and", "$reduce_or", "$reduce_xor", "$reduce_xnor", "$reduce_bool",
- "$logic_not", "$slice", "$lut"
+ "$logic_not", "$slice", "$lut", "$sop"
};
std::vector<RTLIL::IdString> binary_ops = {
@@ -357,6 +357,32 @@ struct CellTypes
return t;
}
+ if (cell->type == "$sop")
+ {
+ int width = cell->parameters.at("\\WIDTH").as_int();
+ int depth = cell->parameters.at("\\DEPTH").as_int();
+ std::vector<RTLIL::State> t = cell->parameters.at("\\TABLE").bits;
+
+ while (GetSize(t) < width*depth*2)
+ t.push_back(RTLIL::S0);
+
+ for (int i = 0; i < depth; i++)
+ {
+ bool match = true;
+
+ for (int j = 0; j < width; j++) {
+ RTLIL::State a = arg1.bits.at(j);
+ if (t.at(2*width*i + 2*j + 0) == State::S1 && a == State::S1) match = false;
+ if (t.at(2*width*i + 2*j + 1) == State::S1 && a == State::S0) match = false;
+ }
+
+ if (match)
+ return State::S1;
+ }
+
+ return State::S0;
+ }
+
bool signed_a = cell->parameters.count("\\A_SIGNED") > 0 && cell->parameters["\\A_SIGNED"].as_bool();
bool signed_b = cell->parameters.count("\\B_SIGNED") > 0 && cell->parameters["\\B_SIGNED"].as_bool();
int result_len = cell->parameters.count("\\Y_WIDTH") > 0 ? cell->parameters["\\Y_WIDTH"].as_int() : -1;