summaryrefslogtreecommitdiff
path: root/decoders/numbers_and_state/__init__.py
diff options
context:
space:
mode:
authorGerhard Sittig <gerhard.sittig@gmx.net>2020-07-19 19:41:18 +0200
committerGerhard Sittig <gerhard.sittig@gmx.net>2020-07-20 20:15:04 +0200
commitb094fdfc1c1cfe1e34f95c62e73241cff5e4074c (patch)
treee626318c24f72a49123d9c1095410e3868ccd6c6 /decoders/numbers_and_state/__init__.py
parent33687d6ed7b923662566e6a6f2761792bb087fb4 (diff)
downloadlibsigrokdecode-b094fdfc1c1cfe1e34f95c62e73241cff5e4074c.tar.gz
libsigrokdecode-b094fdfc1c1cfe1e34f95c62e73241cff5e4074c.zip
numbers_and_state: introduce decoder (based on vector slicer)
The idea was taken from the vector slicer as suggested in github PR 17. The code was rewritten to avoid cluttering the decoder set with lots of tiny implementations. Create a single decoder which does all of the bit accumulation as well as number format interpretation and also includes number to text formatting with user selectable presentations. Optional clock is supported, to avoid too many annotations in glitchy setups. The IEEE 754 format was added as another interpretation. The enum code path accepts data files in either the Python or JSON format (the latter feels backwards to me). Putting enums on separate rows helps visualize state transitions. Users can disable GUI traces or select CLI rows to silence the output if it feels noisy. The most appropriate (useful, and usable) number of supported channels is yet to get determined. This version accepts up to 16 inputs.
Diffstat (limited to 'decoders/numbers_and_state/__init__.py')
-rw-r--r--decoders/numbers_and_state/__init__.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/decoders/numbers_and_state/__init__.py b/decoders/numbers_and_state/__init__.py
new file mode 100644
index 0000000..4fe42a3
--- /dev/null
+++ b/decoders/numbers_and_state/__init__.py
@@ -0,0 +1,41 @@
+##
+## This file is part of the libsigrokdecode project.
+##
+## Copyright (C) 2019 Comlab AG
+## Copyright (C) 2020 Gerhard Sittig <gerhard.sittig@gmx.net>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, see <http://www.gnu.org/licenses/>.
+##
+
+'''
+This protocol decoder takes a set of logic input signals, and interprets
+their bit pattern according to user specifications as different kinds of
+numbers, or an enumeration of e.g. machine states.
+
+Supported formats are: signed and unsigned integers, fixed point numbers,
+IEEE754 floating point numbers, and number to text mapping controlled by
+external data files. (Support for half precision floats depends on the
+Python runtime, and may not universally be available.)
+
+User provided text mapping files can either use the JSON format:
+ {"one": 1, "two": 2, "four": 4}
+or the Python programming language:
+ enumtext = { 1: "one", 2: "two", 3: "three", }
+
+In addition to all enum values on one row (sequential presentation of
+the data), a limited number of enum values also are shown in tabular
+presentation, which can help visualize state machines or task switches.
+'''
+
+from .pd import Decoder