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.
| function | data_transfer | 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 |
No diagnostics: the figure read as its kind must.
Subject: kind command_dword, name Ring, lower 11, upper 11. Shape: layout.
| range | name | acronym | description |
|---|---|---|---|
| 31:16 | Ring Mode | R 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"
}
}