Bytefield
Bytefield draws byte and bit field diagrams, including nested structures and variable-length gaps. It is written in a small Clojure-flavoured syntax, which looks unusual and is quickly learned.
It is the best tool here for file formats and register maps.
#What it is good at
File format documentation.
Embedded register maps and flash layouts.
Structures with variable-length sections, which fixed grids cannot express.
#What it draws
Element | Syntax |
|---|---|
Column headers | (draw-column-headers) |
Field | (draw-box "length" {:span 4}) |
Variable region | (draw-gap "payload") |
Styling | (defattrs :bg-green {:fill "#a0ffa0"}) |
Close | (draw-bottom) |
#A worked example
A file header with a fixed part and a variable body:
The source, which you can paste into a new diagram and edit:
#A few things that catch people out
State endianness once at the top of the page. The diagram cannot show it.
Draw padding explicitly, or the diagram implies fields are adjacent when they are not.
Use draw-gap for variable regions rather than guessing a size.
#Related
Thirty-one languages. Nobody knows them all.
