Skip to content

Commit 81f691a

Browse files
authored
Merge pull request #22 from pulp-platform/snitch-new
Add PULP extensions and LLVM tablegen generation
2 parents a9327c3 + 08de734 commit 81f691a

45 files changed

Lines changed: 2376 additions & 58 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/python-app.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
# Generate all output with code coverage. Unfortunately due to limitations in
4747
# the `coverage` tool we need to run `riscv_opcodes` as a module.
4848
- name: Generate
49-
run: uv run -- coverage run -m riscv_opcodes -c -chisel -sverilog -rust -latex -spinalhdl -svg -go "rv*" "unratified/rv*"
49+
run: uv run -- coverage run -m riscv_opcodes --warn-overlap -c -chisel -sverilog -rust -latex -spinalhdl -svg -go "rv*" "unratified/rv*"
5050

5151
- name: Check C output
5252
run: cat encoding.out.h | cpp

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ inst.spinalhdl
1010
inst.sverilog
1111
inst.svg
1212
instr_dict.json
13+
inst.*.td
14+
csr.td
15+
feature.td
1316

1417
__pycache__/
1518

Makefile

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ ENV_H := ../riscv-tests/env/encoding.h
55
OPENOCD_H := ../riscv-openocd/src/target/riscv/encoding.h
66
INSTALL_HEADER_FILES := $(ISASIM_H) $(PK_H) $(ENV_H) $(OPENOCD_H)
77
PSEUDO_FLAG := $(if $(PSEUDO),-pseudo,)
8+
FLAGS := --warn-overlap
89

910
ifeq ($(shell command -v uv 2>/dev/null),)
1011
RUNNER := PYTHONPATH=src python -m
@@ -21,25 +22,25 @@ pseudo:
2122
@$(MAKE) PSEUDO=1 everything
2223

2324
everything:
24-
@$(RUNNER) riscv_opcodes $(PSEUDO_FLAG) -c -go -chisel -sverilog -rust -latex -spinalhdl $(EXTENSIONS)
25+
@$(RUNNER) riscv_opcodes $(FLAGS) $(PSEUDO_FLAG) -c -go -chisel -sverilog -rust -latex -spinalhdl $(EXTENSIONS)
2526

2627
encoding.out.h:
27-
@$(RUNNER) riscv_opcodes -c $(PSEUDO_FLAG) $(EXTENSIONS)
28+
@$(RUNNER) riscv_opcodes $(FLAGS) -c $(PSEUDO_FLAG) $(EXTENSIONS)
2829

2930
inst.chisel:
30-
@$(RUNNER) riscv_opcodes -chisel $(PSEUDO_FLAG) $(EXTENSIONS)
31+
@$(RUNNER) riscv_opcodes $(FLAGS) -chisel $(PSEUDO_FLAG) $(EXTENSIONS)
3132

3233
inst.go:
33-
@$(RUNNER) riscv_opcodes -go $(PSEUDO_FLAG) $(EXTENSIONS)
34+
@$(RUNNER) riscv_opcodes $(FLAGS) -go $(PSEUDO_FLAG) $(EXTENSIONS)
3435

3536
latex:
36-
@$(RUNNER) riscv_opcodes -latex $(PSEUDO_FLAG) $(EXTENSIONS)
37+
@$(RUNNER) riscv_opcodes $(FLAGS) -latex $(PSEUDO_FLAG) $(EXTENSIONS)
3738

3839
inst.sverilog:
39-
@$(RUNNER) riscv_opcodes -sverilog $(PSEUDO_FLAG) $(EXTENSIONS)
40+
@$(RUNNER) riscv_opcodes $(FLAGS) -sverilog $(PSEUDO_FLAG) $(EXTENSIONS)
4041

4142
inst.rs:
42-
@$(RUNNER) riscv_opcodes -rust $(PSEUDO_FLAG) $(EXTENSIONS)
43+
@$(RUNNER) riscv_opcodes $(FLAGS) -rust $(PSEUDO_FLAG) $(EXTENSIONS)
4344

4445
clean:
4546
rm -f inst* priv-instr-table.tex encoding.out.h
@@ -58,4 +59,4 @@ instr-table.tex: latex
5859
priv-instr-table.tex: latex
5960

6061
inst.spinalhdl:
61-
@$(RUNNER) riscv_opcodes -spinalhdl $(PSEUDO_FLAG) $(EXTENSIONS)
62+
@$(RUNNER) riscv_opcodes $(FLAGS) -spinalhdl $(PSEUDO_FLAG) $(EXTENSIONS)

PULP.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Adding a custom ISA extension
2+
3+
If you have a custom ISA extension, create a new file under `extensions/unratified`.
4+
The extension name should be prefixed with an `x` to properly identify custom extensions; refer to the existing extensions.
5+
6+
Finally, list the extension in `pulp-extensions.txt` for it to be picked up as a PULP extension, e.g. by our compiler generation scripts.

arg_lut.csv

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,10 @@
113113
"p_rd_p", 11, 8
114114
"p_rs1_p", 19, 16
115115
"p_rs2_p", 24, 21
116+
"shamt", 25, 20
117+
"prs3", 11, 7
118+
"L", 7, 7
119+
"uimms", 19, 15
120+
"Luimm5", 29, 25
121+
"stagger_max", 14, 12
122+
"stagger_mask", 11, 8
File renamed without changes.
File renamed without changes.

csrs/unratified/.gitkeep

Whitespace-only changes.

csrs/unratified/rv_xpulp.csv

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# PULP/Snitch custom CSRs.
2+
#
3+
# format of a line in this file:
4+
# 0xENCODING, "csr_name"
5+
0x7C0, "ssr"
6+
0x7C3, "sc"
7+
0x7C4, "user_low"
8+
0x7C5, "user_high"
9+
# Smallfloat and misc PULP CSRs
10+
0x7C1, "fpmode"
11+
0x7C2, "barrier"
12+
0x7C6, "copift"
13+
0x7C7, "dump"
14+
0x7D1, "stacklimit"
15+
0x800, "fmode"

encoding.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,28 @@
486486
#define IRQ_RAS_LOW_PRIO 35
487487
#define IRQ_RAS_HIGH_PRIO 43
488488

489+
/* PULP/Snitch custom interrupt sources */
490+
#define IRQ_HOST 13 /* legacy alias for IRQ_LCOF */
491+
#define IRQ_S_CLUSTER 17
492+
#define IRQ_M_CLUSTER 19
493+
#define IRQ_M_ACC 20 /* machine-level accelerator interrupt */
494+
495+
#define MIP_SCIP (1 << IRQ_S_CLUSTER)
496+
#define MIP_MCIP (1 << IRQ_M_CLUSTER)
497+
#define MIP_MXIP (1 << IRQ_M_ACC)
498+
499+
/* PULP/Snitch custom CSR addresses */
500+
#define CSR_SSR 0x7C0 // Stream semantic registers
501+
#define CSR_FPMODE 0x7C1 // Floating-point mode
502+
#define CSR_BARRIER 0x7C2 // Hardware barrier
503+
#define CSR_SC 0x7C3 // Scalar chaining
504+
#define CSR_USER_LOW 0x7C4 // AWUSER[31:0]
505+
#define CSR_USER_HIGH 0x7C5 // AWUSER[63:32]
506+
#define CSR_COPIFT 0x7C6 // Enable COPIFT
507+
#define CSR_DUMP 0x7C7 // Dump CSR
508+
#define CSR_STACKLIMIT 0x7D1 // Mempool stack overflow limit
509+
#define CSR_FMODE 0x800 // Floating-point mode (legacy)
510+
489511
/* page table entry (PTE) fields */
490512
#define PTE_V 0x001 /* Valid */
491513
#define PTE_R 0x002 /* Read */

0 commit comments

Comments
 (0)