mirror of
https://github.com/YosysHQ/yosys
synced 2026-07-20 06:05:50 +00:00
WIP
This commit is contained in:
parent
015ab4e45b
commit
f592f2f3af
203 changed files with 4575 additions and 4481 deletions
|
|
@ -130,7 +130,7 @@ struct ConstEvalAig
|
|||
sig2deps[output].insert(output);
|
||||
|
||||
RTLIL::Cell *cell = sig2driver.at(output);
|
||||
RTLIL::SigBit sig_a = cell->getPort(ID::A);
|
||||
RTLIL::SigBit sig_a = cell->getPort(TW::A);
|
||||
sig2deps[sig_a].reserve(sig2deps[sig_a].size() + sig2deps[output].size()); // Reserve so that any invalidation
|
||||
// that may occur does so here, and
|
||||
// not mid insertion (below)
|
||||
|
|
@ -139,7 +139,7 @@ struct ConstEvalAig
|
|||
compute_deps(sig_a, inputs);
|
||||
|
||||
if (cell->type == ID($_AND_)) {
|
||||
RTLIL::SigSpec sig_b = cell->getPort(ID::B);
|
||||
RTLIL::SigSpec sig_b = cell->getPort(TW::B);
|
||||
sig2deps[sig_b].reserve(sig2deps[sig_b].size() + sig2deps[output].size()); // Reserve so that any invalidation
|
||||
// that may occur does so here, and
|
||||
// not mid insertion (below)
|
||||
|
|
@ -155,11 +155,11 @@ struct ConstEvalAig
|
|||
|
||||
bool eval(RTLIL::Cell *cell)
|
||||
{
|
||||
RTLIL::SigBit sig_y = cell->getPort(ID::Y);
|
||||
RTLIL::SigBit sig_y = cell->getPort(TW::Y);
|
||||
if (values_map.count(sig_y))
|
||||
return true;
|
||||
|
||||
RTLIL::SigBit sig_a = cell->getPort(ID::A);
|
||||
RTLIL::SigBit sig_a = cell->getPort(TW::A);
|
||||
if (!eval(sig_a))
|
||||
return false;
|
||||
|
||||
|
|
@ -175,7 +175,7 @@ struct ConstEvalAig
|
|||
}
|
||||
|
||||
{
|
||||
RTLIL::SigBit sig_b = cell->getPort(ID::B);
|
||||
RTLIL::SigBit sig_b = cell->getPort(TW::B);
|
||||
if (!eval(sig_b))
|
||||
return false;
|
||||
if (sig_b == State::S0) {
|
||||
|
|
@ -978,7 +978,7 @@ void AigerReader::post_process()
|
|||
|
||||
for (auto cell : module->cells().to_vector()) {
|
||||
if (cell->type != ID($lut)) continue;
|
||||
auto y_port = cell->getPort(ID::Y).as_bit();
|
||||
auto y_port = cell->getPort(TW::Y).as_bit();
|
||||
if (y_port.wire->width == 1)
|
||||
module->rename(cell, stringf("$lut%s", y_port.wire->name));
|
||||
else
|
||||
|
|
|
|||
|
|
@ -62,10 +62,10 @@ static RTLIL::SigSpec uniop2rtlil(AstNode *that, IdString type, int result_width
|
|||
|
||||
cell->parameters[ID::A_SIGNED] = RTLIL::Const(that->children[0]->is_signed);
|
||||
cell->parameters[ID::A_WIDTH] = RTLIL::Const(arg.size());
|
||||
cell->setPort(ID::A, arg);
|
||||
cell->setPort(TW::A, arg);
|
||||
|
||||
cell->parameters[ID::Y_WIDTH] = result_width;
|
||||
cell->setPort(ID::Y, wire);
|
||||
cell->setPort(TW::Y, wire);
|
||||
return wire;
|
||||
}
|
||||
|
||||
|
|
@ -94,10 +94,10 @@ static void widthExtend(AstNode *that, RTLIL::SigSpec &sig, int width, bool is_s
|
|||
|
||||
cell->parameters[ID::A_SIGNED] = RTLIL::Const(is_signed);
|
||||
cell->parameters[ID::A_WIDTH] = RTLIL::Const(sig.size());
|
||||
cell->setPort(ID::A, sig);
|
||||
cell->setPort(TW::A, sig);
|
||||
|
||||
cell->parameters[ID::Y_WIDTH] = width;
|
||||
cell->setPort(ID::Y, wire);
|
||||
cell->setPort(TW::Y, wire);
|
||||
sig = wire;
|
||||
}
|
||||
|
||||
|
|
@ -124,11 +124,11 @@ static RTLIL::SigSpec binop2rtlil(AstNode *that, IdString type, int result_width
|
|||
cell->parameters[ID::A_WIDTH] = RTLIL::Const(left.size());
|
||||
cell->parameters[ID::B_WIDTH] = RTLIL::Const(right.size());
|
||||
|
||||
cell->setPort(ID::A, left);
|
||||
cell->setPort(ID::B, right);
|
||||
cell->setPort(TW::A, left);
|
||||
cell->setPort(TW::B, right);
|
||||
|
||||
cell->parameters[ID::Y_WIDTH] = result_width;
|
||||
cell->setPort(ID::Y, wire);
|
||||
cell->setPort(TW::Y, wire);
|
||||
return wire;
|
||||
}
|
||||
|
||||
|
|
@ -155,10 +155,10 @@ static RTLIL::SigSpec mux2rtlil(AstNode *that, const RTLIL::SigSpec &cond, const
|
|||
|
||||
cell->parameters[ID::WIDTH] = RTLIL::Const(left.size());
|
||||
|
||||
cell->setPort(ID::A, right);
|
||||
cell->setPort(ID::B, left);
|
||||
cell->setPort(ID::S, cond);
|
||||
cell->setPort(ID::Y, wire);
|
||||
cell->setPort(TW::A, right);
|
||||
cell->setPort(TW::B, left);
|
||||
cell->setPort(TW::S, cond);
|
||||
cell->setPort(TW::Y, wire);
|
||||
|
||||
return wire;
|
||||
}
|
||||
|
|
@ -842,8 +842,8 @@ struct AST_INTERNAL::ProcessGenerator
|
|||
cell->setParam(ID::TRG_ENABLE, (always->type == AST_INITIAL) || !triggers.empty());
|
||||
cell->setParam(ID::TRG_POLARITY, polarity);
|
||||
cell->setParam(ID::PRIORITY, --last_effect_priority);
|
||||
cell->setPort(ID::TRG, triggers);
|
||||
cell->setPort(ID::EN, en);
|
||||
cell->setPort(TW::TRG, triggers);
|
||||
cell->setPort(TW::EN, en);
|
||||
|
||||
int default_base = 10;
|
||||
if (ast->str.back() == 'b')
|
||||
|
|
@ -947,9 +947,9 @@ struct AST_INTERNAL::ProcessGenerator
|
|||
cell->setParam(ID::TRG_ENABLE, (always->type == AST_INITIAL) || !triggers.empty());
|
||||
cell->setParam(ID::TRG_POLARITY, polarity);
|
||||
cell->setParam(ID::PRIORITY, --last_effect_priority);
|
||||
cell->setPort(ID::TRG, triggers);
|
||||
cell->setPort(ID::EN, en);
|
||||
cell->setPort(ID::A, check);
|
||||
cell->setPort(TW::TRG, triggers);
|
||||
cell->setPort(TW::EN, en);
|
||||
cell->setPort(TW::A, check);
|
||||
|
||||
// No message is emitted to ensure Verilog code roundtrips correctly.
|
||||
Fmt fmt;
|
||||
|
|
@ -2058,10 +2058,10 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
|
|||
|
||||
RTLIL::SigSpec addr_sig = children[0]->genRTLIL();
|
||||
|
||||
cell->setPort(ID::CLK, RTLIL::SigSpec(RTLIL::State::Sx, 1));
|
||||
cell->setPort(ID::EN, RTLIL::SigSpec(RTLIL::State::Sx, 1));
|
||||
cell->setPort(ID::ADDR, addr_sig);
|
||||
cell->setPort(ID::DATA, RTLIL::SigSpec(wire));
|
||||
cell->setPort(TW::CLK, RTLIL::SigSpec(RTLIL::State::Sx, 1));
|
||||
cell->setPort(TW::EN, RTLIL::SigSpec(RTLIL::State::Sx, 1));
|
||||
cell->setPort(TW::ADDR, addr_sig);
|
||||
cell->setPort(TW::DATA, RTLIL::SigSpec(wire));
|
||||
|
||||
cell->parameters[ID::MEMID] = RTLIL::Const(str);
|
||||
cell->parameters[ID::ABITS] = RTLIL::Const(GetSize(addr_sig));
|
||||
|
|
@ -2098,9 +2098,9 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
|
|||
|
||||
SigSpec addr_sig = children[0]->genRTLIL();
|
||||
|
||||
cell->setPort(ID::ADDR, addr_sig);
|
||||
cell->setPort(ID::DATA, children[1]->genWidthRTLIL(current_module->memories[str]->width * num_words, true));
|
||||
cell->setPort(ID::EN, en_sig);
|
||||
cell->setPort(TW::ADDR, addr_sig);
|
||||
cell->setPort(TW::DATA, children[1]->genWidthRTLIL(current_module->memories[str]->width * num_words, true));
|
||||
cell->setPort(TW::EN, en_sig);
|
||||
|
||||
cell->parameters[ID::MEMID] = RTLIL::Const(str);
|
||||
cell->parameters[ID::ABITS] = RTLIL::Const(GetSize(addr_sig));
|
||||
|
|
@ -2147,9 +2147,9 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
|
|||
cell->parameters[ID::TRG_ENABLE] = 0;
|
||||
cell->parameters[ID::TRG_POLARITY] = 0;
|
||||
cell->parameters[ID::PRIORITY] = 0;
|
||||
cell->setPort(ID::TRG, RTLIL::SigSpec());
|
||||
cell->setPort(ID::EN, RTLIL::S1);
|
||||
cell->setPort(ID::A, check);
|
||||
cell->setPort(TW::TRG, RTLIL::SigSpec());
|
||||
cell->setPort(TW::EN, RTLIL::S1);
|
||||
cell->setPort(TW::A, check);
|
||||
|
||||
// No message is emitted to ensure Verilog code roundtrips correctly.
|
||||
Fmt fmt;
|
||||
|
|
@ -2262,8 +2262,8 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
|
|||
cell->attributes[attr.first] = attr.second->asAttrConst();
|
||||
}
|
||||
if (cell->type == ID($specify2)) {
|
||||
int src_width = GetSize(cell->getPort(ID::SRC));
|
||||
int dst_width = GetSize(cell->getPort(ID::DST));
|
||||
int src_width = GetSize(cell->getPort(TW::SRC));
|
||||
int dst_width = GetSize(cell->getPort(TW::DST));
|
||||
bool full = cell->getParam(ID::FULL).as_bool();
|
||||
if (!full && src_width != dst_width)
|
||||
input_error("Parallel specify SRC width does not match DST width.\n");
|
||||
|
|
@ -2271,17 +2271,17 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
|
|||
cell->setParam(ID::DST_WIDTH, Const(dst_width));
|
||||
}
|
||||
else if (cell->type == ID($specify3)) {
|
||||
int dat_width = GetSize(cell->getPort(ID::DAT));
|
||||
int dst_width = GetSize(cell->getPort(ID::DST));
|
||||
int dat_width = GetSize(cell->getPort(TW::DAT));
|
||||
int dst_width = GetSize(cell->getPort(TW::DST));
|
||||
if (dat_width != dst_width)
|
||||
input_error("Specify DAT width does not match DST width.\n");
|
||||
int src_width = GetSize(cell->getPort(ID::SRC));
|
||||
int src_width = GetSize(cell->getPort(TW::SRC));
|
||||
cell->setParam(ID::SRC_WIDTH, Const(src_width));
|
||||
cell->setParam(ID::DST_WIDTH, Const(dst_width));
|
||||
}
|
||||
else if (cell->type == ID($specrule)) {
|
||||
int src_width = GetSize(cell->getPort(ID::SRC));
|
||||
int dst_width = GetSize(cell->getPort(ID::DST));
|
||||
int src_width = GetSize(cell->getPort(TW::SRC));
|
||||
int dst_width = GetSize(cell->getPort(TW::DST));
|
||||
cell->setParam(ID::SRC_WIDTH, Const(src_width));
|
||||
cell->setParam(ID::DST_WIDTH, Const(dst_width));
|
||||
}
|
||||
|
|
@ -2370,7 +2370,7 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
|
|||
|
||||
Wire *wire = current_module->addWire(myid + "_wire", width);
|
||||
set_src_attr(wire, this);
|
||||
cell->setPort(ID::Y, wire);
|
||||
cell->setPort(TW::Y, wire);
|
||||
|
||||
is_signed = sign_hint;
|
||||
return SigSpec(wire);
|
||||
|
|
|
|||
|
|
@ -1479,7 +1479,7 @@ bool AstNode::simplify(bool const_fold, int stage, int width_hint, bool sign_hin
|
|||
continue;
|
||||
|
||||
// determine the full name of port this argument is connected to
|
||||
RTLIL::IdString port_name;
|
||||
TwineRef port_name;
|
||||
if (child->str.size())
|
||||
port_name = child->str;
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ void parse_blif(RTLIL::Design *design, std::istream &f, IdString dff_name, bool
|
|||
|
||||
for (auto cell : module->cells())
|
||||
if (cell->type == ID($lut) && cell->getParam(ID::LUT) == buffer_lut) {
|
||||
module->connect(cell->getPort(ID::Y), cell->getPort(ID::A));
|
||||
module->connect(cell->getPort(TW::Y), cell->getPort(TW::A));
|
||||
remove_cells.push_back(cell);
|
||||
}
|
||||
|
||||
|
|
@ -376,9 +376,9 @@ void parse_blif(RTLIL::Design *design, std::istream &f, IdString dff_name, bool
|
|||
if (dff_name.empty()) {
|
||||
cell = module->addFfGate(NEW_ID, blif_wire(d), blif_wire(q));
|
||||
} else {
|
||||
cell = module->addCell(NEW_ID, dff_name);
|
||||
cell->setPort(ID::D, blif_wire(d));
|
||||
cell->setPort(ID::Q, blif_wire(q));
|
||||
cell = module->addCell(NEW_TWINE, dff_name);
|
||||
cell->setPort(TW::D, blif_wire(d));
|
||||
cell->setPort(TW::Q, blif_wire(q));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -395,7 +395,7 @@ void parse_blif(RTLIL::Design *design, std::istream &f, IdString dff_name, bool
|
|||
goto error;
|
||||
|
||||
IdString celltype = RTLIL::escape_id(p);
|
||||
RTLIL::Cell *cell = module->addCell(NEW_ID, celltype);
|
||||
RTLIL::Cell *cell = module->addCell(NEW_TWINE, celltype);
|
||||
RTLIL::Module *cell_mod = design->module(celltype);
|
||||
|
||||
dict<RTLIL::IdString, dict<int, SigBit>> cell_wideports_cache;
|
||||
|
|
@ -442,7 +442,7 @@ void parse_blif(RTLIL::Design *design, std::istream &f, IdString dff_name, bool
|
|||
if (it.second.count(idx))
|
||||
sig.append(it.second.at(idx));
|
||||
else
|
||||
sig.append(module->addWire(NEW_ID));
|
||||
sig.append(module->addWire(NEW_TWINE));
|
||||
}
|
||||
|
||||
cell->setPort(it.first, sig);
|
||||
|
|
@ -539,12 +539,12 @@ void parse_blif(RTLIL::Design *design, std::istream &f, IdString dff_name, bool
|
|||
|
||||
if (sop_mode)
|
||||
{
|
||||
sopcell = module->addCell(NEW_ID, ID($sop));
|
||||
sopcell = module->addCell(NEW_TWINE, ID($sop));
|
||||
sopcell->parameters[ID::WIDTH] = RTLIL::Const(input_sig.size());
|
||||
sopcell->parameters[ID::DEPTH] = 0;
|
||||
sopcell->parameters[ID::TABLE] = RTLIL::Const();
|
||||
sopcell->setPort(ID::A, input_sig);
|
||||
sopcell->setPort(ID::Y, output_sig);
|
||||
sopcell->setPort(TW::A, input_sig);
|
||||
sopcell->setPort(TW::Y, output_sig);
|
||||
sopmode = -1;
|
||||
lastcell = sopcell;
|
||||
}
|
||||
|
|
@ -555,11 +555,11 @@ void parse_blif(RTLIL::Design *design, std::istream &f, IdString dff_name, bool
|
|||
}
|
||||
else
|
||||
{
|
||||
RTLIL::Cell *cell = module->addCell(NEW_ID, ID($lut));
|
||||
RTLIL::Cell *cell = module->addCell(NEW_TWINE, ID($lut));
|
||||
cell->parameters[ID::WIDTH] = RTLIL::Const(input_sig.size());
|
||||
cell->parameters[ID::LUT] = RTLIL::Const(RTLIL::State::Sx, 1 << input_sig.size());
|
||||
cell->setPort(ID::A, input_sig);
|
||||
cell->setPort(ID::Y, output_sig);
|
||||
cell->setPort(TW::A, input_sig);
|
||||
cell->setPort(TW::Y, output_sig);
|
||||
lutptr = &cell->parameters.at(ID::LUT);
|
||||
lut_default_state = RTLIL::State::Sx;
|
||||
lastcell = cell;
|
||||
|
|
@ -607,10 +607,10 @@ void parse_blif(RTLIL::Design *design, std::istream &f, IdString dff_name, bool
|
|||
if (sopmode == -1) {
|
||||
sopmode = (*output == '1');
|
||||
if (!sopmode) {
|
||||
SigSpec outnet = sopcell->getPort(ID::Y);
|
||||
SigSpec tempnet = module->addWire(NEW_ID);
|
||||
SigSpec outnet = sopcell->getPort(TW::Y);
|
||||
SigSpec tempnet = module->addWire(NEW_TWINE);
|
||||
module->addNotGate(NEW_ID, tempnet, outnet);
|
||||
sopcell->setPort(ID::Y, tempnet);
|
||||
sopcell->setPort(TW::Y, tempnet);
|
||||
}
|
||||
} else
|
||||
log_assert(sopmode == (*output == '1'));
|
||||
|
|
|
|||
|
|
@ -572,7 +572,7 @@ void json_import(Design *design, string &modname, JsonNode *node)
|
|||
if (bitval_node->type == 'N') {
|
||||
int bitidx = bitval_node->data_number;
|
||||
if (signal_bits.count(bitidx) == 0)
|
||||
signal_bits[bitidx] = module->addWire(NEW_ID);
|
||||
signal_bits[bitidx] = module->addWire(NEW_TWINE);
|
||||
sig.append(signal_bits.at(bitidx));
|
||||
} else
|
||||
log_error("JSON cells node '%s' connection '%s' has invalid bit value on bit %d.\n",
|
||||
|
|
|
|||
|
|
@ -185,12 +185,12 @@ static RTLIL::SigSpec create_tristate(RTLIL::Module *module, RTLIL::SigSpec func
|
|||
{
|
||||
RTLIL::SigSpec three_state = parse_func_expr(module, three_state_expr);
|
||||
|
||||
RTLIL::Cell *cell = module->addCell(NEW_ID, ID($tribuf));
|
||||
RTLIL::Cell *cell = module->addCell(NEW_TWINE, ID($tribuf));
|
||||
cell->setParam(ID::WIDTH, GetSize(func));
|
||||
cell->setPort(ID::A, func);
|
||||
cell->setPort(ID::EN, module->NotGate(NEW_ID, three_state));
|
||||
cell->setPort(ID::Y, module->addWire(NEW_ID));
|
||||
return cell->getPort(ID::Y);
|
||||
cell->setPort(TW::A, func);
|
||||
cell->setPort(TW::EN, module->NotGate(NEW_ID, three_state));
|
||||
cell->setPort(TW::Y, module->addWire(NEW_TWINE));
|
||||
return cell->getPort(TW::Y);
|
||||
}
|
||||
|
||||
static void create_latch_ff_wires(RTLIL::Module *module, const LibertyAst *node)
|
||||
|
|
@ -243,18 +243,18 @@ static void create_ff(RTLIL::Module *module, const LibertyAst *node)
|
|||
rerun_invert_rollback = false;
|
||||
|
||||
for (auto &it : module->cells_) {
|
||||
if (it.second->type == ID($_NOT_) && it.second->getPort(ID::Y) == clk_sig) {
|
||||
clk_sig = it.second->getPort(ID::A);
|
||||
if (it.second->type == ID($_NOT_) && it.second->getPort(TW::Y) == clk_sig) {
|
||||
clk_sig = it.second->getPort(TW::A);
|
||||
clk_polarity = !clk_polarity;
|
||||
rerun_invert_rollback = true;
|
||||
}
|
||||
if (it.second->type == ID($_NOT_) && it.second->getPort(ID::Y) == clear_sig) {
|
||||
clear_sig = it.second->getPort(ID::A);
|
||||
if (it.second->type == ID($_NOT_) && it.second->getPort(TW::Y) == clear_sig) {
|
||||
clear_sig = it.second->getPort(TW::A);
|
||||
clear_polarity = !clear_polarity;
|
||||
rerun_invert_rollback = true;
|
||||
}
|
||||
if (it.second->type == ID($_NOT_) && it.second->getPort(ID::Y) == preset_sig) {
|
||||
preset_sig = it.second->getPort(ID::A);
|
||||
if (it.second->type == ID($_NOT_) && it.second->getPort(TW::Y) == preset_sig) {
|
||||
preset_sig = it.second->getPort(TW::A);
|
||||
preset_polarity = !preset_polarity;
|
||||
rerun_invert_rollback = true;
|
||||
}
|
||||
|
|
@ -264,14 +264,14 @@ static void create_ff(RTLIL::Module *module, const LibertyAst *node)
|
|||
for (auto& [out_sig, cp_var, neg] : {tuple{iq_sig, clear_preset_var1, false}, {iqn_sig, clear_preset_var2, true}}) {
|
||||
SigSpec q_sig = out_sig;
|
||||
if (neg) {
|
||||
q_sig = module->addWire(NEW_ID, out_sig.as_wire());
|
||||
q_sig = module->addWire(NEW_TWINE, out_sig.as_wire());
|
||||
module->addNotGate(NEW_ID, q_sig, out_sig);
|
||||
}
|
||||
|
||||
RTLIL::Cell* cell = module->addCell(NEW_ID, "");
|
||||
cell->setPort(ID::D, data_sig);
|
||||
cell->setPort(ID::Q, q_sig);
|
||||
cell->setPort(ID::C, clk_sig);
|
||||
RTLIL::Cell* cell = module->addCell(NEW_TWINE, "");
|
||||
cell->setPort(TW::D, data_sig);
|
||||
cell->setPort(TW::Q, q_sig);
|
||||
cell->setPort(TW::C, clk_sig);
|
||||
|
||||
if (clear_sig.size() == 0 && preset_sig.size() == 0) {
|
||||
cell->type = stringf("$_DFF_%c_", clk_polarity ? 'P' : 'N');
|
||||
|
|
@ -279,12 +279,12 @@ static void create_ff(RTLIL::Module *module, const LibertyAst *node)
|
|||
|
||||
if (clear_sig.size() == 1 && preset_sig.size() == 0) {
|
||||
cell->type = stringf("$_DFF_%c%c0_", clk_polarity ? 'P' : 'N', clear_polarity ? 'P' : 'N');
|
||||
cell->setPort(ID::R, clear_sig);
|
||||
cell->setPort(TW::R, clear_sig);
|
||||
}
|
||||
|
||||
if (clear_sig.size() == 0 && preset_sig.size() == 1) {
|
||||
cell->type = stringf("$_DFF_%c%c1_", clk_polarity ? 'P' : 'N', preset_polarity ? 'P' : 'N');
|
||||
cell->setPort(ID::R, preset_sig);
|
||||
cell->setPort(TW::R, preset_sig);
|
||||
}
|
||||
|
||||
if (clear_sig.size() == 1 && preset_sig.size() == 1) {
|
||||
|
|
@ -313,8 +313,8 @@ static void create_ff(RTLIL::Module *module, const LibertyAst *node)
|
|||
log_debug("cell %s variable %d undef c&p behavior\n", name, (int)neg + 1);
|
||||
}
|
||||
|
||||
cell->setPort(ID::S, s_sig);
|
||||
cell->setPort(ID::R, r_sig);
|
||||
cell->setPort(TW::S, s_sig);
|
||||
cell->setPort(TW::R, r_sig);
|
||||
}
|
||||
|
||||
log_assert(!cell->type.empty());
|
||||
|
|
@ -352,27 +352,27 @@ static bool create_latch(RTLIL::Module *module, const LibertyAst *node, bool fla
|
|||
rerun_invert_rollback = false;
|
||||
|
||||
for (auto &it : module->cells_) {
|
||||
if (it.second->type == ID($_NOT_) && it.second->getPort(ID::Y) == enable_sig) {
|
||||
enable_sig = it.second->getPort(ID::A);
|
||||
if (it.second->type == ID($_NOT_) && it.second->getPort(TW::Y) == enable_sig) {
|
||||
enable_sig = it.second->getPort(TW::A);
|
||||
enable_polarity = !enable_polarity;
|
||||
rerun_invert_rollback = true;
|
||||
}
|
||||
if (it.second->type == ID($_NOT_) && it.second->getPort(ID::Y) == clear_sig) {
|
||||
clear_sig = it.second->getPort(ID::A);
|
||||
if (it.second->type == ID($_NOT_) && it.second->getPort(TW::Y) == clear_sig) {
|
||||
clear_sig = it.second->getPort(TW::A);
|
||||
clear_polarity = !clear_polarity;
|
||||
rerun_invert_rollback = true;
|
||||
}
|
||||
if (it.second->type == ID($_NOT_) && it.second->getPort(ID::Y) == preset_sig) {
|
||||
preset_sig = it.second->getPort(ID::A);
|
||||
if (it.second->type == ID($_NOT_) && it.second->getPort(TW::Y) == preset_sig) {
|
||||
preset_sig = it.second->getPort(TW::A);
|
||||
preset_polarity = !preset_polarity;
|
||||
rerun_invert_rollback = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RTLIL::Cell *cell = module->addCell(NEW_ID, ID($_NOT_));
|
||||
cell->setPort(ID::A, iq_sig);
|
||||
cell->setPort(ID::Y, iqn_sig);
|
||||
RTLIL::Cell *cell = module->addCell(NEW_TWINE, ID($_NOT_));
|
||||
cell->setPort(TW::A, iq_sig);
|
||||
cell->setPort(TW::Y, iqn_sig);
|
||||
|
||||
if (clear_sig.size() == 1)
|
||||
{
|
||||
|
|
@ -381,25 +381,25 @@ static bool create_latch(RTLIL::Module *module, const LibertyAst *node, bool fla
|
|||
|
||||
if (clear_polarity == true || clear_polarity != enable_polarity)
|
||||
{
|
||||
RTLIL::Cell *inv = module->addCell(NEW_ID, ID($_NOT_));
|
||||
inv->setPort(ID::A, clear_sig);
|
||||
inv->setPort(ID::Y, module->addWire(NEW_ID));
|
||||
RTLIL::Cell *inv = module->addCell(NEW_TWINE, ID($_NOT_));
|
||||
inv->setPort(TW::A, clear_sig);
|
||||
inv->setPort(TW::Y, module->addWire(NEW_TWINE));
|
||||
|
||||
if (clear_polarity == true)
|
||||
clear_negative = inv->getPort(ID::Y);
|
||||
clear_negative = inv->getPort(TW::Y);
|
||||
if (clear_polarity != enable_polarity)
|
||||
clear_enable = inv->getPort(ID::Y);
|
||||
clear_enable = inv->getPort(TW::Y);
|
||||
}
|
||||
|
||||
RTLIL::Cell *data_gate = module->addCell(NEW_ID, ID($_AND_));
|
||||
data_gate->setPort(ID::A, data_sig);
|
||||
data_gate->setPort(ID::B, clear_negative);
|
||||
data_gate->setPort(ID::Y, data_sig = module->addWire(NEW_ID));
|
||||
RTLIL::Cell *data_gate = module->addCell(NEW_TWINE, ID($_AND_));
|
||||
data_gate->setPort(TW::A, data_sig);
|
||||
data_gate->setPort(TW::B, clear_negative);
|
||||
data_gate->setPort(TW::Y, data_sig = module->addWire(NEW_TWINE));
|
||||
|
||||
RTLIL::Cell *enable_gate = module->addCell(NEW_ID, enable_polarity ? ID($_OR_) : ID($_AND_));
|
||||
enable_gate->setPort(ID::A, enable_sig);
|
||||
enable_gate->setPort(ID::B, clear_enable);
|
||||
enable_gate->setPort(ID::Y, enable_sig = module->addWire(NEW_ID));
|
||||
RTLIL::Cell *enable_gate = module->addCell(NEW_TWINE, enable_polarity ? ID($_OR_) : ID($_AND_));
|
||||
enable_gate->setPort(TW::A, enable_sig);
|
||||
enable_gate->setPort(TW::B, clear_enable);
|
||||
enable_gate->setPort(TW::Y, enable_sig = module->addWire(NEW_TWINE));
|
||||
}
|
||||
|
||||
if (preset_sig.size() == 1)
|
||||
|
|
@ -409,31 +409,31 @@ static bool create_latch(RTLIL::Module *module, const LibertyAst *node, bool fla
|
|||
|
||||
if (preset_polarity == false || preset_polarity != enable_polarity)
|
||||
{
|
||||
RTLIL::Cell *inv = module->addCell(NEW_ID, ID($_NOT_));
|
||||
inv->setPort(ID::A, preset_sig);
|
||||
inv->setPort(ID::Y, module->addWire(NEW_ID));
|
||||
RTLIL::Cell *inv = module->addCell(NEW_TWINE, ID($_NOT_));
|
||||
inv->setPort(TW::A, preset_sig);
|
||||
inv->setPort(TW::Y, module->addWire(NEW_TWINE));
|
||||
|
||||
if (preset_polarity == false)
|
||||
preset_positive = inv->getPort(ID::Y);
|
||||
preset_positive = inv->getPort(TW::Y);
|
||||
if (preset_polarity != enable_polarity)
|
||||
preset_enable = inv->getPort(ID::Y);
|
||||
preset_enable = inv->getPort(TW::Y);
|
||||
}
|
||||
|
||||
RTLIL::Cell *data_gate = module->addCell(NEW_ID, ID($_OR_));
|
||||
data_gate->setPort(ID::A, data_sig);
|
||||
data_gate->setPort(ID::B, preset_positive);
|
||||
data_gate->setPort(ID::Y, data_sig = module->addWire(NEW_ID));
|
||||
RTLIL::Cell *data_gate = module->addCell(NEW_TWINE, ID($_OR_));
|
||||
data_gate->setPort(TW::A, data_sig);
|
||||
data_gate->setPort(TW::B, preset_positive);
|
||||
data_gate->setPort(TW::Y, data_sig = module->addWire(NEW_TWINE));
|
||||
|
||||
RTLIL::Cell *enable_gate = module->addCell(NEW_ID, enable_polarity ? ID($_OR_) : ID($_AND_));
|
||||
enable_gate->setPort(ID::A, enable_sig);
|
||||
enable_gate->setPort(ID::B, preset_enable);
|
||||
enable_gate->setPort(ID::Y, enable_sig = module->addWire(NEW_ID));
|
||||
RTLIL::Cell *enable_gate = module->addCell(NEW_TWINE, enable_polarity ? ID($_OR_) : ID($_AND_));
|
||||
enable_gate->setPort(TW::A, enable_sig);
|
||||
enable_gate->setPort(TW::B, preset_enable);
|
||||
enable_gate->setPort(TW::Y, enable_sig = module->addWire(NEW_TWINE));
|
||||
}
|
||||
|
||||
cell = module->addCell(NEW_ID, stringf("$_DLATCH_%c_", enable_polarity ? 'P' : 'N'));
|
||||
cell->setPort(ID::D, data_sig);
|
||||
cell->setPort(ID::Q, iq_sig);
|
||||
cell->setPort(ID::E, enable_sig);
|
||||
cell = module->addCell(NEW_TWINE, stringf("$_DLATCH_%c_", enable_polarity ? 'P' : 'N'));
|
||||
cell->setPort(TW::D, data_sig);
|
||||
cell->setPort(TW::Q, iq_sig);
|
||||
cell->setPort(TW::E, enable_sig);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -793,7 +793,7 @@ struct LibertyFrontend : public Frontend {
|
|||
if (wi->port_input) {
|
||||
for (auto wo : module->wires())
|
||||
if (wo->port_output) {
|
||||
RTLIL::Cell *spec = module->addCell(NEW_ID, ID($specify2));
|
||||
RTLIL::Cell *spec = module->addCell(NEW_TWINE, ID($specify2));
|
||||
spec->setParam(ID::SRC_WIDTH, wi->width);
|
||||
spec->setParam(ID::DST_WIDTH, wo->width);
|
||||
spec->setParam(ID::T_FALL_MAX, 1000);
|
||||
|
|
@ -805,9 +805,9 @@ struct LibertyFrontend : public Frontend {
|
|||
spec->setParam(ID::SRC_DST_POL, false);
|
||||
spec->setParam(ID::SRC_DST_PEN, false);
|
||||
spec->setParam(ID::FULL, true);
|
||||
spec->setPort(ID::EN, Const(1, 1));
|
||||
spec->setPort(ID::SRC, wi);
|
||||
spec->setPort(ID::DST, wo);
|
||||
spec->setPort(TW::EN, Const(1, 1));
|
||||
spec->setPort(TW::SRC, wi);
|
||||
spec->setPort(TW::DST, wo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -445,7 +445,7 @@ struct RTLILFrontendWorker {
|
|||
|
||||
current_module = new RTLIL::Module;
|
||||
current_module->design = design;
|
||||
current_module->meta_->name_id = module_name;
|
||||
current_module->meta_->name = module_name;
|
||||
if (delete_current_module) {
|
||||
// Module is about to be discarded — drop its src attribute
|
||||
// rather than push it into a pool we'll never reach.
|
||||
|
|
@ -706,7 +706,7 @@ struct RTLILFrontendWorker {
|
|||
expect_eol();
|
||||
}
|
||||
|
||||
void legalize_width_parameter(RTLIL::Cell *cell, RTLIL::IdString port_name)
|
||||
void legalize_width_parameter(RTLIL::Cell *cell, TwineRef port_name)
|
||||
{
|
||||
std::string width_param_name = port_name.str() + "_WIDTH";
|
||||
if (cell->parameters.count(width_param_name) == 0)
|
||||
|
|
@ -763,7 +763,7 @@ struct RTLILFrontendWorker {
|
|||
cell->parameters.insert({std::move(param_name), std::move(val)});
|
||||
expect_eol();
|
||||
} else if (try_parse_keyword("connect")) {
|
||||
RTLIL::IdString port_name = parse_id();
|
||||
TwineRef port_name = parse_id();
|
||||
if (cell->hasPort(port_name)) {
|
||||
if (flag_legalize)
|
||||
log("Legalizing redefinition of cell port %s.", port_name);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue