5. Code Docs

5.1. CGF Normalization

riscv_isac.cgf_normalize.alternate(var, size, signed=True, fltr_func=None, scale_func=None)[source]

This function converts an abstract alternate function into individual coverpoints that can be used by ISAC. The unrolling of the function accounts of the size, sign-bit, filters and scales. The unrolled coverpoints will contain a pattern of alternating 1s and 0s. The final coverpoints can vary depending on the filtering and scaling functions

Parameters
  • var (str) – input variable that needs to be assigned the coverpoints

  • size (int) – size of the bit-vector to generate walking-1s

  • signed (bool) – when true indicates that the unrolled points be treated as signed integers.

  • fltr_func (function) – a lambda function which defines a filtering routine to keep only a certain values from the unrolled coverpoints

  • scale_func (function) – a lambda function which defines the scaling that should be applied to the unrolled coverpoints that have been generated.

Result

dictionary of unrolled filtered and scaled coverpoints

riscv_isac.cgf_normalize.expand_cgf(cgf, xlen)[source]

This function will replace all the abstract functions with their unrolled coverpoints

Parameters
  • cgf (dict) – input cgf yaml

  • xlen (int) – XLEN of the riscv-trace

riscv_isac.cgf_normalize.twos(val, bits)[source]

Finds the twos complement of the number :param val: input to be complemented :param bits: size of the input

Result

two’s complement version of the input

riscv_isac.cgf_normalize.walking_ones(var, size, signed=True, fltr_func=None, scale_func=None)[source]

This function converts an abstract walking-ones function into individual coverpoints that can be used by ISAC. The unrolling of the function accounts of the size, sign-bit, filters and scales. The unrolled coverpoints will contain a pattern a single one trickling down from LSB to MSB. The final coverpoints can vary depending on the filtering and scaling functions

Parameters
  • var (str) – input variable that needs to be assigned the coverpoints

  • size (int) – size of the bit-vector to generate walking-1s

  • signed (bool) – when true indicates that the unrolled points be treated as signed integers.

  • fltr_func (function) – a lambda function which defines a filtering routine to keep only a certain values from the unrolled coverpoints

  • scale_func (function) – a lambda function which defines the scaling that should be applied to the unrolled coverpoints that have been generated.

Result

dictionary of unrolled filtered and scaled coverpoints

riscv_isac.cgf_normalize.walking_zeros(var, size, signed=True, fltr_func=None, scale_func=None)[source]

This function converts an abstract walking-zeros function into individual coverpoints that can be used by ISAC. The unrolling of the function accounts of the size, sign-bit, filters and scales. The unrolled coverpoints will contain a pattern a single zero trickling down from LSB to MSB. The final coverpoints can vary depending on the filtering and scaling functions

Parameters
  • var (str) – input variable that needs to be assigned the coverpoints

  • size (int) – size of the bit-vector to generate walking-1s

  • signed (bool) – when true indicates that the unrolled points be treated as signed integers.

  • fltr_func (function) – a lambda function which defines a filtering routine to keep only a certain values from the unrolled coverpoints

  • scale_func (function) – a lambda function which defines the scaling that should be applied to the unrolled coverpoints that have been generated.

Result

dictionary of unrolled filtered and scaled coverpoints

5.2. Coverage

5.3. Parsers

Parser for the log file

riscv_isac.parsers.RS2_MASK = 32505856

Regex pattern and functions for extracting instruction and address

riscv_isac.parsers.extractAddress(line, mode='standard')[source]

Function to extract the address from the line Check for the mode - spike or standard

riscv_isac.parsers.extractInstruction(line, mode='standard')[source]

Function to extract the instruction code from the line Check for the mode - spike or standard

riscv_isac.parsers.extractOpcode(instr)[source]

Function to extract the opcode from the instruction hex

riscv_isac.parsers.extractRegisterCommitVal(line, mode)[source]

Function to extract the register commit value Only works for spike mode

riscv_isac.parsers.parseCompressedInstruction(input_line, mode, arch)[source]

Parse a compressed instruction Args: input_line - Line from the log file Returns: (instr_obj)

riscv_isac.parsers.parseInstruction(input_line, mode, arch='rv32')[source]

Check if we are parsing compressed or normal instructions

riscv_isac.parsers.parseStandardInstruction(input_line, mode, arch)[source]

Parse an input line and decode the instruction Args: input_line - Line from the log file Returns: (instr_name, rd, rs1, rs2, imm)

riscv_isac.parsers.quad0(instr, addr, arch)[source]

Parse instructions from Quad0 in the RISCV-ISA-Standard

riscv_isac.parsers.quad1(instr, addr, arch)[source]

Parse instructions from Quad1 in the RISCV-ISA-Standard

riscv_isac.parsers.quad2(instr, addr, arch)[source]

Parse instructions from Quad3 in the RISCV-ISA-Standard