Skip to content

Commit 62e0711

Browse files
committed
Add README.md with instruction on how to use this tool.
Signed-off-by: Afonso Oliveira <[email protected]>
1 parent fb3408d commit 62e0711

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

ext/opcodes_maker/README.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# RISC-V Instruction Format Generator
2+
3+
This tool converts RISC-V instruction YAML definitions into various output formats including C headers, Chisel, Rust, Go, and LaTeX documentation.
4+
5+
## Prerequisites
6+
7+
- Python 3
8+
- YAML Python package (`pip install pyyaml`)
9+
- Make
10+
11+
## Directory Structure
12+
13+
```
14+
.
15+
├── yaml_to_json.py # Converts YAML instruction definitions to JSON
16+
├── generator.py # Generates various output formats from JSON
17+
├── output/ # Generated files directory
18+
└── Makefile # Build system configuration
19+
```
20+
21+
## Input/Output Format
22+
23+
### Input
24+
- YAML files containing RISC-V instruction definitions
25+
- Default input directory: `../../arch/inst`
26+
- Can be customized using `YAML_DIR` variable
27+
28+
### Output
29+
All outputs are generated in the `output` directory:
30+
- `encoding.out.h` - C header definitions
31+
- `inst.chisel` - Chisel implementation
32+
- `inst.spinalhdl` - SpinalHDL implementation
33+
- `inst.sverilog` - SystemVerilog implementation
34+
- `inst.rs` - Rust implementation
35+
- `inst.go` - Go implementation
36+
- `instr-table.tex` - LaTeX instruction table
37+
- `priv-instr-table.tex` - LaTeX privileged instruction table
38+
- `instr_dict.json` - Intermediate JSON representation
39+
- `processed_instr_dict.json` - Final processed JSON
40+
41+
## Usage
42+
43+
### Basic Usage
44+
```bash
45+
make # Use default YAML directory
46+
make YAML_DIR=/custom/path # Use custom YAML directory
47+
make clean # Remove all generated files
48+
make help # Show help message
49+
```
50+
51+
### Pipeline Steps
52+
1. YAML to JSON conversion (`yaml_to_json.py`)
53+
- Reads YAML instruction definitions
54+
- Creates intermediate JSON representation
55+
56+
2. Output Generation (`generator.py`)
57+
- Takes JSON input
58+
- Generates all output formats
59+
- Places results in output directory
60+
61+
### Customization
62+
- Input directory can be changed:
63+
```bash
64+
make YAML_DIR=/path/to/yaml/files
65+
```
66+
- Default paths in Makefile:
67+
```makefile
68+
YAML_DIR ?= ../../arch/inst
69+
OPCODES_DIR := ../riscv-opcodes
70+
OUTPUT_DIR := output
71+
```
72+
73+
## Error Handling
74+
- Checks for required Python scripts before execution
75+
- Verifies input directory exists
76+
- Creates output directory if missing
77+
- Shows helpful error messages for missing files/directories
78+
79+
## Cleaning Up
80+
```bash
81+
make clean # Removes all generated files and output directory
82+
```
83+
84+
## Dependencies
85+
- Requires access to RISC-V opcodes repository (expected at `../riscv-opcodes`)
86+
- Python scripts use standard libraries plus PyYAML
87+
88+
## Note
89+
Make sure your input YAML files follow the expected RISC-V instruction definition format. For format details, refer to the RISC-V specification or example YAML files in the arch/inst directory.

0 commit comments

Comments
 (0)