mirror of
https://github.com/YosysHQ/yosys
synced 2025-09-20 16:34:51 +00:00
Update passes/opt to avoid bits()
This commit is contained in:
parent
d4e2fa0c4f
commit
bab72e0af7
10 changed files with 71 additions and 56 deletions
|
@ -405,27 +405,29 @@ struct OptDffWorker
|
|||
} else if (ff.pol_clr == ff.pol_set) {
|
||||
// Try a more complex conversion to plain async reset.
|
||||
State val_neutral = ff.pol_set ? State::S0 : State::S1;
|
||||
Const val_arst;
|
||||
SigBit sig_arst;
|
||||
if (ff.sig_clr[0] == val_neutral)
|
||||
sig_arst = ff.sig_set[0];
|
||||
else
|
||||
sig_arst = ff.sig_clr[0];
|
||||
bool failed = false;
|
||||
Const::Builder val_arst_builder(ff.width);
|
||||
for (int i = 0; i < ff.width; i++) {
|
||||
if (ff.sig_clr[i] == sig_arst && ff.sig_set[i] == val_neutral)
|
||||
val_arst.bits().push_back(State::S0);
|
||||
val_arst_builder.push_back(State::S0);
|
||||
else if (ff.sig_set[i] == sig_arst && ff.sig_clr[i] == val_neutral)
|
||||
val_arst.bits().push_back(State::S1);
|
||||
else
|
||||
val_arst_builder.push_back(State::S1);
|
||||
else {
|
||||
failed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!failed) {
|
||||
log("Converting CLR/SET to ARST on %s (%s) from module %s.\n",
|
||||
log_id(cell), log_id(cell->type), log_id(module));
|
||||
ff.has_sr = false;
|
||||
ff.has_arst = true;
|
||||
ff.val_arst = val_arst;
|
||||
ff.val_arst = val_arst_builder.build();
|
||||
ff.sig_arst = sig_arst;
|
||||
ff.pol_arst = ff.pol_clr;
|
||||
changed = true;
|
||||
|
@ -637,7 +639,7 @@ struct OptDffWorker
|
|||
// Try to merge sync resets.
|
||||
std::map<ctrls_t, std::vector<int>> groups;
|
||||
std::vector<int> remaining_indices;
|
||||
Const val_srst;
|
||||
Const::Builder val_srst_builder(ff.width);
|
||||
|
||||
for (int i = 0 ; i < ff.width; i++) {
|
||||
ctrls_t resets;
|
||||
|
@ -679,16 +681,18 @@ struct OptDffWorker
|
|||
groups[resets].push_back(i);
|
||||
} else
|
||||
remaining_indices.push_back(i);
|
||||
val_srst.bits().push_back(reset_val);
|
||||
val_srst_builder.push_back(reset_val);
|
||||
}
|
||||
Const val_srst = val_srst_builder.build();
|
||||
|
||||
for (auto &it : groups) {
|
||||
FfData new_ff = ff.slice(it.second);
|
||||
new_ff.val_srst = Const();
|
||||
Const::Builder new_val_srst_builder(new_ff.width);
|
||||
for (int i = 0; i < new_ff.width; i++) {
|
||||
int j = it.second[i];
|
||||
new_ff.val_srst.bits().push_back(val_srst[j]);
|
||||
new_val_srst_builder.push_back(val_srst[j]);
|
||||
}
|
||||
new_ff.val_srst = new_val_srst_builder.build();
|
||||
ctrl_t srst = combine_resets(it.first, ff.is_fine);
|
||||
|
||||
new_ff.has_srst = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue