Altera_Forum
Honored Contributor
11 years agoInferred latch warning
Hi,
When I write the following code: ENTITY test IS GENERIC ( DW: INTEGER := 4 ); ... clk, rst_n and other ports END ENTITY; ARCHITECTURE rtl OF test IS a: UNSIGNED(31 DOWNTO 0); BEGIN -- arch PROCESS (clk, rst_n) BEGIN IF rst_n='0' THEN a <= TO_UNSIGNED(0, a'LENGTH); ELSIF clk'EVENT AND clk = '1' THEN a <= a + DW; END IF; ... other code using a (this is the wrong place to do that, as was pointed out in the discussion) END PROCESS; ... other code (incl. processes) that use a END ARCHITECTURE; When DW is e.g. 2 or 4 (but not 1), the compiler warns (10631) about latches being inferred for a. The warning seems incorrect to me: it is true that a(0) will not be assigned in the synthesized design, but only because the compiler has optimized away my assignment to it. And in effect, it becomes stuck to '0' and won't become a latch, as is expected. This kind of warning is a nuisance in modular code since the warning is usually indicative of a serious design error, but it is false, and draws my attention away. Sooner or later I look over a genuine warning... Can I avoid it somehow ? Thanks, J.