Skip to content

Commit

Permalink
clockgate: bail on constant signals
Browse files Browse the repository at this point in the history
  • Loading branch information
widlarizer committed Sep 9, 2024
1 parent dc039d8 commit 7e47329
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
3 changes: 2 additions & 1 deletion passes/techmap/clockgate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ struct ClockgatePass : public Pass {
continue;

FfData ff(&initvals, cell);
if (ff.has_ce) {
// It would be odd to get constants, but we better handle it
if (ff.has_ce && ff.sig_clk.is_wire() && ff.sig_ce.is_wire()) {
ce_ffs.insert(cell);

ClkNetInfo info = clk_info_from_ff(ff);
Expand Down
46 changes: 46 additions & 0 deletions tests/techmap/clockgate.ys
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,50 @@ select -module dffe_01 -assert-count 0 t:\\pdk_icg
select -module dffe_10 -assert-count 0 t:\\pdk_icg
select -module dffe_11 -assert-count 0 t:\\pdk_icg

#------------------------------------------------------------------------------

design -reset
read_rtlil << EOT

module \bad1
wire input 1 \clk
wire input 3 \d1
wire input 2 \en
wire output 4 \q1
cell $dffe $auto$ff.cc:266:slice$27
parameter \CLK_POLARITY 1
parameter \EN_POLARITY 1
parameter \WIDTH 1
connect \CLK \clk
connect \D \d1
connect \EN 1'1
connect \Q \q1
end
end

module \bad2
wire input 1 \clk
wire input 3 \d1
wire input 2 \en
wire output 4 \q1
cell $dffe $auto$ff.cc:266:slice$27
parameter \CLK_POLARITY 1
parameter \EN_POLARITY 1
parameter \WIDTH 1
connect \CLK 1'1
connect \D \d1
connect \EN \en
connect \Q \q1
end
end

EOT

# Check we don't choke on constants
clockgate -pos pdk_icg ce:clkin:clkout -tie_lo scanen
select -module bad1 -assert-count 0 t:\\pdk_icg
select -module bad2 -assert-count 0 t:\\pdk_icg

#------------------------------------------------------------------------------

# TODO test -tie_lo

0 comments on commit 7e47329

Please sign in to comment.