forked from pulp-platform/riscv-opcodes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
based on pulp-platform/mempool/commit/82639303ea9266e601cbd228a0f540648d78061e
- Loading branch information
1 parent
2888e05
commit cfbb942
Showing
37 changed files
with
7,667 additions
and
504 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,39 @@ | ||
SHELL := /bin/sh | ||
|
||
ALL_OPCODES := opcodes-pseudo opcodes opcodes-rvc opcodes-rvc-pseudo opcodes-custom | ||
ALL_REAL_ILEN32_OPCODES := opcodes-rv32i opcodes-rv64i opcodes-rv32m opcodes-rv64m opcodes-rv32a opcodes-rv64a opcodes-rv32h opcodes-rv64h opcodes-rv32f opcodes-rv64f opcodes-rv32d opcodes-rv64d opcodes-rv32q opcodes-rv64q opcodes-system | ||
ALL_REAL_OPCODES := $(ALL_REAL_ILEN32_OPCODES) opcodes-rvc opcodes-rv32c opcodes-rv64c opcodes-custom opcodes-rvv | ||
# Add here your opcodes | ||
MY_OPCODES := opcodes-frep_CUSTOM opcodes-xpulpimg_CUSTOM opcodes-rv32d-zfh_DRAFT opcodes-rv32q-zfh_DRAFT opcodes-rv32zfh_DRAFT opcodes-rv64zfh_DRAFT opcodes_sflt_CUSTOM | ||
|
||
ALL_OPCODES := opcodes-pseudo $(ALL_REAL_OPCODES) $(MY_OPCODES) opcodes-rvv-pseudo | ||
# Opcodes to be discarded | ||
DISCARDED_OPCODES := opcodes-frep_CUSTOM | ||
|
||
inst.chisel: $(ALL_OPCODES) parse-opcodes | ||
cat opcodes opcodes-rvc opcodes-rvc-pseudo opcodes-custom opcodes-pseudo | ./parse-opcodes -chisel > $@ | ||
OPCODES = $(filter-out $(sort $(DISCARDED_OPCODES)), $(sort $(ALL_OPCODES))) | ||
|
||
inst.go: opcodes opcodes-pseudo parse-opcodes | ||
cat opcodes opcodes-pseudo opcodes-pulp | ./parse-opcodes -go > $@ | ||
all: encoding_out.h inst.sverilog | ||
|
||
inst.c: opcodes opcodes-pseudo parse-opcodes | ||
cat opcodes opcodes-pseudo opcodes-pulp | ./parse-opcodes -c > $@ | ||
# Makefile inserted as prerequisite of every recipe because it can change due to DISCARDED_OPCODES | ||
|
||
inst.sv: opcodes opcodes-pseudo parse-opcodes | ||
cat opcodes opcodes-rvc opcodes-rvc-pseudo opcodes-pseudo opcodes-pulp | ./parse-opcodes -sv > $@ | ||
encoding_out.h: $(OPCODES) parse_opcodes encoding.h Makefile | ||
echo "/*" > $@ | ||
echo " * This file is auto-generated by running 'make $@' in 'riscv-opcodes'" >> $@ | ||
echo " */" >> $@ | ||
echo >> $@ | ||
cat encoding.h >> $@ | ||
cat $(OPCODES) | ./parse_opcodes -c >> $@ | ||
|
||
inst.py: opcodes opcodes-pseudo parse-opcodes | ||
cat opcodes opcodes-pseudo opcodes-pulp | ./parse-opcodes -py > $@ | ||
inst.chisel: $(OPCODES) parse_opcodes Makefile | ||
cat $(OPCODES) | ./parse_opcodes -chisel > $@ | ||
|
||
inst.go: $(ALL_REAL_ILEN32_OPCODES) parse_opcodes Makefile | ||
cat $(ALL_REAL_ILEN32_OPCODES) | ./parse_opcodes -go > $@ | ||
|
||
inst.sverilog: opcodes opcodes-pseudo parse-opcodes | ||
cat opcodes opcodes-rvc opcodes-rvc-pseudo opcodes-custom opcodes-pseudo | ./parse-opcodes -sverilog > $@ | ||
inst.sverilog: $(OPCODES) parse_opcodes Makefile | ||
cat $(OPCODES) | ./parse_opcodes -sverilog > $@ | ||
|
||
instr-table.tex: $(ALL_OPCODES) parse-opcodes | ||
cat opcodes opcodes-pseudo opcodes-pulp | ./parse-opcodes -tex > $@ | ||
instr-table.tex: $(OPCODES) parse_opcodes Makefile | ||
cat $(OPCODES) | ./parse_opcodes -tex > $@ | ||
|
||
priv-instr-table.tex: $(ALL_OPCODES) parse-opcodes | ||
cat opcodes opcodes-pseudo | ./parse-opcodes -privtex > $@ | ||
priv-instr-table.tex: $(OPCODES) parse_opcodes Makefile | ||
cat $(OPCODES) | ./parse_opcodes -privtex > $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,39 @@ | ||
riscv-opcodes | ||
=========================================================================== | ||
|
||
This repo enumerates standard RISC-V instruction opcodes, control and status | ||
registers and PULP specific instruction opcodes. It also contains a script to | ||
convert them into several formats (C, Python, Go, Scala, SystemVerilog LaTeX). | ||
Functions will be instantiated to decode those instructions. | ||
This repo enumerates standard RISC-V instruction opcodes and control and | ||
status registers, as well as some custom modifications. It also contains a | ||
script to convert them into several formats (C, SystemVerilog, Scala, LaTeX), | ||
starting from their high-level, human-readable description. | ||
|
||
## Practical info | ||
- Every output of the parser is generated inside this folder; tools which | ||
need such automatically generated files must use soft link to point to them. | ||
For example, supposing `RISCV_ISA_SIM_TOOL` is set to the source code directory of | ||
the Spike simulator: | ||
|
||
```bash | ||
ln -sfr encoding_out.h $RISCV_ISA_SIM_TOOL/encoding.h | ||
``` | ||
|
||
Example of where the outputs of `parse-opcodes` are used in other projects | ||
|
||
| Parser output | Destination | | ||
|:--------------:|:-----------------------------------------------| | ||
| encoding_out.h | riscv-gnu-toolchain/riscv-binutils-gdb/include/opcode/riscv-opc.h <br> riscv-isa-sim/riscv/encoding.h <br> riscv-pk/machine/encoding.h <br> riscv-tests/env/encoding.h <br> riscv-openocd/src/target/riscv/encoding.h <br> _custom use_ i.e. apps/common/encoding.h | | ||
| inst.sverilog | snitch/src/riscv_instr.sv | | ||
|
||
- opcodes description files organization matches the same of the official | ||
repository upstream [riscv-opcodes](https://github.com/riscv/riscv-opcodes), | ||
with the addition of several custom instruction set extensions: you can | ||
add your own custom extensions as text file in the root, subsequently | ||
adding it to the variable `MY_OPCODES` of the `Makefile` | ||
- in the `Makefile`, you can select which opcodes files not to take into account | ||
for the parsing script execution, basing on the target architecture, by | ||
listing them in the variable `DISCARDED_OPCODES`; | ||
- opcodes files from the official 128-bit extension have not been introduced | ||
due to the other changes which they imply to other opcodes specifications; | ||
- some of the instructions originally declared in the vectorial extension | ||
(`opcodes-rvv` file) have been set as pseudo-instruction due to the overlapping | ||
of their opcodes space with the opcodes space of the SIMD instructions from | ||
Xpulpv2, defined in `opcodes-xpulpimg_CUSTOM`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.