We have recently added the following module that contains a latch to our design repo. The module is instanced 3000+ times in our design, and has caused a major simulation performance degradation. Here is the source code:
module clk_gater (
input clk,
input clk_en,
input TE,
output clk_gated
);
reg clk_en_latch;
always_latch begin
if (~clk) begin
clk_en_latch = (clk_en | TE);
end
end
We use VCS as our simulator, and its simulation profiler is telling us that the latch in this module is accounting for 13% of our simulation wallclock time. Our design is huge, so it’s laughable to think that a latch is causing such a problem - even if it’s instanced this many times.
I’m a DV engineer, not an RTLer, so I don’t implement latches ever. Two things that look fishy to me are:
- The use of a clock signal as the input expression to an if statement.
- The signal “clk_en_latch” is a variable, and not a wire.
Anyone have any recommendations for how to improve the simulation performance of the code above?