mirror of
https://github.com/YosysHQ/yosys
synced 2026-06-02 15:18:07 +00:00
Merge pull request #5655 from YosysHQ/emil/dffsr-sr-priority-undef
Undefine set&reset behavior of $dffsr
This commit is contained in:
commit
3d72a94509
13 changed files with 452 additions and 68 deletions
|
|
@ -157,6 +157,7 @@ struct Async2syncPass : public Pass {
|
|||
|
||||
SigSpec sig_set = ff.sig_set;
|
||||
SigSpec sig_clr = ff.sig_clr;
|
||||
SigSpec sig_clr_inv = ff.sig_clr;
|
||||
|
||||
if (!ff.pol_set) {
|
||||
if (!ff.is_fine)
|
||||
|
|
@ -166,24 +167,42 @@ struct Async2syncPass : public Pass {
|
|||
}
|
||||
|
||||
if (ff.pol_clr) {
|
||||
if (!ff.is_fine)
|
||||
sig_clr_inv = module->Not(NEW_ID, sig_clr);
|
||||
else
|
||||
sig_clr_inv = module->NotGate(NEW_ID, sig_clr);
|
||||
} else {
|
||||
if (!ff.is_fine)
|
||||
sig_clr = module->Not(NEW_ID, sig_clr);
|
||||
else
|
||||
sig_clr = module->NotGate(NEW_ID, sig_clr);
|
||||
}
|
||||
|
||||
// At this point, sig_set and sig_clr are now unconditionally
|
||||
// active-high, and sig_clr_inv is inverted sig_clr
|
||||
|
||||
SigSpec set_and_clr;
|
||||
if (!ff.is_fine)
|
||||
set_and_clr = module->And(NEW_ID, sig_set, sig_clr);
|
||||
else
|
||||
set_and_clr = module->AndGate(NEW_ID, sig_set, sig_clr);
|
||||
|
||||
if (!ff.is_fine) {
|
||||
SigSpec tmp = module->Or(NEW_ID, ff.sig_d, sig_set);
|
||||
module->addAnd(NEW_ID, tmp, sig_clr, new_d);
|
||||
tmp = module->And(NEW_ID, tmp, sig_clr_inv);
|
||||
module->addBwmux(NEW_ID, tmp, Const(State::Sx, ff.width), set_and_clr, new_d);
|
||||
|
||||
tmp = module->Or(NEW_ID, new_q, sig_set);
|
||||
module->addAnd(NEW_ID, tmp, sig_clr, ff.sig_q);
|
||||
tmp = module->And(NEW_ID, tmp, sig_clr_inv);
|
||||
module->addBwmux(NEW_ID, tmp, Const(State::Sx, ff.width), set_and_clr, ff.sig_q);
|
||||
} else {
|
||||
SigSpec tmp = module->OrGate(NEW_ID, ff.sig_d, sig_set);
|
||||
module->addAndGate(NEW_ID, tmp, sig_clr, new_d);
|
||||
tmp = module->AndGate(NEW_ID, tmp, sig_clr_inv);
|
||||
module->addMuxGate(NEW_ID, tmp, State::Sx, set_and_clr, new_d);
|
||||
|
||||
tmp = module->OrGate(NEW_ID, new_q, sig_set);
|
||||
module->addAndGate(NEW_ID, tmp, sig_clr, ff.sig_q);
|
||||
tmp = module->AndGate(NEW_ID, tmp, sig_clr_inv);
|
||||
module->addMuxGate(NEW_ID, tmp, State::Sx, set_and_clr, ff.sig_q);
|
||||
}
|
||||
|
||||
ff.sig_d = new_d;
|
||||
|
|
|
|||
|
|
@ -123,10 +123,14 @@ struct Clk2fflogicPass : public Pass {
|
|||
return module->Mux(NEW_ID, a, b, s);
|
||||
}
|
||||
SigSpec bitwise_sr(Module *module, SigSpec a, SigSpec s, SigSpec r, bool is_fine) {
|
||||
if (is_fine)
|
||||
return module->AndGate(NEW_ID, module->OrGate(NEW_ID, a, s), module->NotGate(NEW_ID, r));
|
||||
else
|
||||
return module->And(NEW_ID, module->Or(NEW_ID, a, s), module->Not(NEW_ID, r));
|
||||
if (is_fine) {
|
||||
return module->MuxGate(NEW_ID, module->AndGate(NEW_ID, module->OrGate(NEW_ID, a, s), module->NotGate(NEW_ID, r)), RTLIL::State::Sx, module->AndGate(NEW_ID, s, r));
|
||||
} else {
|
||||
std::vector<SigBit> y;
|
||||
for (int i = 0; i < a.size(); i++)
|
||||
y.push_back(module->MuxGate(NEW_ID, module->AndGate(NEW_ID, module->OrGate(NEW_ID, a[i], s[i]), module->NotGate(NEW_ID, r[i])), RTLIL::State::Sx, module->AndGate(NEW_ID, s[i], r[i])));
|
||||
return y;
|
||||
}
|
||||
}
|
||||
void execute(std::vector<std::string> args, RTLIL::Design *design) override
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue