11. Code Documentation

11.1. Database Generator(dbgen)

11.2. Utils

class riscof.utils.Command(*args, pathstyle='auto', ensure_absolute_paths=False)[source]

Class for command build which is supported by suprocess module. Supports automatic conversion of pathlib.Path instances to valid format for subprocess functions.

__init__(*args, pathstyle='auto', ensure_absolute_paths=False)[source]

Constructor.

Parameters
  • pathstyle (str) – Determine the path style when adding instance of pathlib.Path. Path style determines the slash type which separates the path components. If pathstyle is auto, then on Windows backslashes are used and on Linux forward slashes are used. When backslashes should be prevented on all systems, the pathstyle should be posix. No other values are allowed.

  • ensure_absolute_paths (bool) – If true, then any passed path will be converted to absolute path.

  • args – Initial command.

__iter__()[source]

Support iteration so functions from subprocess module support Command instance.

__repr__()[source]

Return repr(self).

__str__()[source]

Return str(self).

__weakref__

list of weak references to the object (if defined)

_is_shell_command()[source]

Return true if current command is supposed to be executed as shell script otherwise false.

_path2str(path)[source]

Convert pathlib.Path to string.

The final form of the string is determined by the configuration of Command instance.

Parameters

path – Path-like object which will be converted into string.

Returns

String representation of path

append(arg)[source]

Add new argument to command.

Parameters

arg – Argument to be added. It may be list, tuple, Command instance or any instance which supports str().

clear()[source]

Clear arguments.

run(**kwargs)[source]

Execute the current command.

Uses subprocess.Popen to execute the command.

Returns

The return code of the process .

Raises

subprocess.CalledProcessError – If check is set to true in kwargs and the process returns non-zero value.

riscof.utils.absolute_path(config_dir, entry_path)[source]

Create an absolute path based on the config’s file directory location and a path value from a configuration entry.

class riscof.utils.makeUtil(makeCommand='make', makefilePath='./Makefile', clean=True)[source]

Utility for ease of use of make commands like make and pmake. Supports automatic addition and execution of targets. Uses the class shellCommand to execute commands.

__init__(makeCommand='make', makefilePath='./Makefile', clean=True)[source]

Constructor.

Parameters
  • makeCommand (str) – The variant of make to be used with optional arguments. Ex - pmake -j 8

  • makefilePath (str) – The path to the makefile to be used.

  • clean (Bool) – Should the Makefile be removed if it already exists.

__weakref__

list of weak references to the object (if defined)

add_target(command, tname='')[source]

Function to add a target to the makefile.

Parameters
  • command (str) – The command to be executed when the target is run.

  • tname (str) – The name of the target to be used. If not specified, TARGET<num> is used as the name.

execute_all(cwd='./', timeout=300)[source]

Function to execute all the defined targets.

Parameters

cwd (str) – The working directory to be set while executing the make command.

execute_target(tname, cwd='./', timeout=300)[source]

Function to execute a particular target only.

Parameters
  • tname (str) – Name of the target to execute.

  • cwd (str) – The working directory to be set while executing the make command.

Raises

AssertionError – If target name is not present in the list of defined targets.

class riscof.utils.shellCommand(*args, pathstyle='auto', ensure_absolute_paths=False)[source]

Sub Class of the command class which always executes commands as shell commands.

__init__(*args, pathstyle='auto', ensure_absolute_paths=False)[source]
Parameters
  • pathstyle (str) – Determine the path style when adding instance of pathlib.Path. Path style determines the slash type which separates the path components. If pathstyle is auto, then on Windows backslashes are used and on Linux forward slashes are used. When backslashes should be prevented on all systems, the pathstyle should be posix. No other values are allowed.

  • ensure_absolute_paths (bool) – If true, then any passed path will be converted to absolute path.

  • args – Initial command.

_is_shell_command()[source]

Return true if current command is supposed to be executed as shell script otherwise false.

11.3. Abstract Base Classes

class riscof.pluginTemplate.pluginTemplate(*args, **kwargs)[source]

Metaclass for plugins as supported by ABC.

abstract __init__(*args, **kwargs)[source]

Constructor.

Parameters
  • name (str) – (passed as kwarg) Name to be displayed in the logger.

  • config (dict) – (passed as kwarg) The configuration for the plugin as specified in the conifig.ini file.

__weakref__

list of weak references to the object (if defined)

abstract build(isa_yaml, platform_yaml)[source]

Build the model as per specifications specified by DUT.

Parameters
  • isa_yaml (str) – Path to the checked isa specs yaml.

  • platform_yaml (str) – Path to the checked platform specs yaml.

abstract initialise(suite, workdir, env)[source]

Initialise the plugin with neccessary parameters.

Parameters
  • suite (str) – The name of the suite directory.This is used to replace the name of the file to create directories in proper order.

  • workdir (str) – The absolute path to the work directory.

  • env (str) – The directory containing the header files for the tests.

abstract runTests(testlist)[source]

Use the model to run the tests and produce signatures. The signature files generated should be named-self.name[:-1]+”.signature”.

Parameters

testlist (dict) – A dictionary of tests and other information about them(like macros,work_dir and isa).

11.4. Framework