10. Code Documentation

10.1. Database Generator(dbgen)

10.2. Utils

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

Class to create a log output which is colored based on level.

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

Initialize the formatter with specified format strings.

Initialize the formatter either with the specified format string, or a default as described above. Allow for specialized date formatting with the optional datefmt argument. If datefmt is omitted, you get an ISO8601-like (or RFC 3339-like) format.

Use a style parameter of ‘%’, ‘{‘ or ‘$’ to specify that you want to use one of %-formatting, str.format() ({}) formatting or string.Template formatting in your format string.

Changed in version 3.2: Added the style parameter.

format(record)[source]

Format the specified record as text.

The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.

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.

class riscof.utils.MyParser(prog=None, usage=None, description=None, epilog=None, parents=[], formatter_class=<class 'argparse.HelpFormatter'>, prefix_chars='-', fromfile_prefix_chars=None, argument_default=None, conflict_handler='error', add_help=True, allow_abbrev=True)[source]
error(message: string)[source]

Prints a usage message incorporating the message to stderr and exits.

If you override this in a subclass, it should not return – it should either exit or raise an exception.

class riscof.utils.SortingHelpFormatter(prog, indent_increment=2, max_help_position=24, width=None)[source]
class riscof.utils.makeUtil(makeCommand='make', makefilePath='./Makefile')[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')[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.

__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)[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='./')[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.

riscof.utils.setup_logging(log_level)[source]

Setup logging

Verbosity decided on user input

Parameters

log_level (str) – User defined log level

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.

10.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).

10.4. Framework