riscfetch 2.2.1

RISC-V architecture information display tool - Show off your RISC-V setup!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
# riscfetch CLI Specification

This document defines the expected behavior of the riscfetch command-line tool.

## Overview

riscfetch is a RISC-V system information display tool. It only runs on RISC-V architecture and exits with an error on other systems.

## Command Line Interface

```
riscfetch [OPTIONS]
```

### Options

| Short | Long | Description |
|-------|------|-------------|
| `-e` | `--explain` | Show detailed explanation of each ISA extension |
| `-j` | `--json` | Output in JSON format |
| `-a` | `--all` | Show all extensions with checkmarks for supported ones |
| `-b` | `--benchmark` | Run ISA-specific benchmarks |
| `-l` | `--logo <VENDOR>` | Vendor logo (see Supported Vendors below) |
| | `--style <STYLE>` | Logo style: normal, small, none |
| `-h` | `--help` | Show help message |
| `-V` | `--version` | Show version |

---

## Exit Codes

| Code | Meaning |
|------|---------|
| 0 | Success |
| 1 | Not running on RISC-V architecture |

---

## Behavior by Architecture

### On RISC-V Systems

- Display system information (see Output Format below)
- Exit with code 0

### On Non-RISC-V Systems

**Normal mode:**
```
Sorry, not RISC-V
```
- Exit with code 1

**JSON mode (`--json`):**
```json
{"error":"not_riscv","message":"This tool only runs on RISC-V architecture"}
```
- Exit with code 1

---

## Output Format (Normal Mode)

### Standard Output

Extensions are grouped by category for better readability:

```
ISA:        rv64imafdcv_zicbom_zicboz_zicntr_zicsr_zifencei_...
Ext:        I M A F D C V
Z-Base:     Zicsr Zifencei Zicntr Zihpm
Z-Bit:      Zba Zbb Zbc Zbs
Z-Cache:    Zicbom Zicboz
Z-Vector:   Zvl128b Zvl256b
S-Sup:      Sstc
Vector:     Enabled, VLEN>=256
Harts:      8 harts
HW IDs:     vendor:0x710 arch:0x8000000000000007 impl:0x0
Cache:      L1D:32K L1I:32K L2:512K

--------------------------------

Board:      SpacemiT K1
OS:         Ubuntu 24.04 LTS
Kernel:     6.1.15-riscv64
Memory:     3.45 GiB / 8.00 GiB
Uptime:     3h 42m
User:       user@spacemit
```

### Field Definitions

| Field | Description | Example |
|-------|-------------|---------|
| ISA | Full ISA string from /proc/cpuinfo | `rv64imafdc_zicsr_zifencei` |
| Ext | Standard extensions (space-separated) | `I M A F D C V` |
| Z-{Category}: | Z-extensions grouped by category | `Z-Bit: Zba Zbb Zbc Zbs` |
| S-{Category}: | S-extensions (privileged) by category | `S-Sup: Sstc` |
| Vector | Vector extension status and VLEN | `Enabled, VLEN>=256` or empty |
| Harts | Number of hardware threads | `4 harts` |
| HW IDs | Hardware identifiers | `vendor:0x489 arch:0x... impl:0x...` |
| Cache | Cache sizes | `L1D:32K L1I:32K L2:2048K` |
| Board | Device tree model name | `SpacemiT K1` |
| OS | Operating system name and version | `Ubuntu 24.04 LTS` |
| Kernel | Kernel version | `6.8.0-riscv64` |
| Memory | Used / Total memory | `3.45 GiB / 8.00 GiB` |
| Uptime | System uptime | `3h 42m` |
| User | Username and hostname | `user@hostname` |

### Extension Categories

**Z-Extension Categories:**
| Category | Display Name | Examples |
|----------|-------------|----------|
| base | Base | Zicsr, Zifencei, Zicntr, Zihpm |
| hint | Hints | Zihintpause, Zihintntl |
| cache | Cache | Zicbom, Zicboz, Zicbop |
| bit | Bit Manipulation | Zba, Zbb, Zbc, Zbs |
| crypto | Cryptography | Zk, Zkn, Zknd, Zkne, ... |
| fp | Floating Point | Zfh, Zfhmin, Zfa, Zfinx, ... |
| comp | Compressed | Zca, Zcb, Zcd, Zcf, ... |
| atomic | Atomics | Zacas, Zabha, Zaamo, ... |
| mem | Memory Model | Za64rs, Za128rs, Ztso, ... |
| vec | Vector | Zve32x, Zvl128b, Zvl256b, ... |
| vcrypto | Vector Crypto | Zvbb, Zvbc, Zvkg, ... |

**S-Extension Categories:**
| Category | Display Name | Examples |
|----------|-------------|----------|
| vm | Virtual Memory | Svinval, Svnapot, Svpbmt, ... |
| sup | Supervisor | Ssaia, Sstc, Ssstateen, ... |
| mach | Machine | Smaia, Smepmp, Smstateen, ... |
| hyp | Hypervisor | Sha, Shgatpa, ... |
| debug | Debug | Sdext, Sdtrig |
| user | User | Supm |

