mirror of
https://github.com/YosysHQ/yosys
synced 2025-07-31 08:23:19 +00:00
Merge branch 'eddie/abc9_refactor' into xaig_dff
This commit is contained in:
commit
24c934f1af
171 changed files with 6745 additions and 4523 deletions
|
@ -30,6 +30,7 @@
|
|||
#include <libkern/OSByteOrder.h>
|
||||
#define __builtin_bswap32 OSSwapInt32
|
||||
#endif
|
||||
#define __STDC_FORMAT_MACROS
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "kernel/yosys.h"
|
||||
|
@ -151,12 +152,12 @@ struct ConstEvalAig
|
|||
|
||||
RTLIL::State eval_ret = RTLIL::Sx;
|
||||
if (cell->type == "$_NOT_") {
|
||||
if (sig_a == RTLIL::S0) eval_ret = RTLIL::S1;
|
||||
else if (sig_a == RTLIL::S1) eval_ret = RTLIL::S0;
|
||||
if (sig_a == State::S0) eval_ret = State::S1;
|
||||
else if (sig_a == State::S1) eval_ret = State::S0;
|
||||
}
|
||||
else if (cell->type == "$_AND_") {
|
||||
if (sig_a == RTLIL::S0) {
|
||||
eval_ret = RTLIL::S0;
|
||||
if (sig_a == State::S0) {
|
||||
eval_ret = State::S0;
|
||||
goto eval_end;
|
||||
}
|
||||
|
||||
|
@ -164,15 +165,15 @@ struct ConstEvalAig
|
|||
RTLIL::SigBit sig_b = cell->getPort("\\B");
|
||||
if (!eval(sig_b))
|
||||
return false;
|
||||
if (sig_b == RTLIL::S0) {
|
||||
eval_ret = RTLIL::S0;
|
||||
if (sig_b == State::S0) {
|
||||
eval_ret = State::S0;
|
||||
goto eval_end;
|
||||
}
|
||||
|
||||
if (sig_a != RTLIL::S1 || sig_b != RTLIL::S1)
|
||||
if (sig_a != State::S1 || sig_b != State::S1)
|
||||
goto eval_end;
|
||||
|
||||
eval_ret = RTLIL::S1;
|
||||
eval_ret = State::S1;
|
||||
}
|
||||
}
|
||||
else log_abort();
|
||||
|
@ -256,7 +257,7 @@ end_of_header:
|
|||
|
||||
RTLIL::Wire* n0 = module->wire("\\__0__");
|
||||
if (n0)
|
||||
module->connect(n0, RTLIL::S0);
|
||||
module->connect(n0, State::S0);
|
||||
|
||||
// Parse footer (symbol table, comments, etc.)
|
||||
unsigned l1;
|
||||
|
@ -301,7 +302,11 @@ static uint32_t parse_xaiger_literal(std::istream &f)
|
|||
uint32_t l;
|
||||
f.read(reinterpret_cast<char*>(&l), sizeof(l));
|
||||
if (f.gcount() != sizeof(l))
|
||||
#if defined(_WIN32) && defined(__MINGW32__)
|
||||
log_error("Offset %I64d: unable to read literal!\n", static_cast<int64_t>(f.tellg()));
|
||||
#else
|
||||
log_error("Offset %" PRId64 ": unable to read literal!\n", static_cast<int64_t>(f.tellg()));
|
||||
#endif
|
||||
return from_big_endian(l);
|
||||
}
|
||||
|
||||
|
@ -333,7 +338,7 @@ static RTLIL::Wire* createWireIfNotExists(RTLIL::Module *module, unsigned litera
|
|||
return wire;
|
||||
}
|
||||
|
||||
void AigerReader::parse_xaiger()
|
||||
void AigerReader::parse_xaiger(const dict<int,IdString> &box_lookup)
|
||||
{
|
||||
std::string header;
|
||||
f >> header;
|
||||
|
@ -367,22 +372,7 @@ void AigerReader::parse_xaiger()
|
|||
|
||||
RTLIL::Wire* n0 = module->wire("\\__0__");
|
||||
if (n0)
|
||||
module->connect(n0, RTLIL::S0);
|
||||
|
||||
dict<int,IdString> box_lookup;
|
||||
for (auto m : design->modules()) {
|
||||
auto it = m->attributes.find("\\abc_box_id");
|
||||
if (it == m->attributes.end())
|
||||
continue;
|
||||
if (m->name.begins_with("$paramod"))
|
||||
continue;
|
||||
auto id = it->second.as_int();
|
||||
auto r = box_lookup.insert(std::make_pair(id, m->name));
|
||||
if (!r.second)
|
||||
log_error("Module '%s' has the same abc_box_id = %d value as '%s'.\n",
|
||||
log_id(m), id, log_id(r.first->second));
|
||||
log_assert(r.second);
|
||||
}
|
||||
module->connect(n0, State::S0);
|
||||
|
||||
// Parse footer (symbol table, comments, etc.)
|
||||
std::string s;
|
||||
|
@ -534,9 +524,9 @@ void AigerReader::parse_aiger_ascii()
|
|||
log_error("Line %u cannot be interpreted as a latch!\n", line_count);
|
||||
|
||||
if (l3 == 0)
|
||||
q_wire->attributes["\\init"] = RTLIL::S0;
|
||||
q_wire->attributes["\\init"] = State::S0;
|
||||
else if (l3 == 1)
|
||||
q_wire->attributes["\\init"] = RTLIL::S1;
|
||||
q_wire->attributes["\\init"] = State::S1;
|
||||
else if (l3 == l1) {
|
||||
//q_wire->attributes["\\init"] = RTLIL::Sx;
|
||||
}
|
||||
|
@ -545,7 +535,7 @@ void AigerReader::parse_aiger_ascii()
|
|||
}
|
||||
else {
|
||||
// AIGER latches are assumed to be initialized to zero
|
||||
q_wire->attributes["\\init"] = RTLIL::S0;
|
||||
q_wire->attributes["\\init"] = State::S0;
|
||||
}
|
||||
latches.push_back(q_wire);
|
||||
}
|
||||
|
@ -661,9 +651,9 @@ void AigerReader::parse_aiger_binary()
|
|||
log_error("Line %u cannot be interpreted as a latch!\n", line_count);
|
||||
|
||||
if (l3 == 0)
|
||||
q_wire->attributes["\\init"] = RTLIL::S0;
|
||||
q_wire->attributes["\\init"] = State::S0;
|
||||
else if (l3 == 1)
|
||||
q_wire->attributes["\\init"] = RTLIL::S1;
|
||||
q_wire->attributes["\\init"] = State::S1;
|
||||
else if (l3 == l1) {
|
||||
//q_wire->attributes["\\init"] = RTLIL::Sx;
|
||||
}
|
||||
|
@ -672,7 +662,7 @@ void AigerReader::parse_aiger_binary()
|
|||
}
|
||||
else {
|
||||
// AIGER latches are assumed to be initialized to zero
|
||||
q_wire->attributes["\\init"] = RTLIL::S0;
|
||||
q_wire->attributes["\\init"] = State::S0;
|
||||
}
|
||||
latches.push_back(q_wire);
|
||||
}
|
||||
|
@ -1044,16 +1034,17 @@ void AigerReader::post_process()
|
|||
}
|
||||
|
||||
module->fixup_ports();
|
||||
|
||||
// Insert into a new (temporary) design so that "clean" will only
|
||||
// operate (and run checks on) this one module
|
||||
RTLIL::Design *mapped_design = new RTLIL::Design;
|
||||
mapped_design->add(module);
|
||||
Pass::call(mapped_design, "clean");
|
||||
mapped_design->modules_.erase(module->name);
|
||||
delete mapped_design;
|
||||
|
||||
design->add(module);
|
||||
|
||||
design->selection_stack.emplace_back(false);
|
||||
RTLIL::Selection& sel = design->selection_stack.back();
|
||||
sel.select(module);
|
||||
|
||||
Pass::call(design, "clean");
|
||||
|
||||
design->selection_stack.pop_back();
|
||||
|
||||
for (auto cell : module->cells().to_vector()) {
|
||||
if (cell->type != "$lut") continue;
|
||||
auto y_port = cell->getPort("\\Y").as_bit();
|
||||
|
@ -1124,8 +1115,8 @@ struct AigerFrontend : public Frontend {
|
|||
if (module_name.empty()) {
|
||||
#ifdef _WIN32
|
||||
char fname[_MAX_FNAME];
|
||||
_splitpath(filename.c_str(), NULL /* drive */, NULL /* dir */, fname, NULL /* ext */)
|
||||
module_name = fname;
|
||||
_splitpath(filename.c_str(), NULL /* drive */, NULL /* dir */, fname, NULL /* ext */);
|
||||
module_name = fname;
|
||||
#else
|
||||
char* bn = strdup(filename.c_str());
|
||||
module_name = RTLIL::escape_id(bn);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue