We have a designer here that has assigned a temporary result to a variable in a combinational always block in order to improve readability. His code looks similar to this:
logic second_condition;
always_comb begin
if (condition) begin
second_condition = long_statement;
if (second_condition) begin
(...)
end
end
end
The problem here is that second_condition
arguably describes a latch, but since this latch has no load (it's not used in any other always block), it is optimized away, and there is no warning about latches being inferred during synthesis. Some tool vendors seem to call this a "hanging latch". Notably a loop iterator can also be considered a hanging latch.
Is this something that is completely safe with all tools, or is it worth having a coding guideline never to do this? In this case you could just add an assignment to zero in the top of the always_comb block to remove the "hanging latch".