Race Hazards, Clock Skew, Cross Simulation & Intra-Assignment Delays


Race Hazards and Clock Skew

In a synchronous system (where a single clock is shared by all sequential elements) almost all timing problems can be overcome by reducing the speed of the clock. The exception is a race hazard where data arrives too early at the D input of a flip-flop allowing the data to pass through one cycle too early.

To avoid hazard:

td1 + tpQ + tcomb > td2 + thold

Where:

this can be re-written as:

tskew < tcomb + tpQ - thold

Where:

In this study we will consider the worst case where there is no combinational logic delay (this is the case most likely to result in a hazard).

The equation for hazard avoidance now gives us an upper limit for the permitted clock skew in terms of characteristics of a D-Type:

tskew < tpQ - thold

Cross Simulation and Intra-Assignment Delays

With a cross simulation we simulate a behavioural module (e.g. controller) alongside a structural module (e.g. datapath).

Since the behavioual module will not include a model for the delay in the clock buffer there is a potential problem as the equation becomes:

tclock_delay(structural) < tpQ(behavioural) - thold(structural)

The solution is to ensure that tpQ(behavioural) is sufficiently large. This Clock to Q delay must be added in for all registers updated within a procedural block controlled by always_ff @(posedge Clock).

The delays can be seen in the code snippet below:

  always_ff @(posedge Clock, negedge nReset)
    if ( ! nReset )
      begin
        started <= 0;
        toggled <= 0;
        count <= 0;
      end
    else
      begin
        if (( started == 1 ) && ( toggled == 0 ))
          count <= #20 count + 1;
        else
          count <= #20 count - 3;
        started <= #20 1;
        toggled <= #20 ! toggled;
      end

Notes


D-Type Timing

For successful operation, data must be available for at least tsetup before the rising clock edge and at least thold after the rising clock edge.

The output will be stable and valid tpQ after the rising clock edge.


Iain McNally

2-10-2011