Download chips/yosys/passes/techmap/simplemap.cc from STAR-future/Trinity-SciData: direct link, hf CLI and curl.
- Browser
- Download file 17.4 kB
-
https://huggingface.co/datasets/STAR-future/Trinity-SciData/resolve/main/chips/yosys/passes/techmap/simplemap.cc
- Command line
-
hf download hf://datasets/STAR-future/Trinity-SciData/chips/yosys/passes/techmap/simplemap.cc
-
curl -L -o simplemap.cc https://huggingface.co/datasets/STAR-future/Trinity-SciData/resolve/main/chips/yosys/passes/techmap/simplemap.cc
17.4 kB
| /* | |
| * yosys -- Yosys Open SYnthesis Suite | |
| * | |
| * Copyright (C) 2012 Claire Xenia Wolf <claire@yosyshq.com> | |
| * | |
| * Permission to use, copy, modify, and/or distribute this software for any | |
| * purpose with or without fee is hereby granted, provided that the above | |
| * copyright notice and this permission notice appear in all copies. | |
| * | |
| * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
| * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
| * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
| * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
| * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
| * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
| * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
| * | |
| */ | |
| USING_YOSYS_NAMESPACE | |
| YOSYS_NAMESPACE_BEGIN | |
| static void transfer_attr (Cell* to, const Cell* from, IdString attr) { | |
| if (from->has_attribute(attr)) | |
| to->attributes[attr] = from->attributes.at(attr); | |
| } | |
| static void transfer_src (Cell* to, const Cell* from) { | |
| transfer_attr(to, from, ID::src); | |
| } | |
| void simplemap_not(RTLIL::Module *module, RTLIL::Cell *cell) | |
| { | |
| RTLIL::SigSpec sig_a = cell->getPort(ID::A); | |
| RTLIL::SigSpec sig_y = cell->getPort(ID::Y); | |
| sig_a.extend_u0(GetSize(sig_y), cell->parameters.at(ID::A_SIGNED).as_bool()); | |
| for (int i = 0; i < GetSize(sig_y); i++) { | |
| RTLIL::Cell *gate = module->addCell(NEW_ID, ID($_NOT_)); | |
| transfer_src(gate, cell); | |
| gate->setPort(ID::A, sig_a[i]); | |
| gate->setPort(ID::Y, sig_y[i]); | |
| } | |
| } | |
| void simplemap_buf(RTLIL::Module *module, RTLIL::Cell *cell) | |
| { | |
| RTLIL::SigSpec sig_a = cell->getPort(ID::A); | |
| RTLIL::SigSpec sig_y = cell->getPort(ID::Y); | |
| if (sig_a.has_const(State::Sz)) { | |
| SigSpec new_a; | |
| SigSpec new_y; | |
| for (int i = 0; i < GetSize(sig_a); ++i) { | |
| SigBit b = sig_a[i]; | |
| if (b == State::Sz) | |
| continue; | |
| new_a.append(b); | |
| new_y.append(sig_y[i]); | |
| } | |
| sig_a = std::move(new_a); | |
| sig_y = std::move(new_y); | |
| } | |
| if (!sig_y.empty()) | |
| module->connect(RTLIL::SigSig(sig_y, sig_a)); | |
| } | |
| void simplemap_pos(RTLIL::Module *module, RTLIL::Cell *cell) | |
| { | |
| RTLIL::SigSpec sig_a = cell->getPort(ID::A); | |
| RTLIL::SigSpec sig_y = cell->getPort(ID::Y); | |
| sig_a.extend_u0(GetSize(sig_y), cell->parameters.at(ID::A_SIGNED).as_bool()); | |
| module->connect(RTLIL::SigSig(sig_y, sig_a)); | |
| } | |
| void simplemap_bitop(RTLIL::Module *module, RTLIL::Cell *cell) | |
| { | |
| RTLIL::SigSpec sig_a = cell->getPort(ID::A); | |
| RTLIL::SigSpec sig_b = cell->getPort(ID::B); | |
| RTLIL::SigSpec sig_y = cell->getPort(ID::Y); | |
| if (cell->type != ID($bweqx)) { | |
| sig_a.extend_u0(GetSize(sig_y), cell->parameters.at(ID::A_SIGNED).as_bool()); | |
| sig_b.extend_u0(GetSize(sig_y), cell->parameters.at(ID::B_SIGNED).as_bool()); | |
| } | |
| IdString gate_type; | |
| if (cell->type == ID($and)) gate_type = ID($_AND_); | |
| if (cell->type == ID($or)) gate_type = ID($_OR_); | |
| if (cell->type == ID($xor)) gate_type = ID($_XOR_); | |
| if (cell->type == ID($xnor)) gate_type = ID($_XNOR_); | |
| if (cell->type == ID($bweqx)) gate_type = ID($_XNOR_); | |
| log_assert(!gate_type.empty()); | |
| for (int i = 0; i < GetSize(sig_y); i++) { | |
| RTLIL::Cell *gate = module->addCell(NEW_ID, gate_type); | |
| transfer_src(gate, cell); | |
| gate->setPort(ID::A, sig_a[i]); | |
| gate->setPort(ID::B, sig_b[i]); | |
| gate->setPort(ID::Y, sig_y[i]); | |
| } | |
| } | |
| void simplemap_reduce(RTLIL::Module *module, RTLIL::Cell *cell) | |
| { | |
| RTLIL::SigSpec sig_a = cell->getPort(ID::A); | |
| RTLIL::SigSpec sig_y = cell->getPort(ID::Y); | |
| if (sig_y.size() == 0) | |
| return; | |
| if (sig_a.size() == 0) { | |
| if (cell->type == ID($reduce_and)) module->connect(RTLIL::SigSig(sig_y, RTLIL::SigSpec(1, sig_y.size()))); | |
| if (cell->type == ID($reduce_or)) module->connect(RTLIL::SigSig(sig_y, RTLIL::SigSpec(0, sig_y.size()))); | |
| if (cell->type == ID($reduce_xor)) module->connect(RTLIL::SigSig(sig_y, RTLIL::SigSpec(0, sig_y.size()))); | |
| if (cell->type == ID($reduce_xnor)) module->connect(RTLIL::SigSig(sig_y, RTLIL::SigSpec(1, sig_y.size()))); | |
| if (cell->type == ID($reduce_bool)) module->connect(RTLIL::SigSig(sig_y, RTLIL::SigSpec(0, sig_y.size()))); | |
| return; | |
| } | |
| if (sig_y.size() > 1) { | |
| module->connect(RTLIL::SigSig(sig_y.extract(1, sig_y.size()-1), RTLIL::SigSpec(0, sig_y.size()-1))); | |
| sig_y = sig_y.extract(0, 1); | |
| } | |
| IdString gate_type; | |
| if (cell->type == ID($reduce_and)) gate_type = ID($_AND_); | |
| if (cell->type == ID($reduce_or)) gate_type = ID($_OR_); | |
| if (cell->type == ID($reduce_xor)) gate_type = ID($_XOR_); | |
| if (cell->type == ID($reduce_xnor)) gate_type = ID($_XOR_); | |
| if (cell->type == ID($reduce_bool)) gate_type = ID($_OR_); | |
| log_assert(!gate_type.empty()); | |
| RTLIL::Cell *last_output_cell = NULL; | |
| while (sig_a.size() > 1) | |
| { | |
| RTLIL::SigSpec sig_t = module->addWire(NEW_ID, sig_a.size() / 2); | |
| for (int i = 0; i < sig_a.size(); i += 2) | |
| { | |
| if (i+1 == sig_a.size()) { | |
| sig_t.append(sig_a[i]); | |
| continue; | |
| } | |
| RTLIL::Cell *gate = module->addCell(NEW_ID, gate_type); | |
| transfer_src(gate, cell); | |
| gate->setPort(ID::A, sig_a[i]); | |
| gate->setPort(ID::B, sig_a[i+1]); | |
| gate->setPort(ID::Y, sig_t[i/2]); | |
| last_output_cell = gate; | |
| } | |
| sig_a = sig_t; | |
| } | |
| if (cell->type == ID($reduce_xnor)) { | |
| RTLIL::SigSpec sig_t = module->addWire(NEW_ID); | |
| RTLIL::Cell *gate = module->addCell(NEW_ID, ID($_NOT_)); | |
| transfer_src(gate, cell); | |
| gate->setPort(ID::A, sig_a); | |
| gate->setPort(ID::Y, sig_t); | |
| last_output_cell = gate; | |
| sig_a = sig_t; | |
| } | |
| if (last_output_cell == NULL) { | |
| module->connect(RTLIL::SigSig(sig_y, sig_a)); | |
| } else { | |
| last_output_cell->setPort(ID::Y, sig_y); | |
| } | |
| } | |
| static void logic_reduce(RTLIL::Module *module, RTLIL::SigSpec &sig, RTLIL::Cell *cell) | |
| { | |
| while (sig.size() > 1) | |
| { | |
| RTLIL::SigSpec sig_t = module->addWire(NEW_ID, sig.size() / 2); | |
| for (int i = 0; i < sig.size(); i += 2) | |
| { | |
| if (i+1 == sig.size()) { | |
| sig_t.append(sig[i]); | |
| continue; | |
| } | |
| RTLIL::Cell *gate = module->addCell(NEW_ID, ID($_OR_)); | |
| transfer_src(gate, cell); | |
| gate->setPort(ID::A, sig[i]); | |
| gate->setPort(ID::B, sig[i+1]); | |
| gate->setPort(ID::Y, sig_t[i/2]); | |
| } | |
| sig = sig_t; | |
| } | |
| if (sig.size() == 0) | |
| sig = State::S0; | |
| } | |
| void simplemap_lognot(RTLIL::Module *module, RTLIL::Cell *cell) | |
| { | |
| RTLIL::SigSpec sig_a = cell->getPort(ID::A); | |
| logic_reduce(module, sig_a, cell); | |
| RTLIL::SigSpec sig_y = cell->getPort(ID::Y); | |
| if (sig_y.size() == 0) | |
| return; | |
| if (sig_y.size() > 1) { | |
| module->connect(RTLIL::SigSig(sig_y.extract(1, sig_y.size()-1), RTLIL::SigSpec(0, sig_y.size()-1))); | |
| sig_y = sig_y.extract(0, 1); | |
| } | |
| RTLIL::Cell *gate = module->addCell(NEW_ID, ID($_NOT_)); | |
| transfer_src(gate, cell); | |
| gate->setPort(ID::A, sig_a); | |
| gate->setPort(ID::Y, sig_y); | |
| } | |
| void simplemap_logbin(RTLIL::Module *module, RTLIL::Cell *cell) | |
| { | |
| RTLIL::SigSpec sig_a = cell->getPort(ID::A); | |
| logic_reduce(module, sig_a, cell); | |
| RTLIL::SigSpec sig_b = cell->getPort(ID::B); | |
| logic_reduce(module, sig_b, cell); | |
| RTLIL::SigSpec sig_y = cell->getPort(ID::Y); | |
| if (sig_y.size() == 0) | |
| return; | |
| if (sig_y.size() > 1) { | |
| module->connect(RTLIL::SigSig(sig_y.extract(1, sig_y.size()-1), RTLIL::SigSpec(0, sig_y.size()-1))); | |
| sig_y = sig_y.extract(0, 1); | |
| } | |
| IdString gate_type; | |
| if (cell->type == ID($logic_and)) gate_type = ID($_AND_); | |
| if (cell->type == ID($logic_or)) gate_type = ID($_OR_); | |
| log_assert(!gate_type.empty()); | |
| RTLIL::Cell *gate = module->addCell(NEW_ID, gate_type); | |
| transfer_src(gate, cell); | |
| gate->setPort(ID::A, sig_a); | |
| gate->setPort(ID::B, sig_b); | |
| gate->setPort(ID::Y, sig_y); | |
| } | |
| void simplemap_eqne(RTLIL::Module *module, RTLIL::Cell *cell) | |
| { | |
| RTLIL::SigSpec sig_a = cell->getPort(ID::A); | |
| RTLIL::SigSpec sig_b = cell->getPort(ID::B); | |
| RTLIL::SigSpec sig_y = cell->getPort(ID::Y); | |
| bool is_signed = cell->parameters.at(ID::A_SIGNED).as_bool(); | |
| bool is_ne = cell->type.in(ID($ne), ID($nex)); | |
| RTLIL::SigSpec xor_out = module->addWire(NEW_ID, max(GetSize(sig_a), GetSize(sig_b))); | |
| RTLIL::Cell *xor_cell = module->addXor(NEW_ID, sig_a, sig_b, xor_out, is_signed); | |
| transfer_src(xor_cell, cell); | |
| simplemap_bitop(module, xor_cell); | |
| module->remove(xor_cell); | |
| RTLIL::SigSpec reduce_out = is_ne ? sig_y : module->addWire(NEW_ID); | |
| RTLIL::Cell *reduce_cell = module->addReduceOr(NEW_ID, xor_out, reduce_out); | |
| transfer_src(reduce_cell, cell); | |
| simplemap_reduce(module, reduce_cell); | |
| module->remove(reduce_cell); | |
| if (!is_ne) { | |
| RTLIL::Cell *not_cell = module->addLogicNot(NEW_ID, reduce_out, sig_y); | |
| transfer_src(not_cell, cell); | |
| simplemap_lognot(module, not_cell); | |
| module->remove(not_cell); | |
| } | |
| } | |
| void simplemap_mux(RTLIL::Module *module, RTLIL::Cell *cell) | |
| { | |
| RTLIL::SigSpec sig_a = cell->getPort(ID::A); | |
| RTLIL::SigSpec sig_b = cell->getPort(ID::B); | |
| RTLIL::SigSpec sig_y = cell->getPort(ID::Y); | |
| for (int i = 0; i < GetSize(sig_y); i++) { | |
| RTLIL::Cell *gate = module->addCell(NEW_ID, ID($_MUX_)); | |
| transfer_src(gate, cell); | |
| gate->setPort(ID::A, sig_a[i]); | |
| gate->setPort(ID::B, sig_b[i]); | |
| gate->setPort(ID::S, cell->getPort(ID::S)); | |
| gate->setPort(ID::Y, sig_y[i]); | |
| } | |
| } | |
| void simplemap_bwmux(RTLIL::Module *module, RTLIL::Cell *cell) | |
| { | |
| RTLIL::SigSpec sig_a = cell->getPort(ID::A); | |
| RTLIL::SigSpec sig_b = cell->getPort(ID::B); | |
| RTLIL::SigSpec sig_s = cell->getPort(ID::S); | |
| RTLIL::SigSpec sig_y = cell->getPort(ID::Y); | |
| for (int i = 0; i < GetSize(sig_y); i++) { | |
| RTLIL::Cell *gate = module->addCell(NEW_ID, ID($_MUX_)); | |
| transfer_src(gate, cell); | |
| gate->setPort(ID::A, sig_a[i]); | |
| gate->setPort(ID::B, sig_b[i]); | |
| gate->setPort(ID::S, sig_s[i]); | |
| gate->setPort(ID::Y, sig_y[i]); | |
| } | |
| } | |
| void simplemap_tribuf(RTLIL::Module *module, RTLIL::Cell *cell) | |
| { | |
| RTLIL::SigSpec sig_a = cell->getPort(ID::A); | |
| RTLIL::SigSpec sig_e = cell->getPort(ID::EN); | |
| RTLIL::SigSpec sig_y = cell->getPort(ID::Y); | |
| for (int i = 0; i < GetSize(sig_y); i++) { | |
| RTLIL::Cell *gate = module->addCell(NEW_ID, ID($_TBUF_)); | |
| transfer_src(gate, cell); | |
| gate->setPort(ID::A, sig_a[i]); | |
| gate->setPort(ID::E, sig_e); | |
| gate->setPort(ID::Y, sig_y[i]); | |
| } | |
| } | |
| void simplemap_bmux(RTLIL::Module *module, RTLIL::Cell *cell) | |
| { | |
| SigSpec sel = cell->getPort(ID::S); | |
| SigSpec data = cell->getPort(ID::A); | |
| int width = GetSize(cell->getPort(ID::Y)); | |
| for (int idx = 0; idx < GetSize(sel); idx++) { | |
| SigSpec new_data = module->addWire(NEW_ID, GetSize(data)/2); | |
| for (int i = 0; i < GetSize(new_data); i += width) { | |
| for (int k = 0; k < width; k++) { | |
| RTLIL::Cell *gate = module->addCell(NEW_ID, ID($_MUX_)); | |
| transfer_src(gate, cell); | |
| gate->setPort(ID::A, data[i*2+k]); | |
| gate->setPort(ID::B, data[i*2+width+k]); | |
| gate->setPort(ID::S, sel[idx]); | |
| gate->setPort(ID::Y, new_data[i+k]); | |
| } | |
| } | |
| data = new_data; | |
| } | |
| module->connect(cell->getPort(ID::Y), data); | |
| } | |
| void simplemap_lut(RTLIL::Module *module, RTLIL::Cell *cell) | |
| { | |
| SigSpec lut_ctrl = cell->getPort(ID::A); | |
| SigSpec lut_data = cell->getParam(ID::LUT); | |
| lut_data.extend_u0(1 << cell->getParam(ID::WIDTH).as_int()); | |
| for (int idx = 0; GetSize(lut_data) > 1; idx++) { | |
| SigSpec new_lut_data = module->addWire(NEW_ID, GetSize(lut_data)/2); | |
| for (int i = 0; i < GetSize(lut_data); i += 2) { | |
| RTLIL::Cell *gate = module->addCell(NEW_ID, ID($_MUX_)); | |
| transfer_src(gate, cell); | |
| gate->setPort(ID::A, lut_data[i]); | |
| gate->setPort(ID::B, lut_data[i+1]); | |
| gate->setPort(ID::S, lut_ctrl[idx]); | |
| gate->setPort(ID::Y, new_lut_data[i/2]); | |
| } | |
| lut_data = new_lut_data; | |
| } | |
| module->connect(cell->getPort(ID::Y), lut_data); | |
| } | |
| void simplemap_sop(RTLIL::Module *module, RTLIL::Cell *cell) | |
| { | |
| SigSpec ctrl = cell->getPort(ID::A); | |
| SigSpec table = cell->getParam(ID::TABLE); | |
| int width = cell->getParam(ID::WIDTH).as_int(); | |
| int depth = cell->getParam(ID::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(ID::Y), module->ReduceOr(NEW_ID, products)); | |
| } | |
| void simplemap_slice(RTLIL::Module *module, RTLIL::Cell *cell) | |
| { | |
| int offset = cell->parameters.at(ID::OFFSET).as_int(); | |
| RTLIL::SigSpec sig_a = cell->getPort(ID::A); | |
| RTLIL::SigSpec sig_y = cell->getPort(ID::Y); | |
| module->connect(RTLIL::SigSig(sig_y, sig_a.extract(offset, sig_y.size()))); | |
| } | |
| void simplemap_concat(RTLIL::Module *module, RTLIL::Cell *cell) | |
| { | |
| RTLIL::SigSpec sig_ab = cell->getPort(ID::A); | |
| sig_ab.append(cell->getPort(ID::B)); | |
| RTLIL::SigSpec sig_y = cell->getPort(ID::Y); | |
| module->connect(RTLIL::SigSig(sig_y, sig_ab)); | |
| } | |
| void simplemap_ff(RTLIL::Module *, RTLIL::Cell *cell) | |
| { | |
| FfData ff(nullptr, cell); | |
| for (int i = 0; i < ff.width; i++) { | |
| FfData fff = ff.slice({i}); | |
| fff.is_fine = true; | |
| fff.emit(); | |
| } | |
| } | |
| void simplemap_pmux(RTLIL::Module *module, RTLIL::Cell *cell) | |
| { | |
| RTLIL::SigSpec sig_a = cell->getPort(ID::A); | |
| RTLIL::SigSpec sig_b = cell->getPort(ID::B); | |
| RTLIL::SigSpec sig_s = cell->getPort(ID::S); | |
| RTLIL::SigSpec sig_y = cell->getPort(ID::Y); | |
| int width = GetSize(sig_a); | |
| int s_width = GetSize(sig_s); | |
| // Implement: |S | |
| RTLIL::SigSpec any_s = sig_s; | |
| logic_reduce(module, any_s, cell); | |
| for (int i = 0; i < width; i++) { | |
| RTLIL::SigSpec b_and_bits; | |
| // Implement: B_AND_BITS = B_AND_S[WIDTH*j+i] | |
| for (int j = 0; j < s_width; j++) { | |
| RTLIL::Cell *and_gate = module->addCell(NEW_ID, ID($_AND_)); | |
| transfer_src(and_gate, cell); | |
| and_gate->setPort(ID::A, sig_b[j * width + i]); | |
| and_gate->setPort(ID::B, sig_s[j]); | |
| RTLIL::SigSpec and_y = module->addWire(NEW_ID, 1); | |
| and_gate->setPort(ID::Y, and_y); | |
| b_and_bits.append(and_y); | |
| } | |
| // Implement: Y_B[i] = |B_AND_BITS | |
| logic_reduce(module, b_and_bits, cell); | |
| // Implement: Y[i] = |S ? Y_B[i] : A[i] | |
| RTLIL::Cell *mux_gate = module->addCell(NEW_ID, ID($_MUX_)); | |
| transfer_src(mux_gate, cell); | |
| mux_gate->setPort(ID::A, sig_a[i]); | |
| mux_gate->setPort(ID::B, b_and_bits); | |
| mux_gate->setPort(ID::S, any_s); | |
| mux_gate->setPort(ID::Y, sig_y[i]); | |
| } | |
| } | |
| SimplemapFn simplemap_mapper(IdString type) | |
| { | |
| if (type == ID($not)) | |
| return simplemap_not; | |
| if (type == ID($pos)) | |
| return simplemap_pos; | |
| if (type == ID($buf)) | |
| return simplemap_buf; | |
| if (type.in(ID($and), ID($or), ID($xor), ID($xnor), ID($bweqx))) | |
| return simplemap_bitop; | |
| if (type.in(ID($reduce_and), ID($reduce_or), ID($reduce_xor), ID($reduce_xnor), ID($reduce_bool))) | |
| return simplemap_reduce; | |
| if (type == ID($logic_not)) | |
| return simplemap_lognot; | |
| if (type.in(ID($logic_and), ID($logic_or))) | |
| return simplemap_logbin; | |
| if (type.in(ID($eq), ID($eqx), ID($ne), ID($nex))) | |
| return simplemap_eqne; | |
| if (type == ID($mux)) | |
| return simplemap_mux; | |
| if (type == ID($pmux)) | |
| return simplemap_pmux; | |
| if (type == ID($bwmux)) | |
| return simplemap_bwmux; | |
| if (type == ID($tribuf)) | |
| return simplemap_tribuf; | |
| if (type == ID($bmux)) | |
| return simplemap_bmux; | |
| if (type == ID($lut)) | |
| return simplemap_lut; | |
| if (type == ID($sop)) | |
| return simplemap_sop; | |
| if (type == ID($slice)) | |
| return simplemap_slice; | |
| if (type == ID($concat)) | |
| return simplemap_concat; | |
| if (type.in(ID($sr), ID($ff), ID($dff), ID($dffe), ID($dffsr), ID($dffsre), ID($adff), ID($sdff), | |
| ID($adffe), ID($sdffe), ID($sdffce), ID($aldff), ID($aldffe), ID($dlatch), ID($adlatch), ID($dlatchsr))) | |
| return simplemap_ff; | |
| return nullptr; | |
| } | |
| void simplemap(RTLIL::Module *module, RTLIL::Cell *cell) | |
| { | |
| SimplemapFn mapper = simplemap_mapper(cell->type); | |
| log_assert(mapper != nullptr); | |
| mapper(module, cell); | |
| } | |
| YOSYS_NAMESPACE_END | |
| PRIVATE_NAMESPACE_BEGIN | |
| struct SimplemapPass : public Pass { | |
| SimplemapPass() : Pass("simplemap", "mapping simple coarse-grain cells") { } | |
| void help() override | |
| { | |
| // |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---| | |
| log("\n"); | |
| log(" simplemap [selection]\n"); | |
| log("\n"); | |
| log("This pass maps a small selection of simple coarse-grain cells to yosys gate\n"); | |
| log("primitives. The following internal cell types are mapped by this pass:\n"); | |
| log("\n"); | |
| log(" $not, $pos, $and, $or, $xor, $xnor\n"); | |
| log(" $reduce_and, $reduce_or, $reduce_xor, $reduce_xnor, $reduce_bool\n"); | |
| log(" $logic_not, $logic_and, $logic_or, $mux, $pmux, $tribuf\n"); | |
| log(" $sr, $ff, $dff, $dffe, $dffsr, $dffsre, $adff, $adffe, $aldff, $aldffe, $sdff,\n"); | |
| log(" $sdffe, $sdffce, $dlatch, $adlatch, $dlatchsr\n"); | |
| log("\n"); | |
| } | |
| void execute(std::vector<std::string> args, RTLIL::Design *design) override | |
| { | |
| log_header(design, "Executing SIMPLEMAP pass (map simple cells to gate primitives).\n"); | |
| extra_args(args, 1, design); | |
| for (auto mod : design->modules()) { | |
| if (!design->selected(mod) || mod->get_blackbox_attribute()) | |
| continue; | |
| std::vector<RTLIL::Cell*> cells = mod->cells(); | |
| for (auto cell : cells) { | |
| SimplemapFn mapper = simplemap_mapper(cell->type); | |
| if (mapper == nullptr) | |
| continue; | |
| if (!design->selected(mod, cell)) | |
| continue; | |
| log("Mapping %s.%s (%s).\n", mod, cell, cell->type.unescape()); | |
| mapper(mod, cell); | |
| mod->remove(cell); | |
| } | |
| } | |
| } | |
| } SimplemapPass; | |
| PRIVATE_NAMESPACE_END | |