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

Commit

Permalink
Merge pull request #35 from edwin7026/riscv-opcode-plugin
Browse files Browse the repository at this point in the history
Add Riscv-opcode plugin.
  • Loading branch information
pawks authored Apr 15, 2022
2 parents 87375b3 + c152cae commit 5a70060
Show file tree
Hide file tree
Showing 15 changed files with 1,166 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

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

## [0.11.0] - 2022-04-03
- Added plugins to use new rvopcode format
- Added CLI option to setup rvopcode plugin

## [0.10.2] - 2022-03-15
- Added method to generate data patterns for bitmanip instructions
-
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
include LICENSE.incore
include README.rst
include riscv_isac/requirements.txt
recursive-include riscv_isac/data/*

recursive-exclude * __pycache__
recursive-exclude * *.py[co]
5 changes: 4 additions & 1 deletion docs/source/add_instr.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
Adding Support for new Instructions
###################################

This section details the steps for adding support for new instructions in RISCV-ISAC.
This section details the steps for adding support for new instructions in the native python plugins
of RISCV-ISAC.

.. note:: An alternative is to add support for the new instructions using the ``riscv/riscv-opcodes`` repository. Refer :here:`rvopcodes` for further information.

Update the Parser-Module
========================
Expand Down
3 changes: 2 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ please refer to the :ref:`Revisions <revisions>` documentation.
overview
quickstart
cgf
rvopcodesdecoder
add_instr
code
contributing
revisions
licensing
python_plugins
code
39 changes: 39 additions & 0 deletions docs/source/rvopcodesdecoder.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
.. _rvopcodes:

Using the encodings from riscv-opcodes
======================================

The `rvopcodesdecoder` is a decoder plugin for RISCV-ISAC, dependent on the official `riscv-opcodes <https://github.com/riscv/riscv-opcodes>`_ repository. The `rvopcodesdecoder` plugin automatically builds the decode tree and decodes instructions based on the encodings specified in the repository. The plugin will support any instruction/extension as long as it is specified in the format adhereing to the official repository.

Usage
~~~~~

Initial Setup
*************
- **Standard version**: This use case is intended for users who want to use the rvopcodes repo as
is from `riscv/riscv-opcodes <https://github.com/riscv/riscv-opcodes>`_. The command generates a
``rvop-plugin`` folder with all the necessary files needed for the plugin. This path will have to
be passed via the CLI while running coverage. ::

riscv_isac setup --plugin-path ./rvop-plugin

- **Custom Version**: This use case is intended for users who have a custom/modified version of the
rvopcodes encodings locally. The ``<path-to-rvopcodes>`` in the following command should point to
the path on the system where the custom/modified ``riscv-opcodes`` repository contents are located.
The command generates a symlink to the path inside the plugin folder and hence all changes to
the encodings are picked up automatically. To add an extension, the user has to create a file
with the ``rv<xlen>`` prefix followed by the extension name. The file can then be populated with
the instruction encodings in the appropriate format. Similar steps can be followed for updating
existing extensions too. ::

riscv_isac setup --plugin-path ./rvop-plugin --rvop-path <path-to-rvopcodes>

Using the decoder with ISAC for coverage
****************************************

To use `rvopcodesdecoder` as the decoder in RISCV-ISAC, ``rvopcodesdecoder`` should be supplied as argument for ``--decoder-name`` option with the ``--decoder-path`` set to the path of ``rvop-plugin`` generated in the previous step.. For example, ::

riscv_isac --verbose info coverage --decoder-name rvopcodesdecoder --decoder-path ./rvop-plugin -t trace.log --parser-name spike -o coverage.rpt -e add-01.out -c rv64i.cgf -x 64
.. note:: Pseudo instructions are always decoded into the mnemonics of the base instruction in this plugin. For example, `zext.h` is always decoded as `pack` only.

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.10.2'
__version__ = '0.11.0'
10 changes: 6 additions & 4 deletions riscv_isac/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,8 +922,9 @@ def compute(trace_file, test_name, cgf, parser_name, decoder_name, detailed, xle
parser_pm.add_hookspecs(ParserSpec)
try:
parserfile = importlib.import_module(parser_name)
except ImportError:
logger.error('Parser name invalid!')
except ImportError as e:
logger.error('Error while importing Parser!')
logger.error(e)
raise SystemExit
parserclass = getattr(parserfile, parser_name)
parser_pm.register(parserclass())
Expand All @@ -934,8 +935,9 @@ def compute(trace_file, test_name, cgf, parser_name, decoder_name, detailed, xle
decoder_pm.add_hookspecs(DecoderSpec)
try:
instructionObjectfile = importlib.import_module(decoder_name)
except ImportError:
logger.error('Decoder name invalid!')
except ImportError as e:
logger.error('Error while importing Decoder!')
logger.error(e)
raise SystemExit
decoderclass = getattr(instructionObjectfile, "disassembler")
decoder_pm.register(decoderclass())
Expand Down
Empty file added riscv_isac/data/__init__.py
Empty file.
Loading

0 comments on commit 5a70060

Please sign in to comment.