bag3_testbenches.design.mixin

This module defines some utility methods and classes to support the interface between designer and generator parameters.

Module Contents

Classes

DesignerMixin

A generic mixin class for design scripts that contains some utility methods.

Functions

get_dut_param_value(name, dsn_params[, gen_specs, ...])

Returns a DUT parameter value by performing lookup in different tables. The lookup order is as follows:

get_nested_param_value(→ Any)

Returns a parameter value from a nested parameter dictionary.

set_nested_param_value(params, nested_key, val)

Sets a parameter value in a nested parameter dictionary.

bag3_testbenches.design.mixin.get_dut_param_value(name: str, dsn_params: Mapping[str, Any], gen_specs: Optional[Mapping[str, Any]] = None, gen_key: Optional[Sequence] = None, default_val: Optional[Any] = None, dtype: Optional[Type] = None)[source]

Returns a DUT parameter value by performing lookup in different tables. The lookup order is as follows: 1. Design parameters (by parameter name) 2. Default generator specs (by gen specs-specific nested key) 3. Default value

Parameter

namestr

The parameter name.

dsn_paramsMapping[str, Any]

The mapping of design parameters.

gen_specsOptional[Mapping[str, Any]]

The optional default generator specs.

gen_keyOptional[Sequence]

The optional nested lookup key for generator specs.

default_valOptional[Any]

The default value.

dtypeOptional[Type]

The optional value data type, used for casting.

returns:

param_val – The parameter value at params[nested_key[0]][nested_key[1]]…[nested_key[-1]].

rtype:

Any

bag3_testbenches.design.mixin.get_nested_param_value(params: Mapping, nested_key: Sequence) Any[source]

Returns a parameter value from a nested parameter dictionary.

Parameter

paramsMapping

The mapping of parameters, of any nesting depth.

nested_keySequence

The nested key, specified as a sequence of keys for to access a sub-section of params.

returns:

param_val – The parameter value at params[nested_key[0]][nested_key[1]]…[nested_key[-1]].

rtype:

Any

bag3_testbenches.design.mixin.set_nested_param_value(params: Dict, nested_key: Sequence, val: Any)[source]

Sets a parameter value in a nested parameter dictionary.

Parameter

paramsDict

The mapping of parameters, of any nesting depth.

nested_keySequence

The nested key, specified as a sequence of keys for to access a sub-section of params.

valAny

The parameter value to set at params[nested_key[0]][nested_key[1]]…[nested_key[-1]].

class bag3_testbenches.design.mixin.DesignerMixin[source]

A generic mixin class for design scripts that contains some utility methods. Most notably, it contains a skeleton for mapping design parameter names to generator spec keys via lookup tables.

Subclasses of this mixin should specify the following class variables:

dsn_to_gen_spec_map_schMapping[str, Sequence[Union[str, int]]]

The mapping of design parameter name to schematic generator parameter nested key. If left unspecified, schematic is assumed to be unsupported.

dsn_to_gen_spec_map_layMapping[str, Sequence[Union[str, int]]]

The mapping of design parameter name to layout generator parameter nested key. If left unspecified, layout is assumed to be unsupported.

dsn_to_gen_val_map_layMapping[str, Any]

The mapping of design parameter name to layout generator’s default/assumed value. In some cases, layout generators may not implement a corresponding schematic generator parameter and instead assume or force some value. In such a case, the design parameter should be set to a fixed value from this mapping.

dsn_to_gen_spec_map_sch: Mapping[str, Sequence[Union[str, int]]][source]
dsn_to_gen_spec_map_lay: Mapping[str, Sequence[Union[str, int]]][source]
dsn_to_gen_val_map_lay: Mapping[str, Any][source]
abstract classmethod get_dut_gen_specs(is_lay: bool, base_gen_specs: bag.util.immutable.Param, dsn_params: Mapping[str, Any]) Union[bag.util.immutable.Param, Dict[str, Any]][source]

Returns the updated generator specs with some design variables.

Parameters:
  • is_lay (bool) – True if DUT is layout, False if schematic.

  • base_gen_specs (Param) – The base/default generator specs.

  • dsn_params (Mapping[str, Any]) – The design variables.

Returns:

gen_specs – The updated generator specs.

Return type:

Union[Param, Dict[str, Any]]

classmethod get_dsn_to_gen_spec_map(is_lay: bool) Mapping[str, Sequence[Union[str, int]]][source]

Return the design parameter to generator specs key lookup table.

classmethod get_dsn_to_gen_val_map(is_lay: bool) Mapping[str, Any][source]

Return the design parameter to generator parameter value lookup table.

classmethod get_dsn_to_gen_var_list(is_lay: bool) List[str][source]

Return the list of design variables that are supported in the designer to generator mapping.

classmethod get_dut_param_value(name: str, dsn_params: Mapping[str, Any], is_lay: bool, gen_specs: Optional[Mapping[str, Any]] = None, default_val: Optional[Any] = None, dtype: Optional = None) Any[source]

Returns a DUT parameter value by performing lookup in different tables. A wrapper around the module function of the same name.

Parameter

namestr

The parameter name.

dsn_paramsMapping[str, Any]

The mapping of design parameters.

is_laybool

True if the DUT generator is a layout generator, False if schematic generator.

gen_specsOptional[Mapping[str, Any]]

The optional default generator specs.

default_valOptional[Any]

The default value.

dtypeOptional[Type]

The optional value data type, used for casting.

returns:

param_val – The DUT parameter value.

rtype:

Any

classmethod set_dut_gen_param_value(name: str, val: Any, is_lay: bool, gen_specs: Dict[str, Any]) Any[source]

Sets a parameter value in the generator specs.

Parameter

namestr

The parameter name.

valAny

The parameter value.

is_laybool

True if the DUT generator is a layout generator, False if schematic generator.

gen_specsDict[str, Any]

The generator specs to update.

static calc_in_sizing(load: Optional[int], fanout: float, size_step: int = 1, size_min: int = 1, is_optional: bool = False) Optional[int][source]

Computes input sizing based on load sizing and desired fanout.

Parameters:
  • load (Optional[int]) – The load sizing.

  • fanout (float) – The desired fanout.

  • size_step (int) – The input sizing quantization.

  • size_min (int) – The minimum input size.

  • is_optional (bool) – True if this computation is optional (in which case if load is None, input sizing is also None). If False, error if load is None. Defaults to False.

Returns:

size_in – The input sizing.

Return type:

Optional[int]

classmethod calc_in_sizing_chain(load: Optional[int], num_stages: int, fanout: float, **kwargs) List[Optional[int]][source]

Computes sizing of the input chain.

Parameters:
  • load (Optional[int]) – The load sizing.

  • num_stages (int) – The number of stages.

  • fanout (float) – The total fanout.

Returns:

sizes – The sizing of the input chain.

Return type:

List[Optional[int]]