mirror of
https://github.com/YosysHQ/yosys
synced 2026-07-26 00:52:35 +00:00
Merge upstream yosys
This commit is contained in:
commit
5f5ed1b29e
41 changed files with 920 additions and 237 deletions
|
|
@ -41,7 +41,7 @@ struct statdata_t
|
|||
X(num_ports) X(num_port_bits) X(num_memories) X(num_memory_bits) X(num_cells) \
|
||||
X(num_processes)
|
||||
|
||||
#define STAT_NUMERIC_MEMBERS STAT_INT_MEMBERS X(area)
|
||||
#define STAT_NUMERIC_MEMBERS STAT_INT_MEMBERS X(area) X(sequential_area)
|
||||
|
||||
#define X(_name) unsigned int _name;
|
||||
STAT_INT_MEMBERS
|
||||
|
|
|
|||
|
|
@ -994,6 +994,11 @@ struct HierarchyPass : public Pass {
|
|||
}
|
||||
}
|
||||
|
||||
bool verific_mod = false;
|
||||
#ifdef YOSYS_ENABLE_VERIFIC
|
||||
verific_mod = verific_import_pending;
|
||||
#endif
|
||||
|
||||
if (top_mod == nullptr && !load_top_mod.empty()) {
|
||||
#ifdef YOSYS_ENABLE_VERIFIC
|
||||
if (verific_import_pending) {
|
||||
|
|
@ -1434,13 +1439,18 @@ struct HierarchyPass : public Pass {
|
|||
if (m == nullptr)
|
||||
continue;
|
||||
|
||||
if (m->get_blackbox_attribute() && !cell->parameters.empty() && m->get_bool_attribute(ID::dynports)) {
|
||||
IdString new_m_name = m->derive(design, cell->parameters, true);
|
||||
if (new_m_name.empty())
|
||||
continue;
|
||||
if (new_m_name != m->name) {
|
||||
m = design->module(new_m_name);
|
||||
blackbox_derivatives.insert(m);
|
||||
bool boxed_params = false;
|
||||
if (m->get_blackbox_attribute() && !cell->parameters.empty()) {
|
||||
if (m->get_bool_attribute(ID::dynports)) {
|
||||
IdString new_m_name = m->derive(design, cell->parameters, true);
|
||||
if (new_m_name.empty())
|
||||
continue;
|
||||
if (new_m_name != m->name) {
|
||||
m = design->module(new_m_name);
|
||||
blackbox_derivatives.insert(m);
|
||||
}
|
||||
} else {
|
||||
boxed_params = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1456,8 +1466,12 @@ struct HierarchyPass : public Pass {
|
|||
|
||||
SigSpec sig = conn.second;
|
||||
|
||||
if (!keep_portwidths && GetSize(w) != GetSize(conn.second))
|
||||
{
|
||||
bool resize_widths = !keep_portwidths && GetSize(w) != GetSize(conn.second);
|
||||
if (resize_widths && verific_mod && boxed_params)
|
||||
log_warning("Ignoring width mismatch on %s.%s.%s from verific, is port width parametrizable?\n",
|
||||
log_id(module), log_id(cell), log_id(conn.first)
|
||||
);
|
||||
else if (resize_widths) {
|
||||
if (GetSize(w) < GetSize(conn.second))
|
||||
{
|
||||
int n = GetSize(conn.second) - GetSize(w);
|
||||
|
|
|
|||
|
|
@ -2232,11 +2232,11 @@ struct MemoryLibMapPass : public Pass {
|
|||
if (module->has_processes_warn())
|
||||
continue;
|
||||
|
||||
MapWorker worker(module);
|
||||
auto worker = std::make_unique<MapWorker>(module);
|
||||
auto mems = Mem::get_selected_memories(module);
|
||||
for (auto &mem : mems)
|
||||
{
|
||||
MemMapping map(worker, mem, lib, opts);
|
||||
MemMapping map(*worker, mem, lib, opts);
|
||||
int idx = -1;
|
||||
int best = map.logic_cost;
|
||||
if (!map.logic_ok) {
|
||||
|
|
@ -2259,7 +2259,7 @@ struct MemoryLibMapPass : public Pass {
|
|||
} else {
|
||||
map.emit(map.cfgs[idx]);
|
||||
// Rebuild indices after modifying module
|
||||
worker = MapWorker(module);
|
||||
worker = std::make_unique<MapWorker>(module);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ struct ShareWorker
|
|||
// Code for sharing and comparing MACC cells
|
||||
// ---------------------------------------------------
|
||||
|
||||
static int bits_macc_port(const Macc::port_t &p, int width)
|
||||
static int bits_macc_term(const Macc::term_t &p, int width)
|
||||
{
|
||||
if (GetSize(p.in_a) == 0 || GetSize(p.in_b) == 0)
|
||||
return min(max(GetSize(p.in_a), GetSize(p.in_b)), width);
|
||||
|
|
@ -120,8 +120,8 @@ struct ShareWorker
|
|||
static int bits_macc(const Macc &m, int width)
|
||||
{
|
||||
int bits = 0;
|
||||
for (auto &p : m.ports)
|
||||
bits += bits_macc_port(p, width);
|
||||
for (auto &p : m.terms)
|
||||
bits += bits_macc_term(p, width);
|
||||
return bits;
|
||||
}
|
||||
|
||||
|
|
@ -132,7 +132,7 @@ struct ShareWorker
|
|||
return bits_macc(m, width);
|
||||
}
|
||||
|
||||
static bool cmp_macc_ports(const Macc::port_t &p1, const Macc::port_t &p2)
|
||||
static bool cmp_macc_ports(const Macc::term_t &p1, const Macc::term_t &p2)
|
||||
{
|
||||
bool mul1 = GetSize(p1.in_a) && GetSize(p1.in_b);
|
||||
bool mul2 = GetSize(p2.in_a) && GetSize(p2.in_b);
|
||||
|
|
@ -161,7 +161,7 @@ struct ShareWorker
|
|||
return false;
|
||||
}
|
||||
|
||||
int share_macc_ports(Macc::port_t &p1, Macc::port_t &p2, int w1, int w2,
|
||||
int share_macc_ports(Macc::term_t &p1, Macc::term_t &p2, int w1, int w2,
|
||||
RTLIL::SigSpec act = RTLIL::SigSpec(), Macc *supermacc = nullptr, pool<RTLIL::Cell*> *supercell_aux = nullptr)
|
||||
{
|
||||
if (p1.do_subtract != p2.do_subtract)
|
||||
|
|
@ -216,12 +216,12 @@ struct ShareWorker
|
|||
supercell_aux->insert(module->addMux(NEW_ID, sig_b2, sig_b1, act, sig_b));
|
||||
}
|
||||
|
||||
Macc::port_t p;
|
||||
Macc::term_t p;
|
||||
p.in_a = sig_a;
|
||||
p.in_b = sig_b;
|
||||
p.is_signed = force_signed;
|
||||
p.do_subtract = p1.do_subtract;
|
||||
supermacc->ports.push_back(p);
|
||||
supermacc->terms.push_back(p);
|
||||
}
|
||||
|
||||
int score = 1000 + abs(GetSize(p1.in_a) - GetSize(p2.in_a)) * max(abs(GetSize(p1.in_b) - GetSize(p2.in_b)), 1);
|
||||
|
|
@ -248,15 +248,15 @@ struct ShareWorker
|
|||
m1.optimize(w1);
|
||||
m2.optimize(w2);
|
||||
|
||||
std::sort(m1.ports.begin(), m1.ports.end(), cmp_macc_ports);
|
||||
std::sort(m2.ports.begin(), m2.ports.end(), cmp_macc_ports);
|
||||
std::sort(m1.terms.begin(), m1.terms.end(), cmp_macc_ports);
|
||||
std::sort(m2.terms.begin(), m2.terms.end(), cmp_macc_ports);
|
||||
|
||||
std::set<int> m1_unmapped, m2_unmapped;
|
||||
|
||||
for (int i = 0; i < GetSize(m1.ports); i++)
|
||||
for (int i = 0; i < GetSize(m1.terms); i++)
|
||||
m1_unmapped.insert(i);
|
||||
|
||||
for (int i = 0; i < GetSize(m2.ports); i++)
|
||||
for (int i = 0; i < GetSize(m2.terms); i++)
|
||||
m2_unmapped.insert(i);
|
||||
|
||||
while (1)
|
||||
|
|
@ -265,7 +265,7 @@ struct ShareWorker
|
|||
|
||||
for (int i : m1_unmapped)
|
||||
for (int j : m2_unmapped) {
|
||||
int score = share_macc_ports(m1.ports[i], m2.ports[j], w1, w2);
|
||||
int score = share_macc_ports(m1.terms[i], m2.terms[j], w1, w2);
|
||||
if (score >= 0 && (best_i < 0 || best_score > score))
|
||||
best_i = i, best_j = j, best_score = score;
|
||||
}
|
||||
|
|
@ -273,55 +273,55 @@ struct ShareWorker
|
|||
if (best_i >= 0) {
|
||||
m1_unmapped.erase(best_i);
|
||||
m2_unmapped.erase(best_j);
|
||||
share_macc_ports(m1.ports[best_i], m2.ports[best_j], w1, w2, act, &supermacc, supercell_aux);
|
||||
share_macc_ports(m1.terms[best_i], m2.terms[best_j], w1, w2, act, &supermacc, supercell_aux);
|
||||
} else
|
||||
break;
|
||||
}
|
||||
|
||||
for (int i : m1_unmapped)
|
||||
{
|
||||
RTLIL::SigSpec sig_a = m1.ports[i].in_a;
|
||||
RTLIL::SigSpec sig_b = m1.ports[i].in_b;
|
||||
RTLIL::SigSpec sig_a = m1.terms[i].in_a;
|
||||
RTLIL::SigSpec sig_b = m1.terms[i].in_b;
|
||||
|
||||
if (supercell_aux && GetSize(sig_a)) {
|
||||
sig_a = module->addWire(NEW_ID, GetSize(sig_a));
|
||||
supercell_aux->insert(module->addMux(NEW_ID, RTLIL::SigSpec(0, GetSize(sig_a)), m1.ports[i].in_a, act, sig_a));
|
||||
supercell_aux->insert(module->addMux(NEW_ID, RTLIL::SigSpec(0, GetSize(sig_a)), m1.terms[i].in_a, act, sig_a));
|
||||
}
|
||||
|
||||
if (supercell_aux && GetSize(sig_b)) {
|
||||
sig_b = module->addWire(NEW_ID, GetSize(sig_b));
|
||||
supercell_aux->insert(module->addMux(NEW_ID, RTLIL::SigSpec(0, GetSize(sig_b)), m1.ports[i].in_b, act, sig_b));
|
||||
supercell_aux->insert(module->addMux(NEW_ID, RTLIL::SigSpec(0, GetSize(sig_b)), m1.terms[i].in_b, act, sig_b));
|
||||
}
|
||||
|
||||
Macc::port_t p;
|
||||
Macc::term_t p;
|
||||
p.in_a = sig_a;
|
||||
p.in_b = sig_b;
|
||||
p.is_signed = m1.ports[i].is_signed;
|
||||
p.do_subtract = m1.ports[i].do_subtract;
|
||||
supermacc.ports.push_back(p);
|
||||
p.is_signed = m1.terms[i].is_signed;
|
||||
p.do_subtract = m1.terms[i].do_subtract;
|
||||
supermacc.terms.push_back(p);
|
||||
}
|
||||
|
||||
for (int i : m2_unmapped)
|
||||
{
|
||||
RTLIL::SigSpec sig_a = m2.ports[i].in_a;
|
||||
RTLIL::SigSpec sig_b = m2.ports[i].in_b;
|
||||
RTLIL::SigSpec sig_a = m2.terms[i].in_a;
|
||||
RTLIL::SigSpec sig_b = m2.terms[i].in_b;
|
||||
|
||||
if (supercell_aux && GetSize(sig_a)) {
|
||||
sig_a = module->addWire(NEW_ID, GetSize(sig_a));
|
||||
supercell_aux->insert(module->addMux(NEW_ID, m2.ports[i].in_a, RTLIL::SigSpec(0, GetSize(sig_a)), act, sig_a));
|
||||
supercell_aux->insert(module->addMux(NEW_ID, m2.terms[i].in_a, RTLIL::SigSpec(0, GetSize(sig_a)), act, sig_a));
|
||||
}
|
||||
|
||||
if (supercell_aux && GetSize(sig_b)) {
|
||||
sig_b = module->addWire(NEW_ID, GetSize(sig_b));
|
||||
supercell_aux->insert(module->addMux(NEW_ID, m2.ports[i].in_b, RTLIL::SigSpec(0, GetSize(sig_b)), act, sig_b));
|
||||
supercell_aux->insert(module->addMux(NEW_ID, m2.terms[i].in_b, RTLIL::SigSpec(0, GetSize(sig_b)), act, sig_b));
|
||||
}
|
||||
|
||||
Macc::port_t p;
|
||||
Macc::term_t p;
|
||||
p.in_a = sig_a;
|
||||
p.in_b = sig_b;
|
||||
p.is_signed = m2.ports[i].is_signed;
|
||||
p.do_subtract = m2.ports[i].do_subtract;
|
||||
supermacc.ports.push_back(p);
|
||||
p.is_signed = m2.terms[i].is_signed;
|
||||
p.do_subtract = m2.terms[i].do_subtract;
|
||||
supermacc.terms.push_back(p);
|
||||
}
|
||||
|
||||
if (supercell)
|
||||
|
|
@ -1000,6 +1000,61 @@ struct ShareWorker
|
|||
}
|
||||
}
|
||||
|
||||
pool<std::pair<SigBit, State>> pattern_bits(const pool<ssc_pair_t> &activation_patterns)
|
||||
{
|
||||
pool<std::pair<SigBit, State>> bits;
|
||||
for (auto const &pattern : activation_patterns) {
|
||||
for (int i = 0; i < GetSize(pattern.second); ++i) {
|
||||
SigBit bit = pattern.first[i];
|
||||
State val = pattern.second[i];
|
||||
bits.emplace(bit, val);
|
||||
}
|
||||
}
|
||||
return bits;
|
||||
}
|
||||
|
||||
bool onesided_restrict_activation_patterns(
|
||||
pool<ssc_pair_t> &activation_patterns, const pool<std::pair<SigBit, State>> &other_bits)
|
||||
{
|
||||
pool<ssc_pair_t> new_activation_patterns;
|
||||
|
||||
bool simplified = false;
|
||||
|
||||
for (auto const &pattern : activation_patterns) {
|
||||
ssc_pair_t new_pair;
|
||||
for (int i = 0; i < GetSize(pattern.second); ++i) {
|
||||
SigBit bit = pattern.first[i];
|
||||
State val = pattern.second[i];
|
||||
if (other_bits.count({bit, val == State::S0 ? State::S1 : State::S0})) {
|
||||
new_pair.first.append(bit);
|
||||
new_pair.second.append(val);
|
||||
} else {
|
||||
simplified = true;
|
||||
}
|
||||
}
|
||||
new_activation_patterns.emplace(std::move(new_pair));
|
||||
}
|
||||
|
||||
activation_patterns = std::move(new_activation_patterns);
|
||||
return simplified;
|
||||
}
|
||||
|
||||
// Only valid if the patterns on their own (i.e. without considering their input cone) are mutually exclusive!
|
||||
bool restrict_activation_patterns(pool<ssc_pair_t> &activation_patterns, pool<ssc_pair_t> &other_activation_patterns)
|
||||
{
|
||||
pool<std::pair<SigBit, State>> bits = pattern_bits(activation_patterns);
|
||||
pool<std::pair<SigBit, State>> other_bits = pattern_bits(other_activation_patterns);
|
||||
|
||||
bool simplified = false;
|
||||
simplified |= onesided_restrict_activation_patterns(activation_patterns, other_bits);
|
||||
simplified |= onesided_restrict_activation_patterns(other_activation_patterns, bits);
|
||||
|
||||
optimize_activation_patterns(activation_patterns);
|
||||
optimize_activation_patterns(other_activation_patterns);
|
||||
|
||||
return simplified;
|
||||
}
|
||||
|
||||
RTLIL::SigSpec make_cell_activation_logic(const pool<ssc_pair_t> &activation_patterns, pool<RTLIL::Cell*> &supercell_aux)
|
||||
{
|
||||
RTLIL::Wire *all_cases_wire = module->addWire(NEW_ID, 0);
|
||||
|
|
@ -1299,17 +1354,18 @@ struct ShareWorker
|
|||
other_cell_active.push_back(qcsat.ez->vec_eq(qcsat.importSig(p.first), qcsat.importSig(p.second)));
|
||||
all_ctrl_signals.append(p.first);
|
||||
}
|
||||
int sub1 = qcsat.ez->expression(qcsat.ez->OpOr, cell_active);
|
||||
int sub2 = qcsat.ez->expression(qcsat.ez->OpOr, other_cell_active);
|
||||
|
||||
bool pattern_only_solve = qcsat.ez->solve(qcsat.ez->AND(sub1, sub2));
|
||||
qcsat.prepare();
|
||||
|
||||
int sub1 = qcsat.ez->expression(qcsat.ez->OpOr, cell_active);
|
||||
if (!qcsat.ez->solve(sub1)) {
|
||||
log(" According to the SAT solver the cell %s is never active. Sharing is pointless, we simply remove it.\n", log_id(cell));
|
||||
cells_to_remove.insert(cell);
|
||||
break;
|
||||
}
|
||||
|
||||
int sub2 = qcsat.ez->expression(qcsat.ez->OpOr, other_cell_active);
|
||||
if (!qcsat.ez->solve(sub2)) {
|
||||
log(" According to the SAT solver the cell %s is never active. Sharing is pointless, we simply remove it.\n", log_id(other_cell));
|
||||
cells_to_remove.insert(other_cell);
|
||||
|
|
@ -1317,28 +1373,43 @@ struct ShareWorker
|
|||
continue;
|
||||
}
|
||||
|
||||
qcsat.ez->non_incremental();
|
||||
pool<ssc_pair_t> optimized_cell_activation_patterns = filtered_cell_activation_patterns;
|
||||
pool<ssc_pair_t> optimized_other_cell_activation_patterns = filtered_other_cell_activation_patterns;
|
||||
|
||||
all_ctrl_signals.sort_and_unify();
|
||||
std::vector<int> sat_model = qcsat.importSig(all_ctrl_signals);
|
||||
std::vector<bool> sat_model_values;
|
||||
if (pattern_only_solve) {
|
||||
qcsat.ez->non_incremental();
|
||||
|
||||
qcsat.ez->assume(qcsat.ez->AND(sub1, sub2));
|
||||
all_ctrl_signals.sort_and_unify();
|
||||
std::vector<int> sat_model = qcsat.importSig(all_ctrl_signals);
|
||||
std::vector<bool> sat_model_values;
|
||||
|
||||
log(" Size of SAT problem: %zu cells, %d variables, %d clauses\n",
|
||||
qcsat.imported_cells.size(), qcsat.ez->numCnfVariables(), qcsat.ez->numCnfClauses());
|
||||
qcsat.ez->assume(qcsat.ez->AND(sub1, sub2));
|
||||
|
||||
if (qcsat.ez->solve(sat_model, sat_model_values)) {
|
||||
log(" According to the SAT solver this pair of cells can not be shared.\n");
|
||||
log(" Model from SAT solver: %s = %d'", log_signal(all_ctrl_signals), GetSize(sat_model_values));
|
||||
for (int i = GetSize(sat_model_values)-1; i >= 0; i--)
|
||||
log("%c", sat_model_values[i] ? '1' : '0');
|
||||
log("\n");
|
||||
continue;
|
||||
log(" Size of SAT problem: %zu cells, %d variables, %d clauses\n",
|
||||
qcsat.imported_cells.size(), qcsat.ez->numCnfVariables(), qcsat.ez->numCnfClauses());
|
||||
|
||||
if (qcsat.ez->solve(sat_model, sat_model_values)) {
|
||||
log(" According to the SAT solver this pair of cells can not be shared.\n");
|
||||
log(" Model from SAT solver: %s = %d'", log_signal(all_ctrl_signals), GetSize(sat_model_values));
|
||||
for (int i = GetSize(sat_model_values)-1; i >= 0; i--)
|
||||
log("%c", sat_model_values[i] ? '1' : '0');
|
||||
log("\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
log(" According to the SAT solver this pair of cells can be shared.\n");
|
||||
} else {
|
||||
log(" According to the SAT solver this pair of cells can be shared. (Pattern only case)\n");
|
||||
|
||||
if (restrict_activation_patterns(optimized_cell_activation_patterns, optimized_other_cell_activation_patterns)) {
|
||||
for (auto &p : optimized_cell_activation_patterns)
|
||||
log(" Simplified activation pattern for cell %s: %s = %s\n", log_id(cell), log_signal(p.first), log_signal(p.second));
|
||||
|
||||
for (auto &p : optimized_other_cell_activation_patterns)
|
||||
log(" Simplified activation pattern for cell %s: %s = %s\n", log_id(other_cell), log_signal(p.first), log_signal(p.second));
|
||||
}
|
||||
}
|
||||
|
||||
log(" According to the SAT solver this pair of cells can be shared.\n");
|
||||
|
||||
if (find_in_input_cone(cell, other_cell)) {
|
||||
log(" Sharing not possible: %s is in input cone of %s.\n", log_id(other_cell), log_id(cell));
|
||||
continue;
|
||||
|
|
@ -1354,20 +1425,20 @@ struct ShareWorker
|
|||
int cell_select_score = 0;
|
||||
int other_cell_select_score = 0;
|
||||
|
||||
for (auto &p : filtered_cell_activation_patterns)
|
||||
for (auto &p : optimized_cell_activation_patterns)
|
||||
cell_select_score += p.first.size();
|
||||
|
||||
for (auto &p : filtered_other_cell_activation_patterns)
|
||||
for (auto &p : optimized_other_cell_activation_patterns)
|
||||
other_cell_select_score += p.first.size();
|
||||
|
||||
RTLIL::Cell *supercell;
|
||||
pool<RTLIL::Cell*> supercell_aux;
|
||||
if (cell_select_score <= other_cell_select_score) {
|
||||
RTLIL::SigSpec act = make_cell_activation_logic(filtered_cell_activation_patterns, supercell_aux);
|
||||
RTLIL::SigSpec act = make_cell_activation_logic(optimized_cell_activation_patterns, supercell_aux);
|
||||
supercell = make_supercell(cell, other_cell, act, supercell_aux);
|
||||
log(" Activation signal for %s: %s\n", log_id(cell), log_signal(act));
|
||||
} else {
|
||||
RTLIL::SigSpec act = make_cell_activation_logic(filtered_other_cell_activation_patterns, supercell_aux);
|
||||
RTLIL::SigSpec act = make_cell_activation_logic(optimized_other_cell_activation_patterns, supercell_aux);
|
||||
supercell = make_supercell(other_cell, cell, act, supercell_aux);
|
||||
log(" Activation signal for %s: %s\n", log_id(other_cell), log_signal(act));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,10 +37,20 @@ struct CutpointPass : public Pass {
|
|||
log(" set cutpoint nets to undef (x). the default behavior is to create\n");
|
||||
log(" an $anyseq cell and drive the cutpoint net from that\n");
|
||||
log("\n");
|
||||
log(" -noscopeinfo\n");
|
||||
log(" do not create '$scopeinfo' cells that preserve attributes of cells that\n");
|
||||
log(" were removed by this pass\n");
|
||||
log("\n");
|
||||
log(" cutpoint -blackbox [options]\n");
|
||||
log("\n");
|
||||
log("Replace all instances of blackboxes in the design with a formal cut point.\n");
|
||||
log("\n");
|
||||
}
|
||||
void execute(std::vector<std::string> args, RTLIL::Design *design) override
|
||||
{
|
||||
bool flag_undef = false;
|
||||
bool flag_undef = false;
|
||||
bool flag_scopeinfo = true;
|
||||
bool flag_blackbox = false;
|
||||
|
||||
log_header(design, "Executing CUTPOINT pass.\n");
|
||||
|
||||
|
|
@ -51,26 +61,31 @@ struct CutpointPass : public Pass {
|
|||
flag_undef = true;
|
||||
continue;
|
||||
}
|
||||
if (args[argidx] == "-noscopeinfo") {
|
||||
flag_scopeinfo = false;
|
||||
continue;
|
||||
}
|
||||
if (args[argidx] == "-blackbox") {
|
||||
flag_blackbox = true;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
extra_args(args, argidx, design);
|
||||
|
||||
for (auto module : design->selected_modules())
|
||||
{
|
||||
if (module->is_selected_whole()) {
|
||||
log("Making all outputs of module %s cut points, removing module contents.\n", log_id(module));
|
||||
module->new_connections(std::vector<RTLIL::SigSig>());
|
||||
for (auto cell : vector<Cell*>(module->cells()))
|
||||
module->remove(cell);
|
||||
vector<Wire*> output_wires;
|
||||
for (auto wire : module->wires())
|
||||
if (wire->port_output)
|
||||
output_wires.push_back(wire);
|
||||
for (auto wire : output_wires)
|
||||
module->connect(wire, flag_undef ? Const(State::Sx, GetSize(wire)) : module->Anyseq(NEW_ID, GetSize(wire)));
|
||||
continue;
|
||||
}
|
||||
if (flag_blackbox) {
|
||||
if (!design->full_selection())
|
||||
log_cmd_error("This command only operates on fully selected designs!\n");
|
||||
design->push_empty_selection();
|
||||
auto &selection = design->selection();
|
||||
for (auto module : design->modules())
|
||||
for (auto cell : module->cells())
|
||||
if (selection.boxed_module(cell->type))
|
||||
selection.select(module, cell);
|
||||
}
|
||||
|
||||
for (auto module : design->all_selected_modules())
|
||||
{
|
||||
SigMap sigmap(module);
|
||||
pool<SigBit> cutpoint_bits;
|
||||
|
||||
|
|
@ -82,7 +97,26 @@ struct CutpointPass : public Pass {
|
|||
if (cell->output(conn.first))
|
||||
module->connect(conn.second, flag_undef ? Const(State::Sx, GetSize(conn.second)) : module->Anyseq(NEW_ID, GetSize(conn.second)));
|
||||
}
|
||||
|
||||
RTLIL::Cell *scopeinfo = nullptr;
|
||||
auto cell_name = cell->name;
|
||||
if (flag_scopeinfo && cell_name.isPublic()) {
|
||||
auto scopeinfo = module->addCell(NEW_ID, ID($scopeinfo));
|
||||
scopeinfo->setParam(ID::TYPE, RTLIL::Const("blackbox"));
|
||||
|
||||
for (auto const &attr : cell->attributes)
|
||||
{
|
||||
if (attr.first == ID::hdlname)
|
||||
scopeinfo->attributes.insert(attr);
|
||||
else
|
||||
scopeinfo->attributes.emplace(stringf("\\cell_%s", RTLIL::unescape_id(attr.first).c_str()), attr.second);
|
||||
}
|
||||
}
|
||||
|
||||
module->remove(cell);
|
||||
|
||||
if (scopeinfo != nullptr)
|
||||
module->rename(scopeinfo, cell_name);
|
||||
}
|
||||
|
||||
for (auto wire : module->selected_wires()) {
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ OBJS += passes/techmap/flowmap.o
|
|||
OBJS += passes/techmap/extractinv.o
|
||||
OBJS += passes/techmap/cellmatch.o
|
||||
OBJS += passes/techmap/clockgate.o
|
||||
OBJS += passes/techmap/constmap.o
|
||||
endif
|
||||
|
||||
ifeq ($(DISABLE_SPAWN),0)
|
||||
|
|
@ -62,5 +63,5 @@ EXTRA_OBJS += passes/techmap/filterlib.o
|
|||
|
||||
$(PROGRAM_PREFIX)yosys-filterlib$(EXE): passes/techmap/filterlib.o
|
||||
$(Q) mkdir -p $(dir $@)
|
||||
$(P) $(CXX) -o $(PROGRAM_PREFIX)yosys-filterlib$(EXE) $(LINKFLAGS) $^ $(LIBS)
|
||||
$(P) $(CXX) -o $(PROGRAM_PREFIX)yosys-filterlib$(EXE) $(LINKFLAGS) $^ $(EXE_LIBS) $(LIBS)
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ struct AlumaccWorker
|
|||
log(" creating $macc model for %s (%s).\n", log_id(cell), log_id(cell->type));
|
||||
|
||||
maccnode_t *n = new maccnode_t;
|
||||
Macc::port_t new_port;
|
||||
Macc::term_t new_term;
|
||||
|
||||
n->cell = cell;
|
||||
n->y = sigmap(cell->getPort(ID::Y));
|
||||
|
|
@ -153,32 +153,32 @@ struct AlumaccWorker
|
|||
|
||||
if (cell->type.in(ID($pos), ID($neg)))
|
||||
{
|
||||
new_port.in_a = sigmap(cell->getPort(ID::A));
|
||||
new_port.is_signed = cell->getParam(ID::A_SIGNED).as_bool();
|
||||
new_port.do_subtract = cell->type == ID($neg);
|
||||
n->macc.ports.push_back(new_port);
|
||||
new_term.in_a = sigmap(cell->getPort(ID::A));
|
||||
new_term.is_signed = cell->getParam(ID::A_SIGNED).as_bool();
|
||||
new_term.do_subtract = cell->type == ID($neg);
|
||||
n->macc.terms.push_back(new_term);
|
||||
}
|
||||
|
||||
if (cell->type.in(ID($add), ID($sub)))
|
||||
{
|
||||
new_port.in_a = sigmap(cell->getPort(ID::A));
|
||||
new_port.is_signed = cell->getParam(ID::A_SIGNED).as_bool();
|
||||
new_port.do_subtract = false;
|
||||
n->macc.ports.push_back(new_port);
|
||||
new_term.in_a = sigmap(cell->getPort(ID::A));
|
||||
new_term.is_signed = cell->getParam(ID::A_SIGNED).as_bool();
|
||||
new_term.do_subtract = false;
|
||||
n->macc.terms.push_back(new_term);
|
||||
|
||||
new_port.in_a = sigmap(cell->getPort(ID::B));
|
||||
new_port.is_signed = cell->getParam(ID::B_SIGNED).as_bool();
|
||||
new_port.do_subtract = cell->type == ID($sub);
|
||||
n->macc.ports.push_back(new_port);
|
||||
new_term.in_a = sigmap(cell->getPort(ID::B));
|
||||
new_term.is_signed = cell->getParam(ID::B_SIGNED).as_bool();
|
||||
new_term.do_subtract = cell->type == ID($sub);
|
||||
n->macc.terms.push_back(new_term);
|
||||
}
|
||||
|
||||
if (cell->type.in(ID($mul)))
|
||||
{
|
||||
new_port.in_a = sigmap(cell->getPort(ID::A));
|
||||
new_port.in_b = sigmap(cell->getPort(ID::B));
|
||||
new_port.is_signed = cell->getParam(ID::A_SIGNED).as_bool();
|
||||
new_port.do_subtract = false;
|
||||
n->macc.ports.push_back(new_port);
|
||||
new_term.in_a = sigmap(cell->getPort(ID::A));
|
||||
new_term.in_b = sigmap(cell->getPort(ID::B));
|
||||
new_term.is_signed = cell->getParam(ID::A_SIGNED).as_bool();
|
||||
new_term.do_subtract = false;
|
||||
n->macc.terms.push_back(new_term);
|
||||
}
|
||||
|
||||
log_assert(sig_macc.count(n->y) == 0);
|
||||
|
|
@ -190,7 +190,7 @@ struct AlumaccWorker
|
|||
{
|
||||
std::vector<int> port_sizes;
|
||||
|
||||
for (auto &port : macc.ports) {
|
||||
for (auto &port : macc.terms) {
|
||||
if (port.is_signed != is_signed)
|
||||
return true;
|
||||
if (!port.is_signed && port.do_subtract)
|
||||
|
|
@ -235,9 +235,9 @@ struct AlumaccWorker
|
|||
if (delete_nodes.count(n))
|
||||
continue;
|
||||
|
||||
for (int i = 0; i < GetSize(n->macc.ports); i++)
|
||||
for (int i = 0; i < GetSize(n->macc.terms); i++)
|
||||
{
|
||||
auto &port = n->macc.ports[i];
|
||||
auto &port = n->macc.terms[i];
|
||||
|
||||
if (GetSize(port.in_b) > 0 || sig_macc.count(port.in_a) == 0)
|
||||
continue;
|
||||
|
|
@ -253,13 +253,13 @@ struct AlumaccWorker
|
|||
log(" merging $macc model for %s into %s.\n", log_id(other_n->cell), log_id(n->cell));
|
||||
|
||||
bool do_subtract = port.do_subtract;
|
||||
for (int j = 0; j < GetSize(other_n->macc.ports); j++) {
|
||||
for (int j = 0; j < GetSize(other_n->macc.terms); j++) {
|
||||
if (do_subtract)
|
||||
other_n->macc.ports[j].do_subtract = !other_n->macc.ports[j].do_subtract;
|
||||
other_n->macc.terms[j].do_subtract = !other_n->macc.terms[j].do_subtract;
|
||||
if (j == 0)
|
||||
n->macc.ports[i--] = other_n->macc.ports[j];
|
||||
n->macc.terms[i--] = other_n->macc.terms[j];
|
||||
else
|
||||
n->macc.ports.push_back(other_n->macc.ports[j]);
|
||||
n->macc.terms.push_back(other_n->macc.terms[j]);
|
||||
}
|
||||
|
||||
delete_nodes.insert(other_n);
|
||||
|
|
@ -288,7 +288,7 @@ struct AlumaccWorker
|
|||
bool subtract_b = false;
|
||||
alunode_t *alunode;
|
||||
|
||||
for (auto &port : n->macc.ports)
|
||||
for (auto &port : n->macc.terms)
|
||||
if (GetSize(port.in_b) > 0) {
|
||||
goto next_macc;
|
||||
} else if (GetSize(port.in_a) == 1 && !port.is_signed && !port.do_subtract) {
|
||||
|
|
|
|||
|
|
@ -227,9 +227,9 @@ struct BoothPassWorker {
|
|||
continue;
|
||||
}
|
||||
|
||||
A = macc.ports[0].in_a;
|
||||
B = macc.ports[0].in_b;
|
||||
is_signed = macc.ports[0].is_signed;
|
||||
A = macc.terms[0].in_a;
|
||||
B = macc.terms[0].in_b;
|
||||
is_signed = macc.terms[0].is_signed;
|
||||
Y = cell->getPort(ID::Y);
|
||||
} else {
|
||||
continue;
|
||||
|
|
|
|||
106
passes/techmap/constmap.cc
Normal file
106
passes/techmap/constmap.cc
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
/*
|
||||
* yosys -- Yosys Open SYnthesis Suite
|
||||
*
|
||||
* Copyright (C) 2025 King Lok Chung <king.chung@manchester.ac.uk>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "kernel/register.h"
|
||||
#include "kernel/rtlil.h"
|
||||
#include "kernel/log.h"
|
||||
|
||||
USING_YOSYS_NAMESPACE
|
||||
PRIVATE_NAMESPACE_BEGIN
|
||||
|
||||
static std::string celltype, cell_portname, cell_paramname;
|
||||
|
||||
static RTLIL::Module *module;
|
||||
static RTLIL::SigChunk value;
|
||||
|
||||
void constmap_worker(RTLIL::SigSpec &sig)
|
||||
{
|
||||
if (sig.is_fully_const()){
|
||||
value = module->addWire(NEW_ID, sig.size());
|
||||
RTLIL::Cell *cell = module->addCell(NEW_ID, celltype);
|
||||
cell->setParam(cell_paramname, sig.as_const());
|
||||
cell->setPort(cell_portname, value);
|
||||
sig = value;
|
||||
}
|
||||
}
|
||||
|
||||
struct ConstmapPass : public Pass {
|
||||
ConstmapPass() : Pass("constmap", "technology mapping of coarse constant value") { }
|
||||
void help() override
|
||||
{
|
||||
log("\n");
|
||||
log(" constmap [options] [selection]\n");
|
||||
log("\n");
|
||||
log("Map constants to a driver cell.\n");
|
||||
log("\n");
|
||||
log(" -cell <celltype> <portname> <paramname>\n");
|
||||
log(" Replace constant bits with this cell.\n");
|
||||
log(" The value of the constant will be stored to the parameter specified.\n");
|
||||
log("\n");
|
||||
}
|
||||
void execute(std::vector<std::string> args, RTLIL::Design *design) override
|
||||
{
|
||||
log_header(design, "Executing CONSTMAP pass (mapping to constant driver).\n");
|
||||
|
||||
size_t argidx;
|
||||
for (argidx = 1; argidx < args.size(); argidx++)
|
||||
{
|
||||
if (args[argidx] == "-cell" && argidx+3 < args.size()){
|
||||
celltype = RTLIL::escape_id(args[++argidx]);
|
||||
cell_portname = RTLIL::escape_id(args[++argidx]);
|
||||
cell_paramname = RTLIL::escape_id(args[++argidx]);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
extra_args(args, argidx, design);
|
||||
|
||||
|
||||
if (design->has(celltype)) {
|
||||
Module *existing = design->module(celltype);
|
||||
bool has_port = false;
|
||||
for (auto &p : existing->ports){
|
||||
if (p == cell_portname){
|
||||
has_port = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!has_port)
|
||||
log_cmd_error("Cell type '%s' does not have port '%s'.\n", celltype.c_str(), cell_portname.c_str());
|
||||
|
||||
bool has_param = false;
|
||||
for (auto &p : existing->avail_parameters){
|
||||
if (p == cell_paramname)
|
||||
has_param = true;
|
||||
}
|
||||
|
||||
if (!has_param)
|
||||
log_cmd_error("Cell type '%s' does not have parameter '%s'.\n", celltype.c_str(), cell_paramname.c_str());
|
||||
}
|
||||
|
||||
|
||||
for (auto mod : design->selected_modules())
|
||||
{
|
||||
module = mod;
|
||||
module->rewrite_sigspecs(constmap_worker);
|
||||
}
|
||||
}
|
||||
} ConstmapPass;
|
||||
|
||||
PRIVATE_NAMESPACE_END
|
||||
|
|
@ -75,7 +75,7 @@ bool LibertyInputStream::extend_buffer_once()
|
|||
buffer.resize(buf_end + chunk_size);
|
||||
}
|
||||
|
||||
size_t read_size = f.rdbuf()->sgetn(buffer.data() + buf_end, chunk_size);
|
||||
size_t read_size = f.rdbuf()->sgetn((char *)buffer.data() + buf_end, chunk_size);
|
||||
buf_end += read_size;
|
||||
if (read_size < chunk_size)
|
||||
eof = true;
|
||||
|
|
@ -436,6 +436,9 @@ void LibertyParser::report_unexpected_token(int tok)
|
|||
eReport += "'.";
|
||||
error(eReport);
|
||||
break;
|
||||
case EOF:
|
||||
error("Unexpected end of file");
|
||||
break;
|
||||
default:
|
||||
eReport = "Unexpected token: ";
|
||||
eReport += static_cast<char>(tok);
|
||||
|
|
@ -484,7 +487,7 @@ void LibertyParser::parse_vector_range(int tok)
|
|||
}
|
||||
}
|
||||
|
||||
LibertyAst *LibertyParser::parse()
|
||||
LibertyAst *LibertyParser::parse(bool top_level)
|
||||
{
|
||||
std::string str;
|
||||
|
||||
|
|
@ -498,7 +501,13 @@ LibertyAst *LibertyParser::parse()
|
|||
while ((tok == 'n') || (tok == ';'))
|
||||
tok = lexer(str);
|
||||
|
||||
if (tok == '}' || tok < 0)
|
||||
if (tok == EOF) {
|
||||
if (top_level)
|
||||
return NULL;
|
||||
report_unexpected_token(tok);
|
||||
}
|
||||
|
||||
if (tok == '}')
|
||||
return NULL;
|
||||
|
||||
if (tok != 'v') {
|
||||
|
|
@ -571,12 +580,18 @@ LibertyAst *LibertyParser::parse()
|
|||
}
|
||||
|
||||
if (tok == '{') {
|
||||
bool terminated = false;
|
||||
while (1) {
|
||||
LibertyAst *child = parse();
|
||||
if (child == NULL)
|
||||
LibertyAst *child = parse(false);
|
||||
if (child == NULL) {
|
||||
terminated = true;
|
||||
break;
|
||||
}
|
||||
ast->children.push_back(child);
|
||||
}
|
||||
if (!terminated) {
|
||||
report_unexpected_token(EOF);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ namespace Yosys
|
|||
|
||||
class LibertyInputStream {
|
||||
std::istream &f;
|
||||
std::vector<char> buffer;
|
||||
std::vector<unsigned char> buffer;
|
||||
size_t buf_pos = 0;
|
||||
size_t buf_end = 0;
|
||||
bool eof = false;
|
||||
|
|
@ -107,7 +107,7 @@ namespace Yosys
|
|||
LibertyInputStream(std::istream &f) : f(f) {}
|
||||
|
||||
size_t buffered_size() { return buf_end - buf_pos; }
|
||||
const char *buffered_data() { return buffer.data() + buf_pos; }
|
||||
const unsigned char *buffered_data() { return buffer.data() + buf_pos; }
|
||||
|
||||
int get() {
|
||||
if (buf_pos == buf_end)
|
||||
|
|
@ -165,7 +165,7 @@ namespace Yosys
|
|||
|
||||
void report_unexpected_token(int tok);
|
||||
void parse_vector_range(int tok);
|
||||
LibertyAst *parse();
|
||||
LibertyAst *parse(bool top_level);
|
||||
void error() const;
|
||||
void error(const std::string &str) const;
|
||||
|
||||
|
|
@ -174,18 +174,29 @@ namespace Yosys
|
|||
const LibertyAst *ast = nullptr;
|
||||
|
||||
LibertyParser(std::istream &f) : f(f), line(1) {
|
||||
shared_ast.reset(parse());
|
||||
shared_ast.reset(parse(true));
|
||||
ast = shared_ast.get();
|
||||
if (!ast) {
|
||||
#ifdef FILTERLIB
|
||||
fprintf(stderr, "No entries found in liberty file.\n");
|
||||
exit(1);
|
||||
#else
|
||||
log_error("No entries found in liberty file.\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef FILTERLIB
|
||||
LibertyParser(std::istream &f, const std::string &fname) : f(f), line(1) {
|
||||
shared_ast = LibertyAstCache::instance.cached_ast(fname);
|
||||
if (!shared_ast) {
|
||||
shared_ast.reset(parse());
|
||||
shared_ast.reset(parse(true));
|
||||
LibertyAstCache::instance.parsed_ast(fname, shared_ast);
|
||||
}
|
||||
ast = shared_ast.get();
|
||||
if (!ast) {
|
||||
log_error("No entries found in liberty file `%s'.\n", fname.c_str());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
|
|
|||
|
|
@ -278,42 +278,42 @@ void maccmap(RTLIL::Module *module, RTLIL::Cell *cell, bool unmap)
|
|||
return;
|
||||
}
|
||||
|
||||
for (auto &port : macc.ports)
|
||||
if (GetSize(port.in_b) == 0)
|
||||
log(" %s %s (%d bits, %s)\n", port.do_subtract ? "sub" : "add", log_signal(port.in_a),
|
||||
GetSize(port.in_a), port.is_signed ? "signed" : "unsigned");
|
||||
for (auto &term : macc.terms)
|
||||
if (GetSize(term.in_b) == 0)
|
||||
log(" %s %s (%d bits, %s)\n", term.do_subtract ? "sub" : "add", log_signal(term.in_a),
|
||||
GetSize(term.in_a), term.is_signed ? "signed" : "unsigned");
|
||||
else
|
||||
log(" %s %s * %s (%dx%d bits, %s)\n", port.do_subtract ? "sub" : "add", log_signal(port.in_a), log_signal(port.in_b),
|
||||
GetSize(port.in_a), GetSize(port.in_b), port.is_signed ? "signed" : "unsigned");
|
||||
log(" %s %s * %s (%dx%d bits, %s)\n", term.do_subtract ? "sub" : "add", log_signal(term.in_a), log_signal(term.in_b),
|
||||
GetSize(term.in_a), GetSize(term.in_b), term.is_signed ? "signed" : "unsigned");
|
||||
|
||||
if (unmap)
|
||||
{
|
||||
typedef std::pair<RTLIL::SigSpec, bool> summand_t;
|
||||
std::vector<summand_t> summands;
|
||||
|
||||
RTLIL::SigSpec bit_ports;
|
||||
RTLIL::SigSpec bit_terms;
|
||||
|
||||
for (auto &port : macc.ports) {
|
||||
for (auto &term : macc.terms) {
|
||||
summand_t this_summand;
|
||||
if (GetSize(port.in_b)) {
|
||||
if (GetSize(term.in_b)) {
|
||||
this_summand.first = module->addWire(NEW_ID, width);
|
||||
module->addMul(NEW_ID, port.in_a, port.in_b, this_summand.first, port.is_signed);
|
||||
} else if (GetSize(port.in_a) == 1 && GetSize(port.in_b) == 0 && !port.is_signed && !port.do_subtract) {
|
||||
// Mimic old 'bit_ports' treatment in case it's relevant for performance,
|
||||
module->addMul(NEW_ID, term.in_a, term.in_b, this_summand.first, term.is_signed);
|
||||
} else if (GetSize(term.in_a) == 1 && GetSize(term.in_b) == 0 && !term.is_signed && !term.do_subtract) {
|
||||
// Mimic old 'bit_terms' treatment in case it's relevant for performance,
|
||||
// i.e. defer single-bit summands to be the last ones
|
||||
bit_ports.append(port.in_a);
|
||||
bit_terms.append(term.in_a);
|
||||
continue;
|
||||
} else if (GetSize(port.in_a) != width) {
|
||||
} else if (GetSize(term.in_a) != width) {
|
||||
this_summand.first = module->addWire(NEW_ID, width);
|
||||
module->addPos(NEW_ID, port.in_a, this_summand.first, port.is_signed);
|
||||
module->addPos(NEW_ID, term.in_a, this_summand.first, term.is_signed);
|
||||
} else {
|
||||
this_summand.first = port.in_a;
|
||||
this_summand.first = term.in_a;
|
||||
}
|
||||
this_summand.second = port.do_subtract;
|
||||
this_summand.second = term.do_subtract;
|
||||
summands.push_back(this_summand);
|
||||
}
|
||||
|
||||
for (auto &bit : bit_ports)
|
||||
for (auto &bit : bit_terms)
|
||||
summands.push_back(summand_t(bit, false));
|
||||
|
||||
if (GetSize(summands) == 0)
|
||||
|
|
@ -350,20 +350,20 @@ void maccmap(RTLIL::Module *module, RTLIL::Cell *cell, bool unmap)
|
|||
else
|
||||
{
|
||||
MaccmapWorker worker(module, width);
|
||||
RTLIL::SigSpec bit_ports;
|
||||
RTLIL::SigSpec bit_terms;
|
||||
|
||||
for (auto &port : macc.ports) {
|
||||
// Mimic old 'bit_ports' treatment in case it's relevant for performance,
|
||||
for (auto &term : macc.terms) {
|
||||
// Mimic old 'bit_terms' treatment in case it's relevant for performance,
|
||||
// i.e. defer single-bit summands to be the last ones
|
||||
if (GetSize(port.in_a) == 1 && GetSize(port.in_b) == 0 && !port.is_signed && !port.do_subtract)
|
||||
bit_ports.append(port.in_a);
|
||||
else if (GetSize(port.in_b) == 0)
|
||||
worker.add(port.in_a, port.is_signed, port.do_subtract);
|
||||
if (GetSize(term.in_a) == 1 && GetSize(term.in_b) == 0 && !term.is_signed && !term.do_subtract)
|
||||
bit_terms.append(term.in_a);
|
||||
else if (GetSize(term.in_b) == 0)
|
||||
worker.add(term.in_a, term.is_signed, term.do_subtract);
|
||||
else
|
||||
worker.add(port.in_a, port.in_b, port.is_signed, port.do_subtract);
|
||||
worker.add(term.in_a, term.in_b, term.is_signed, term.do_subtract);
|
||||
}
|
||||
|
||||
for (auto bit : bit_ports)
|
||||
for (auto bit : bit_terms)
|
||||
worker.add(bit, 0);
|
||||
|
||||
module->connect(cell->getPort(ID::Y), worker.synth());
|
||||
|
|
|
|||
|
|
@ -189,17 +189,17 @@ static RTLIL::Cell* create_gold_module(RTLIL::Design *design, RTLIL::IdString ce
|
|||
} else
|
||||
size_b = 0;
|
||||
|
||||
Macc::port_t this_port;
|
||||
Macc::term_t this_term;
|
||||
|
||||
wire_a->width += size_a;
|
||||
this_port.in_a = RTLIL::SigSpec(wire_a, wire_a->width - size_a, size_a);
|
||||
this_term.in_a = RTLIL::SigSpec(wire_a, wire_a->width - size_a, size_a);
|
||||
|
||||
wire_a->width += size_b;
|
||||
this_port.in_b = RTLIL::SigSpec(wire_a, wire_a->width - size_b, size_b);
|
||||
this_term.in_b = RTLIL::SigSpec(wire_a, wire_a->width - size_b, size_b);
|
||||
|
||||
this_port.is_signed = xorshift32(2) == 1;
|
||||
this_port.do_subtract = xorshift32(2) == 1;
|
||||
macc.ports.push_back(this_port);
|
||||
this_term.is_signed = xorshift32(2) == 1;
|
||||
this_term.do_subtract = xorshift32(2) == 1;
|
||||
macc.terms.push_back(this_term);
|
||||
}
|
||||
// Macc::to_cell sets the input ports
|
||||
macc.to_cell(cell);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue