Обычно считается, что FPGA не годятся для асинхронной логики. Родной софт от Xilinx способствует этому предубеждению: при попытке создать latch традиционными средствами языка Verilog, к примеру:
always @(*)
if (set)
z <= 1;
else if (clr)
z <= 0;
получаем серию страшных предупреждений типа:WARNING:Xst:737 - Found 1-bit latch for signal <z>. Latches mayМежду тем, задача отлично решается посредством компонента FDCPE из библиотеки Xilinx. Немного лёгкого шаманства, и он превращается в асинхронную защёлку:
be generated from incomplete case or if statements. We do not
recommend the use of latches in FPGA/CPLD designs, as they may
lead to timing problems.
(*) This 1 clock signal(s) are generated by combinatorial logic,
and XST is not able to identify which are the primary clock signals.
Please use the CLOCK_SIGNAL constraint to specify the clock signal(s)
generated by combinatorial logic.
WARNING:PhysDesignRules:372 - Gated clock. Clock net clr is sourced by a
combinatorial pin. This is not good design practice. Use the CE pin to
control the loading of data into the flip-flop.
module th22 (input a, input b, output z);
assign set = a & b;
assign clr = !a & !b;
FDCPE latch (
.Q (z), // Data output
.D (0), // Data input
.C (0), // Clock input
.CE (0), // Clock enable
.PRE (set), // Asynchronous set
.CLR (clr) // Asynchronous clear
);
endmodule