Code Documentation

riscv_config.checker

riscv_config.checker.add_debug_setters(schema_yaml)[source]

Function to set the default setters for various fields in the debug schema

riscv_config.checker.add_def_setters(schema_yaml)[source]

Function to set the default setters for various fields in the schema

riscv_config.checker.check_custom_specs(custom_spec, work_dir, logging=False, no_anchors=False)[source]

Function to perform ensure that the isa and platform specifications confirm to their schemas. The Cerberus module is used to validate that the specifications confirm to their respective schemas.

Parameters
  • isa_spec (str) – The path to the DUT isa specification yaml file.

  • logging (bool) – A boolean to indicate whether log is to be printed.

Raises

ValidationError – It is raised when the specifications violate the schema rules. It also contains the specific errors in each of the fields.

Returns

A tuple with the first entry being the absolute path to normalized isa file and the second being the absolute path to the platform spec file.

riscv_config.checker.check_debug_specs(debug_spec, isa_spec, work_dir, logging=False, no_anchors=False)[source]

Function to perform ensure that the isa and debug specifications confirm to their schemas. The Cerberus module is used to validate that the specifications confirm to their respective schemas.

Parameters
  • debug_spec – The path to the DUT debug specification yaml file.

  • isa_spec (str) – The path to the DUT isa specification yaml file.

  • logging (bool) – A boolean to indicate whether log is to be printed.

Raises

ValidationError – It is raised when the specifications violate the schema rules. It also contains the specific errors in each of the fields.

Returns

A tuple with the first entry being the absolute path to normalized isa file and the second being the absolute path to the platform spec file.

riscv_config.checker.check_isa_specs(isa_spec, work_dir, logging=False, no_anchors=False)[source]

Function to perform ensure that the isa and platform specifications confirm to their schemas. The Cerberus module is used to validate that the specifications confirm to their respective schemas.

Parameters
  • isa_spec (str) – The path to the DUT isa specification yaml file.

  • logging (bool) – A boolean to indicate whether log is to be printed.

Raises

ValidationError – It is raised when the specifications violate the schema rules. It also contains the specific errors in each of the fields.

Returns

A tuple with the first entry being the absolute path to normalized isa file and the second being the absolute path to the platform spec file.

riscv_config.checker.check_mhpm(spec, logging=False)[source]

Check if the mhpmcounters and corresponding mhpmevents are implemented and of the same size as the source

riscv_config.checker.check_pmp(spec, logging=False)[source]

Check if the mhpmcounters and corresponding mhpmevents are implemented and of the same size as the source

riscv_config.checker.check_reset_fill_fields(spec, logging=False)[source]

The check_reset_fill_fields function fills the field node with the names of the sub-fields of the register and then checks whether the reset-value of the register is a legal value. To do so, it iterates over all the subfields and extracts the corresponding field value from the reset-value. Then it checks the legality of the value according to the given field description. If the fields is implemented i.e accessible in both 64 bit and 32 bit modes, the 64 bit mode is given preference.

riscv_config.checker.check_shadows(spec, logging=False)[source]

Check if the shadowed fields are implemented and of the same size as the source

riscv_config.checker.delegset()[source]

Function to set “implemented” value for mideleg regisrer.

riscv_config.checker.groupc(test_list)[source]

Generator function to squash consecutive numbers for wpri bits.

riscv_config.checker.nregset()[source]

Function to set defaults based on presence of ‘N’ extension.

riscv_config.checker.nuset()[source]

Function to check and set defaults for all fields which are dependent on the presence of ‘U’ extension and ‘N’ extension.

riscv_config.checker.sregset()[source]

Function to set defaults based on presence of ‘S’ extension.

riscv_config.checker.sregseth()[source]

Function to set defaults based on presence of ‘S’ extension.

riscv_config.checker.sset()[source]

Function to set defaults based on presence of ‘S’ extension.

riscv_config.checker.trim(foo)[source]

Function to trim the dictionary. Any node with implemented field set to false is trimmed of all the other nodes.

Parameters

foo (dict) – The dictionary to be trimmed.

Returns

The trimmed dictionary.

riscv_config.checker.twset()[source]

Function to check and set value for tw field in misa.

riscv_config.checker.uregset()[source]

Function to set defaults based on presence of ‘U’ extension.

riscv_config.checker.uregseth()[source]

Function to set defaults based on presence of ‘U’ extension.

riscv_config.checker.uset()[source]

Function to set defaults based on presence of ‘U’ extension.

riscv_config.schemaValidator

class riscv_config.schemaValidator.schemaValidator(*args, **kwargs)[source]

Custom validator for schema having the custom rules necessary for implementation and checks.

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

The arguments will be treated as with this signature:

__init__(self, schema=None, ignore_none_values=False,

allow_unknown=False, require_all=False, purge_unknown=False, purge_readonly=False, error_handler=errors.BasicErrorHandler)

_check_with_cannot_be_false_rv32(field, value)[source]

Functions ensures that the field cannot be False in rv32 mode

_check_with_cannot_be_false_rv64(field, value)[source]

Functions ensures that the field cannot be False in rv64 mode

_check_with_capture_isa_specifics(field, value)[source]

Function to extract and store ISA specific information(such as xlen,user spec version and extensions present) and check whether the dependencies in ISA extensions are satisfied.

_check_with_max_length(field, value)[source]

Function to check whether the given value is less than the maximum value that can be stored(2^xlen-1).

_check_with_s_debug_check(field, value)[source]

Function ensures that the ro_constant is hardwired to zero when S is present in the ISA string Used mainly for debug schema

_check_with_u_debug_check(field, value)[source]

Function ensures that the ro_constant is hardwired to zero when U is present in the ISA string Used mainly for debug schema

_check_with_xcause_check(field, value)[source]

Function to verify the inputs for mcause.

_check_with_xtveccheck(field, value)[source]

Function to check whether the inputs in range type in mtvec are valid.

Utils

class riscv_config.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 riscv_config.utils.SortingHelpFormatter(prog, indent_increment=2, max_help_position=24, width=None)[source]
riscv_config.utils.setup_logging(log_level)[source]

Setup logging

Verbosity decided on user input

Parameters

log_level (str) – User defined log level