2
\$\begingroup\$

This is a follow-up question to https://electronics.stackexchange.com/a/95195/13354, in which I was asking about a specific solution to the more general problem described here.

I'd like to create a logic function that toggles with the (inverted) clock when enabled and stays low when disabled, like so:

clk ena out
 0   0   0
 1   0   0
 0   1   1
 1   1   0

In addition to that, I'd like the out signal to be glitch-free, as shown in the following example waveform:

Desired waveform

As shown in this image, potential glitches of the ena input can happen shortly after the clk edges; nevertheless, the out waveform should be glitch free.

According to this answer to aforementioned question, the circuit should be a clock gate rather than a self-resetting flip-flop. This is the proposed schematic:

schematic

simulate this circuit – Schematic created using CircuitLab

Unfortunately, this still causes glitches when ena goes low, because the Q output of the flip-flop is delayed with respect to clk (note that I ignored the common delay between clk and its inversion, which I think doesn't contribute to the issue):

Waveform with clock gate

Now my question: What circuit should I choose to have the out signal glitch-free?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

I think, that in this case you should delay the inverted clock signal, using the even number of inverters between the CLK input of REG1 and the lower input of the AND gate.

Please note, that even in this case you may run into trouble caused by the metastability of REG1. To reduce this risk, I'd suggest to add yet one stage of synchronization of the ena signal (however of course it will slightly change the functionality, as ENA will be delayed).

schematic

simulate this circuit – Schematic created using CircuitLab

You can also try another circuits shown in the article linked in my response to your previous question, however you should keep in mind that the last and most promising one seems to be patented :-(.

\$\endgroup\$
6
  • \$\begingroup\$ Thanks for the answer! Could you explain why there might be a metastability problem in REG1 if there is no REG2? To clarify, the glitches on ena only ever occur after a clk edge (rising or falling), therefore any clk edge sampling ena should be safe. \$\endgroup\$
    – FriendFX
    Jan 7, 2014 at 6:42
  • \$\begingroup\$ If ena changes its state near to the active edge of the clk signal (violating the setup time and hold time requirements), the flip-flop may respond in a non-standard way, due to metastability. E.g. its propagation time may significantly increase. Addition of another synchronizing stage (REG2) decreases the risk, that the signal on D input of REG1 will violate setup time and hold time requirements (however such a risk still exists). \$\endgroup\$
    – wzab
    Jan 23, 2014 at 22:32
  • \$\begingroup\$ Thanks for the explanation. Unfortunately I can't accept your answer as it stands because it wouldn't produce the same timing as the one I asked for. If we assume that setup and hold times of ena with respect to clk are always met, I think it is safe to remove REG2, in which case your circuit exhibits the behaviour I asked for - but only if the delay caused by NOT2 and NOT3 is big enough to "cover" the glitches, or am I missing something else? \$\endgroup\$
    – FriendFX
    Jan 24, 2014 at 0:23
  • \$\begingroup\$ In case of metastability you always have a trade-off between the delay introduced by additional synchronizing flip-flops, and reliability of the system. Please note, that metastability may also cause a jitter of the gclk signal. If you accept this risk, you may ommit REG2 \$\endgroup\$
    – wzab
    Jan 26, 2014 at 16:18
  • \$\begingroup\$ I know about metastability problems, what I am trying to say is that I think they don't apply here because ena changes synchronously with clk, i.e. after either one of clk's edges. Therefore I think having REG2 only introduces delay while not adding anything valuable to the behaviour. Of course, if ena was asynchronous to clk, you'd use as many stages of registers as feasible to avoid metastability. \$\endgroup\$
    – FriendFX
    Jan 27, 2014 at 3:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.