mirror of https://github.com/YosysHQ/yosys.git
Aiger use newcelltypes.
This commit is contained in:
parent
6d4736269b
commit
cae54a4c7b
|
|
@ -23,7 +23,7 @@
|
||||||
// - zero-width operands
|
// - zero-width operands
|
||||||
|
|
||||||
#include "kernel/register.h"
|
#include "kernel/register.h"
|
||||||
#include "kernel/celltypes.h"
|
#include "kernel/newcelltypes.h"
|
||||||
#include "kernel/rtlil.h"
|
#include "kernel/rtlil.h"
|
||||||
|
|
||||||
USING_YOSYS_NAMESPACE
|
USING_YOSYS_NAMESPACE
|
||||||
|
|
@ -45,10 +45,30 @@ PRIVATE_NAMESPACE_BEGIN
|
||||||
// TODO
|
// TODO
|
||||||
//#define ARITH_OPS ID($add), ID($sub), ID($neg)
|
//#define ARITH_OPS ID($add), ID($sub), ID($neg)
|
||||||
|
|
||||||
// TODO convert to newcelltypes
|
static constexpr auto known_ops = []() constexpr {
|
||||||
|
StaticCellTypes::Categories::Category c{};
|
||||||
#define KNOWN_OPS BITWISE_OPS, REDUCE_OPS, LOGIC_OPS, GATE_OPS, ID($pos), CMP_OPS, \
|
// bitwise
|
||||||
ID($pmux), ID($bmux) /*, ARITH_OPS*/
|
for (auto id : {ID($buf), ID($not), ID($mux), ID($and), ID($or), ID($xor), ID($xnor), ID($fa), ID($bwmux)})
|
||||||
|
c.set_id(id);
|
||||||
|
// reduce
|
||||||
|
for (auto id : {ID($reduce_and), ID($reduce_or), ID($reduce_xor), ID($reduce_xnor), ID($reduce_bool)})
|
||||||
|
c.set_id(id);
|
||||||
|
// logic
|
||||||
|
for (auto id : {ID($logic_and), ID($logic_or), ID($logic_not)})
|
||||||
|
c.set_id(id);
|
||||||
|
// gates
|
||||||
|
for (auto id : {ID($_BUF_), ID($_NOT_), ID($_AND_), ID($_NAND_), ID($_OR_), ID($_NOR_),
|
||||||
|
ID($_XOR_), ID($_XNOR_), ID($_ANDNOT_), ID($_ORNOT_), ID($_MUX_), ID($_NMUX_),
|
||||||
|
ID($_AOI3_), ID($_OAI3_), ID($_AOI4_), ID($_OAI4_)})
|
||||||
|
c.set_id(id);
|
||||||
|
// compare
|
||||||
|
for (auto id : {ID($eq), ID($ne), ID($lt), ID($le), ID($ge), ID($gt)})
|
||||||
|
c.set_id(id);
|
||||||
|
// other
|
||||||
|
for (auto id : {ID($pos), ID($pmux), ID($bmux)})
|
||||||
|
c.set_id(id);
|
||||||
|
return c;
|
||||||
|
}();
|
||||||
|
|
||||||
template<typename Writer, typename Lit, Lit CFALSE, Lit CTRUE>
|
template<typename Writer, typename Lit, Lit CFALSE, Lit CTRUE>
|
||||||
struct Index {
|
struct Index {
|
||||||
|
|
@ -94,7 +114,7 @@ struct Index {
|
||||||
int pos = index_wires(info, m);
|
int pos = index_wires(info, m);
|
||||||
|
|
||||||
for (auto cell : m->cells()) {
|
for (auto cell : m->cells()) {
|
||||||
if (cell->type.in(KNOWN_OPS) || cell->type.in(ID($scopeinfo), ID($specify2), ID($specify3), ID($input_port)))
|
if (known_ops(cell->type) || cell->type.in(ID($scopeinfo), ID($specify2), ID($specify3), ID($input_port)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Module *submodule = m->design->module(cell->type);
|
Module *submodule = m->design->module(cell->type);
|
||||||
|
|
@ -106,7 +126,7 @@ struct Index {
|
||||||
pos += index_module(submodule);
|
pos += index_module(submodule);
|
||||||
} else {
|
} else {
|
||||||
if (allow_blackboxes) {
|
if (allow_blackboxes) {
|
||||||
info.found_blackboxes.insert(cell);
|
info.found_blackboxes.insert(cell);
|
||||||
} else {
|
} else {
|
||||||
// Even if we don't allow blackboxes these might still be
|
// Even if we don't allow blackboxes these might still be
|
||||||
// present outside of any traversed input cones, so we
|
// present outside of any traversed input cones, so we
|
||||||
|
|
@ -271,7 +291,7 @@ struct Index {
|
||||||
} else if (cell->type.in(ID($lt), ID($le), ID($gt), ID($ge))) {
|
} else if (cell->type.in(ID($lt), ID($le), ID($gt), ID($ge))) {
|
||||||
if (cell->type.in(ID($gt), ID($ge)))
|
if (cell->type.in(ID($gt), ID($ge)))
|
||||||
std::swap(aport, bport);
|
std::swap(aport, bport);
|
||||||
int carry = cell->type.in(ID($le), ID($ge)) ? CFALSE : CTRUE;
|
int carry = cell->type.in(ID($le), ID($ge)) ? CFALSE : CTRUE;
|
||||||
Lit a = Writer::EMPTY_LIT;
|
Lit a = Writer::EMPTY_LIT;
|
||||||
Lit b = Writer::EMPTY_LIT;
|
Lit b = Writer::EMPTY_LIT;
|
||||||
// TODO: this might not be the most economic structure; revisit at a later date
|
// TODO: this might not be the most economic structure; revisit at a later date
|
||||||
|
|
@ -581,7 +601,7 @@ struct Index {
|
||||||
// an output of a cell
|
// an output of a cell
|
||||||
Cell *driver = bit.wire->driverCell();
|
Cell *driver = bit.wire->driverCell();
|
||||||
|
|
||||||
if (driver->type.in(KNOWN_OPS)) {
|
if (known_ops(driver->type)) {
|
||||||
ret = impl_op(cursor, driver, bit.wire->driverPort(), bit.offset);
|
ret = impl_op(cursor, driver, bit.wire->driverPort(), bit.offset);
|
||||||
} else {
|
} else {
|
||||||
Module *def = cursor.enter(*this, driver);
|
Module *def = cursor.enter(*this, driver);
|
||||||
|
|
@ -918,15 +938,15 @@ struct XAigerWriter : AigerWriter {
|
||||||
std::vector<HierBit> pos;
|
std::vector<HierBit> pos;
|
||||||
std::vector<HierBit> pis;
|
std::vector<HierBit> pis;
|
||||||
|
|
||||||
// * The aiger output port sequence is COs (inputs to modeled boxes),
|
// * The aiger output port sequence is COs (inputs to modeled boxes),
|
||||||
// inputs to opaque boxes, then module outputs. COs going first is
|
// inputs to opaque boxes, then module outputs. COs going first is
|
||||||
// required by abc.
|
// required by abc.
|
||||||
// * proper_pos_counter counts ports which follow after COs
|
// * proper_pos_counter counts ports which follow after COs
|
||||||
// * The mapping file `pseudopo` and `po` statements use indexing relative
|
// * The mapping file `pseudopo` and `po` statements use indexing relative
|
||||||
// to the first port following COs.
|
// to the first port following COs.
|
||||||
// * If a module output is directly driven by an opaque box, the emission
|
// * If a module output is directly driven by an opaque box, the emission
|
||||||
// of the po statement in the mapping file is skipped. This is done to
|
// of the po statement in the mapping file is skipped. This is done to
|
||||||
// aid re-integration of the mapped result.
|
// aid re-integration of the mapped result.
|
||||||
int proper_pos_counter = 0;
|
int proper_pos_counter = 0;
|
||||||
|
|
||||||
pool<SigBit> driven_by_opaque_box;
|
pool<SigBit> driven_by_opaque_box;
|
||||||
|
|
@ -1333,41 +1353,50 @@ struct Aiger2Backend : Backend {
|
||||||
log(" perform structural hashing while writing\n");
|
log(" perform structural hashing while writing\n");
|
||||||
log("\n");
|
log("\n");
|
||||||
log(" -flatten\n");
|
log(" -flatten\n");
|
||||||
log(" allow descending into submodules and write a flattened view of the design\n");
|
log(" allow descending into submodules and write a flattened view of the design\n");
|
||||||
log(" hierarchy starting at the selected top\n");
|
log(" hierarchy starting at the selected top\n");
|
||||||
log("\n");
|
log("\n");
|
||||||
log("This command is able to ingest all combinational cells except for:\n");
|
log("This command is able to ingest all combinational cells except for:\n");
|
||||||
log("\n");
|
log("\n");
|
||||||
pool<IdString> supported = {KNOWN_OPS};
|
|
||||||
CellTypes ct;
|
|
||||||
ct.setup_internals_eval();
|
|
||||||
log(" ");
|
log(" ");
|
||||||
int col = 0;
|
int col = 0;
|
||||||
for (auto pair : ct.cell_types)
|
for (size_t i = 0; i < StaticCellTypes::builder.count; i++) {
|
||||||
if (!supported.count(pair.first)) {
|
auto &cell = StaticCellTypes::builder.cells[i];
|
||||||
if (col + pair.first.size() + 2 > 72) {
|
if (!cell.features.is_evaluable)
|
||||||
|
continue;
|
||||||
|
if (cell.features.is_stdcell)
|
||||||
|
continue;
|
||||||
|
if (known_ops(cell.type))
|
||||||
|
continue;
|
||||||
|
std::string name = log_id(cell.type);
|
||||||
|
if (col + name.size() + 2 > 72) {
|
||||||
log("\n ");
|
log("\n ");
|
||||||
col = 0;
|
col = 0;
|
||||||
}
|
}
|
||||||
col += pair.first.size() + 2;
|
col += name.size() + 2;
|
||||||
log("%s, ", log_id(pair.first));
|
log("%s, ", name.c_str());
|
||||||
}
|
}
|
||||||
log("\n");
|
log("\n");
|
||||||
log("\n");
|
log("\n");
|
||||||
log("And all combinational gates except for:\n");
|
log("And all combinational gates except for:\n");
|
||||||
log("\n");
|
log("\n");
|
||||||
CellTypes ct2;
|
|
||||||
ct2.setup_stdcells();
|
|
||||||
log(" ");
|
log(" ");
|
||||||
col = 0;
|
col = 0;
|
||||||
for (auto pair : ct2.cell_types)
|
for (size_t i = 0; i < StaticCellTypes::builder.count; i++) {
|
||||||
if (!supported.count(pair.first)) {
|
auto &cell = StaticCellTypes::builder.cells[i];
|
||||||
if (col + pair.first.size() + 2 > 72) {
|
if (!cell.features.is_evaluable)
|
||||||
|
continue;
|
||||||
|
if (!cell.features.is_stdcell)
|
||||||
|
continue;
|
||||||
|
if (known_ops(cell.type))
|
||||||
|
continue;
|
||||||
|
std::string name = log_id(cell.type);
|
||||||
|
if (col + name.size() + 2 > 72) {
|
||||||
log("\n ");
|
log("\n ");
|
||||||
col = 0;
|
col = 0;
|
||||||
}
|
}
|
||||||
col += pair.first.size() + 2;
|
col += name.size() + 2;
|
||||||
log("%s, ", log_id(pair.first));
|
log("%s, ", name.c_str());
|
||||||
}
|
}
|
||||||
log("\n");
|
log("\n");
|
||||||
}
|
}
|
||||||
|
|
@ -1425,20 +1454,20 @@ struct XAiger2Backend : Backend {
|
||||||
log(" perform structural hashing while writing\n");
|
log(" perform structural hashing while writing\n");
|
||||||
log("\n");
|
log("\n");
|
||||||
log(" -flatten\n");
|
log(" -flatten\n");
|
||||||
log(" allow descending into submodules and write a flattened view of the design\n");
|
log(" allow descending into submodules and write a flattened view of the design\n");
|
||||||
log(" hierarchy starting at the selected top\n");
|
log(" hierarchy starting at the selected top\n");
|
||||||
log("\n");
|
log("\n");
|
||||||
log(" -mapping_prep\n");
|
log(" -mapping_prep\n");
|
||||||
log(" after the file is written, prepare the module for reintegration of\n");
|
log(" after the file is written, prepare the module for reintegration of\n");
|
||||||
log(" a mapping in a subsequent command. all cells which are not blackboxed nor\n");
|
log(" a mapping in a subsequent command. all cells which are not blackboxed nor\n");
|
||||||
log(" whiteboxed are removed from the design as well as all wires which only\n");
|
log(" whiteboxed are removed from the design as well as all wires which only\n");
|
||||||
log(" connect to removed cells\n");
|
log(" connect to removed cells\n");
|
||||||
log(" (conflicts with -flatten)\n");
|
log(" (conflicts with -flatten)\n");
|
||||||
log("\n");
|
log("\n");
|
||||||
log(" -map2 <file>\n");
|
log(" -map2 <file>\n");
|
||||||
log(" write a map2 file which 'read_xaiger2 -sc_mapping' can read to\n");
|
log(" write a map2 file which 'read_xaiger2 -sc_mapping' can read to\n");
|
||||||
log(" reintegrate a mapping\n");
|
log(" reintegrate a mapping\n");
|
||||||
log(" (conflicts with -flatten)\n");
|
log(" (conflicts with -flatten)\n");
|
||||||
log("\n");
|
log("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue