{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://wavedrom.com/schema/wavedrom.json",
  "$comment": "Generated by wavedrom-schema v0.5.0 https://github.com/wavedrom/schema",
  "title": "WaveDrom",
  "description": "WaveJSON: WaveDrom timing diagram, bit-field (register), or logic circuit description\nhttps://wavedrom.com",
  "definitions": {
    "assign": {
      "type": "object",
      "title": "logic circuit",
      "description": "WaveDrom logic circuit (schematic) diagram\nhttps://wavedrom.com/tutorial2.html",
      "required": [
        "assign"
      ],
      "properties": {
        "assign": {
          "type": "array",
          "description": "List of assignments, one cone per item: [\"out\", expression], e.g. [\"z\", [\"&\", \"a\", [\"~\", \"b\"]]]",
          "items": {
            "description": "Assignment cone [\"out\", expression]",
            "allOf": [
              {
                "type": "array",
                "minItems": 2
              },
              {
                "$ref": "#/definitions/assignTree"
              }
            ],
            "examples": [
              [
                "z",
                [
                  "&",
                  "a",
                  [
                    "~",
                    "b"
                  ]
                ]
              ]
            ]
          }
        },
        "config": {
          "type": "object",
          "description": "Rendering options",
          "properties": {
            "fontWidth": {
              "type": "number",
              "exclusiveMinimum": 0,
              "default": 7.23,
              "description": "Average character width (px) used for label box sizing"
            },
            "treeSpacing": {
              "type": "number",
              "minimum": 0,
              "default": 16,
              "description": "Vertical space (px) between assignment trees"
            }
          }
        }
      }
    },
    "assignTree": {
      "title": "logic expression",
      "description": "Logic expression tree: wire name (string) or [\"op\", {attributes}?, ...operands].\nShape gates: & | ^ (AND OR XOR), ~& ~| ~^ (NAND NOR XNOR), ~ (NOT), buf1, + - * / %, aliases and or xor andr orr xorr add sub mul input;\nIEC boxes: BUF INV AND NAND OR NOR XOR XNOR eq ne slt sle sgt sge ult ule ugt uge box CONCAT case casez casex;\nMUX; flip-flops ff[n][e][c|p[n]][r|s[n]] (e.g. ff, ffe, ffr, ffnecrn); bit slice \"[7:0]\";\n\"=\" with name + expression [\"=\", \"net\", expr] labels an intermediate net;\npin / pout / pinout with {\"instance\", \"pin\"} attributes draw module ports;\nany other string is drawn as a labeled box.",
      "oneOf": [
        {
          "type": "string",
          "description": "Wire / input name"
        },
        {
          "type": "array",
          "minItems": 1,
          "items": {
            "description": "First item: operator (gate type) or output / leaf name; second item: optional attributes object; then operands",
            "examples": [
              "&",
              "|",
              "^",
              "~",
              "~&",
              "~|",
              "~^",
              "+",
              "-",
              "*",
              "=",
              "MUX",
              "ff",
              "ffe",
              "ffr",
              "CONCAT",
              "eq",
              "[7:0]",
              "pin",
              "pout"
            ],
            "anyOf": [
              {
                "$ref": "#/definitions/assignTree"
              },
              {
                "type": "object",
                "description": "Node attributes (only as the second element)",
                "properties": {
                  "width": {
                    "type": "integer",
                    "minimum": 0,
                    "description": "Bus width (0 - zero-width, 1 - scalar wire, >1 - vector bus)"
                  },
                  "label": {
                    "type": "string",
                    "description": "Output label / tooltip"
                  },
                  "dir": {
                    "enum": [
                      "in",
                      "out"
                    ],
                    "description": "Port direction, draws chevron-shaped port box"
                  },
                  "instance": {
                    "type": "string",
                    "description": "Instance name (pin / pout / pinout)"
                  },
                  "pin": {
                    "type": "string",
                    "description": "Pin name (pin / pout / pinout)"
                  },
                  "imm": {
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "description": "Folded immediate literal appended to the operator label, e.g. \"8'h55\""
                  },
                  "module": {
                    "type": "string",
                    "description": "Source module (tooltip / cross-reference)"
                  },
                  "name": {
                    "type": "string",
                    "description": "Source name (tooltip / cross-reference)"
                  },
                  "loc": {
                    "type": "string",
                    "description": "Source location (tooltip / cross-reference)"
                  },
                  "nodeId": {
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "description": "Node id (cross-reference)"
                  },
                  "siteKey": {
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "number"
                      }
                    ],
                    "description": "Site key (cross-reference)"
                  }
                }
              }
            ]
          }
        }
      ]
    },
    "reg": {
      "type": "object",
      "title": "register",
      "description": "WaveDrom bit-field (register) diagram\nhttps://github.com/wavedrom/bitfield",
      "required": [
        "reg"
      ],
      "properties": {
        "reg": {
          "type": "array",
          "description": "List of bit fields, starting from LSB (bit 0). Sum of \"bits\" defines the register width unless config.bits is set.",
          "items": {
            "type": "object",
            "required": [
              "bits"
            ],
            "properties": {
              "bits": {
                "type": "integer",
                "minimum": 1,
                "description": "Field width in bits"
              },
              "name": {
                "description": "Field name. String / JsonML is rendered centered; a number is rendered as binary value across the field bits (e.g. opcode 0x37). Field without name and type is drawn as reserved (shaded).",
                "$ref": "#/definitions/textSpan"
              },
              "attr": {
                "description": "Field attribute(s), rendered below the field, one row per array item. Number is rendered as binary. null items are skipped.",
                "oneOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "number"
                  },
                  {
                    "type": "array",
                    "items": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "number"
                        },
                        {
                          "type": "null"
                        },
                        {
                          "$ref": "#/definitions/jsonml"
                        }
                      ]
                    }
                  }
                ]
              },
              "type": {
                "type": "integer",
                "minimum": 0,
                "description": "Field color type: 2 red, 3 lime, 4 cyan, 5 amber, 6 green, 7 blue; other values - gray shade. Used as key for config.legend."
              },
              "rotate": {
                "type": "number",
                "description": "Rotation angle of the field name (degrees), e.g. -90 for narrow fields"
              },
              "rect": {
                "type": "object",
                "description": "Extra SVG attributes for the field background <rect>, e.g. {\"style\": \"fill:#ff0;fill-opacity:0.3\"}"
              }
            }
          }
        },
        "config": {
          "type": "object",
          "description": "Rendering options",
          "properties": {
            "hspace": {
              "type": "integer",
              "minimum": 40,
              "description": "Diagram width (px)",
              "default": 800
            },
            "vspace": {
              "type": "number",
              "exclusiveMinimum": 0,
              "description": "Lane height (px). Default: (max number of attr rows + 4) * fontsize"
            },
            "lanes": {
              "type": "integer",
              "minimum": 1,
              "description": "Number of lanes (rows) the register is split into",
              "default": 1
            },
            "bits": {
              "type": "integer",
              "minimum": 1,
              "description": "Overall bit width (default: sum of field bits)"
            },
            "fontsize": {
              "type": "integer",
              "minimum": 6,
              "description": "Font size (px)",
              "default": 14
            },
            "fontfamily": {
              "type": "string",
              "description": "Font family",
              "default": "sans-serif"
            },
            "fontweight": {
              "type": "string",
              "description": "Font weight",
              "default": "normal"
            },
            "compact": {
              "type": "boolean",
              "description": "Compact format: lanes stacked without gaps, bit numbers shown once on top",
              "default": false
            },
            "hflip": {
              "type": "boolean",
              "description": "Horizontal flip: LSB lane on top",
              "default": false
            },
            "vflip": {
              "type": "boolean",
              "description": "Vertical flip: bit 0 on the left",
              "default": false
            },
            "sparse": {
              "type": "boolean",
              "description": "Sparse cage: draw tick marks only at field boundaries",
              "default": false
            },
            "uneven": {
              "type": "boolean",
              "description": "Uneven lanes: with odd bit width the last lane is one bit shorter (used with sparse)",
              "default": false
            },
            "trim": {
              "type": "number",
              "exclusiveMinimum": 0,
              "description": "Trim long field names to fit the field (\"...\"); value is the estimated character width (px), e.g. 8"
            },
            "offset": {
              "type": "integer",
              "description": "Offset added to the bit index labels",
              "default": 0
            },
            "legend": {
              "type": "object",
              "description": "Color legend above the diagram: {\"label\": type}, e.g. {\"Control\": 2, \"Status\": 4}",
              "additionalProperties": {
                "type": "integer",
                "minimum": 0
              }
            },
            "margin": {
              "type": "object",
              "description": "Margins around the diagram (px). Defaults depend on fontsize, attr rows and labels.",
              "properties": {
                "top": {
                  "type": "number",
                  "description": "Top margin"
                },
                "right": {
                  "type": "number",
                  "description": "Right margin"
                },
                "bottom": {
                  "type": "number",
                  "description": "Bottom margin"
                },
                "left": {
                  "type": "number",
                  "description": "Left margin"
                }
              }
            },
            "label": {
              "type": "object",
              "description": "Lane labels on the left / right side (margins grow to 10% of hspace)",
              "properties": {
                "left": {
                  "description": "Lane labels on the left side: string - same label on every lane; number N - lane index + N; array - label per lane (index 0 = LSB lane)",
                  "oneOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "array",
                      "items": {
                        "description": "Text (string / JsonML). A number is rendered as its binary value, one bit per bit cell.",
                        "$ref": "#/definitions/textSpan"
                      }
                    }
                  ]
                },
                "right": {
                  "description": "Lane labels on the right side: string - same label on every lane; number N - lane index + N; array - label per lane (index 0 = LSB lane)",
                  "oneOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "number"
                    },
                    {
                      "type": "array",
                      "items": {
                        "description": "Text (string / JsonML). A number is rendered as its binary value, one bit per bit cell.",
                        "$ref": "#/definitions/textSpan"
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "textSpan": {
      "description": "Text: plain string with optional inline markup <b> <i> <o> (overline) <ins> (underline) <s> (strike) <sub> <sup> <tt> (monospace), e.g. \"CS<sub>n</sub>\", \"<o>RST</o>\"; or a number; or JsonML (SVG tspan) markup, e.g. [\"tspan\", {\"class\": \"h1\"}, \"Title\"]",
      "oneOf": [
        {
          "type": "string"
        },
        {
          "type": "number"
        },
        {
          "$ref": "#/definitions/jsonml"
        }
      ]
    },
    "jsonml": {
      "type": "array",
      "title": "JsonML",
      "description": "JsonML (SVG) markup: [\"tag\", {attributes}, ...children], e.g. [\"tspan\", {\"class\": \"h1\"}, \"Title\"]. Usual tag is \"tspan\"; children are strings, numbers or nested JsonML nodes.",
      "minItems": 1,
      "items": {
        "description": "First item: SVG tag name (usually \"tspan\"); then optional attributes object; then children",
        "anyOf": [
          {
            "type": "string",
            "description": "Tag name (first item) or text"
          },
          {
            "type": "number"
          },
          {
            "type": "object",
            "description": "SVG attributes, e.g. {\"class\": \"h3\"}, {\"fill\": \"red\"}, {\"font-weight\": \"bold\"}, {\"dy\": \"-5\"}. Theme classes: h1..h6, muted, info, success, warning, error",
            "additionalProperties": {
              "oneOf": [
                {
                  "type": "string"
                },
                {
                  "type": "number"
                }
              ]
            }
          },
          {
            "$ref": "#/definitions/jsonml"
          }
        ]
      }
    },
    "textNode": {
      "type": "object",
      "description": "Header / footer of the timing diagram",
      "properties": {
        "text": {
          "$ref": "#/definitions/textSpan",
          "description": "Title text (plain string, inline <b>/<i>/<sub>... markup, or JsonML tspan markup), rendered centered"
        },
        "tick": {
          "description": "Tick labels aligned to the cycle boundaries (clock edges). Number N: sequential cycle labels N, N+1, N+2, ... (shifted by config.hbounds[0]). String: space-separated explicit labels, e.g. \"A B C\" (note: WaveDrom 3.x appends the hbounds offset to the string, so the last label becomes \"C0\"; prefer a number).",
          "oneOf": [
            {
              "type": "number"
            },
            {
              "type": "string"
            }
          ]
        },
        "tock": {
          "description": "Tock labels placed in the middle of each cycle. Number N: sequential cycle labels N, N+1, N+2, ... (shifted by config.hbounds[0]). String: space-separated explicit labels, e.g. \"A B C\" (note: WaveDrom 3.x appends the hbounds offset to the string, so the last label becomes \"C0\"; prefer a number).",
          "oneOf": [
            {
              "type": "number"
            },
            {
              "type": "string"
            }
          ]
        },
        "every": {
          "type": "integer",
          "minimum": 1,
          "description": "Show only every N-th tick / tock label (labels whose value is divisible by N). Works only with numeric tick / tock."
        }
      }
    },
    "waveLane": {
      "type": "object",
      "title": "wave lane",
      "description": "Signal descriptor. Empty object {} creates a gap between lanes. Lane without \"name\" (e.g. only \"node\") is not drawn but still occupies a row and may carry edge nodes.",
      "properties": {
        "name": {
          "description": "Signal label, rendered left of the wave. Plain string (inline <b>/<i>/<sub>/<o>... markup supported) or JsonML tspan markup.",
          "oneOf": [
            {
              "type": "string"
            },
            {
              "$ref": "#/definitions/jsonml"
            }
          ]
        },
        "wave": {
          "description": "Signal activity, one character per cycle (or piece-wise analog [\"pw\", {d}] array)",
          "oneOf": [
            {
              "type": "string",
              "description": "One character per cycle (period):\np n - clock with positive / negative edge first; P N - same with arrow;\nh l - high / low with sharp edge; H L - same with arrow;\n0 1 - low / high level; x - undefined; z - high impedance; u - pull-up (weak 1); d - pull-down (weak 0);\n= 2 3 4 5 6 7 8 9 - data value with color (= is color 2), labels taken from \"data\";\n. - extend previous state; | - extend and draw a gap (break) mark;\n< > - start / end sub-cycle group: each character inside takes one brick (half a cycle) instead of a full period.\nUnknown characters are rendered as \"x\".",
              "pattern": "^[pnPNhHlL01=2-9xzud.|<>]*$",
              "examples": [
                "p.....",
                "01.zx=ud.23.45",
                "x.==.=x",
                "x=<x|>=."
              ]
            },
            {
              "type": "array",
              "title": "piece-wise wave",
              "description": "Piece-wise analog wave: [\"pw\", {\"d\": SVG path}]. Path uses relative SVG commands (m l h v q t a) where x unit = 1 cycle, y unit = lane height (positive y goes up).",
              "minItems": 2,
              "maxItems": 2,
              "items": [
                {
                  "const": "pw",
                  "description": "Piece-wise wave marker"
                },
                {
                  "type": "object",
                  "required": [
                    "d"
                  ],
                  "properties": {
                    "d": {
                      "description": "SVG path data, e.g. \"m0,0 l1,1 h2 l1,-1\" or [\"m\", 0, 0, \"l\", 1, 1]",
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "array",
                          "items": {
                            "oneOf": [
                              {
                                "type": "string"
                              },
                              {
                                "type": "number"
                              }
                            ]
                          }
                        }
                      ]
                    }
                  }
                }
              ]
            }
          ]
        },
        "data": {
          "description": "Labels for data (value) cycles \"=\" and \"2\"-\"9\", in order of appearance: array of text items, or a single space-separated string \"A B C\". Items hidden by negative phase / hbounds are skipped.",
          "oneOf": [
            {
              "type": "array",
              "items": {
                "$ref": "#/definitions/textSpan"
              }
            },
            {
              "type": "string"
            }
          ]
        },
        "period": {
          "type": "number",
          "description": "Lane period: width of one wave character in cycles (default 1). E.g. 2 for half-rate clock, 0.5 for double rate.",
          "exclusiveMinimum": 0,
          "default": 1
        },
        "phase": {
          "type": "number",
          "description": "Phase shift in cycles (default 0). Positive value shifts the wave to the left (into the past, earlier); negative to the right (delay). Wave is shifted in half-cycle steps; nodes and over / under lines use exact value.",
          "default": 0
        },
        "node": {
          "type": "string",
          "description": "Named nodes (anchors for \"edge\" arrows), one character per cycle (at cycle start, scaled by period / phase): \".\" - no node; uppercase letters - invisible node; other characters (lowercase, digits ...) - node with visible label. Each character should be unique across the diagram.",
          "examples": [
            ".a..b..",
            "...A..B"
          ]
        },
        "over": {
          "type": "string",
          "description": "Colored line above the lane (with serif marks), one character per period: \"1\"-\"8\" start a line of that color (1 black, 2 red, 3 green, 4 blue, 5 magenta, 6 olive, 7 teal, 8 violet); \"0\" ends the line; \".\" extends previous state",
          "pattern": "^[.0-9]*$",
          "examples": [
            "0.1..0",
            ".2.3."
          ]
        },
        "under": {
          "type": "string",
          "description": "Colored line below the lane, one character per period: \"1\"-\"8\" start a line of that color; \"0\" ends the line; \".\" extends previous state",
          "pattern": "^[.0-9]*$",
          "examples": [
            "0.1..0"
          ]
        }
      }
    },
    "waveGroup": {
      "type": "array",
      "title": "wave group",
      "description": "Group of wave lanes drawn with a bracket on the left. Optional first element (string or number) is the group label. Groups can be nested.",
      "items": {
        "oneOf": [
          {
            "type": "string",
            "description": "Group label (only the first element is used as label, other strings are ignored)"
          },
          {
            "type": "number",
            "description": "Group label (only the first element is used as label, other numbers are ignored)"
          },
          {
            "$ref": "#/definitions/waveLane"
          },
          {
            "$ref": "#/definitions/waveGroup"
          }
        ]
      }
    },
    "signal": {
      "type": "object",
      "title": "timing diagram",
      "description": "WaveDrom digital timing diagram\nhttps://wavedrom.com/tutorial.html",
      "required": [
        "signal"
      ],
      "properties": {
        "signal": {
          "type": "array",
          "description": "List of wave lanes {name, wave, data, ...} and wave groups [\"label\", lane, ...]",
          "items": {
            "oneOf": [
              {
                "$ref": "#/definitions/waveLane"
              },
              {
                "$ref": "#/definitions/waveGroup"
              }
            ]
          }
        },
        "head": {
          "$ref": "#/definitions/textNode",
          "description": "Diagram header: title text and / or tick / tock cycle labels"
        },
        "foot": {
          "$ref": "#/definitions/textNode",
          "description": "Diagram footer: caption text and / or tick / tock cycle labels"
        },
        "edge": {
          "type": "array",
          "description": "Arrows between nodes defined in lane \"node\" strings",
          "items": {
            "type": "string",
            "description": "Arrow: \"<from><shape><to> [label]\", e.g. \"a~>b\", \"c-|->d 5 ns\".\nfrom / to: node characters; label: rest of the string after the first space.\nShapes: - straight, ~ curve, -~ / ~- curve with horizontal start / end, -| / |- corner, -|- step;\nappend > for arrowhead (->, ~>, -~>, ~->, -|>, |->, -|->), prefix < for double-headed (<->, <~>, <-~>, <-|>, <-|->);\n+ straight line with tee ends (for time spans).\nUnknown shape is drawn as a red straight line; edges with undefined nodes are ignored.",
            "pattern": "^\\s*\\S(<-\\|->|-\\|->|<-~>|<-\\|>|-\\|-|-~>|~->|-\\|>|\\|->|<->|<~>|-~|~-|-\\||\\|-|->|~>|-|~|\\+)\\S(\\s.*)?$",
            "examples": [
              "a~>b",
              "a->b label",
              "c-|->d t1",
              "e<->f 3 ms",
              "g+h 5 ns"
            ]
          }
        },
        "gaps": {
          "type": "string",
          "description": "Vertical gap / time-break marks across all lanes, space-separated, one token per cycle (drawn at the middle of the cycle):\n. - none; 0 - blank; 1 or | - single line; 2 - double line; 3 - triple line;\n[ ] - square bracket; ( ) - round bracket; )( (( )) - double round brackets;\ns - wave gap (break) symbol on every lane.",
          "pattern": "^\\s*((\\)\\(|\\(\\(|\\)\\)|\\.|0|1|\\||2|3|\\[|\\]|\\(|\\)|s)(\\s+|$))*$",
          "examples": [
            ". . 2 . . s",
            ". ( . ) ."
          ]
        },
        "config": {
          "type": "object",
          "description": "Rendering options",
          "properties": {
            "hscale": {
              "type": "number",
              "minimum": 1,
              "maximum": 100,
              "default": 1,
              "description": "Horizontal scale: width multiplier of a cycle (rounded to integer, 1..100)"
            },
            "skin": {
              "description": "Skin name. Must be loaded on the page (skins/*.js); unknown skin falls back to \"default\". Skin applies to the whole page (first diagram).",
              "default": "default",
              "anyOf": [
                {
                  "enum": [
                    "default",
                    "narrow",
                    "narrower",
                    "narrowerer",
                    "lowkey",
                    "dark"
                  ]
                },
                {
                  "type": "string"
                }
              ]
            },
            "hbounds": {
              "type": "array",
              "description": "Visible horizontal window [start, end] in cycles (start rounded down, end rounded up; ignored unless start < end). Shifts tick / tock labels and hides data labels before start.",
              "items": {
                "type": "number"
              },
              "minItems": 2,
              "maxItems": 2
            },
            "marks": {
              "type": "boolean",
              "description": "Draw vertical dotted cycle marks",
              "default": true
            },
            "arcFontSize": {
              "type": "number",
              "exclusiveMinimum": 0,
              "default": 11,
              "description": "Font size (px) of edge (arc) labels and node labels"
            }
          }
        }
      }
    }
  },
  "type": "object",
  "properties": {
    "signal": {
      "description": "Timing diagram: list of wave lanes and groups"
    },
    "assign": {
      "description": "Logic circuit: list of assignments"
    },
    "reg": {
      "description": "Bit-field (register) diagram: list of fields"
    }
  },
  "if": {
    "properties": {
      "signal": true
    },
    "required": [
      "signal"
    ]
  },
  "then": {
    "$ref": "#/definitions/signal"
  },
  "else": {
    "if": {
      "properties": {
        "assign": true
      },
      "required": [
        "assign"
      ]
    },
    "then": {
      "$ref": "#/definitions/assign"
    },
    "else": {
      "if": {
        "properties": {
          "reg": true
        },
        "required": [
          "reg"
        ]
      },
      "then": {
        "$ref": "#/definitions/reg"
      },
      "else": {
        "description": "Root object must have \"signal\", \"assign\" or \"reg\" property",
        "anyOf": [
          {
            "properties": {
              "signal": true
            },
            "required": [
              "signal"
            ]
          },
          {
            "properties": {
              "assign": true
            },
            "required": [
              "assign"
            ]
          },
          {
            "properties": {
              "reg": true
            },
            "required": [
              "reg"
            ]
          }
        ]
      }
    }
  }
}
