]> sigrok.org Git - libsigrokdecode.git/commitdiff
parallel: Make CLK probe optional.
authorUwe Hermann <redacted>
Mon, 13 Jan 2014 22:26:36 +0000 (23:26 +0100)
committerUwe Hermann <redacted>
Mon, 13 Jan 2014 22:26:36 +0000 (23:26 +0100)
When no CLK probe is supplied to this PD, handle any transition on
any of the supplied data probes as if there had been a CLK transition.

(based on a suggestion/patch by "bmx" from the #sigrok channel, thanks!)

decoders/parallel/__init__.py
decoders/parallel/pd.py

index a338c43ae4bf01c0c78e8575870f57a2d0e82344..ea55077d04804d51d5979212b8ccfafebc1c3d88 100644 (file)
 
 '''
 This protocol decoder can decode synchronous parallel buses with various
 
 '''
 This protocol decoder can decode synchronous parallel buses with various
-number of data bits/probes and one clock line.
+number of data bits/probes and one (optional) clock line.
+
+If no clock line is supplied, the decoder works slightly differently in
+that it interprets every transition on any of the supplied data probes
+like there had been a clock transition.
 
 It is required to use the lowest data probes, and use consecutive ones.
 For example, for a 4-bit sync parallel bus, probes D0/D1/D2/D3 (and CLK)
 
 It is required to use the lowest data probes, and use consecutive ones.
 For example, for a 4-bit sync parallel bus, probes D0/D1/D2/D3 (and CLK)
index e766ac162662156e56ea3a40c47a4033909f477d..c31718fb4efc371fadfe17d056425a40d805e988 100644 (file)
@@ -57,7 +57,7 @@ Packet:
 '''
 
 def probe_list(num_probes):
 '''
 
 def probe_list(num_probes):
-    l = []
+    l = [{'id': 'clk', 'name': 'CLK', 'desc': 'Clock line'}]
     for i in range(num_probes):
         d = {'id': 'd%d' % i, 'name': 'D%d' % i, 'desc': 'Data line %d' % i}
         l.append(d)
     for i in range(num_probes):
         d = {'id': 'd%d' % i, 'name': 'D%d' % i, 'desc': 'Data line %d' % i}
         l.append(d)
@@ -72,9 +72,7 @@ class Decoder(srd.Decoder):
     license = 'gplv2+'
     inputs = ['logic']
     outputs = ['parallel']
     license = 'gplv2+'
     inputs = ['logic']
     outputs = ['parallel']
-    probes = [
-        {'id': 'clk', 'name': 'CLK', 'desc': 'Clock line'},
-    ]
+    probes = []
     optional_probes = probe_list(8)
     options = {
         'clock_edge': ['Clock edge to sample on', 'rising'],
     optional_probes = probe_list(8)
     options = {
         'clock_edge': ['Clock edge to sample on', 'rising'],
@@ -187,7 +185,10 @@ class Decoder(srd.Decoder):
 
             # State machine.
             if self.state == 'IDLE':
 
             # State machine.
             if self.state == 'IDLE':
-                self.find_clk_edge(pins[0], pins[1:])
+                if pins[0] not in (0, 1):
+                    self.handle_bits(pins[1:])
+                else:
+                    self.find_clk_edge(pins[0], pins[1:])
             else:
                 raise Exception('Invalid state: %s' % self.state)
 
             else:
                 raise Exception('Invalid state: %s' % self.state)