How do I compare two signals whose edges are almost in the same place?
-
21-12-2019 - |
Question
I am verifying part of a design which generates pulses with precisely timed edges. I have a basic behavioral model which produces an output which is similar, but not exactly the same as the design. The differences between the two are smaller than the precision needed for the design, so my model is good enough. The problem is: how do I do a comparison between these two signals?
I tried:
assert(out1 == out1_behav);
But that fails since the two signals have edges which happen 1ps apart. The design only requires that the edges be placed with 100ps precision, so I want a pass in this situation.
I thought about using a specify block with $delay()
timing checks, however this causes me other problems since I need to run with +no_timing_checks
to keep my ram models from failing in this RTL sim.
Is there a simple way to check that these edges are "almost" the same?
Solution
With the design requirement for the the signals to match within 100ps
you could add a compare logic will a 100ps
transition delay to act as a filter.
bit match;
assign #100ps match = (out1 == out1_behav);
always @*
assert #0 (match==1);
Verilog has different ways of assigning delay: transition and transport. Transition delays control the rise, fall, and indeterminate/high-Z timing. They can act as a filter if a driving signal gives a pulse less then the delay. Transport delays will always follow the the driving signals with a time shift. When the delays are large transition and transport will look the same.
assign #delay transition = driver; // Transition delay
always @(rhs) transport <= #dealy driver; // Transport delay
example: http://www.edaplayground.com/s/6/878, click the run button to see the waveform.
OTHER TIPS
If you are using Modelsim/Questa, you can still use +notimingchecks, and then use the tcl command tchech_set
to turn on individual timing checks, like $fullskew
Otherwise you will have to write a behavioral block that records the timestamps of the rising and falling edges of the two signals and checks the absolute value of the difference.