Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate JSON instead of YAML #304

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install PyYAML
- name: Install Coverage
run: |
pip3 install -r requirements.txt
pip3 install coverage
- name: Run pre-commit
run: |
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install PyYAML
- name: Install Coverage
run: |
pip3 install -r requirements.txt
pip3 install coverage
- name: Test error outputs
run: coverage run -m unittest -b
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ priv-instr-table.tex
inst.rs
inst.spinalhdl
inst.sverilog
instr_dict.yaml
instr_dict.json

__pycache__/
4 changes: 0 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,9 @@ repos:
# rev: v3.3.1
# hooks:
# - id: pylint
# additional_dependencies:
# - "pyyaml==6.0.2"

# TODO: Enable this when types are added.
# - repo: https://github.com/RobertCraigie/pyright-python
# rev: v1.1.383
# hooks:
# - id: pyright
# additional_dependencies:
# - "pyyaml==6.0.2"
22 changes: 8 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,11 @@ of extensions are being processed such that the *base-instruction* is not includ

The following artifacts can be generated using parse.py:

- instr\_dict.yaml : This is file generated always by parse.py and contains the
entire main dictionary `instr\_dict` in YAML format. Note, in this yaml the
*dots* in an instruction are replaced with *underscores*
- instr\_dict.json : This is always generated by parse.py and contains the
entire main dictionary `instr\_dict` in JSON format. Note, in this file the
*dots* in an instruction are replaced with *underscores*. In previous
versions of this project the generated file was instr\_dict.yaml. Note that
JSON is a subset of YAML so the file can still be read by any YAML parser.
- encoding.out.h : this is the header file that is used by tools like spike, pk, etc
- instr-table.tex : the latex table of instructions used in the riscv-unpriv spec
- priv-instr-table.tex : the latex table of instruction used in the riscv-priv spec
Expand All @@ -138,14 +140,6 @@ The following artifacts can be generated using parse.py:
- inst.spinalhdl : spinalhdl code to decode instructions
- inst.go : go code to decode instructions

Make sure you install the required python pre-requisites are installed by executing the following
command:

```
sudo apt-get install python-pip3
pip3 install -r requirements.txt
```

To generate all the above artifacts for all instructions currently checked in, simply run `make` from the root-directory. This should print the following log on the command-line:

```
Expand Down Expand Up @@ -220,6 +214,6 @@ DEBUG:: Processing line: bne bimm12hi rs1 rs2 bimm12lo 14..12=1 6..2=0x
## How do I find where an instruction is defined?

You can use `grep "^\s*<instr-name>" rv* unratified/rv*` OR run `make` and open
`instr_dict.yaml` and search of the instruction you are looking for. Within that
instruction the `extension` field will indicate which file the instruction was
picked from.
`instr_dict.json` and search for the instruction you are looking for. Within
that instruction the `extension` field will indicate which file the
instruction was picked from.
2 changes: 0 additions & 2 deletions latex_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import re
import sys

import yaml

from constants import *
from shared_utils import *

Expand Down
7 changes: 3 additions & 4 deletions parse.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#!/usr/bin/env python3
import collections
import json
import logging
import pprint
import sys

import yaml

from c_utils import *
from chisel_utils import *
from constants import *
Expand Down Expand Up @@ -44,8 +43,8 @@

instr_dict = create_inst_dict(extensions, include_pseudo)

with open("instr_dict.yaml", "w") as outfile:
yaml.dump(add_segmented_vls_insn(instr_dict), outfile, default_flow_style=False)
with open("instr_dict.json", "w") as outfile:
json.dump(add_segmented_vls_insn(instr_dict), outfile, indent=2)
Timmmm marked this conversation as resolved.
Show resolved Hide resolved
instr_dict = collections.OrderedDict(sorted(instr_dict.items()))

if "-c" in sys.argv[1:]:
Expand Down
1 change: 0 additions & 1 deletion requirements.txt

This file was deleted.

Loading