From the figure to the data model

This page follows two figures of senfd's example document, example/example.docx, through the three forms that senfd makes of them. The example document is a synthetic specification written to exercise the reader, so the page shows no text of NVM Express's. toolbox/example_stages.py writes every file on this page from example/output, and a test checks that the files match what the script writes.

As written

The figure document holds each table as the document has it: rows of cells, with the merged cells marked. A reader of a document format has to produce only this form. The .docx reader and the PDF reader both produce it, and no stage after this one knows which reader produced it. Figure 1 is an opcode table, and Figure 19 is a command dword:

Figure 1: Opcodes for Foobar Command Set Commands
Function Data Transfer Combined Opcode Command Reference
0000 00b 01b 01h Ding 3.1
0000 01b 10b 02h Dong 3.2
0000 10b 00b 04h Ring1 3.3
0000 11b 00b x Zing 3.4
0001 00b 01b 08h Foo Migrate 3.5
80h to FFh Reserved
Figure 19: Ring – Command Dword 11
Bits Description
31:16 Ring Mode (R MODE)

Normalised

senfd recognises the kind of each figure by its caption and the shape of its table, and reads the figure as that kind. senfd reads Figure 1 as the opcodes of the Foobar command set, one entry per row. senfd reads Figure 19 as dword 11 of the Ring command: a layout of fields, with each range read as bits and each acronym taken from the parentheses. Each thing that senfd had to normalise on the way is a diagnostic on the figure, such as a dash in a caption or a range given in words:

Subject: kind opcodes, name Foobar. Shape: opcode.

functiondata_transferopcodecommandreference
0000 00b01b01hDing3.1
0000 01b10b02hDong3.2
0000 10b00b04hRing13.3
0000 11b00bxZing3.4
0001 00b01b08hFoo Migrate3.5
80h to FFhReserved

No diagnostics: the figure read as its kind must.

Subject: kind command_dword, name Ring, lower 11, upper 11. Shape: layout.

rangenameacronymdescription
31:16Ring ModeR MODE

No diagnostics: the figure read as its kind must.

In the data model

In the data model, the figures become the things they define. The opcode table gives the command Ring, opcode 04h, with the footnote marker dropped from its name. Three dword figures, Figures 18, 19 and 20, give the submission queue entry of Ring, and each dword cites the figure and page it is from. The command is one entry of the data model. The expert, the MCP server and the code generator all read this entry:

{
  "name": "Ring",
  "opcode": 4,
  "sqe": [
    {
      "lower": 14,
      "upper": 15,
      "condition": null,
      "selected_when": null,
      "qualifier": null,
      "refines": null,
      "fields": [],
      "source": {
        "document": "example",
        "figure_nr": 18,
        "page_nr": 18,
        "pdf_page": null,
        "section": "1.2",
        "section_title": "Ding command"
      }
    },
    {
      "lower": 11,
      "upper": 11,
      "condition": null,
      "selected_when": null,
      "qualifier": null,
      "refines": null,
      "fields": [
        {
          "name": "Ring Mode",
          "acronym": null,
          "upper": 31,
          "lower": 16,
          "range": "31:16",
          "description": "",
          "section": null,
          "elided": false,
          "columns": {},
          "union": null,
          "alternative": null,
          "placements": [],
          "byte_order": null,
          "encoding": null,
          "encoding_from": null,
          "byte_order_from": null,
          "footnotes": [],
          "values": [],
          "unit": "bits",
          "role": "field",
          "kind": "span",
          "formula": null,
          "width": 16,
          "fields": [],
          "values_in": null,
          "cases": [],
          "array": null,
          "part": null,
          "structure": null
        }
      ],
      "source": {
        "document": "example",
        "figure_nr": 19,
        "page_nr": 19,
        "pdf_page": null,
        "section": "1.2",
        "section_title": "Ding command"
      }
    },
    {
      "lower": 10,
      "upper": 10,
      "condition": null,
      "selected_when": null,
      "qualifier": null,
      "refines": null,
      "fields": [
        {
          "name": "Ring Count",
          "acronym": "RCNT",
          "upper": 31,
          "lower": 0,
          "range": "31:00",
          "description": "How many rings.",
          "section": null,
          "elided": false,
          "columns": {},
          "union": null,
          "alternative": null,
          "placements": [],
          "byte_order": null,
          "encoding": null,
          "encoding_from": null,
          "byte_order_from": null,
          "footnotes": [],
          "values": [],
          "unit": "bits",
          "role": "field",
          "kind": "span",
          "formula": null,
          "width": 32,
          "fields": [],
          "values_in": null,
          "cases": [],
          "array": null,
          "part": null,
          "structure": null
        }
      ],
      "source": {
        "document": "example",
        "figure_nr": 20,
        "page_nr": 20,
        "pdf_page": null,
        "section": "1.2",
        "section_title": "Ding command"
      }
    }
  ],
  "cqe": [],
  "operations": [],
  "status_values": [],
  "status_codes": [],
  "uses": [
    "CDW10",
    "CDW11"
  ],
  "uses_stated": false,
  "delegated": [],
  "columns": {
    "function": "0000 10b",
    "data_transfer": "00b",
    "reference": "3.3"
  },
  "typed": {},
  "footnotes": {},
  "source": {
    "document": "example",
    "figure_nr": 1,
    "page_nr": 1,
    "pdf_page": null,
    "section": "1.1",
    "section_title": "Foobar Commands"
  }
}

What the author sees

Reading the figures as data also checks them. A figure that does not read as data becomes a candidate erratum, reported with the document, section, figure and page. No rule was written for any of the candidate errata below; each one is a figure that did not fit its kind. The opcode of Zing is not a value. The acronym of Ring Mode has a space in it. Bits 0 to 15 of Ring's dword 11 belong to no field. Bit 64 of Ring Tail lies beyond the 64 bits of its two dwords. A support requirement reads "Maybe", which is not a support level:

example, 1.1, Figure 1, page 1: Command Zing: opcode is not a value
example, 1.2, Figure 18, page 18: Field 64:00 Ring Tail: bit 64 beyond the 64 bits of its dwords
example, 1.2, Figure 19, page 19: Field 31:16 Ring Mode: acronym 'R MODE' is not one
example, 1.2, Figure 19, page 19: Ring cdw11: bits 0 to 15 are of no field
example, 2, Figure 23, page 23: Foo Set: the Reference column gives section 4.2, and the dwords of the command are in section 4
example, 2, Figure 33, page 33: 'Maybe' in the column "I/O" is not a level
example, 4, Figure 89, page 89: Byte 1 is of no field, before 03:02 Foo Flags

senfd lint lists the candidate errata together with the document errors, the figures of a shape senfd does not read, and the dwords that no command claims; see the linter. An editor who makes the data model of a draft gets this check with no further work.