### Separator

A line of dashes (`--------------------------------`) separates RISC-V specific info (above) from general system info (below).

---

## Output Format (--explain Mode)

Shows each extension with its description, grouped by category with aligned columns:

```
Extensions:
  I          Base Integer Instructions
  M          Integer Multiply/Divide
  A          Atomic Instructions
  F          Single-Precision Float
  D          Double-Precision Float
  C          Compressed (16-bit)
  V          Vector (SIMD)

Z-Extensions (Base):
  Zicsr      CSR Instructions
  Zifencei   Instruction-Fetch Fence
  Zicntr     Base Counters/Timers
  Zihpm      Hardware Perf Counters

Z-Extensions (Bit Manipulation):
  Zba        Address Generation
  Zbb        Basic Bit Manipulation
  Zbc        Carry-less Multiply
  Zbs        Single-bit Operations

Z-Extensions (Cryptography):
  Zkt        Data-Indep Timing

Z-Extensions (Vector):
  Zvl128b    VLEN >= 128 bits
  Zvl256b    VLEN >= 256 bits
  Zvkt       Vector Data-Indep Time

S-Extensions (Supervisor):
  Sstc       Supervisor Timer
```

---

## Output Format (--all Mode)

Shows ALL defined extensions (144 total) with checkmarks indicating support status:

- `` (green, bold) = Supported by this CPU
- `` (gray/dim) = Not supported

### Compact mode (`-a`)

```
Ext:        ✓I ✗E ✓M ✓A ✓F ✓D ✗Q ✓C ✗B ✗V ✗H
Z-Base:     ✓Zicsr ✓Zifencei ✗Zicntr ✗Zihpm
Z-Bit:      ✓Zba ✓Zbb ✗Zbc ✓Zbs
Z-Cache:    ✗Zicbom ✗Zicboz ✗Zicbop
...
```

### Explained mode (`-a -e`)

```
Extensions:
 ✓ I          Base Integer Instructions
 ✗ E          Embedded (16 registers)
 ✓ M          Integer Multiply/Divide
 ...

Z-Extensions (Base):
 ✓ Zicsr      CSR Instructions
 ✓ Zifencei   Instruction-Fetch Fence
 ✗ Zicntr     Base Counters/Timers
 ...
```

The `--all` flag can be combined with other options (`-e`, `-l`, `-j`, `-r`, etc.).

---

## Output Format (--json Mode)

### Success (on RISC-V)

```json
{
  "isa": "rv64imafdcv_zicsr_zifencei_zba_zbb_sstc",
  "extensions": [
    {"name": "I", "description": "Base Integer Instructions"},
    {"name": "M", "description": "Integer Multiply/Divide"},
    {"name": "A", "description": "Atomic Instructions"},
    {"name": "F", "description": "Single-Precision Float"},
    {"name": "D", "description": "Double-Precision Float"},
    {"name": "C", "description": "Compressed (16-bit)"},
    {"name": "V", "description": "Vector (SIMD)"}
  ],
  "z_extensions": [
    {"name": "Zicsr", "description": "CSR Instructions"},
    {"name": "Zifencei", "description": "Instruction-Fetch Fence"},
    {"name": "Zba", "description": "Address Generation"},
    {"name": "Zbb", "description": "Basic Bit Manipulation"}
  ],
  "s_extensions": [
    {"name": "Sstc", "description": "Supervisor Timer"}
  ],
  "vector": {
    "enabled": true,
    "vlen": null,
    "elen": null
  },
  "hart_count": 8,
  "hardware_ids": {
    "mvendorid": "0x710",
    "marchid": "0x8000000000000007",
    "mimpid": "0x0"
  },
  "cache": {
    "l1d": "32K",
    "l1i": "32K",
    "l2": "512K",
    "l3": null
  },
  "board": "SpacemiT K1",
  "memory_used_bytes": 3707764736,
  "memory_total_bytes": 8589934592,
  "kernel": "6.1.15-riscv64",
  "os": "Ubuntu 24.04 LTS",
  "uptime_seconds": 13320
}
```

### Error (on non-RISC-V)

```json
{
  "error": "not_riscv",
  "message": "This tool only runs on RISC-V architecture"
}
```

---

## Output Format (--all --json Mode)

When `--all` is combined with `--json`, extensions include ALL defined extensions with a `supported` field:

