pychopmarg.<misc.>

Miscellaneous modules in the PyChOpMarg package.

utility

General purpose utilities for PyChOpMarg.

Original author: David Banas <capn.freako@gmail.com>

Original date: March 3, 2024 (Copied from pybert.utility.)

Copyright (c) 2024 David Banas; all rights reserved World wide.

pychopmarg.utility.all_combs(xss: list[list[T]]) list[list[T]][source]

Generate all combinations of input.

Parameters:

xss – The lists of candidates for each position in the final output.

Returns:

All possible combinations of input lists.

pychopmarg.utility.calc_Hffe(freqs: ndarray[Any, dtype[Real]], td: float, tap_weights: ndarray[Any, dtype[Real]], n_post: int, hasCurs: bool = False) ndarray[Any, dtype[Comp]][source]

Calculate the voltage transfer function, H(f), for a digital FFE, according to (93A-21).

Parameters:
  • freqs – Frequencies at which to calculate Hffe (Hz).

  • td – Tap delay time (s).

  • tap_weights – The filter tap weights.

  • n_post – The number of post-cursor taps.

Keyword Arguments:

hasCurstap_weights includes the cursor tap weight when True. Default: False (Cursor tap weight will be calculated.)

Returns:

The complex voltage transfer function, H(f), for the FFE.

Raises:

None

pychopmarg.utility.delta_pmf(h_samps: ndarray[Any, dtype[Real]], L: int = 4, RLM: float = 1.0, curs_ix: int | None = None, y: ndarray[Any, dtype[Real]] | None = None, dbg_dict: Dict[str, Any] = None) ndarray[Any, dtype[Real]][source]

Calculate the “delta-pmf” for a set of pulse response samples, as per (93A-40).

Parameters:

h_samps – Vector of pulse response samples.

Keyword Arguments:
  • L – Number of modulation levels. Default: 4

  • RLM – Relative level mismatch. Default: 1.0

  • curs_ix – Cursor index override. Default: None (Means use argmax() to find cursor.)

  • y – y-values override vector. Default: None (Means calculate appropriate y-value vector here.)

  • dbg_dict – Optional dictionary into which debugging values may be stashed, for later analysis. Default: None

Returns:

  • the voltages corresponding to the bins, and

  • their probabilities.

Return type:

A pair consisting of

Raises:
  • ValueError

  • ValueError

Notes

  1. The input set of pulse response samples is filtered,

    as per Note 2 of 93A.1.7.1, unless a y-values override vector is provided, in which case it is assumed that the caller has already done the filtering.

pychopmarg.utility.filt_pr_samps(pr_samps: ndarray[Any, dtype[Real]], As: float, rel_thresh: float = 0.001) ndarray[Any, dtype[Real]][source]

Filter a list of pulse response samples for minimum magnitude.

Parameters:
  • pr_samps – The pulse response samples to filter.

  • As – Signal amplitude, as per 93A.1.6.c.

Keyword Arguments:

rel_thresh – Filtration threshold (As). Default: 0.001 (i.e. - 0.1%, as per Note 2 of 93A.1.7.1)

Returns:

The subset of pr_samps passing filtration.

pychopmarg.utility.from_dB(x: float) float[source]

Convert from (dB) to real, assuming square law applies.

pychopmarg.utility.from_irfft(x: ndarray[Any, dtype[Real]], t_irfft: ndarray[Any, dtype[Real]], t: ndarray[Any, dtype[Real]], nspui: int) ndarray[Any, dtype[Real]][source]

Interpolate irfft() output to t and subsample at fBaud.

Parameters:
  • xirfft() results to be interpolated and subsampled.

  • t_irfft – Time index vector for x.

  • t – Desired new time index vector (same units as t_irfft).

  • nspui – Number of samples per unit interval.

Returns:

interpolated and subsampled vector.

Return type:

y

Raises:

IndexError – If length of input doesn’t match length of t_irfft vector.

Notes

  1. Input vector is shifted, such that its peak occurs at 0.1 * max(t), before interpolating.
    This is done to:
    • ensure that we don’t omit any non-causal behavior,

    which ends up at the end of an IFFT output vector when the peak is very near the beginning, and - to ensure that the majority of our available time span is available for capturing reflections.

  2. The sub-sampling phase is adjusted, so as to ensure that we catch the peak.

pychopmarg.utility.import_s32p(filename: str, vic_chnl: int = 1) list[tuple[Network, str]][source]

Read in a 32-port Touchstone file, and return an equivalent list of 8 2-port differential networks: a single victim through channel and 7 crosstalk aggressors, according to the VITA 68.2 convention.

