You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Browse filesBrowse the repository at this point in the historyBrowse files
Tim Hutt
committed
Reorganise Python code using pyproject.toml
Add pyproject.toml (the modern alternative to requirements.txt), making this a proper Python package that can be installed via pip and potentially uploaded to PyPI.
This also loads the files using `importlib.resources` and installs them into the wheel. This means that when you create a wheel using `uv build` it will still be able to load all the opcodes and CSV files.
To avoid moving those resource files in the source repo, the Python build backend (hatchling) is instructed to move them to the right place when building a wheel, and the `resource_root()` function checks in both places so it always works. This is a little hacky but it works.
CI builds source and binary wheels (not actually binary) that can be uploaded to PyPI. If we do upload them then using this project is as simple as
```
uvx riscv_opcodes -c 'rv*'
```
└── src/riscv_opcodes # python files to perform checks on
18
+
# the instructions and generate artifacts
21
19
```
22
20
23
21
## File Naming Policy
24
22
25
23
This project follows a very specific file structure to define the instruction encodings. All files
26
24
containing instruction encodings start with the prefix `rv`. These files can either be present in
27
-
the root directory (if the instructions have been ratified) or the `unratified` directory. The exact
25
+
the `extensions` directory (if the instructions have been ratified) or the `extensions/unratified` directory. The exact
28
26
file-naming policy and location is as mentioned below:
29
27
30
28
1.`rv_x` - contains instructions common within the 32-bit and 64-bit modes of extension X.
@@ -140,10 +138,11 @@ The following artifacts can be generated using parse.py:
140
138
- inst.spinalhdl : spinalhdl code to decode instructions
141
139
- inst.go : go code to decode instructions
142
140
143
-
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:
141
+
To generate all the above artifacts for all instructions currently checked in, simply run `make` from the root-directory. [`uv`](https://docs.astral.sh/uv/) is required (see [easy installation instructions](https://docs.astral.sh/uv/getting-started/installation/)).
142
+
143
+
`make` should print the following log on the command-line:
@@ -181,7 +179,7 @@ If you only want a specific artifact you can use one or more of the following ta
181
179
For example, if you want to generate the `c` based artifact with extensions as shown earlier, you can use the following command:
182
180
183
181
```bash
184
-
./parse.py -c rv*_irv*_m
182
+
uv run riscv_opcodes -c 'rv*_i''rv*_m'
185
183
```
186
184
Which will print the following log:
187
185
@@ -202,7 +200,6 @@ You can use the `clean` target to remove all artifacts.
202
200
To add a new extension of instructions, create an appropriate `rv*` file based on the policy defined in [File Structure](#file-naming-policy). Run `make` from the root directory to ensure that all checks pass and all artifacts are created correctly. A successful run should print the following log on the terminal:
To enable debug logs in parse.py change `level=logging.INFO` to `level=logging.DEBUG` and run the python command. You will now see debug statements on
216
+
To enable debug logs in `parse.py` change `level=logging.INFO` to `level=logging.DEBUG` and run the python command. You will now see debug statements on
0 commit comments