```json
{
  "isa": "rv64imafdc_zicsr_zifencei_zba_zbb",
  "extensions": [
    {"name": "I", "description": "Base Integer Instructions", "supported": true},
    {"name": "E", "description": "Embedded (16 registers)", "supported": false},
    {"name": "M", "description": "Integer Multiply/Divide", "supported": true},
    ...
  ],
  "z_extensions": [
    {"name": "Zicsr", "description": "CSR Instructions", "category": "base", "supported": true},
    {"name": "Zifencei", "description": "Instruction-Fetch Fence", "category": "base", "supported": true},
    {"name": "Zicntr", "description": "Base Counters/Timers", "category": "base", "supported": false},
    ...
  ],
  "s_extensions": [
    {"name": "Sstc", "description": "Supervisor Timer", "category": "sup", "supported": true},
    {"name": "Svinval", "description": "Fine-Grained Invalidation", "category": "vm", "supported": false},
    ...
  ],
  "vector": "Enabled, VLEN>=256",
  "hart_count": 8,
  "hardware_ids": {...},
  "cache": "L1D:32K L1I:32K L2:512K",
  "board": "SpacemiT K1",
  "memory_used_bytes": 3707764736,
  "memory_total_bytes": 8589934592,
  "kernel": "6.1.15-riscv64",
  "os": "Ubuntu 24.04 LTS",
  "uptime_seconds": 13320
}
```

With `--riscv-only` (`-a -r -j`), system fields (board, memory, kernel, os, uptime) are omitted.

---

## Output Format (--benchmark Mode)

```
RISC-V ISA Benchmarks
=====================

Integer (I):      1234.56 MIPS
Multiply (M):     567.89 MIPS
Atomic (A):       45.67 Mops/s
Float-SP (F):     234.56 MFLOPS
Float-DP (D):     123.45 MFLOPS
Vector (V):       Not available

Total score: 1234
```

- Only benchmark extensions that are present
- Show "Not available" for missing extensions

---

## Vendor Logos (--logo)

| Vendor | Description |
|--------|-------------|
| default | Generic RISC-V logo |
| sifive | SiFive (HiFive Unmatched, Unleashed) |
| starfive | StarFive (VisionFive 2) |
| thead | T-Head/Alibaba (XuanTie C906, C910) |
| milkv | Milk-V (Duo, Mars, Pioneer) |
| sipeed | Sipeed (Lichee, Maix series) |
| pine64 | Pine64 (Star64, Oz64) |
| kendryte | Kendryte/Canaan (K210, K510) |
| allwinner | Allwinner (D1) |
| espressif | Espressif (ESP32-C3, C6) |
| spacemit | SpacemiT (K1, Orange Pi RV2) |
| sophgo | Sophgo (CV1800B, SG2000) |
| wch | WCH (CH32V003, CH32V103) |

## Logo Styles (--style)

| Style | Description |
|-------|-------------|
| normal | Full ASCII art logo (default) |
| small | Compact one-line logo |
| none | No logo, data only |

---

## Help Output (--help)

Must include:
- Program description: "RISC-V architecture information display tool"
- All options with short and long forms
- Brief description of each option

```
RISC-V architecture information display tool

Usage: riscfetch [OPTIONS]

Options:
  -l, --logo <VENDOR>   Vendor logo (default, sifive, starfive, thead, milkv, sipeed, pine64, kendryte, allwinner, espressif, spacemit, sophgo, wch)
      --style <STYLE>   Logo style (normal, small, none)
  -b, --benchmark       Run simple benchmarks
  -e, --explain         Show detailed explanation of each ISA extension
  -j, --json            Output in JSON format (machine-readable)
  -a, --all             Show all extensions with checkmarks for supported ones
  -h, --help            Print help
  -V, --version         Print version
```

---

## Version Output (--version)

```
riscfetch <version>
```

Example: `riscfetch 0.2.0`

---

## Test Requirements

### Tests That Work on Any System

1. `--help` output contains expected strings
2. `--version` output contains program name
3. On non-RISC-V: exits with code 1
4. On non-RISC-V: shows appropriate error message
5. On non-RISC-V with `--json`: outputs valid JSON error

### Tests That Require RISC-V Hardware

1. Normal output format matches specification
2. `--json` outputs valid JSON with all required fields
3. `--explain` shows extension descriptions
4. Exit code is 0
5. All displayed values are accurate (match /proc/cpuinfo, etc.)

---

## Data Sources

| Field | Source |
|-------|--------|
| ISA | `/proc/cpuinfo` (isa line) |
| Hardware IDs | `/proc/cpuinfo` (mvendorid, marchid, mimpid) |
| Hart count | `/proc/cpuinfo` (count of processor entries) |
| Board | `/proc/device-tree/model` or `/sys/firmware/devicetree/base/model` |
| Cache | `/sys/devices/system/cpu/cpu0/cache/` |
| OS | `/etc/os-release` |
| Kernel | `uname -r` |
| Memory | sysinfo crate |
| Uptime | sysinfo crate |

---

## Version

- Spec version: 2.1
- Last updated: 2025-12
- Based on RISC-V ISA spec version: 2025-11-26
- Supports 98 Z-extensions and 46 S-extensions (144 total)