P10.7.1 Separate the DCD

MediumImplementIcarus · browser samples / server checksReview the topic

A scope hands you the timing error of every edge. Pull the duty-cycle distortion out of it, and the peak to peak with and without it.

Hardware context: The digital blocks of a serializer/deserializer: line encoder and decoder, scrambler, CRC and error-correcting code. Keep the line balanced and busy, and detect or correct the errors a fast serial link makes.

A jitter analyser measures the time interval error (TIE) of each edge, in milli-UI. It also says whether each edge was rising or falling.

Write jt_edge(tie, rising) to take one edge, and jt_reset() to start again. Then write two results.

jt_dcd() returns the duty-cycle distortion: the mean TIE of the rising edges minus the mean TIE of the falling edges. jt_pp(remove_dcd) returns the TIE peak to peak, over all edges as measured, or after taking each edge's own direction mean off.

Signals in the Timeline

SignalWidthRole
test_number8input of each check
Full specification
Signatures (keep them)
function automatic void jt_reset();
function automatic void jt_edge(input int tie, input bit rising);   // tie in milli-UI
function automatic int jt_dcd();
function automatic int jt_pp(input bit remove_dcd);
ItemRule
MeansEach direction's mean is its sum divided by its count, rounded toward zero (SV integer division).
DCDRising mean minus falling mean. It may be negative.
Peak to peak, remove_dcd = 0Largest TIE minus smallest TIE over all edges.
Peak to peak, remove_dcd = 1The same, after subtracting the rising mean from each rising edge and the falling mean from each falling edge.
EdgesAt most 4,096 per run. Rising and falling edges alternate.

The tests build TIE values from a DCD, a random part, a periodic part and a constant offset, all bench values. A constant offset must not change any result.

Examples

Example 1

DCD Only
Input
1,000 edges, DCD 30 milli-UI
Output
dcd_wrong = no, pp_wrong = no, pp_without_dcd_wrong = no, your_dcd = 30

Rising edges sit at +15 and falling edges at -15. The DCD is 30; the peak to peak is 30 as measured and 0 with the DCD removed.

Example 2

DCD with Random Jitter
Input
2,000 edges, DCD 40, random +-25
Output
dcd_wrong = no, pp_wrong = no, pp_without_dcd_wrong = no, your_dcd = 39

The random part nearly averages out of each mean: the DCD comes back as 39, not 40. Removing it narrows the peak to peak by about that much.

Example 3

Negative DCD with an Offset
Input
DCD -20, offset 300
Output
dcd_wrong = no, pp_wrong = no, pp_without_dcd_wrong = no, your_dcd = -19

The offset moves both means by 300 and cancels in their difference. The DCD comes back as -19: falling edges are late.

Constraints and Contract

  • Keep the four function names and their arguments.
  • Keep your state in module-level variables, and clear it in jt_reset().
  • Results are integers in milli-UI.

Hints

Hint 1

Keep a sum and a count for each direction. The DCD needs nothing else.

Hint 2

The peak to peak without DCD needs both means, and they are known only at the end. Store the edges.

Hint 3

A constant offset moves both means by the same amount. Why does that leave the DCD unchanged?

What the grader checks: The fixture feeds six edge sequences to your functions and compares the three results with a reference computed the same way. It does not model a scope, a clock recovery reference or random jitter with Gaussian tails.

6 checks on Icarus · browser samples / server checks. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain public samples only. A passing result establishes the tested cases, not a proof for all possible inputs.

See all 1 steps and the final capstone

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

DCD Only

Input
1,000 edges, DCD 30 milli-UI
Expected output
dcd_wrong = no, pp_wrong = no, pp_without_dcd_wrong = no, your_dcd = 30

Rising edges sit at +15 and falling edges at -15. The DCD is 30; the peak to peak is 30 as measured and 0 with the DCD removed.

Run samples executes all 3 public checks. Check all tests runs 6 checks on the server.

Icarus · browser samples / server checks