2
\$\begingroup\$

I implemented an SR latch in Verilog.

module sr_latch(
 output Q,
 output P,
 input S,
 input R
);
nor(P, S, Q);
nor(Q, R, P);
endmodule

However, Xilinx ISE reports a warning:

WARNING:Xst:2170 - Unit sr_latch : the following signal(s) form a combinatorial loop: n0000.

Is this warning avoidable for implementing an SR latch?

Should I just ignore it?

asked Jul 25, 2021 at 10:33
\$\endgroup\$
1
  • \$\begingroup\$ No you can't. FPGAs are not meant for implementing latches in RTL. They have to be properly timed due to the combi feedback, which FPGA timing analysers can't do. \$\endgroup\$ Commented Jul 25, 2021 at 12:05

1 Answer 1

5
\$\begingroup\$

It doesn't seem avoidable. Even in this document by Xilinx themselves they use this Verilog code to generate an SR-latch

module SR_latch_gate (input R, input S, output Q, output Qbar);
 nor (Q, R, Qbar);
 nor (Qbar, S, Q);
endmodule
module SR_latch_dataflow (input R, input S, output Q, output Qbar);
 assign #2 Q_i = Q;
 assign #2 Qbar_i = Qbar;
 assign #2 Q = ~ (R | Qbar);
 assign #2 Qbar = ~ (S | Q);
endmodule 

which returns this warning when synthesizing (I couldn't recreate the warning you show in your question)

Critical Warning: 1 LUT cells form a combinatorial loop. This can create a race condition. Timing analysis may not be accurate. The preferred resolution is to modify the design to remove combinatorial logic loops.

answered Jul 25, 2021 at 11:24
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.