WaveJSON is the input format of the WaveDrom rendering engine.
It is JSON (WaveDrom itself also accepts JSON5 / JavaScript object literals)
with reserved keywords and structural rules described below.
The rules are derived from the WaveDrom 3.7 source code
(wavedrom, bit-field 1.9, logidrom 1.0, tspan 0.4) and enforced by waveschema.json.
The root is an object. The diagram kind is chosen by the first present key, in this order:
| key | diagram |
|---|---|
signal |
digital timing diagram |
assign |
logic circuit (schematic) |
reg |
bit-field (register) diagram |
Other root keys are ignored, so "$schema" can be added for editor support.
See WaveDrom Tutorial for examples.
Most labels (name, data, head.text, foot.text, group labels, register fields) accept:
- plain string, with inline markup:
<b><i><o>(overline)<ins>(underline)<s>(strike)<sub><sup><tt>(monospace), e.g."CS<sub>n</sub>","<o>RST</o>" - number
- JsonML SVG markup:
["tspan", {attributes}, ...children], e.g.["tspan", {"class": "h3"}, "Title"]. Theme classes:h1..h6,muted,info,success,warning,error.
{
signal: [ lane | group, ... ],
edge: [ "a->b label", ... ],
gaps: ". . 2 . .",
head: {text, tick, tock, every},
foot: {text, tick, tock, every},
config: {hscale, skin, hbounds, marks, arcFontSize}
}Array of wave lanes (objects) and groups (arrays).
- empty object
{}- blank row (gap) between lanes - lane without
name- invisible row, still usable to holdnodeanchors - group
["label", lane, lane, ["sub group", lane], ...]- drawn with a bracket on the left; the first element (string or number) is the label, other non-object elements are ignored. Groups nest.
Label text left of the wave.
String, one character per period:
| char | meaning |
|---|---|
p n |
clock, positive / negative edge first |
P N |
same with arrow on the edge |
h l |
high / low with sharp edge |
H L |
same with arrow |
0 1 |
low / high level (soft edges) |
x |
undefined |
z |
high impedance |
u d |
pull-up (weak 1) / pull-down (weak 0) |
= 2..9 |
data value; = is color 2. Labels from data |
. |
extend previous state |
| |
extend previous state, draw gap (break) mark |
< > |
start / end of sub-cycle group: characters inside take one brick (half a cycle) each |
Any other character is rendered as x - the schema rejects it.
Alternative: piece-wise analog wave ["pw", {"d": path}] where path is an SVG path
(string "m0,0 l1,1" or array ["m", 0, 0, "l", 1, 1]) with relative commands m l h v q t a;
x unit = 1 cycle, y unit = lane height, y grows up.
Labels for the data cycles (=, 2..9) in order: array of text items, or a space-separated string "A B C".
Labels of cycles hidden by phase / hbounds are skipped.
period- positive number (default 1): width of one wave character in cycles, e.g.2for half-rate,0.5for double-rate.phase- number of cycles (default 0); positive shifts the wave left (earlier), negative right (delay). Wave is shifted in half-cycle steps; nodes and over / under lines use the exact value.
One character per period, anchors for edge arrows:
.- no node- uppercase letter - invisible node
- any other character - node with a visible label
Colored line above (with serif marks) / below the lane, one character per period:
1..8 start a line of that color (black, red, green, blue, magenta, olive, teal, violet),
0 ends it, . extends previous state.
Array of arrow strings "<from><shape><to> label". from / to are node characters,
label is everything after the first space. Edges referring to undefined nodes are ignored.
| shape | line | with arrowhead | double-headed |
|---|---|---|---|
| straight | - |
-> |
<-> |
| curve | ~ |
~> |
<~> |
| curve, horizontal start | -~ |
-~> |
<-~> |
| curve, horizontal end | ~- |
~-> |
|
| corner, horizontal first | -| |
-|> |
<-|> |
| corner, vertical first | |- |
|-> |
|
| step | -|- |
-|-> |
<-|-> |
| tee ends (time span) | + |
Any other shape is drawn as a red straight line - the schema rejects it.
Space-separated tokens, one per cycle, drawn across all lanes at mid-cycle:
. none, 0 blank, 1 / | single line, 2 double, 3 triple,
[ ] square bracket, ( ) round bracket, )( (( )) double round brackets,
s wave gap symbol on every lane.
text- title / captiontick- labels at cycle boundaries;tock- labels at mid-cycle. NumberNproducesN, N+1, .... A string of space-separated labels is also accepted, but WaveDrom 3.x appends thehboundsoffset to it ("A B C"renders asA B C0); prefer numbers. Arrays are not supported.every- show only labels whose value is divisible by N (numerictick/tockonly)
| key | type | default | |
|---|---|---|---|
hscale |
number 1..100 | 1 | cycle width multiplier, rounded |
skin |
string | default |
default narrow narrower narrowerer lowkey dark; must be loaded, unknown falls back to default |
hbounds |
[start, end] | visible cycle window, ignored unless start < end | |
marks |
boolean | true | vertical dotted cycle marks |
arcFontSize |
number | 11 | font size of edge and node labels |
{
reg: [ {bits, name, attr, type, rotate, rect}, ... ], // from LSB
config: {...}
}Field:
bits- required, integer >= 1name- text; a number is drawn as binary value across the field bitsattr- text, number (binary), or array of rows (nullrows skipped)type- color: 2 red, 3 lime, 4 cyan, 5 amber, 6 green, 7 blue, other - gray. A field with neithernamenortypeis drawn as reservedrotate- name rotation in degreesrect- extra SVG attributes of the field background
config:
| key | default | |
|---|---|---|
hspace |
800 | width px, integer >= 40 |
vspace |
(attr rows + 4) * fontsize | lane height px |
lanes |
1 | number of rows |
bits |
sum of field bits | |
fontsize |
14 | integer >= 6 |
fontfamily / fontweight |
sans-serif / normal |
|
compact |
false | lanes without gaps, bit numbers on top |
hflip / vflip |
false | LSB lane on top / bit 0 on the left |
sparse / uneven |
false | ticks only at field boundaries / shorter last lane for odd widths |
trim |
trim long names, value = estimated char width px | |
offset |
0 | added to bit index labels |
legend |
{"label": type, ...} color legend |
|
margin |
{top, right, bottom, left} |
|
label |
{left, right}: string (all lanes), number (lane index + N), or array per lane |
{
assign: [ ["out", expression], ... ],
config: {fontWidth: 7.23, treeSpacing: 16}
}Expression is a wire name (string) or ["op", {attributes}?, ...operands]:
- shape gates:
&|^~&~|~^~buf1+-*/%; aliasesandorxorandrorrxorraddsubmulinput - IEC boxes:
BUFINVANDNANDORNORXORXNOReqnesltslesgtsgeultuleugtugeboxCONCATcasecasezcasex MUX; flip-flopsff[n][e][c|p[n]][r|s[n]](ff,ffe,ffr,ffnecrn, ...); bit slice"[7:0]"["=", "net", expr]- labeled intermediate netpin/pout/pinoutwith{"instance", "pin"}- module ports- any other string - labeled box
Attributes: width (bus width), label, dir (in / out), instance, pin, imm, module, name, loc, nodeId, siteKey.