0

Suppose that the circuit has several inputs from an external circuit which do not have an effect until the clock next rise edge due to using synchronous flip-flops. If the external circuit sends several inputs and because there is a different propagation delay for each line one or two inputs arrive late after the clock has rise and after other inputs were activated will the circuit encounter a hazard?

JRE
  • 67,678
  • 8
  • 104
  • 179
dev65
  • 165
  • 4
  • 1
    Of course it will be a hazard. The calculation at that cycle will have wrong inputs and will probably produce wrong outputs. – Eugene Sh. Dec 02 '21 at 15:08
  • Do you have any example circuit to demonstrate your question? – Mitu Raj Dec 02 '21 at 15:10
  • @EugeneSh. but then how synchronous guarantees no race – dev65 Dec 02 '21 at 15:10
  • @MituRaj no I just though of this situation – dev65 Dec 02 '21 at 15:11
  • Synchronous implies your clock cycle is sufficient for the signal to propagate and settle. If it is too short, your design is simply broken. – Eugene Sh. Dec 02 '21 at 15:12
  • Then it needs more clarity, it depends on where this input is going to. Is it driving a combinational logic and the output is combinational? Or is it going to another flip flop input... – Mitu Raj Dec 02 '21 at 15:13
  • @EugeneSh. this is different. What you say is that you guarantee the clock will not go to rise again until the circuit has reached its stable state – dev65 Dec 02 '21 at 15:14
  • @MituRaj I think of cpu taking input from memory and memory inputs may not arrive all before the click rise due to different clocks in cpu and ram – dev65 Dec 02 '21 at 15:15
  • Different from what? This is a basic timing requirement for a sequential circuit. If the timing constraint is not satisfied, the circuit is broken and won't guarantee you anything except of troubles. – Eugene Sh. Dec 02 '21 at 15:16
  • @dev65 If the memory inputs don't arrive in time for the clock edge, then you've simply failed to design a device that meets timing specification. – nanofarad Dec 02 '21 at 15:17
  • @EugeneSh. I mean we are talking about different things here – dev65 Dec 02 '21 at 15:18
  • If it is supposed to arrive before next clock edge, it doesn't arrive, then the design is said to be a fail. Because it violated timing requirement. – Mitu Raj Dec 02 '21 at 15:19
  • @nanofarad you are right but how to ensure this does not happen ? – dev65 Dec 02 '21 at 15:19
  • 2
    Of course we are talking about the same thing. *"how to ensure this does not happen "* - by calculating the critical path delay and setting the minimal clock cycle accordingly. – Eugene Sh. Dec 02 '21 at 15:20
  • You would have to ensure it by performing 'Static Timing Analysis' of the design in all timing paths. – Mitu Raj Dec 02 '21 at 15:22
  • @dev65 By analyzing the circuit timing and ensuring that the design does not violate them. You check skew against your clock source, you cross clock domains with appropriate synchronizers, you ensure that any derived clocks have the necessary phase relationships as a function of ensuring that the PLLs are configured accordingly, etc. – nanofarad Dec 02 '21 at 15:24
  • You might want to look over the discussion here: https://electronics.stackexchange.com/questions/570352/is-metastability-not-a-concern-in-cdc-if-the-signal-in-source-clock-is-at-least/570379#570379 – SteveSh Dec 02 '21 at 18:33

2 Answers2

2

If the delays are constant and those inputs always arrive after the clock edge, there is no race condition, there is a pipeline error.

You can solve this by (for example) delaying the faster input by a clock period to match the other inputs : this Q&A illustrates a pipeline error and its resolution.

If the delays are variable (or the input is completely unsynchronised) there is a race condition, and several bad things can happen when the input arrives at approximately the same time as the clock edge.

