risc‑v‑db

The RISC‑V ISA, modeled as data.

A pipeline that turns 1,700+ specification files — every instruction, extension, and register — into a normalized, queryable PostgreSQL database.

explore an extension
decode fetch alu vector unit load / store csr file extract normalize load query verify

Extension explorer

Search an extension, watch it grow

164 extensions indexed
 
selected extension requires / required‑by instruction it defines pseudoinstruction scroll to zoom · drag empty space to pan · drag a node to move it
details click a node
Select any node in the graph to see its real column values here.
sql/queries.sql click a node to see its query
-- nothing selected yet --

How it's built

Three stages, one direction

01

extract_*.py

Walks riscv-unified-db/spec/std/isa, parses every extension, instruction, and CSR YAML file with pyyaml, tags each record with its source path.

02

data/*.json

Normalized JSON snapshots — stable, diffable, and disconnected from the upstream repo so loading doesn't require re-parsing YAML.

03

load_*.py

Inserts into 8 PostgreSQL tables via psycopg2, resolving extension references and flattening nested requirement logic into foreign-keyed rows.

04

query.py / .sql

What it was all for — "which extension defines this instruction" answered in one indexed join, not a grep.

164Extensions
1,351Instructions
396CSRs
1,304CSR fields
8Relational tables
3NFNormal form

What it's for

Questions that used to mean opening ten YAML files

  • Which extension defines a given instruction, and what's its assembly form?
  • What CSRs exist at a given privilege mode, and at what address?
  • Which instructions expand into pseudoinstructions, and under what condition?
  • What does an extension require to be implemented — and what requires it?
  • Which instructions have no cleanly resolvable defining extension?
sql/queries.sql
-- which extension defines an instruction
SELECT i.name, i.assembly, e.name AS extension
FROM instructions i
LEFT JOIN extensions e ON e.extension_id = i.extension_id
WHERE i.name = 'addi';

-- csrs at machine privilege, by address
SELECT name, address, length
FROM csrs
WHERE priv_mode = 'M'
ORDER BY address;

Built with

Python PostgreSQL psycopg2 PyYAML python-dotenv riscv-unified-db