vvp: Only ignore leading null-bytes when reading as string through VPI
Currently when reading a number literal through the VPI API as a
vpiStringVal all null-bytes in the literal get ignored. This behavior is
different from when reading a signal through the VPI API as a vpiStringVal.
The latter will only ignore leading null-bytes and replace other null-bytes
with a space. E.g. the following two will print different values.
```
$display("%s", "a\000b"); // -> " ab"
reg [23:0] x = "a\000b";
$display("%s", x); // -> "a b"
```
For consistency modify the number literal formatting code so that it has
the same behavior as the signal value formatting code and only replaces
leading null-bytes.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
b8ddeb8848
commit
3cfbd7345f
|
|
@ -635,6 +635,8 @@ static void vec4_get_value_string(const vvp_vector4_t&word_val, unsigned width,
|
|||
|
||||
if (char_val != 0)
|
||||
*cp++ = char_val;
|
||||
else if (cp != rbuf)
|
||||
*cp++ = ' ';
|
||||
}
|
||||
|
||||
for (unsigned idx = 0 ; idx < nchar ; idx += 1) {
|
||||
|
|
@ -645,8 +647,13 @@ static void vec4_get_value_string(const vvp_vector4_t&word_val, unsigned width,
|
|||
if (val == BIT4_1)
|
||||
char_val |= 1 << bdx;
|
||||
}
|
||||
// Ignore leading null-bytes and replace other null-bytes with space.
|
||||
// The LRM is not entirely clear on how null bytes should be handled.
|
||||
// This is the implementation chosen for iverilog.
|
||||
if (char_val != 0)
|
||||
*cp++ = char_val;
|
||||
else if (cp != rbuf)
|
||||
*cp++ = ' ';
|
||||
}
|
||||
|
||||
*cp = 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue