Protocol decoder:numbers_and_state

From sigrok
Revision as of 18:44, 20 July 2020 by Gsi (talk | contribs) (create numbers_and_state decoder page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
numbers_and_state
Numbers state mugshot.png
Name Numbers and state
Description Interpret bit patterns as different kinds of numbers (integer, float, enum)
Status in progress
License GPLv2+
Source code decoders/numbers_and_state
Input logic
Output numbers_and_state

The Numbers and state decoder takes a set of logic input signals, and interprets their bit pattern according to user specs as either signed or unsigned integers, or floating point numbers. Users can specify external data files and have raw numbers mapped to user provided text strings. Which can help identify machine states, or locations along a code path, or RTOS tasks.

Decoder

The decoder expects a set of data lines as input. Not connected bit positions are assumed to be low (0). Users can specify the number's total width in bits. This allows to grab just a few signals of a wider bus, and see if there is _some_ activity. Which can be useful when the acquisition device lacks spare channels for the full number.

An optional clock signal is supported. When connected, data gets sampled at rising, falling, or either edges. When the clock is not provided, data gets sampled when any of the data lines changes. Which can result in very short and rather many annotations for glitchy setups (like software bitbanged busses).

Options:

  • Clock edge: rising, falling, either
  • Total bits count: a user provided number, or automatic when 0 (derived from connected input signals)
  • Interpretation: unsigned, signed, fixpoint, fixsigned, ieee754, enum
  • Fraction bits count: a user provided number, can also be negative (then multiplies)
  • Enum to text map file: name of a Python or JSON file which maps integers to text strings
  • Number format: -, bin, oct, dec, hex

Enumerations are a special mode. A bit pattern is taken as a number which represents a state or condition. User provided map files can translate these numbers to display text. In addition the numbers are shown on individual rows, which results in a tabular presentation of e.g. state machine transitions, or RTOS task switches. The number of rows is limited, when more enum states are seen then these all end up in an overflow row.