mirror of
https://github.com/YosysHQ/yosys
synced 2026-07-22 23:25:51 +00:00
WIP
This commit is contained in:
parent
015ab4e45b
commit
f592f2f3af
203 changed files with 4575 additions and 4481 deletions
|
|
@ -66,7 +66,7 @@ void create_ice40_dsp(ice40_dsp_pm &pm)
|
|||
if (cell->type == ID($mul)) {
|
||||
log(" replacing %s with SB_MAC16 cell.\n", st.mul->type.unescape());
|
||||
|
||||
cell = pm.module->addCell(NEW_ID, ID(SB_MAC16));
|
||||
cell = pm.module->addCell(NEW_TWINE, ID(SB_MAC16));
|
||||
pm.module->swap_names(cell, st.mul);
|
||||
}
|
||||
else log_assert(cell->type == ID(SB_MAC16));
|
||||
|
|
@ -86,10 +86,10 @@ void create_ice40_dsp(ice40_dsp_pm &pm)
|
|||
else
|
||||
log_assert(GetSize(CD) == 32);
|
||||
|
||||
cell->setPort(ID::A, A);
|
||||
cell->setPort(ID::B, B);
|
||||
cell->setPort(ID::C, CD.extract(16, 16));
|
||||
cell->setPort(ID::D, CD.extract(0, 16));
|
||||
cell->setPort(TW::A, A);
|
||||
cell->setPort(TW::B, B);
|
||||
cell->setPort(TW::C, CD.extract(16, 16));
|
||||
cell->setPort(TW::D, CD.extract(0, 16));
|
||||
|
||||
cell->setParam(ID(A_REG), st.ffA ? State::S1 : State::S0);
|
||||
cell->setParam(ID(B_REG), st.ffB ? State::S1 : State::S0);
|
||||
|
|
@ -98,15 +98,15 @@ void create_ice40_dsp(ice40_dsp_pm &pm)
|
|||
|
||||
SigSpec AHOLD, BHOLD, CDHOLD;
|
||||
if (st.ffA && st.ffA->hasPort(ID::EN))
|
||||
AHOLD = st.ffA->getParam(ID::EN_POLARITY).as_bool() ? pm.module->Not(NEW_ID, st.ffA->getPort(ID::EN)) : st.ffA->getPort(ID::EN);
|
||||
AHOLD = st.ffA->getParam(ID::EN_POLARITY).as_bool() ? pm.module->Not(NEW_ID, st.ffA->getPort(TW::EN)) : st.ffA->getPort(TW::EN);
|
||||
else
|
||||
AHOLD = State::S0;
|
||||
if (st.ffB && st.ffB->hasPort(ID::EN))
|
||||
BHOLD = st.ffB->getParam(ID::EN_POLARITY).as_bool() ? pm.module->Not(NEW_ID, st.ffB->getPort(ID::EN)) : st.ffB->getPort(ID::EN);
|
||||
BHOLD = st.ffB->getParam(ID::EN_POLARITY).as_bool() ? pm.module->Not(NEW_ID, st.ffB->getPort(TW::EN)) : st.ffB->getPort(TW::EN);
|
||||
else
|
||||
BHOLD = State::S0;
|
||||
if (st.ffCD && st.ffCD->hasPort(ID::EN))
|
||||
CDHOLD = st.ffCD->getParam(ID::EN_POLARITY).as_bool() ? pm.module->Not(NEW_ID, st.ffCD->getPort(ID::EN)) : st.ffCD->getPort(ID::EN);
|
||||
CDHOLD = st.ffCD->getParam(ID::EN_POLARITY).as_bool() ? pm.module->Not(NEW_ID, st.ffCD->getPort(TW::EN)) : st.ffCD->getPort(TW::EN);
|
||||
else
|
||||
CDHOLD = State::S0;
|
||||
cell->setPort(ID(AHOLD), AHOLD);
|
||||
|
|
@ -116,11 +116,11 @@ void create_ice40_dsp(ice40_dsp_pm &pm)
|
|||
|
||||
SigSpec IRSTTOP, IRSTBOT;
|
||||
if (st.ffA && st.ffA->hasPort(ID::ARST))
|
||||
IRSTTOP = st.ffA->getParam(ID::ARST_POLARITY).as_bool() ? st.ffA->getPort(ID::ARST) : pm.module->Not(NEW_ID, st.ffA->getPort(ID::ARST));
|
||||
IRSTTOP = st.ffA->getParam(ID::ARST_POLARITY).as_bool() ? st.ffA->getPort(TW::ARST) : pm.module->Not(NEW_ID, st.ffA->getPort(TW::ARST));
|
||||
else
|
||||
IRSTTOP = State::S0;
|
||||
if (st.ffB && st.ffB->hasPort(ID::ARST))
|
||||
IRSTBOT = st.ffB->getParam(ID::ARST_POLARITY).as_bool() ? st.ffB->getPort(ID::ARST) : pm.module->Not(NEW_ID, st.ffB->getPort(ID::ARST));
|
||||
IRSTBOT = st.ffB->getParam(ID::ARST_POLARITY).as_bool() ? st.ffB->getPort(TW::ARST) : pm.module->Not(NEW_ID, st.ffB->getPort(TW::ARST));
|
||||
else
|
||||
IRSTBOT = State::S0;
|
||||
cell->setPort(ID(IRSTTOP), IRSTTOP);
|
||||
|
|
@ -128,7 +128,7 @@ void create_ice40_dsp(ice40_dsp_pm &pm)
|
|||
|
||||
if (st.clock != SigBit())
|
||||
{
|
||||
cell->setPort(ID::CLK, st.clock);
|
||||
cell->setPort(TW::CLK, st.clock);
|
||||
cell->setPort(ID(CE), State::S1);
|
||||
cell->setParam(ID(NEG_TRIGGER), st.clock_pol ? State::S0 : State::S1);
|
||||
|
||||
|
|
@ -156,7 +156,7 @@ void create_ice40_dsp(ice40_dsp_pm &pm)
|
|||
}
|
||||
else
|
||||
{
|
||||
cell->setPort(ID::CLK, State::S0);
|
||||
cell->setPort(TW::CLK, State::S0);
|
||||
cell->setPort(ID(CE), State::S0);
|
||||
cell->setParam(ID(NEG_TRIGGER), State::S0);
|
||||
}
|
||||
|
|
@ -164,12 +164,12 @@ void create_ice40_dsp(ice40_dsp_pm &pm)
|
|||
// SB_MAC16 Cascade Interface
|
||||
|
||||
cell->setPort(ID(SIGNEXTIN), State::Sx);
|
||||
cell->setPort(ID(SIGNEXTOUT), pm.module->addWire(NEW_ID));
|
||||
cell->setPort(ID(SIGNEXTOUT), pm.module->addWire(NEW_TWINE));
|
||||
|
||||
cell->setPort(ID::CI, State::Sx);
|
||||
cell->setPort(TW::CI, State::Sx);
|
||||
|
||||
cell->setPort(ID(ACCUMCI), State::Sx);
|
||||
cell->setPort(ID(ACCUMCO), pm.module->addWire(NEW_ID));
|
||||
cell->setPort(ID(ACCUMCO), pm.module->addWire(NEW_TWINE));
|
||||
|
||||
// SB_MAC16 Output Interface
|
||||
|
||||
|
|
@ -181,16 +181,16 @@ void create_ice40_dsp(ice40_dsp_pm &pm)
|
|||
if (st.add->getParam(ID::A_SIGNED).as_bool() && st.add->getParam(ID::B_SIGNED).as_bool())
|
||||
pm.module->connect(O[32], O[31]);
|
||||
else
|
||||
cell->setPort(ID::CO, O[32]);
|
||||
cell->setPort(TW::CO, O[32]);
|
||||
O.remove(O_width-1);
|
||||
}
|
||||
else
|
||||
cell->setPort(ID::CO, pm.module->addWire(NEW_ID));
|
||||
cell->setPort(TW::CO, pm.module->addWire(NEW_TWINE));
|
||||
log_assert(GetSize(O) <= 32);
|
||||
if (GetSize(O) < 32)
|
||||
O.append(pm.module->addWire(NEW_ID, 32-GetSize(O)));
|
||||
O.append(pm.module->addWire(NEW_TWINE, 32-GetSize(O)));
|
||||
|
||||
cell->setPort(ID::O, O);
|
||||
cell->setPort(TW::O, O);
|
||||
|
||||
bool accum = false;
|
||||
if (st.add) {
|
||||
|
|
@ -208,7 +208,7 @@ void create_ice40_dsp(ice40_dsp_pm &pm)
|
|||
|
||||
SigSpec OHOLD;
|
||||
if (st.ffO && st.ffO->hasPort(ID::EN))
|
||||
OHOLD = st.ffO->getParam(ID::EN_POLARITY).as_bool() ? pm.module->Not(NEW_ID, st.ffO->getPort(ID::EN)) : st.ffO->getPort(ID::EN);
|
||||
OHOLD = st.ffO->getParam(ID::EN_POLARITY).as_bool() ? pm.module->Not(NEW_ID, st.ffO->getPort(TW::EN)) : st.ffO->getPort(TW::EN);
|
||||
else
|
||||
OHOLD = State::S0;
|
||||
cell->setPort(ID(OHOLDTOP), OHOLD);
|
||||
|
|
@ -216,7 +216,7 @@ void create_ice40_dsp(ice40_dsp_pm &pm)
|
|||
|
||||
SigSpec ORST;
|
||||
if (st.ffO && st.ffO->hasPort(ID::ARST))
|
||||
ORST = st.ffO->getParam(ID::ARST_POLARITY).as_bool() ? st.ffO->getPort(ID::ARST) : pm.module->Not(NEW_ID, st.ffO->getPort(ID::ARST));
|
||||
ORST = st.ffO->getParam(ID::ARST_POLARITY).as_bool() ? st.ffO->getPort(TW::ARST) : pm.module->Not(NEW_ID, st.ffO->getPort(TW::ARST));
|
||||
else
|
||||
ORST = State::S0;
|
||||
cell->setPort(ID(ORSTTOP), ORST);
|
||||
|
|
@ -225,11 +225,11 @@ void create_ice40_dsp(ice40_dsp_pm &pm)
|
|||
SigSpec acc_reset = State::S0;
|
||||
if (st.mux) {
|
||||
if (st.muxAB == ID::A)
|
||||
acc_reset = st.mux->getPort(ID::S);
|
||||
acc_reset = st.mux->getPort(TW::S);
|
||||
else
|
||||
acc_reset = pm.module->Not(NEW_ID, st.mux->getPort(ID::S));
|
||||
acc_reset = pm.module->Not(NEW_ID, st.mux->getPort(TW::S));
|
||||
} else if (st.ffO && st.ffO->hasPort(ID::SRST)) {
|
||||
acc_reset = st.ffO->getParam(ID::SRST_POLARITY).as_bool() ? st.ffO->getPort(ID::SRST) : pm.module->Not(NEW_ID, st.ffO->getPort(ID::SRST));
|
||||
acc_reset = st.ffO->getParam(ID::SRST_POLARITY).as_bool() ? st.ffO->getPort(TW::SRST) : pm.module->Not(NEW_ID, st.ffO->getPort(TW::SRST));
|
||||
}
|
||||
cell->setPort(ID(OLOADTOP), acc_reset);
|
||||
cell->setPort(ID(OLOADBOT), acc_reset);
|
||||
|
|
@ -259,7 +259,7 @@ void create_ice40_dsp(ice40_dsp_pm &pm)
|
|||
else
|
||||
cell->setParam(ID(TOPOUTPUT_SELECT), Const(1, 2));
|
||||
|
||||
st.ffO->connections_.at(ID::Q).replace(O, pm.module->addWire(NEW_ID, GetSize(O)));
|
||||
st.ffO->connections_.at(ID::Q).replace(O, pm.module->addWire(NEW_TWINE, GetSize(O)));
|
||||
cell->setParam(ID(BOTOUTPUT_SELECT), Const(1, 2));
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ code sigA sigB sigH
|
|||
wire_width++;
|
||||
else {
|
||||
if (wire_width) { // add empty wires for bit offset if needed
|
||||
sigH.append(module->addWire(NEW_ID, wire_width));
|
||||
sigH.append(module->addWire(NEW_TWINE, wire_width));
|
||||
wire_width = 0;
|
||||
}
|
||||
sigH.append(O[j]);
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ static void run_ice40_opts(Module *module)
|
|||
SigBit inbit[3] = {
|
||||
get_bit_or_zero(cell->getPort(ID(I0))),
|
||||
get_bit_or_zero(cell->getPort(ID(I1))),
|
||||
get_bit_or_zero(cell->getPort(ID::CI))
|
||||
get_bit_or_zero(cell->getPort(TW::CI))
|
||||
};
|
||||
for (int i = 0; i < 3; i++)
|
||||
if (inbit[i].wire == nullptr) {
|
||||
|
|
@ -79,8 +79,8 @@ static void run_ice40_opts(Module *module)
|
|||
replacement_output = non_const_inputs;
|
||||
|
||||
if (GetSize(replacement_output)) {
|
||||
optimized_co.insert(sigmap(cell->getPort(ID::CO)[0]));
|
||||
module->connect(cell->getPort(ID::CO)[0], replacement_output);
|
||||
optimized_co.insert(sigmap(cell->getPort(TW::CO)[0]));
|
||||
module->connect(cell->getPort(TW::CO)[0], replacement_output);
|
||||
module->design->scratchpad_set_bool("opt.did_something", true);
|
||||
log("Optimized away SB_CARRY cell %s.%s: CO=%s\n",
|
||||
module, cell, log_signal(replacement_output));
|
||||
|
|
@ -95,9 +95,9 @@ static void run_ice40_opts(Module *module)
|
|||
int count_zeros = 0, count_ones = 0;
|
||||
|
||||
SigBit inbit[3] = {
|
||||
cell->getPort(ID::A),
|
||||
cell->getPort(ID::B),
|
||||
cell->getPort(ID::CI)
|
||||
cell->getPort(TW::A),
|
||||
cell->getPort(TW::B),
|
||||
cell->getPort(TW::CI)
|
||||
};
|
||||
for (int i = 0; i < 3; i++)
|
||||
if (inbit[i].wire == nullptr) {
|
||||
|
|
@ -116,7 +116,7 @@ static void run_ice40_opts(Module *module)
|
|||
replacement_output = non_const_inputs;
|
||||
|
||||
if (GetSize(replacement_output)) {
|
||||
optimized_co.insert(sigmap(cell->getPort(ID::CO)[0]));
|
||||
optimized_co.insert(sigmap(cell->getPort(TW::CO)[0]));
|
||||
auto it = cell->attributes.find(IdString{"\\SB_LUT4.name"});
|
||||
if (it != cell->attributes.end()) {
|
||||
module->rename(cell, it->second.decode_string());
|
||||
|
|
@ -134,20 +134,20 @@ static void run_ice40_opts(Module *module)
|
|||
log_abort();
|
||||
cell->attributes = std::move(new_attr);
|
||||
}
|
||||
module->connect(cell->getPort(ID::CO)[0], replacement_output);
|
||||
module->connect(cell->getPort(TW::CO)[0], replacement_output);
|
||||
module->design->scratchpad_set_bool("opt.did_something", true);
|
||||
log("Optimized $__ICE40_CARRY_WRAPPER cell back to logic (without SB_CARRY) %s.%s: CO=%s\n",
|
||||
module, cell, log_signal(replacement_output));
|
||||
cell->type = ID($lut);
|
||||
auto I3 = get_bit_or_zero(cell->getPort(cell->getParam(ID(I3_IS_CI)).as_bool() ? ID::CI : ID(I3)));
|
||||
cell->setPort(ID::A, { I3, inbit[1], inbit[0], get_bit_or_zero(cell->getPort(ID(I0))) });
|
||||
cell->setPort(ID::Y, cell->getPort(ID::O));
|
||||
cell->unsetPort(ID::B);
|
||||
cell->unsetPort(ID::CI);
|
||||
cell->setPort(TW::A, { I3, inbit[1], inbit[0], get_bit_or_zero(cell->getPort(ID(I0))) });
|
||||
cell->setPort(TW::Y, cell->getPort(TW::O));
|
||||
cell->unsetPort(TW::B);
|
||||
cell->unsetPort(TW::CI);
|
||||
cell->unsetPort(ID(I0));
|
||||
cell->unsetPort(ID(I3));
|
||||
cell->unsetPort(ID::CO);
|
||||
cell->unsetPort(ID::O);
|
||||
cell->unsetPort(TW::CO);
|
||||
cell->unsetPort(TW::O);
|
||||
cell->setParam(ID::WIDTH, 4);
|
||||
cell->unsetParam(ID(I3_IS_CI));
|
||||
}
|
||||
|
|
@ -182,18 +182,18 @@ static void run_ice40_opts(Module *module)
|
|||
cell->setParam(ID::LUT, cell->getParam(ID(LUT_INIT)));
|
||||
cell->unsetParam(ID(LUT_INIT));
|
||||
|
||||
cell->setPort(ID::A, SigSpec({
|
||||
cell->setPort(TW::A, SigSpec({
|
||||
get_bit_or_zero(cell->getPort(ID(I3))),
|
||||
get_bit_or_zero(cell->getPort(ID(I2))),
|
||||
get_bit_or_zero(cell->getPort(ID(I1))),
|
||||
get_bit_or_zero(cell->getPort(ID(I0)))
|
||||
}));
|
||||
cell->setPort(ID::Y, cell->getPort(ID::O)[0]);
|
||||
cell->setPort(TW::Y, cell->getPort(TW::O)[0]);
|
||||
cell->unsetPort(ID(I0));
|
||||
cell->unsetPort(ID(I1));
|
||||
cell->unsetPort(ID(I2));
|
||||
cell->unsetPort(ID(I3));
|
||||
cell->unsetPort(ID::O);
|
||||
cell->unsetPort(TW::O);
|
||||
|
||||
cell->check();
|
||||
simplemap_lut(module, cell);
|
||||
|
|
|
|||
|
|
@ -37,14 +37,14 @@ void create_ice40_wrapcarry(ice40_wrapcarry_pm &pm)
|
|||
|
||||
log(" replacing SB_LUT + SB_CARRY with $__ICE40_CARRY_WRAPPER cell.\n");
|
||||
|
||||
Cell *cell = pm.module->addCell(NEW_ID, ID($__ICE40_CARRY_WRAPPER));
|
||||
Cell *cell = pm.module->addCell(NEW_TWINE, ID($__ICE40_CARRY_WRAPPER));
|
||||
pm.module->swap_names(cell, st.carry);
|
||||
|
||||
cell->setPort(ID::A, st.carry->getPort(ID(I0)));
|
||||
cell->setPort(ID::B, st.carry->getPort(ID(I1)));
|
||||
auto CI = st.carry->getPort(ID::CI);
|
||||
cell->setPort(ID::CI, CI);
|
||||
cell->setPort(ID::CO, st.carry->getPort(ID::CO));
|
||||
cell->setPort(TW::A, st.carry->getPort(ID(I0)));
|
||||
cell->setPort(TW::B, st.carry->getPort(ID(I1)));
|
||||
auto CI = st.carry->getPort(TW::CI);
|
||||
cell->setPort(TW::CI, CI);
|
||||
cell->setPort(TW::CO, st.carry->getPort(TW::CO));
|
||||
|
||||
cell->setPort(ID(I0), st.lut->getPort(ID(I0)));
|
||||
auto I3 = st.lut->getPort(ID(I3));
|
||||
|
|
@ -55,7 +55,7 @@ void create_ice40_wrapcarry(ice40_wrapcarry_pm &pm)
|
|||
else
|
||||
cell->setParam(ID(I3_IS_CI), State::S0);
|
||||
cell->setPort(ID(I3), I3);
|
||||
cell->setPort(ID::O, st.lut->getPort(ID::O));
|
||||
cell->setPort(TW::O, st.lut->getPort(TW::O));
|
||||
cell->setParam(ID::LUT, st.lut->getParam(ID(LUT_INIT)));
|
||||
|
||||
for (const auto &a : st.carry->attributes)
|
||||
|
|
@ -134,19 +134,19 @@ struct Ice40WrapCarryPass : public Pass {
|
|||
if (cell->type != ID($__ICE40_CARRY_WRAPPER))
|
||||
continue;
|
||||
|
||||
auto carry = module->addCell(NEW_ID, ID(SB_CARRY));
|
||||
carry->setPort(ID(I0), cell->getPort(ID::A));
|
||||
carry->setPort(ID(I1), cell->getPort(ID::B));
|
||||
carry->setPort(ID::CI, cell->getPort(ID::CI));
|
||||
carry->setPort(ID::CO, cell->getPort(ID::CO));
|
||||
auto carry = module->addCell(NEW_TWINE, ID(SB_CARRY));
|
||||
carry->setPort(ID(I0), cell->getPort(TW::A));
|
||||
carry->setPort(ID(I1), cell->getPort(TW::B));
|
||||
carry->setPort(TW::CI, cell->getPort(TW::CI));
|
||||
carry->setPort(TW::CO, cell->getPort(TW::CO));
|
||||
module->swap_names(carry, cell);
|
||||
auto lut_name = cell->attributes.at(IdString{"\\SB_LUT4.name"}, Const(NEW_ID.str())).decode_string();
|
||||
auto lut = module->addCell(lut_name, ID($lut));
|
||||
lut->setParam(ID::WIDTH, 4);
|
||||
lut->setParam(ID::LUT, cell->getParam(ID::LUT));
|
||||
auto I3 = cell->getPort(cell->getParam(ID(I3_IS_CI)).as_bool() ? ID::CI : ID(I3));
|
||||
lut->setPort(ID::A, { I3, cell->getPort(ID::B), cell->getPort(ID::A), cell->getPort(ID(I0)) });
|
||||
lut->setPort(ID::Y, cell->getPort(ID::O));
|
||||
lut->setPort(TW::A, { I3, cell->getPort(TW::B), cell->getPort(TW::A), cell->getPort(ID(I0)) });
|
||||
lut->setPort(TW::Y, cell->getPort(TW::O));
|
||||
|
||||
std::string carry_src, lut_src, fallback_src;
|
||||
if (cell->src_id() != Twine::Null)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue