diff options
author | Clifford Wolf <clifford@clifford.at> | 2016-06-17 16:31:16 +0200 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2016-06-17 16:31:16 +0200 |
commit | 95757efb25dc51a73b384b475b0fc87d0e11d10e (patch) | |
tree | b0c4518d676e8389629ca96482231616232add14 /passes/techmap | |
parent | 52bb1b968d4bfbbbd84eca88f0e80c486cc1a16e (diff) | |
download | yosys-95757efb25dc51a73b384b475b0fc87d0e11d10e.tar.gz yosys-95757efb25dc51a73b384b475b0fc87d0e11d10e.tar.bz2 yosys-95757efb25dc51a73b384b475b0fc87d0e11d10e.zip |
Improved support for $sop cells
Diffstat (limited to 'passes/techmap')
-rw-r--r-- | passes/techmap/simplemap.cc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/passes/techmap/simplemap.cc b/passes/techmap/simplemap.cc index 777e80142..0fb647344 100644 --- a/passes/techmap/simplemap.cc +++ b/passes/techmap/simplemap.cc @@ -321,6 +321,36 @@ void simplemap_lut(RTLIL::Module *module, RTLIL::Cell *cell) module->connect(cell->getPort("\\Y"), lut_data); } +void simplemap_sop(RTLIL::Module *module, RTLIL::Cell *cell) +{ + SigSpec ctrl = cell->getPort("\\A"); + SigSpec table = cell->getParam("\\TABLE"); + + int width = cell->getParam("\\WIDTH").as_int(); + int depth = cell->getParam("\\DEPTH").as_int(); + table.extend_u0(2 * width * depth); + + SigSpec products; + + for (int i = 0; i < depth; i++) { + SigSpec in, pat; + for (int j = 0; j < width; j++) { + if (table[2*i*width + 2*j + 0] == State::S1) { + in.append(ctrl[j]); + pat.append(State::S0); + } + if (table[2*i*width + 2*j + 1] == State::S1) { + in.append(ctrl[j]); + pat.append(State::S1); + } + } + + products.append(GetSize(in) > 0 ? module->Eq(NEW_ID, in, pat) : State::S1); + } + + module->connect(cell->getPort("\\Y"), module->ReduceOr(NEW_ID, products)); +} + void simplemap_slice(RTLIL::Module *module, RTLIL::Cell *cell) { int offset = cell->parameters.at("\\OFFSET").as_int(); @@ -498,6 +528,7 @@ void simplemap_get_mappers(std::map<RTLIL::IdString, void(*)(RTLIL::Module*, RTL mappers["$mux"] = simplemap_mux; mappers["$tribuf"] = simplemap_tribuf; mappers["$lut"] = simplemap_lut; + mappers["$sop"] = simplemap_sop; mappers["$slice"] = simplemap_slice; mappers["$concat"] = simplemap_concat; mappers["$sr"] = simplemap_sr; |