bag.simulation.measure

Module Contents

Classes

MeasInfo

MeasurementManager

A class that handles circuit performance measurement.

MeasurementManagerFSM

A class that handles circuit performance measurement in an FSM-like fashion.

class bag.simulation.measure.MeasInfo[source]
state: str[source]
prev_results: Mapping[str, Any][source]
class bag.simulation.measure.MeasurementManager(meas_specs: Mapping[str, Any], log_file: str, log_level: pybag.enum.LogLevel = LogLevel.DEBUG, precision: int = 6)[source]

Bases: bag.util.logging.LoggingBase, abc.ABC

A class that handles circuit performance measurement.

This class handles all the steps needed to measure a specific performance metric of the device-under-test. This may involve creating and simulating multiple different testbenches, where configuration of successive testbenches depends on previous simulation results. This class reduces the potentially complex measurement tasks into a few simple abstract methods that designers simply have to implement.

property specs: Mapping[str, Any][source]
property precision: int[source]
commit() None[source]

Commit changes to specs dictionary. Perform necessary initialization.

make_tbm(tbm_cls: Union[Type[bag.simulation.core.TestbenchManager], str], tbm_specs: Mapping[str, Any]) bag.simulation.core.TestbenchManager[source]
make_mm(mm_cls: Union[Type[MeasurementManager], str], mm_specs: Mapping[str, Any]) MeasurementManager[source]
abstract async async_measure_performance(name: str, sim_dir: pathlib.Path, sim_db: bag.simulation.cache.SimulationDB, dut: Optional[bag.simulation.cache.DesignInstance], harnesses: Optional[Sequence[bag.simulation.cache.DesignInstance]] = None) Mapping[str, Any][source]

A coroutine that performs measurement.

Parameters:
  • name (str) – name of this measurement.

  • sim_dir (Path) – simulation directory.

  • sim_db (SimulationDB) – the simulation database object.

  • dut (Optional[DesignInstance]) – the DUT to measure.

  • harnesses (Optional[Sequence[DesignInstance]]) – the list of DUT and harnesses to measure.

Returns:

output – the measurement results.

Return type:

Mapping[str, Any]

measure_performance(name: str, sim_dir: pathlib.Path, sim_db: bag.simulation.cache.SimulationDB, dut: Optional[bag.simulation.cache.DesignInstance], harnesses: Optional[Sequence[bag.simulation.cache.DesignInstance]] = None) Mapping[str, Any][source]
class bag.simulation.measure.MeasurementManagerFSM(meas_specs: Mapping[str, Any], log_file: str, log_level: pybag.enum.LogLevel = LogLevel.DEBUG, precision: int = 6)[source]

Bases: MeasurementManager, abc.ABC

A class that handles circuit performance measurement in an FSM-like fashion.

Any subclass of MeasurementManagerFSM will need to implement the following methods:

initialize, process_output, get_sim_info.

Refer to async_measure_performance to see how the above methods are integrated together into the measurement process.

async async_measure_performance(name: str, sim_dir: pathlib.Path, sim_db: bag.simulation.cache.SimulationDB, dut: Optional[bag.simulation.cache.DesignInstance], harnesses: Optional[Sequence[bag.simulation.cache.DesignInstance]] = None) Mapping[str, Any][source]

A coroutine that performs measurement.

The measurement is done like a FSM. On each iteration, depending on the current state, it creates a new testbench (or reuse an existing one) and simulate it. It then post-process the simulation data to determine the next FSM state, or if the measurement is done.

Parameters:
  • name (str) – name of this measurement.

  • sim_dir (Path) – simulation directory.

  • sim_db (SimulationDB) – the simulation database object.

  • dut (Optional[DesignInstance]) – the DUT to measure.

  • harnesses (Optional[Sequence[DesignInstance]]) – the list of DUT and harnesses to measure.

Returns:

output – the last dictionary returned by process_output().

Return type:

Mapping[str, Any]

abstract initialize(sim_db: bag.simulation.cache.SimulationDB, dut: bag.simulation.cache.DesignInstance, harnesses: Optional[Sequence[bag.simulation.cache.DesignInstance]] = None) Tuple[bool, MeasInfo][source]

Initialize this MeasurementManager to get ready for measurement.

Parameters:
Returns:

  • done (bool) – If True, then do not run measurement.

  • info (MeasInfo) – the initial MeasInfo object.

abstract process_output(cur_info: MeasInfo, sim_results: Union[bag.simulation.cache.SimResults, bag.simulation.cache.MeasureResult]) Tuple[bool, MeasInfo][source]

Process simulation output data.

Parameters:
  • cur_info (MeasInfo) – the MeasInfo object representing the current measurement state.

  • sim_results (Union[SimResults, MeasureResult]) – the simulation results object.

Returns:

  • done (bool) – True if this measurement is finished.

  • next_info (MeasInfo) – the updated measurement state.

abstract get_sim_info(sim_db: bag.simulation.cache.SimulationDB, dut: bag.simulation.cache.DesignInstance, cur_info: MeasInfo, harnesses: Optional[Sequence[bag.simulation.cache.DesignInstance]] = None) Tuple[Union[Tuple[bag.simulation.core.TestbenchManager, Mapping[str, Any]], MeasurementManager], bool][source]

Get the testbench manager needed for the current measurement state.

Override to customize your testbench manager.

Parameters:
  • sim_db (SimulationDB) – the simulation database object.

  • dut (DesignInstance) – the design instance.

  • cur_info (MeasInfo) – the MeasInfo object representing the current measurement state.

  • harnesses (Optional[Sequence[DesignInstance]]) – the list of harness instances

Returns:

  • sim_object (Union[Tuple[TestbenchManager, Mapping[str, Any]], MeasurementManager]) – either a TestbenchManager/tb_params tuple, or a measurement manager instance.

  • use_dut (bool) – True to run simulation with DesignInstance.