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
//! `kiln schema` — prints a JSON Schema for `Kiln.toml` to stdout.
//!
//! Wire this into your editor via `taplo` or VS Code's Even Better TOML
//! extension for completion and inline validation.
use anyhow::Result;
use serde_json::{json, Value};
pub fn run() -> Result<()> {
let schema = build_schema();
println!("{}", serde_json::to_string_pretty(&schema)?);
Ok(())
}
fn build_schema() -> Value {
let severity = json!({
"type": "string",
"enum": ["error", "warn", "off", "deny"]
});
let trace_format = json!({
"oneOf": [
{ "type": "boolean", "enum": [false] },
{ "type": "string", "enum": ["vcd", "fst"] }
],
"description": "Trace output format: false (off), \"vcd\", or \"fst\""
});
json!({
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Kiln.toml",
"description": "Manifest for a kiln SystemVerilog project",
"type": "object",
"required": ["package", "design"],
"additionalProperties": false,
"properties": {
"package": {
"type": "object",
"required": ["name", "version"],
"additionalProperties": false,
"properties": {
"name": { "type": "string", "description": "Package name (valid SV identifier)" },
"version": { "type": "string", "description": "Semver version string" },
"authors": { "type": "array", "items": { "type": "string" } },
"description": { "type": "string" },
"license": { "type": "string" }
}
},
"design": {
"type": "object",
"required": ["top"],
"additionalProperties": false,
"properties": {
"top": { "type": "string", "description": "Top module name" },
"sources": {
"type": "array",
"items": { "type": "string" },
"default": ["src/**/*.sv", "src/**/*.svh", "src/**/*.v"]
},
"timescale": { "type": "string", "description": "e.g. \"1ns/1ps\"" },
"language": {
"type": "string",
"enum": ["sv2005", "sv2009", "sv2012", "sv2017", "sv2023"]
},
"include_dirs": { "type": "array", "items": { "type": "string" } },
"defines": {
"type": "object",
"additionalProperties": { "type": "string" }
},
"libraries": { "type": "array", "items": { "type": "string" } },
"test_sources": { "type": "array", "items": { "type": "string" } }
}
},
"dependencies": {
"type": "object",
"additionalProperties": true,
"description": "Bender-compatible dependency entries"
},
"lint": {
"type": "object",
"description": "Lint severity overrides",
"properties": {
"slang": {
"type": "object",
"description": "Slang-specific lint rules",
"additionalProperties": severity.clone()
},
"verilator": {
"type": "object",
"description": "Verilator-specific lint rules (WIDTHTRUNC-style names)",
"additionalProperties": severity.clone()
}
},
"additionalProperties": severity.clone()
},
"tool": {
"type": "object",
"additionalProperties": false,
"properties": {
"slang": {
"type": "object",
"additionalProperties": false,
"properties": {
"path": { "type": "string" },
"extra_args": { "type": "array", "items": { "type": "string" } }
}
},
"verilator": {
"type": "object",
"additionalProperties": false,
"properties": {
"path": { "type": "string" },
"threads": { "type": "integer", "minimum": 1 },
"trace": trace_format.clone(),
"coverage": { "type": "boolean" },
"extra_args": { "type": "array", "items": { "type": "string" } }
}
},
"verible": {
"type": "object",
"additionalProperties": false,
"properties": {
"path": { "type": "string" },
"extra_args": { "type": "array", "items": { "type": "string" } }
}
}
}
},
"profile": {
"type": "object",
"description": "Named build profiles (dev, release, test, or custom)",
"additionalProperties": {
"type": "object",
"additionalProperties": false,
"properties": {
"lint": {
"type": "object",
"additionalProperties": severity.clone()
},
"tool": {
"type": "object",
"additionalProperties": false,
"properties": {
"slang": {
"type": "object",
"additionalProperties": false,
"properties": {
"path": { "type": "string" },
"extra_args": { "type": "array", "items": { "type": "string" } }
}
},
"verilator": {
"type": "object",
"additionalProperties": false,
"properties": {
"path": { "type": "string" },
"threads": { "type": "integer", "minimum": 1 },
"trace": trace_format,
"coverage": { "type": "boolean" },
"extra_args": { "type": "array", "items": { "type": "string" } }
}
},
"verible": {
"type": "object",
"additionalProperties": false,
"properties": {
"path": { "type": "string" },
"extra_args": { "type": "array", "items": { "type": "string" } }
}
}
}
}
}
}
},
"wave": {
"type": "object",
"additionalProperties": false,
"properties": {
"format": { "type": "string", "enum": ["fst", "vcd"] },
"enabled_by_default": { "type": "boolean" }
}
}
}
})
}