mirror of
https://github.com/YosysHQ/yosys
synced 2026-07-14 19:25:40 +00:00
Merge pull request #6038 from YosysHQ/emil/dfflibmap-fix-resetval
dfflibmap: fix resetval clobber
This commit is contained in:
commit
d4f39588a7
3 changed files with 69 additions and 3 deletions
|
|
@ -272,17 +272,18 @@ static void find_cell(std::vector<const LibertyAst *> cells, IdString cell_type,
|
|||
if (!parse_next_state(cell, ff->find("next_state"), cell_next_pin, cell_next_pol, cell_enable_pin, cell_enable_pol) || (has_enable && (cell_enable_pin.empty() || cell_enable_pol != enapol)))
|
||||
continue;
|
||||
|
||||
bool cell_rstval = rstval;
|
||||
if (has_reset && !cell_next_pol) {
|
||||
// next_state is negated
|
||||
// we later propagate this inversion to the output,
|
||||
// which requires the negation of the reset value
|
||||
rstval = !rstval;
|
||||
cell_rstval = !rstval;
|
||||
}
|
||||
if (has_reset && rstval == false) {
|
||||
if (has_reset && cell_rstval == false) {
|
||||
if (!parse_pin(cell, ff->find("clear"), cell_rst_pin, cell_rst_pol) || cell_rst_pol != rstpol)
|
||||
continue;
|
||||
}
|
||||
if (has_reset && rstval == true) {
|
||||
if (has_reset && cell_rstval == true) {
|
||||
if (!parse_pin(cell, ff->find("preset"), cell_rst_pin, cell_rst_pol) || cell_rst_pol != rstpol)
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
52
tests/techmap/dfflibmap_resetval_clobber.lib
Normal file
52
tests/techmap/dfflibmap_resetval_clobber.lib
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
library(test) {
|
||||
cell (bad_dff) {
|
||||
area : 1;
|
||||
ff("IQ", "IQN") {
|
||||
next_state : "!D"; // Look here
|
||||
clocked_on : "CLK";
|
||||
preset : "!RST"; // Look here
|
||||
}
|
||||
pin(D) {
|
||||
direction : input;
|
||||
}
|
||||
pin(CLK) {
|
||||
direction : input;
|
||||
}
|
||||
pin(RST) {
|
||||
direction : input;
|
||||
}
|
||||
pin(Q) {
|
||||
direction: output;
|
||||
function : "IQ";
|
||||
}
|
||||
pin(QN) {
|
||||
direction: output;
|
||||
function : "IQN";
|
||||
}
|
||||
}
|
||||
cell (good_dff) {
|
||||
area : 1;
|
||||
ff("IQ", "IQN") {
|
||||
next_state : "D"; // Look here
|
||||
clocked_on : "CLK";
|
||||
clear : "RST"; // Look here
|
||||
}
|
||||
pin(D) {
|
||||
direction : input;
|
||||
}
|
||||
pin(CLK) {
|
||||
direction : input;
|
||||
}
|
||||
pin(RST) {
|
||||
direction : input;
|
||||
}
|
||||
pin(Q) {
|
||||
direction: output;
|
||||
function : "IQ";
|
||||
}
|
||||
pin(QN) {
|
||||
direction: output;
|
||||
function : "IQN";
|
||||
}
|
||||
}
|
||||
}
|
||||
13
tests/techmap/dfflibmap_resetval_clobber.ys
Normal file
13
tests/techmap/dfflibmap_resetval_clobber.ys
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
read_verilog -icells <<EOT
|
||||
module top(input C, D, R, output Q);
|
||||
$_DFF_PP0_ ff (.C(C), .D(D), .R(R), .Q(Q));
|
||||
endmodule
|
||||
EOT
|
||||
|
||||
dfflibmap -liberty dfflibmap_resetval_clobber.lib top
|
||||
read_liberty dfflibmap_resetval_clobber.lib
|
||||
flatten -noscopeinfo
|
||||
opt_clean
|
||||
|
||||
select -assert-count 1 t:* top %i
|
||||
select -assert-count 1 t:$_DFF_PP0_ top %i
|
||||
Loading…
Add table
Add a link
Reference in a new issue