Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
anku-anand authored Sep 8, 2022
2 parents a0b076c + ba72cb7 commit 16ddd43
Show file tree
Hide file tree
Showing 13 changed files with 4,526 additions and 4,208 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.15.0] - 2022-08-25
- Added support for instruction aliases

## [0.14.0] - 2022-08-08
- Add fields to instruction object
- Enable generic coverage evaluation mechanisms for floating point instructions
- Fix coverpoint generation to account for nan boxing of fp instructions.
- Add fields(frm, fcsr, nan_prefix) for fp instructions

## [0.13.2] - 2022-05-23
- Error reporting for missing coverlabel in cgf file

## [0.13.1] - 2022-05-07
- Fix mistune version for doc builds.

Expand Down
5 changes: 4 additions & 1 deletion docs/source/cgf.rst
Original file line number Diff line number Diff line change
Expand Up @@ -376,13 +376,16 @@ A covergroup contains the following nodes:
This string is divided into three parts - opcode list, assign list and condition list separated by :: symbol. It is parsed and all the three lists are obtained separately. The variables available for use in the expression are as follows:

* ``instr_name`` : The instruction names in the opcode list

* ``instruction_alias``: The instruction alias for a set of instructions as defined in ``/riscv_isac/data/instr_alias.yaml``

* ``rs1`` : The register number of source register 1 of the current instruction in the assign list.

* ``rs2`` : The register number of source register 2 of the current instruction in the assign list.

* ``rd`` : The register number of destination register of the current instruction in the assign list.

Instruction aliases when used will be expanded into a tuple of instruction under the given alias.
Along with the above mentioned variable any valid python comparison operators can be used in the condition list.


Expand All @@ -401,7 +404,7 @@ A covergroup contains the following nodes:

.. code-block:: python
[(add,sub) : ? : (add,sub) ] :: [a=rd : ? : ? ] :: [rd==x10 : rd!=a and rs1!=a and rs2!=a : rs1==a or rs2==a ]
[(add,sub) : rv32i_arith : (add,sub) ] :: [a=rd : ? : ? ] :: [rd==x10 : rd!=a and rs1!=a and rs2!=a : rs1==a or rs2==a ]
3. WAW for an add instruction followed by a subtract instruction with 3 non-consuming instructions in between.

Expand Down
2 changes: 1 addition & 1 deletion riscv_isac/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

__author__ = """InCore Semiconductors Pvt Ltd"""
__email__ = '[email protected]'
__version__ = '0.13.1'
__version__ = '0.15.0'
38 changes: 32 additions & 6 deletions riscv_isac/cgf_normalize.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# See LICENSE.incore for details
from math import *
import pprint
import riscv_isac.utils as utils
import itertools
import random
Expand Down Expand Up @@ -548,24 +549,26 @@ def alternate(var, size, signed=True, fltr_func=None,scale_func=None):
#return [(coverpoint,"Alternate") for coverpoint in coverpoints]


def expand_cgf(cgf_files, xlen):
def expand_cgf(cgf_files, xlen,flen):
'''
This function will replace all the abstract functions with their unrolled
coverpoints. It replaces node
:param cgf_files: list of yaml file paths which together define the coverpoints
:param xlen: XLEN of the riscv-trace
:param xlen: XLEN of the DUT/Configuration
:param flen: FLEN of the DUT/Configuration
:type cgf: list
:type xlen: int
:type flen: int
'''
cgf = utils.load_cgf(cgf_files)
for labels, cats in cgf.items():
if labels != 'datasets':
# If 'opcode' found, rename it to 'mnemonics'
if 'opcode' in cats:
logger.warning("Deprecated node used: 'opcode'. Use 'mnemonics' instead")

temp = cgf[labels]['opcode']
del cgf[labels]['opcode']
cgf[labels].insert(1, 'mnemonics', temp)
Expand All @@ -577,20 +580,43 @@ def expand_cgf(cgf_files, xlen):
if len(cgf[labels]['mnemonics'].keys()) > 1:
logger.error(f'Multiple instruction mnemonics found when base_op label defined in {labels} label.')

# Substitute instruction aliases with equivalent tuple of instructions
if 'cross_comb' in cats:
temp = cats['cross_comb']

for covp, covge in dict(temp).items():
data = covp.split('::')
ops = data[0].replace(' ', '')[1:-1].split(':')
# Substitute with tuple of instructions
for i in range(len(ops)):
exp_alias = utils.import_instr_alias(ops[i])
if exp_alias != None:
ops[i] = tuple(exp_alias).__str__().replace("'", '').replace(" ", '')

data[0] = '[' + ':'.join(ops) + ']'
data = '::'.join(data)
del temp[covp]
temp[data] = covge

cgf[labels].insert(1, 'cross_comb', temp)

l = len(cats.items())
i = 0
for label,node in cats.items():
if isinstance(node,dict):
if 'abstract_comb' in node:
temp = node['abstract_comb']
del node['abstract_comb']

for coverpoints, coverage in temp.items():
i = 0
try:
exp_cp = eval(coverpoints)
except Exception as e:
pass
logger.error("Error evaluating abstract comb: "+(coverpoints)\
+" in "+labels+": "+str(e) )
else:
for cp,comment in exp_cp:
cgf[labels][label].insert(1,cp,coverage,comment=comment)
cgf[labels][label].insert(l+i,cp,coverage,comment=comment)
i += 1
return dict(cgf)

Loading

0 comments on commit 16ddd43

Please sign in to comment.