Intel® Quartus® Prime Pro Edition User Guide: Design Recommendations

ID 683082
Date 6/20/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

1.5.3.2. Inferring Latches Correctly

Synthesis tools can infer a latch that does not exhibit the glitch and timing hazard problems typically associated with combinational loops. Intel® Quartus® Prime Pro Edition software reports latches that synthesis inferred in the User-Specified and Inferred Latches section of the Compilation Report. This report indicates whether the latch presents a timing hazard, and the total number of user-specified and inferred latches.
Note: In some cases, timing analysis does not completely model latch timing. As a best practice, avoid latches unless required by the design and you fully understand the impact.

If latches or combinational loops in the design do not appear in the User Specified and Inferred Latches section, then Intel® Quartus® Prime synthesis did not infer the latch as a safe latch, so the latch is not considered glitch-free.

All combinational loops listed in the Analysis & Synthesis Logic Cells Representing Combinational Loops table in the Compilation Report are at risk of timing hazards. These entries indicate possible problems with the design that require further investigation. However, correct designs can include combinational loops. For example, it is possible that the combinational loop cannot be sensitized. This occurs when there is an electrical path in the hardware, but either:

  • The designer knows that the circuit never encounters data that causes that path to be activated, or
  • The surrounding logic is set up in a mutually exclusive manner that prevents that path from ever being sensitized, independent of the data input.

For 6-input LUT-based devices, Intel® Quartus® Prime synthesis implements all latch inputs with a single adaptive look-up table (ALUT) in the combinational loop. Therefore, all latches in the User-Specified and Inferred Latches table are free of timing hazards when a single input changes.

If Intel® Quartus® Prime synthesis report lists a latch as a safe latch, other optimizations, such as physical synthesis netlist optimizations in the Fitter, maintain the hazard-free performance. To ensure hazard-free behavior, only one control input can change at a time. Changing two inputs simultaneously, such as deasserting set and reset at the same time, or changing data and enable at the same time, can produce incorrect behavior in any latch.

Intel® Quartus® Prime synthesis infers latches from always blocks in Verilog HDL and process statements in VHDL. However, Intel® Quartus® Prime synthesis does not infer latches from continuous assignments in Verilog HDL, or concurrent signal assignments in VHDL. These rules are the same as for register inference. The Intel® Quartus® Prime synthesis infers registers or flipflops only from always blocks and process statements.

Verilog HDL Set-Reset Latch

module simple_latch (
   input SetTerm,
   input ResetTerm,
   output reg LatchOut
   );
   always @ (SetTerm or ResetTerm) begin
      if (SetTerm)
         LatchOut = 1'b1;
      else if (ResetTerm)
         LatchOut = 1'b0;
   end
endmodule

VHDL Data Type Latch

LIBRARY IEEE;
USE IEEE.std_logic_1164.all;
ENTITY simple_latch IS
	PORT (
		enable, data    : IN STD_LOGIC;
		q               : OUT STD_LOGIC
	);
END simple_latch;
ARCHITECTURE rtl OF simple_latch IS
BEGIN
	latch : PROCESS (enable, data)
		BEGIN
		IF (enable = '1') THEN
			q <= data;
		END IF;
	END PROCESS latch;
END rtl;

Verilog Continuous Assignment Does Not Infer Latch

The following example shows a Verilog HDL continuous assignment that does not infer a latch in the Intel® Quartus® Prime software:

assign latch_out = (~en & latch_out) | (en & data);

The behavior of the assignment is similar to a latch, but it may not function correctly as a latch, and its timing is not analyzed as a latch. Intel® Quartus® Prime Pro Edition synthesis also creates safe latches when possible for instantiations of an Intel FPGA latch IP core. Intel FPGA latch IPs allow you to define a latch with any combination of data, enable, set, and reset inputs. The same limitations apply for creating safe latches as for inferring latches from HDL code.

Inferring the Intel FPGA latch IP core in another synthesis tool ensures that Intel® Quartus® Prime synthesis also recognizes the implementation as a latch. If a third-party synthesis tool implements a latch using the Intel FPGA latch IP core, Intel® Quartus® Prime Pro Edition synthesis reports the latch in the User-Specified and Inferred Latches table, in the same manner as it lists latches you define in HDL source code. The coding style necessary to produce an Intel FPGA latch IP core implementation depends on the synthesis tool. Some third-party synthesis tools list the number of Intel FPGA latch IP cores that are inferred.

The Fitter uses global routing for control signals, including signals that synthesis identifies as latch enables. In some cases, the global insertion delay decreases timing performance. If necessary, you can turn off the Intel® Quartus® Prime Global Signal logic option to manually prevent the use of global signals. The Global & Other Fast Signals table in the Compilation Report reports Global latch enables.