Parameters:

filename – Name of Touchstone file to read in.

Keyword Arguments:

vic_chnl – Victim channel number (from 1). Default = 1

Returns:

  • a 2-port network representing a differential channel, and

  • the type of that channel, one of: ‘THRU’, ‘NEXT’, or ‘FEXT.

    (First element is the victim and the only one of type ‘THRU’.)

Return type:

List of 8 pairs, each consisting of

Raises:

ValueError – If Touchstone file is not 32-port.

Notes

  1. Input Touchstone file is assumed single-ended.

  2. The differential through and xtalk channels are returned.

  3. Port 2 of all returned channels correspond to the same physical circuit node,

    typically, the Rx input node.

pychopmarg.utility.mk_combs(trips: list[tuple[float, float, float]]) list[list[float]][source]

Make all possible combinations of tap weights, given a list of “(min, max, step)” triples.

Parameters:

trips – A list of “(min, max, step)” triples, one per weight.

Returns:

A list of lists of tap weights, including all possible combinations.

Return type:

combs

pychopmarg.utility.null_filter(nTaps: int, nPreTaps: int = 0) ndarray[Any, dtype[Real]][source]

Construct a null filter w/ nTaps taps and (optionally) nPreTaps pre-cursor taps.

Parameters:

nTaps – Total number of taps, including the cursor tap.

Keyword Arguments:

nPreTaps – Number of pre-cursor taps. Default: 0

Returns:

The filter tap weight vector, including the cursor tap weight.

Return type:

taps

pychopmarg.utility.sCshunt(freqs: list[float], c: float, r0: float = 50.0) Network[source]

Calculate the 2-port network for a shunt capacitance.

Parameters:
  • freqs – The frequencies at which to calculate network data (Hz).

  • c – The capacitance (F).

Keyword Arguments:

r0 – The reference impedance for the network (Ohms). Default: 50 Ohms.

Returns:

The network corresponding to a shunt capacitance, c,

calculated at the given frequencies, freqs.

Return type:

s2p

pychopmarg.utility.sDieLadderSegment(freqs: list[float], trip: tuple[float, float, float]) Network[source]

Calculate one segment of the on-die parasitic ladder network.

Parameters:
  • f – List of frequencies to use for network creation (Hz).

  • trip – Triple containing: - R0: Reference impedance for network (Ohms). - Cd: Shunt capacitance (F). - Ls: Series inductance (H).

Returns:

Two port network for segment.

Return type:

s2p

pychopmarg.utility.sLseries(freqs: list[float], l: float, r0: float = 50.0) Network[source]

Calculate the 2-port network for a series inductance.

Parameters:
  • freqs – The frequencies at which to calculate network data (Hz).

  • l – The inductance (H).

Keyword Arguments:

r0 – The reference impedance for the network (Ohms). Default: 50 Ohms.

Returns:

The network corresponding to a series inductance, l,

calculated at the given frequencies, freqs.

Return type:

s2p

pychopmarg.utility.sdd_21(ntwk: Network, norm: float = 0.5, renumber: bool = False) Network[source]

Given a 4-port single-ended network, return its differential throughput as a 2-port network.

Parameters:

ntwk – 4-port single ended network.

Keyword Arguments:
  • norm – Normalization factor. (Default = 0.5)

  • renumber – Automatically detect correct through path when True. Default: False

Returns:

Sdd (2-port).

Notes

  1. A “1->2/3->4” port ordering convention is assumed when renumber is False.

  2. Automatic renumbering should not be used unless a solid d.c. thru path exists.

pychopmarg.utility.se2mm(ntwk: Network, norm: float = 0.5, renumber: bool = False) Network[source]

Given a 4-port single-ended network, return its mixed mode equivalent.

Parameters:

ntwk – 4-port single ended network.

Keyword Arguments:
  • norm – Normalization factor. (Default = 0.5)

  • renumber – Automatically detect correct through path when True. Default: False

Returns:

Sdd11 Sdd12 Sdc11 Sdc12 Sdd21 Sdd22 Sdc21 Sdc22 Scd11 Scd12 Scc11 Scc12 Scd21 Scd22 Scc21 Scc22

Return type:

Mixed mode equivalent network, in the following format

Notes

  1. A “1->2/3->4” port ordering convention is assumed when renumber is False.

  2. Automatic renumbering should not be used unless a solid d.c. thru path exists.

cli

view

common

Definitions common to all PyChOpMarg modules.

Original author: David Banas <capn.freako@gmail.com>

Original date: March 3, 2024 (Copied from pybert.utility.)

Copyright (c) 2024 David Banas; all rights reserved World wide.