Very rarely, this results in metastability, where the two (data and clock) arrive at precisely the same instant so that the changing data cannot be resolved as either '0' or '1'. This can result in an intermediate output state which takes a long time (worst case, more than a clock period) to resolve into a valid logic level. (In modern FPGA technology, "very rarely" translates into "maybe once or twice before the heat death of the universe" though in the early 2000s it was a more significant problem.

Much more commonly, (and often confused with metastability) the input signal arrives at two or more destinations within the circuit, before the clock edge at one register, and after it at another, and is thus seen as both '0' and '1' by different parts of the circuit.

  • I understand this but how to make sure the inputs will not arrive around the edge if the two circuits have different clock rates ? – dev65 Dec 02 '21 at 16:20
  • @dev65 that is not what your post asks ... please post a new question, so that it is not burried inside a comment – jsotola Dec 02 '21 at 16:34
  • @jsotola I know my question was answered above but I want also to know how to solve it or even a hint for what I should search for – dev65 Dec 02 '21 at 16:36
  • 1
    that should be a new question ... this site is not a forum – jsotola Dec 02 '21 at 16:36
  • 2
    If you have two signal sources that are not synchronous, then you have to synchronize them. There is no way around it. Different clocks (unless it is just a phase) imply that you will get more different signals from one source than from the other in a unit of time, and it does not make any sense if you want to process all of them. – Eugene Sh. Dec 02 '21 at 16:41
  • 1
    "Input synchronizer" as a search term should yield myriad examples. –  Dec 02 '21 at 18:25
0

I found this problem in Wikipedia and it seems to be called Metastability problem. According to wikipedia this problem can't be solved entirely and there is no metastable-proof flip-flop. For circuits that is entirely made by the designer the designer must make sure they are metastable and for circuits that is external is to connect two or more flip-flops in a chain.

from wikipedia:

Timing parameters

Flip-flop setup, hold and clock-to-output timing parameters The input must be held steady in a period around the rising edge of the clock known as the aperture. Imagine taking a picture of a frog on a lily-pad.[29] Suppose the frog then jumps into the water. If you take a picture of the frog as it jumps into the water, you will get a blurry picture of the frog jumping into the water—it's not clear which state the frog was in. But if you take a picture while the frog sits steadily on the pad (or is steadily in the water), you will get a clear picture. In the same way, the input to a flip-flop must be held steady during the aperture of the flip-flop.

Setup time is the minimum amount of time the data input should be held steady before the clock event, so that the data is reliably sampled by the clock.

Hold time is the minimum amount of time the data input should be held steady after the clock event, so that the data is reliably sampled by the clock.

Aperture is the sum of setup and hold time. The data input should be held steady throughout this time period.[29]

Recovery time is the minimum amount of time the asynchronous set or reset input should be inactive before the clock event, so that the data is reliably sampled by the clock. The recovery time for the asynchronous set or reset input is thereby similar to the setup time for the data input.

Removal time is the minimum amount of time the asynchronous set or reset input should be inactive after the clock event, so that the data is reliably sampled by the clock. The removal time for the asynchronous set or reset input is thereby similar to the hold time for the data input.

Short impulses applied to asynchronous inputs (set, reset) should not be applied completely within the recovery-removal period, or else it becomes entirely indeterminable whether the flip-flop will transition to the appropriate state. In another case, where an asynchronous signal simply makes one transition that happens to fall between the recovery/removal time, eventually the flip-flop will transition to the appropriate state, but a very short glitch may or may not appear on the output, dependent on the synchronous input signal. This second situation may or may not have significance to a circuit design.

Set and Reset (and other) signals may be either synchronous or asynchronous and therefore may be characterized with either Setup/Hold or Recovery/Removal times, and synchronicity is very dependent on the design of the flip-flop.

Differentiation between Setup/Hold and Recovery/Removal times is often necessary when verifying the timing of larger circuits because asynchronous signals may be found to be less critical than synchronous signals. The differentiation offers circuit designers the ability to define the verification conditions for these types of signals independently.

dev65
  • 165
  • 4