]> sigrok.org Git - libsigrok.git/commitdiff
input: vcd: support 1 bit vectors
authorWolfram Sang <redacted>
Sat, 9 Jan 2016 22:17:02 +0000 (23:17 +0100)
committerUwe Hermann <redacted>
Thu, 28 Jan 2016 18:03:53 +0000 (19:03 +0100)
Use the new process_bit() function to parse 1 bit vectors, too.

This is the first step to fix bug #723. Minimal testcase vcd:

$timescale 1 ns $end
$var wire 1 n0 addr_0 $end
$var wire 1 n1 addr_1 $end
$enddefinitions $end
#0
0n0
b1 n1
#1
1n0
b0 n1
#2
0n0
b1 n1
#3
1n0
b0 n1

Signed-off-by: Wolfram Sang <redacted>
src/input/vcd.c

index 47511c416ee90be723e6a20bcde6660ac37dd01b..a9d3c45c1b91c2ba907336f7dea8452290dbe731 100644 (file)
@@ -428,14 +428,28 @@ static void parse_contents(const struct sr_input *in, char *data)
                                inc->skip_until_end = TRUE;
                                break;
                        }
-               } else if (strchr("bBrR", tokens[i][0]) != NULL) {
-                       sr_dbg("Vector values not supported yet");
+               } else if (strchr("rR", tokens[i][0]) != NULL) {
+                       sr_dbg("Real type vector values not supported yet!");
                        if (!tokens[++i])
                                /* No tokens left, bail out */
                                break;
                        else
                                /* Process next token */
                                continue;
+               } else if (strchr("bB", tokens[i][0]) != NULL) {
+                       bit = (tokens[i][1] == '1');
+
+                       /*
+                        * Bail out if a) char after 'b' is NUL, or b) there is
+                        * a second character after 'b', or c) there is no
+                        * identifier.
+                        */
+                       if (!tokens[i][1] || tokens[i][2] || !tokens[++i]) {
+                               sr_dbg("Unexpected vector format!");
+                               break;
+                       }
+
+                       process_bit(inc, tokens[i], bit);
                } else if (strchr("01xXzZ", tokens[i][0]) != NULL) {
                        char *identifier;