{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://openspacehdl.org/composer/schema/system-1.json",
  "title": "Open Space Composer system, format version 1",
  "description": "One FPGA system built from Open Space HDL cores and Open Logic blocks: what the user designed (system, instances, connections, externals, layout) and, optionally, what the Composer derived from it (resolved, checks, agent). The format reference is https://openspacehdl.org/composer/format/.",
  "type": "object",
  "required": [
    "format",
    "formatVersion",
    "system",
    "instances",
    "connections"
  ],
  "additionalProperties": false,
  "properties": {
    "$schema": {
      "type": "string"
    },
    "format": {
      "const": "open-space-composer-system"
    },
    "formatVersion": {
      "const": 1
    },
    "generator": {
      "type": "object",
      "description": "Tool that wrote the file and the identifier of the block catalog it used.",
      "required": [
        "name",
        "version"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "version": {
          "type": "string"
        },
        "catalog": {
          "type": "string"
        }
      }
    },
    "system": {
      "type": "object",
      "required": [
        "name"
      ],
      "additionalProperties": false,
      "properties": {
        "name": {
          "$ref": "#/$defs/identifier",
          "description": "Name of the top-level entity."
        },
        "description": {
          "type": "string"
        },
        "faultTolerance": {
          "type": "boolean",
          "description": "Adapters the Composer inserts use the fault-tolerant Open Logic entities and triplicated synchronisers."
        },
        "eccMonitor": {
          "$ref": "#/$defs/identifier",
          "description": "Since 0.8.0-beta: the instance of an ECC monitor (a block with ECC event inputs) that reports the ECC events of the crossings the Composer inserts: each takes a free channel, in the order of its connection."
        }
      }
    },
    "sources": {
      "type": "array",
      "description": "Repositories of the blocks used, pinned to the commit the catalog was checked against.",
      "items": {
        "type": "object",
        "required": [
          "id",
          "url",
          "commit",
          "library",
          "fileList"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri"
          },
          "tag": {
            "type": "string"
          },
          "commit": {
            "type": "string",
            "pattern": "^[0-9a-f]{40}$"
          },
          "library": {
            "$ref": "#/$defs/vhdlName",
            "description": "VHDL library the sources are compiled into."
          },
          "fileList": {
            "type": "string",
            "description": "File of the repository with the sources in compile order."
          },
          "fileListFormat": {
            "enum": [
              "modules",
              "files"
            ],
            "description": "modules: one module directory per line, relative to the repository root (blank lines and lines starting with # are ignored), its sources in <module>/src/*.vhd without a given order inside the module (packages first, then in dependency order, or let the tool order them); files: one VHDL file per line, in compile order."
          },
          "verifiedWith": {
            "type": "string",
            "description": "Open Logic FT tag the repository is verified with (its open-logic submodule); the system compiles one olo library, see the note of the olo source."
          }
        }
      }
    },
    "clockDomains": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "name",
          "frequencyHz",
          "source"
        ],
        "additionalProperties": false,
        "properties": {
          "id": {
            "$ref": "#/$defs/identifier"
          },
          "name": {
            "type": "string"
          },
          "frequencyHz": {
            "type": "number",
            "exclusiveMinimum": 0
          },
          "source": {
            "oneOf": [
              {
                "type": "object",
                "required": [
                  "kind"
                ],
                "additionalProperties": false,
                "properties": {
                  "kind": {
                    "const": "external"
                  }
                }
              },
              {
                "type": "object",
                "required": [
                  "kind",
                  "instance",
                  "port"
                ],
                "additionalProperties": false,
                "properties": {
                  "kind": {
                    "const": "block"
                  },
                  "instance": {
                    "$ref": "#/$defs/identifier"
                  },
                  "port": {
                    "$ref": "#/$defs/vhdlName"
                  }
                }
              }
            ]
          }
        }
      },
      "description": "Clock domains: external clocks (a top-level clock port Clk_<id>) or the clock output of a block. Every clock input of every instance is assigned to one domain; the Composer inserts clock crossings between domains and one reset generator per domain."
    },
    "instances": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "block"
        ],
        "additionalProperties": false,
        "properties": {
          "id": {
            "$ref": "#/$defs/identifier",
            "description": "Instance label in the top level."
          },
          "block": {
            "type": "string",
            "pattern": "^[a-z][a-z0-9-]*/[a-z][a-z0-9_]*$",
            "description": "Catalog block id <source>/<entity>."
          },
          "preset": {
            "type": "string"
          },
          "generics": {
            "type": "object",
            "description": "Generic values that differ from the catalog default and the preset. std_logic as \"0\" or \"1\", std_logic_vector and integer_vector as VHDL literals, string generics without quotes.",
            "propertyNames": {
              "$ref": "#/$defs/vhdlName"
            },
            "additionalProperties": {
              "type": [
                "boolean",
                "number",
                "string"
              ]
            }
          },
          "clocks": {
            "type": "object",
            "description": "Clock port of the block -> clock domain id.",
            "propertyNames": {
              "$ref": "#/$defs/vhdlName"
            },
            "additionalProperties": {
              "$ref": "#/$defs/identifier"
            }
          },
          "constants": {
            "type": "object",
            "description": "Constants of unconnected interfaces whose inputs are constants of the instance (for example the key slot of ocr_framer): interface -> field -> value.",
            "additionalProperties": {
              "type": "object",
              "additionalProperties": {
                "type": [
                  "integer",
                  "boolean"
                ]
              }
            }
          },
          "traffic": {
            "type": "object",
            "additionalProperties": false,
            "description": "Since 0.9.0-beta: values about the data that the rate data of the block cannot know, stated by the user and written only when set.",
            "properties": {
              "ratio": {
                "type": "number",
                "exclusiveMinimum": 0,
                "description": "Assumed compression ratio of a compressor (uncompressed bytes per compressed byte), used by the throughput budget and the packet sizes instead of the worst case; an assumption about the data, not a property of the block."
              }
            }
          }
        }
      }
    },
    "connections": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "id",
          "from",
          "to"
        ],
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[A-Za-z][A-Za-z0-9_]*$"
          },
          "from": {
            "$ref": "#/$defs/endpoint",
            "description": "Driving interface (source, master, event output)."
          },
          "to": {
            "$ref": "#/$defs/endpoint",
            "description": "Receiving interface (sink, slave, event input)."
          },
          "sideband": {
            "type": "object",
            "description": "Constants of a side band the receiving interface needs, for example the APID of an OpenSPP send port.",
            "additionalProperties": {
              "type": [
                "boolean",
                "integer"
              ]
            }
          },
          "adapters": {
            "type": "object",
            "description": "Generic values of the adapters the Composer inserts on the connection: cdc (clock crossing, for example Depth_g of an asynchronous FIFO) and wconv (width converter).",
            "additionalProperties": false,
            "properties": {
              "cdc": {
                "type": "object",
                "propertyNames": {
                  "pattern": "^[A-Za-z][A-Za-z0-9_]*_g$"
                },
                "additionalProperties": {
                  "type": [
                    "number",
                    "boolean"
                  ]
                }
              },
              "wconv": {
                "type": "object",
                "propertyNames": {
                  "pattern": "^[A-Za-z][A-Za-z0-9_]*_g$"
                },
                "additionalProperties": {
                  "type": [
                    "number",
                    "boolean"
                  ]
                }
              }
            }
          }
        }
      }
    },
    "externals": {
      "type": "array",
      "description": "Interfaces that become ports of the top level.",
      "items": {
        "type": "object",
        "required": [
          "interface",
          "prefix"
        ],
        "additionalProperties": false,
        "properties": {
          "interface": {
            "$ref": "#/$defs/endpoint"
          },
          "prefix": {
            "type": "string",
            "pattern": "^[A-Za-z](?:_?[A-Za-z0-9])*_?$"
          },
          "traffic": {
            "type": "object",
            "description": "Stated traffic of the interface (since 0.3.0-beta): the typical length of its packets, optionally the payload rate offered at an input or required at an output (throughput budget), and, since 0.4.0-beta, the largest packet (packet sizes along the chain).",
            "required": [
              "packetBytes"
            ],
            "additionalProperties": false,
            "properties": {
              "packetBytes": {
                "type": "integer",
                "minimum": 1
              },
              "bitsPerSecond": {
                "type": "number",
                "exclusiveMinimum": 0
              },
              "maxPacketBytes": {
                "type": "integer",
                "minimum": 1
              }
            }
          }
        }
      }
    },
    "layout": {
      "type": "object",
      "description": "Positions on the canvas; not relevant for the hardware.",
      "properties": {
        "instances": {
          "type": "object",
          "additionalProperties": {
            "type": "object",
            "required": [
              "x",
              "y"
            ],
            "properties": {
              "x": {
                "type": "number"
              },
              "y": {
                "type": "number"
              }
            }
          }
        },
        "viewport": {
          "type": "object",
          "properties": {
            "x": {
              "type": "number"
            },
            "y": {
              "type": "number"
            },
            "zoom": {
              "type": "number",
              "exclusiveMinimum": 0
            }
          }
        },
        "domains": {
          "type": "object",
          "description": "Placeholder boxes of clock domains without blocks.",
          "additionalProperties": {
            "type": "object",
            "required": [
              "x",
              "y",
              "w",
              "h"
            ],
            "properties": {
              "x": {
                "type": "number"
              },
              "y": {
                "type": "number"
              },
              "w": {
                "type": "number"
              },
              "h": {
                "type": "number"
              }
            }
          }
        }
      }
    },
    "resolved": {
      "type": "object",
      "description": "Derived by the Composer from the system: the netlist of the VHDL top level. Write a signal per entry of signals, instantiate every entry of instances with its generic map and port map, and write every net as a concurrent assignment \"to <= from;\". See https://openspacehdl.org/composer/format/.",
      "required": [
        "catalog",
        "entity",
        "ports",
        "clocks",
        "resets",
        "instances",
        "signals",
        "nets",
        "packing",
        "constraints",
        "compile",
        "problems",
        "context"
      ],
      "additionalProperties": false,
      "properties": {
        "version": {
          "type": "integer",
          "minimum": 1,
          "description": "Layout version of resolved, 1. It changes only with an incompatible change of the layout (a key removed or renamed, or a value with another meaning); new keys keep it. A file of a Composer before 0.9.8-beta has no version and the layout of version 1."
        },
        "catalog": {
          "type": "string",
          "description": "Content identifier of the block catalog the system was resolved with."
        },
        "entity": {
          "$ref": "#/$defs/identifier",
          "description": "Name of the top-level entity."
        },
        "ports": {
          "type": "array",
          "description": "Ports of the top-level entity, in order.",
          "items": {
            "type": "object",
            "required": [
              "name",
              "dir",
              "type",
              "kind"
            ],
            "additionalProperties": false,
            "properties": {
              "name": {
                "$ref": "#/$defs/vhdlName"
              },
              "dir": {
                "enum": [
                  "in",
                  "out",
                  "inout"
                ]
              },
              "type": {
                "type": "string",
                "description": "VHDL type with evaluated bounds: std_logic or std_logic_vector(<hi> downto 0)."
              },
              "kind": {
                "enum": [
                  "reset",
                  "clock",
                  "interface"
                ],
                "description": "reset: asynchronous system reset, high-active; clock: clock of an external clock domain; interface: a signal of an external interface."
              },
              "interface": {
                "$ref": "#/$defs/endpoint",
                "description": "External interface of the port."
              },
              "domain": {
                "$ref": "#/$defs/identifier",
                "description": "Clock domain of the port: the domain of a clock port, or of the clock of the interface of the port."
              },
              "signal": {
                "type": "string",
                "description": "Logical signal of the interface that the port carries (data, keep, last, user, valid, ready, a field)."
              },
              "fields": {
                "type": "array",
                "items": {
                  "type": "object",
                  "required": [
                    "name",
                    "label",
                    "lsb",
                    "bits"
                  ],
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "label": {
                      "type": "string",
                      "description": "Meaning of the field."
                    },
                    "lsb": {
                      "type": "integer",
                      "description": "Lowest bit of the field in the signal."
                    },
                    "bits": {
                      "type": "integer"
                    },
                    "value": {
                      "type": [
                        "integer",
                        "boolean"
                      ],
                      "description": "Value of the field (constants only)."
                    }
                  }
                },
                "description": "Meaning of the bits of the port (the side band of a send port, the user bits of a stream)."
              }
            }
          }
        },
        "clocks": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "id",
              "name",
              "frequencyHz",
              "actual",
              "source"
            ],
            "properties": {
              "id": {
                "$ref": "#/$defs/identifier"
              },
              "name": {
                "type": "string"
              },
              "frequencyHz": {
                "type": "number"
              },
              "actual": {
                "type": "string",
                "description": "Port actual of the clock inputs of the domain: a top-level port or the signal of a clock output."
              },
              "source": {
                "type": "string",
                "description": "\"top\" or the clock output <instance>.<port> that drives the domain."
              }
            }
          }
        },
        "resets": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "domain",
              "generator",
              "input",
              "output"
            ],
            "properties": {
              "domain": {
                "$ref": "#/$defs/identifier"
              },
              "generator": {
                "$ref": "#/$defs/identifier",
                "description": "Instance of olo_base_reset_gen."
              },
              "input": {
                "type": "string"
              },
              "output": {
                "type": "string",
                "description": "Signal with the synchronous reset of the domain."
              }
            }
          }
        },
        "instances": {
          "type": "array",
          "description": "Every instance of the top level: placed blocks, inserted adapters and reset generators.",
          "items": {
            "type": "object",
            "required": [
              "id",
              "entity",
              "library",
              "block",
              "origin",
              "generics",
              "ports"
            ],
            "properties": {
              "id": {
                "$ref": "#/$defs/identifier"
              },
              "entity": {
                "$ref": "#/$defs/vhdlName"
              },
              "library": {
                "$ref": "#/$defs/vhdlName"
              },
              "block": {
                "type": "string"
              },
              "origin": {
                "enum": [
                  "user",
                  "auto"
                ]
              },
              "role": {
                "enum": [
                  "cdc",
                  "wconv",
                  "reset"
                ]
              },
              "reason": {
                "type": "string"
              },
              "connection": {
                "type": "string"
              },
              "domain": {
                "$ref": "#/$defs/identifier"
              },
              "generics": {
                "type": "array",
                "description": "Every generic of the entity, in order. Put the ones with default false into the generic map.",
                "items": {
                  "type": "object",
                  "required": [
                    "name",
                    "value",
                    "vhdl",
                    "default"
                  ],
                  "properties": {
                    "name": {
                      "$ref": "#/$defs/vhdlName"
                    },
                    "value": {
                      "description": "Value as JSON (null for a generic the Composer cannot represent)."
                    },
                    "vhdl": {
                      "type": "string",
                      "description": "VHDL literal of the value."
                    },
                    "default": {
                      "type": "boolean",
                      "description": "The value is the VHDL default."
                    }
                  }
                }
              },
              "ports": {
                "type": "array",
                "description": "Every port of the entity, in order, with its actual.",
                "items": {
                  "type": "object",
                  "required": [
                    "name",
                    "dir",
                    "type",
                    "actual"
                  ],
                  "properties": {
                    "name": {
                      "$ref": "#/$defs/vhdlName"
                    },
                    "dir": {
                      "enum": [
                        "in",
                        "out",
                        "inout"
                      ]
                    },
                    "type": {
                      "type": "string",
                      "description": "VHDL type with evaluated bounds: std_logic or std_logic_vector(<hi> downto 0)."
                    },
                    "actual": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "A signal, a top-level clock or reset port, \"open\", or null for a port that keeps its VHDL default."
                    },
                    "useDefault": {
                      "type": "boolean",
                      "description": "Leave the port out of the port map."
                    },
                    "default": {
                      "type": "string",
                      "description": "The VHDL default of a port that keeps it (always given with useDefault)."
                    },
                    "domain": {
                      "$ref": "#/$defs/identifier",
                      "description": "Clock domain of the port: of its clock, of its synchronous reset or of the clock of its interface. Asynchronous resets and ports outside an interface have none."
                    },
                    "reset": {
                      "type": "object",
                      "required": [
                        "kind",
                        "note"
                      ],
                      "additionalProperties": false,
                      "description": "A reset input: synchronous (from the reset generator of its domain) or asynchronous (the block synchronises the release itself), and why.",
                      "properties": {
                        "kind": {
                          "enum": [
                            "sync",
                            "async"
                          ]
                        },
                        "note": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "signals": {
          "type": "array",
          "description": "Signals of the architecture, one per port with a signal actual, named <instance>_<port>_s.",
          "items": {
            "type": "object",
            "required": [
              "name",
              "type"
            ],
            "additionalProperties": false,
            "properties": {
              "name": {
                "$ref": "#/$defs/vhdlName"
              },
              "type": {
                "type": "string",
                "description": "VHDL type with evaluated bounds: std_logic or std_logic_vector(<hi> downto 0)."
              }
            }
          }
        },
        "nets": {
          "type": "array",
          "description": "Concurrent assignments \"to <= from;\" of the architecture.",
          "items": {
            "type": "object",
            "required": [
              "to",
              "from",
              "kind"
            ],
            "additionalProperties": false,
            "properties": {
              "to": {
                "type": "string",
                "description": "Signal, slice or bit of a signal, or a top-level output port."
              },
              "from": {
                "type": "string",
                "description": "Signal, slice, bit, top-level input port or constant (VHDL expression)."
              },
              "kind": {
                "enum": [
                  "connection",
                  "constant",
                  "top",
                  "tie-off"
                ]
              },
              "connection": {
                "type": "string",
                "description": "Connection id of the system."
              },
              "signal": {
                "type": "string",
                "description": "Logical signal of the interface (data, keep, last, user, valid, ready, a field) or the port."
              },
              "reason": {
                "type": "string"
              },
              "fields": {
                "type": "array",
                "items": {
                  "type": "object",
                  "required": [
                    "name",
                    "label",
                    "lsb",
                    "bits"
                  ],
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "label": {
                      "type": "string",
                      "description": "Meaning of the field."
                    },
                    "lsb": {
                      "type": "integer",
                      "description": "Lowest bit of the field in the signal."
                    },
                    "bits": {
                      "type": "integer"
                    },
                    "value": {
                      "type": [
                        "integer",
                        "boolean"
                      ],
                      "description": "Value of the field (constants only)."
                    }
                  }
                },
                "description": "Field map of a constant: the side band constants of a connection or the constants of an instance."
              }
            }
          }
        },
        "packing": {
          "type": "array",
          "description": "Bit fields of the packed data words (clock crossings and Open Logic blocks that carry a typed stream).",
          "items": {
            "type": "object",
            "required": [
              "instance",
              "interface",
              "width",
              "fields"
            ],
            "properties": {
              "instance": {
                "$ref": "#/$defs/identifier"
              },
              "interface": {
                "type": "string"
              },
              "width": {
                "type": "integer"
              },
              "fields": {
                "type": "array",
                "items": {
                  "type": "object",
                  "required": [
                    "signal",
                    "lsb",
                    "width"
                  ],
                  "properties": {
                    "signal": {
                      "type": "string"
                    },
                    "lsb": {
                      "type": "integer"
                    },
                    "width": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        },
        "constraints": {
          "type": "array",
          "description": "Timing and placement constraints in terms of the top level: max_delay (from, to, ns, datapathOnly, instances: for every pair of clock domains with a clock crossing, both directions, the period of the faster clock, data path only; no asynchronous clock groups, which would override these limits in Vivado), false_path (from: the input ports that a block synchronises itself; exported as set_false_path -through, valid whether the system is the top level or inside a larger design; none on the system reset, whose consumers release it through olo_base_reset_gen), io_register (ports), vendor_scoped (file of Open Logic with its scoped constraints).",
          "items": {
            "type": "object",
            "required": [
              "kind"
            ]
          }
        },
        "compile": {
          "type": "array",
          "description": "VHDL libraries in compile order with their pinned sources.",
          "items": {
            "type": "object",
            "required": [
              "library",
              "source",
              "url",
              "fileList",
              "fileListFormat",
              "entities"
            ],
            "properties": {
              "library": {
                "$ref": "#/$defs/vhdlName"
              },
              "source": {
                "type": "string"
              },
              "url": {
                "type": "string"
              },
              "tag": {
                "type": "string"
              },
              "commit": {
                "type": "string",
                "pattern": "^[0-9a-f]{40}$"
              },
              "fileList": {
                "type": "string"
              },
              "fileListFormat": {
                "enum": [
                  "files",
                  "modules"
                ],
                "description": "modules: one module directory per line, relative to the repository root (blank lines and lines starting with # are ignored), its sources in <module>/src/*.vhd without a given order inside the module (packages first, then in dependency order, or let the tool order them); files: one VHDL file per line, in compile order."
              },
              "verifiedWith": {
                "type": "string",
                "description": "Open Logic FT tag the repository is verified with (as sources[].verifiedWith)."
              },
              "note": {
                "type": "string"
              },
              "entities": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          }
        },
        "problems": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Inconsistencies found while building the netlist (none for a correct catalog)."
        },
        "context": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Context clause of the top level: library ieee with std_logic_1164, every library of compile, and a use clause for every package whose constants a generic map names."
        },
        "addressMap": {
          "type": "array",
          "description": "Address spaces of the system (since 0.5.0-beta), written when the system has one. A space starts at an AXI slave of the top level (kind port) or at the AXI master of a block (kind master). banks are the register files in it: base, size (2^addrWidth bytes), the window they sit in and the decoder ports on the way (via), the value of their ID register, and where the C header and register map of their core are (registers). unused are decoder ports without a slave: they answer DECERR. what says what the addresses are, windows the windows of a block that accepts only addresses inside them (an RMAP target) and their state after the reset; external the top-level port where the space leaves the system.",
          "items": {
            "type": "object",
            "required": [
              "space",
              "label",
              "kind",
              "addrWidth",
              "banks",
              "unused",
              "decoders"
            ],
            "properties": {
              "space": {
                "type": "string"
              },
              "label": {
                "type": "string"
              },
              "kind": {
                "enum": [
                  "port",
                  "master"
                ]
              },
              "addrWidth": {
                "type": "integer",
                "minimum": 1
              },
              "banks": {
                "type": "array",
                "items": {
                  "type": "object",
                  "required": [
                    "instance",
                    "interface",
                    "block",
                    "entity",
                    "base",
                    "size",
                    "addrWidth",
                    "window",
                    "via"
                  ],
                  "properties": {
                    "instance": {
                      "type": "string"
                    },
                    "interface": {
                      "type": "string"
                    },
                    "block": {
                      "type": "string"
                    },
                    "entity": {
                      "type": "string"
                    },
                    "base": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "size": {
                      "type": "integer",
                      "minimum": 1
                    },
                    "addrWidth": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "window": {
                      "type": "integer",
                      "minimum": 1
                    },
                    "via": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "id": {
                      "type": "string"
                    },
                    "registers": {
                      "type": "object",
                      "required": [
                        "source",
                        "url",
                        "commit",
                        "header",
                        "doc",
                        "prefix"
                      ],
                      "properties": {
                        "source": {
                          "type": "string"
                        },
                        "url": {
                          "type": "string"
                        },
                        "commit": {
                          "type": "string"
                        },
                        "header": {
                          "type": "string"
                        },
                        "doc": {
                          "type": "string"
                        },
                        "prefix": {
                          "type": "string"
                        }
                      }
                    },
                    "doc": {
                      "type": "string"
                    }
                  }
                }
              },
              "unused": {
                "type": "array",
                "items": {
                  "type": "object",
                  "required": [
                    "via",
                    "base",
                    "size"
                  ],
                  "properties": {
                    "via": {
                      "type": "string"
                    },
                    "base": {
                      "type": "integer"
                    },
                    "size": {
                      "type": "integer"
                    }
                  }
                }
              },
              "decoders": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              },
              "external": {
                "type": "string"
              },
              "what": {
                "type": "string"
              },
              "windows": {
                "type": "object"
              }
            }
          }
        },
        "interrupts": {
          "type": "array",
          "description": "Interrupt outputs of the system (since 0.6.0-beta), written when the system has one: the source, its clock domain, where it goes (to: a top-level port, the event input of a block, or open) and its enable, status and events registers in the register map of its block (name and byte offset).",
          "items": {
            "type": "object",
            "required": [
              "source",
              "instance",
              "entity",
              "to",
              "enable"
            ],
            "properties": {
              "source": {
                "type": "string"
              },
              "instance": {
                "type": "string"
              },
              "entity": {
                "type": "string"
              },
              "domain": {
                "type": "string"
              },
              "to": {
                "type": "object",
                "required": [
                  "kind"
                ],
                "properties": {
                  "kind": {
                    "enum": [
                      "port",
                      "block",
                      "open"
                    ]
                  },
                  "port": {
                    "type": "string"
                  },
                  "to": {
                    "type": "string"
                  },
                  "toEntity": {
                    "type": "string"
                  },
                  "channel": {
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                }
              },
              "enable": {
                "type": "array",
                "items": {
                  "type": "object",
                  "required": [
                    "name",
                    "offset"
                  ],
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "offset": {
                      "type": "integer",
                      "minimum": 0
                    }
                  }
                }
              },
              "status": {
                "type": "object",
                "required": [
                  "name",
                  "offset"
                ],
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "offset": {
                    "type": "integer",
                    "minimum": 0
                  }
                }
              },
              "events": {
                "type": "object",
                "required": [
                  "name",
                  "offset"
                ],
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "offset": {
                    "type": "integer",
                    "minimum": 0
                  }
                }
              }
            }
          }
        },
        "protection": {
          "type": "object",
          "description": "Protection scope of the system (since 0.6.0-beta), written when there is something to report. blocks: the blocks that protect their memories with SECDED ECC and report it in their registers (channels, status, select, count and injection registers, evidence). events: every ECC event output of a memory and where it is reported (to; open means not reported); inserted marks the crossings the Composer inserts. crossings: the inserted clock domain crossings (FIFOs for streams, pulse or bit crossings for events and levels), with their ECC and whether their synchronisers are triplicated. faultTolerance: whether they are fault-tolerant.",
          "required": [
            "faultTolerance",
            "blocks",
            "events",
            "crossings"
          ],
          "properties": {
            "faultTolerance": {
              "type": "boolean"
            },
            "blocks": {
              "type": "array",
              "items": {
                "type": "object",
                "required": [
                  "instance",
                  "entity",
                  "channels",
                  "status",
                  "select",
                  "count",
                  "inject",
                  "evidence"
                ],
                "properties": {
                  "instance": {
                    "type": "string"
                  },
                  "entity": {
                    "type": "string"
                  },
                  "channels": {
                    "type": "integer",
                    "minimum": 1
                  },
                  "status": {
                    "type": "object",
                    "required": [
                      "name",
                      "offset"
                    ],
                    "properties": {
                      "name": {
                        "type": "string"
                      },
                      "offset": {
                        "type": "integer",
                        "minimum": 0
                      }
                    }
                  },
                  "select": {
                    "type": "object",
                    "required": [
                      "name",
                      "offset"
                    ],
                    "properties": {
                      "name": {
                        "type": "string"
                      },
                      "offset": {
                        "type": "integer",
                        "minimum": 0
                      }
                    }
                  },
                  "count": {
                    "type": "object",
                    "required": [
                      "name",
                      "offset"
                    ],
                    "properties": {
                      "name": {
                        "type": "string"
                      },
                      "offset": {
                        "type": "integer",
                        "minimum": 0
                      }
                    }
                  },
                  "inject": {
                    "type": "object",
                    "required": [
                      "name",
                      "offset"
                    ],
                    "properties": {
                      "name": {
                        "type": "string"
                      },
                      "offset": {
                        "type": "integer",
                        "minimum": 0
                      }
                    }
                  },
                  "evidence": {
                    "type": "string"
                  }
                }
              }
            },
            "events": {
              "type": "array",
              "items": {
                "type": "object",
                "required": [
                  "source",
                  "instance",
                  "entity",
                  "memory",
                  "inserted",
                  "registers",
                  "to"
                ],
                "properties": {
                  "source": {
                    "type": "string"
                  },
                  "instance": {
                    "type": "string"
                  },
                  "entity": {
                    "type": "string"
                  },
                  "memory": {
                    "type": "string"
                  },
                  "inserted": {
                    "type": "boolean"
                  },
                  "registers": {
                    "type": "boolean"
                  },
                  "to": {
                    "type": "object",
                    "required": [
                      "kind"
                    ],
                    "properties": {
                      "kind": {
                        "enum": [
                          "port",
                          "block",
                          "open"
                        ]
                      },
                      "port": {
                        "type": "string"
                      },
                      "to": {
                        "type": "string"
                      },
                      "toEntity": {
                        "type": "string"
                      },
                      "channel": {
                        "type": [
                          "integer",
                          "null"
                        ]
                      }
                    }
                  }
                }
              }
            },
            "crossings": {
              "type": "array",
              "items": {
                "type": "object",
                "required": [
                  "instance",
                  "entity",
                  "connection",
                  "ecc",
                  "syncTmr"
                ],
                "properties": {
                  "instance": {
                    "type": "string"
                  },
                  "entity": {
                    "type": "string"
                  },
                  "connection": {
                    "type": "string"
                  },
                  "ecc": {
                    "type": "boolean"
                  },
                  "syncTmr": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "readiness": {
          "type": "object",
          "description": "Readiness of the parts of the system (since 0.7.0-beta): every source repository of its blocks with the technology readiness level its project states (trl, status: the sentence of the TRL page) and the instances of its blocks; lowest is the lowest TRL. The composed system has no TRL of its own.",
          "required": [
            "parts",
            "lowest"
          ],
          "properties": {
            "parts": {
              "type": "array",
              "items": {
                "type": "object",
                "required": [
                  "source",
                  "name",
                  "trl",
                  "status",
                  "instances"
                ],
                "properties": {
                  "source": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "trl": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 9
                  },
                  "status": {
                    "type": "string"
                  },
                  "instances": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            },
            "lowest": {
              "type": [
                "integer",
                "null"
              ]
            }
          }
        }
      }
    },
    "checks": {
      "type": "array",
      "description": "Derived by the Composer: results of the structural checks and the design rules, errors first in importance.",
      "items": {
        "type": "object",
        "required": [
          "severity",
          "rule",
          "message"
        ],
        "additionalProperties": false,
        "properties": {
          "severity": {
            "enum": [
              "error",
              "warning",
              "info"
            ]
          },
          "rule": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "instance": {
            "type": "string"
          },
          "connection": {
            "type": "string"
          },
          "domain": {
            "type": "string"
          }
        }
      }
    },
    "agent": {
      "type": "object",
      "description": "Derived by the Composer: build instructions for an AI agent or an engineer.",
      "required": [
        "brief"
      ],
      "additionalProperties": false,
      "properties": {
        "brief": {
          "type": "string",
          "description": "Markdown: sources and compile order, the top-level entity, how to write the architecture from resolved, clocks and resets, constraints, notes of the user guides, open checks and a verification plan."
        }
      }
    },
    "catalogSubset": {
      "type": "object",
      "required": [
        "id",
        "types",
        "blocks"
      ],
      "description": "Derived by the Composer: the catalog entries of the blocks of the system (placed and inserted) and of their interface types, so that the file explains itself; id is the content identifier of the whole catalog, for change detection.",
      "properties": {
        "id": {
          "type": "string"
        },
        "note": {
          "type": "string"
        },
        "types": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "id",
              "name",
              "kind"
            ]
          }
        },
        "blocks": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "id",
              "entity",
              "library",
              "ports",
              "interfaces"
            ]
          }
        }
      }
    }
  },
  "$defs": {
    "identifier": {
      "type": "string",
      "pattern": "^[a-z](?:_?[a-z0-9])*$",
      "maxLength": 40,
      "description": "Lower-case VHDL basic identifier without double or trailing underscore."
    },
    "vhdlName": {
      "type": "string",
      "pattern": "^[A-Za-z](?:_?[A-Za-z0-9])*$"
    },
    "endpoint": {
      "type": "string",
      "pattern": "^[a-z](?:_?[a-z0-9])*\\.[A-Za-z][A-Za-z0-9_]*(?:\\[[0-9]+\\])?$",
      "description": "<instance id>.<interface name>, with [index] for an element of a vector interface."
    }
  }
}
