bag.data.digital

This module defines functions useful for digital verification/postprocessing.

Module Contents

Functions

de_bruijn(→ List[float])

Returns a De Bruijn sequence with subsequence of length n.

dig_to_pwl(→ Tuple[List[float], List[float]])

Convert a list of digital bits to PWL waveform.

get_crossing_index(→ int)

Returns the first index that the given numpy array crosses the given threshold.

get_flop_timing(tvec, d, q, clk, ttol[, data_thres, ...])

Calculate flop timing parameters given the associated waveforms.

bag.data.digital.de_bruijn(n: int, symbols: Optional[List[float]] = None) List[float][source]

Returns a De Bruijn sequence with subsequence of length n.

a De Bruijn sequence with subsequence of length n is a sequence such that all possible subsequences of length n appear exactly once somewhere in the sequence. This method is useful for simulating the worst case eye diagram given finite impulse response.

Parameters:
  • n (int) – length of the subsequence.

  • symbols (Optional[List[float]] or None) – the list of symbols. If None, defaults to [0.0, 1.0].

Returns:

seq – the de bruijn sequence.

Return type:

List[float]

bag.data.digital.dig_to_pwl(values: List[float], tper: float, trf: float, td: float = 0) Tuple[List[float], List[float]][source]

Convert a list of digital bits to PWL waveform.

This function supports negative delay. However, time/value pairs for negative data are truncated.

Parameters:
  • values (List[float]) – list of values for each bit.

  • tper (float) – the period in seconds.

  • trf (float) – the rise/fall time in seconds.

  • td (float) – the delay

Returns:

  • tvec (List[float]) – the time vector.

  • yvec (List[float]) – the value vector.

bag.data.digital.get_crossing_index(yvec: numpy.array, threshold: float, n: int = 0, rising: bool = True) int[source]

Returns the first index that the given numpy array crosses the given threshold.

Parameters:
  • yvec (np.array) – the numpy array.

  • threshold (float) – the crossing threshold.

  • n (int) – returns the nth edge index, with n=0 being the first index.

  • rising (bool) – True to return rising edge index. False to return falling edge index.

Returns:

idx – the crossing edge index.

Return type:

int

bag.data.digital.get_flop_timing(tvec, d, q, clk, ttol, data_thres=0.5, clk_thres=0.5, tstart=0.0, clk_edge='rising', tag=None, invert=False)[source]

Calculate flop timing parameters given the associated waveforms.

This function performs the following steps:

  1. find all valid clock edges. Compute period of the clock (clock waveform must be periodic).

  2. For each valid clock edge:

    1. Check if the input changes in the previous cycle. If so, compute tsetup. Otherwise, tsetup = tperiod.

    2. Check if input changes in the current cycle. If so, compute thold. Otherwise, thold = tperiod.

    3. Check that output transition at most once and that output = input. Otherwise, record an error.

    4. record the output data polarity.

  3. For each output data polarity, compute the minimum tsetup and thold and any errors. Return summary as a dictionary.

The output is a dictionary with keys ‘setup’, ‘hold’, ‘delay’, and ‘errors’. the setup/hold/delay entries contains 2-element tuples describing the worst setup/hold/delay time. The first element is the setup/hold/delay time, and the second element is the clock edge time at which it occurs. The errors field stores all clock edge times at which an error occurs.

Parameters:
  • tvec (np.ndarray) – the time data.

  • d (np.ndarray) – the input data.

  • q (np.ndarray) – the output data.

  • clk (np.ndarray) – the clock data.

  • ttol (float) – time resolution.

  • data_thres (float) – the data threshold.

  • clk_thres (float) – the clock threshold.

  • tstart (float) – ignore data points before tstart.

  • clk_edge (str) – the clock edge type. Valid values are “rising”, “falling”, or “both”.

  • tag (obj) – an identifier tag to append to results.

  • invert (bool) – if True, the flop output is inverted from the data.

Returns:

data – A dictionary describing the worst setup/hold/delay and errors, if any.

Return type:

dict[str, any]