sonar.core package

Submodules

sonar.core.generate module

Generate the testbenches based on the configuration defined by the user.

sonar.core.generate.add_endpoint_combinations(testbench_config)

If there are multiple endpoints added, duplicate test vectors to capture all the combinations

Parameters:testbench_config (Testbench) – The testbench
Returns:Updated testbench
Return type:Testbench
sonar.core.generate.configure_prologue(testbench_config)

If a prologue thread is added, add it to all test vectors and delay other threads to wait for it to finish

Parameters:testbench_config (Testbench) – The user-defined testbench configuration
Returns:Updated testbench configuration
Return type:Testbench
sonar.core.generate.filter_langs(active_langs, sonar_tb_filepath)

If any of the generated testbenches are newer than the sonar testbench script, skip generating it. This probably implies the user has manually edited the generated testbench.

Parameters:active_langs (tuple) – Original list of languages to use
Returns:Filtered list of languages to generate testbenches for
Return type:tuple
sonar.core.generate.finalize_waits(testbench_config)

Using the test vectors in the testbench, this method aggregates all the wait conditions as required for the Sonar backend

Parameters:testbench_config (Testbench) – The user-defined testbench configuration
Returns:Updated testbench configuration
Return type:Testbench
sonar.core.generate.get_data_filepath(sonar_tb_filepath, lang)

Get the path of the generated data file for a particular language

Parameters:
  • sonar_tb_filepath (str) – Path to the file used to create the testbench_config
  • lang (str) – Language of the testbench
Returns:

Path to the data file

Return type:

str

sonar.core.generate.get_tb_filepath(sonar_tb_filepath, lang)

Get the path of the generated testbench for a particular language

Parameters:
  • sonar_tb_filepath (str) – Path to the file used to create the testbench_config
  • lang (str) – Language of the testbench
Returns:

Path to the testbench file

Return type:

str

sonar.core.generate.legalize_config(testbench_config)

There are some additional automatic steps that must be performed on the testbench configuration once the user has finished it

Parameters:testbench_config (Testbench) – The user-defined testbench configuration
Returns:Updated testbench configuration
Return type:Testbench
sonar.core.generate.parse_sonar_tb(sonar_tb_filepath)

From the passed in sonar_tb_filepath, extract the name of the file and the directory relative to which the generated files will be created

Parameters:sonar_tb_filepath (str) – Path to the file used to create the testbench_config
Returns:The name of the DUT, directory in which to place generated files
Return type:tuple
sonar.core.generate.sonar(testbench_config, sonar_tb_filepath, languages='sv', force=False, legalize=True)

Call the appropriate backends to generate testbenches in the chosen languages.

Parameters:
  • testbench_config (Testbench) – The user-defined testbench configuration
  • sonar_tb_filepath (str) – Path to the Python file used to generate testbench_config
  • languages (str or tuple, optional) – Language(s) to generate testbenches for. Defaults to “sv”.
  • force (bool, optional) – Force testbench generation. Defaults to False
  • legalize (bool, optional) – Perform testbench legalization on the config
Raises:

SonarInvalidArgError – Raised for invalid languages

sonar.core.include module

Broadly used functions and classes across sonar core

class sonar.core.include.Constants

Bases: object

Holds sonar constants as attributes

ARGPARSE_FAILURE = 2
SONAR_BASE_PATH = PosixPath('/home/docs')
SONAR_BOARD_SOURCE = PosixPath('sonar_board.sh')
SONAR_CONFIG_FILE = PosixPath('.sonar.toml')
SONAR_CONFIG_FILE_PATH = PosixPath('.sonar/.sonar.toml')
SONAR_DB = PosixPath('sonar_db')
SONAR_DB_PATH = '/home/docs/.sonar/sonar_db'
SONAR_DIRECTORY = PosixPath('.sonar')
SONAR_IP_MAKEFILE = 'sonar.mk'
SONAR_LOG_FILE = PosixPath('sonar.log')
SONAR_LOG_PATH = PosixPath('/home/docs/.sonar/sonar.log')
SONAR_MAIN_SOURCE = PosixPath('sonar.sh')
SONAR_PATH = PosixPath('/home/docs/.sonar')
SONAR_REPO_SOURCE = PosixPath('sonar_repo.sh')
SONAR_SHELL_BOARD_SOURCE = PosixPath('/home/docs/.sonar/shell/sonar_board.sh')
SONAR_SHELL_MAIN_SOURCE = PosixPath('/home/docs/.sonar/shell/sonar.sh')
SONAR_SHELL_PATH = PosixPath('/home/docs/.sonar/shell')
SONAR_SHELL_REPO_SOURCE = PosixPath('/home/docs/.sonar/shell/sonar_repo.sh')
SONAR_SHELL_SCRIPTS = PosixPath('shell')
SONAR_SHELL_TOOL_SOURCE = PosixPath('/home/docs/.sonar/shell/sonar_tool.sh')
SONAR_TOOL_SOURCE = PosixPath('sonar_tool.sh')
classmethod add_derived()

This method of adding the derived constants allows overriding the base attributes (above) and then defining the derived attributes based on their new values. This functionality is used in the tests to define a new SONAR_BASE_PATH for example.

sonar.core.include.configure_logging()

Defines a standard set of logging practices across sonar

sonar.core.include.init_constants(cls)

Add the derived constants to the Constants class

Returns:Holds sonar constants as attributes
Return type:Constants

Module contents