* smctr: add custom fieid mask
Based on 1.0.0 section 2.1 and 2.2
1. add custom field for mctrctl
2. add custom field for sctrctl
Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
* smctr: add field mask for data record
Based on 1.0.0 and section 3.1/3.2/3.3
1. add fields for ctrsource
2. add fields for ctrtarget
3. add fields for ctrdata
Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
---------
Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
The SVG generation in #364 broke this in a surprising way (though #364
really is not to blame). The addition of a file in the root directory
that began with `rv` caused the Make rule to glob that file, rather than
passing the string `rv*` through to `parse.py`.
* Adding support to generate an svg from opcodes
* Attempt to fix linting issues
* Adding matplotlib dependency to precommit hooks
* Update linting changes
* Added typed tuples
* Fixing further linting issue (WiP)
* Resolved all linting issue
Matplotlib types cannot be resolved by the linter.
Matplotlib calles are ignored for type checking
* Adding matplotlib to dependencies and svg to output for coverage
* Don't run go fmt error in go_utils.py
go_utils.py currently runs go fmt to pretty print the generated
inst.go file. Unfortunately, this call to go fmt always fails as
inst.go contains an internal import and go fmt is being run out of
tree. Here we remove the code that attempts to format inst.go
resulting in a clean run of go_utils.py without any errors. The
generated file, inst.go, can be formatted when it's copied into the
Go source tree, prior to its submission to the Golang project.
* Add CSR support to go_utils.py
go_utils.py now generates a Go map that maps CSR numbers to CSR
names. The resulting map is written into inst.go for use by the
Go assembler.
This is more maintainable and scalable and gives better errors and a nice `--help` message. The interface is compatible with the previous version.
Co-authored-by: Tim Hutt <timothy.hutt@codasip.com>
If we're sorting the dictionary anyway we may as well output the JSON sorted.
Also since Python 3.6 we can just use `dict()` since the insertion order is preserved.
* Remove wildcard imports
Use explicit imports rather than wildcards. This is more maintainable.
* Enable Pylint in CI and fix its errors
The main fixes were:
* Specify encoding for all file opens. By default it depends on environment variables which is bad.
* Use `with` to open files. Otherwise they don't necessarily get closed.
There were also a few minor things like using `enumerate`, not using objects as default arguments, etc. In some cases I slightly refactored the code.
This makes the code easier to understand and navigate, and also detected a few of bugs:
1. Missing brackets on e.upper. (Fixed)
2. Not strictly related to types, but a lot of the regexes were not raw strings and therefore contained invalid escape sequences. Python prints a warning about these in recent versions. (Fixed)
3. Expression in `process_pseudo_instructions()` that is always false. (Not fixed)
4. Missing definition of `log_and_exit()`. (Fixed)
This is validated via pre-commit in CI.
Previously this generate a `instr_dict.yaml` file, however there is no need to use YAML here. The only advantages of YAML over JSON are that it is (debatably) easier for humans to write, making it suitable as human-edited input files. This is a machine-generated output file so JSON is better.
The main advantages are:
1. It removes the dependency on PyYAML, which is the only external dependency of this project. Python external dependencies are quite a pain - PyYAML is a particularly troublesome one - and having no dependencies is very convenient (no need for venv etc.).
2. It means consumers of the file don't need to depend on PyYAML.
Note this could have been done in an 100% backwards compatible way by keeping the file name unchanged (since JSON is valid YAML), however I figured there probably aren't that many users of this file, and since the only thing they need to change is the filename it's probably better to minimise confusion by renaming it. It also makes it clear that it is guaranteed to be JSON.