• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Nic30 / pyDigitalWaveTools / c2b72869-550c-445e-8d6c-bec0b3f12af8

04 May 2026 10:23PM UTC coverage: 80.567% (-0.2%) from 80.777%
c2b72869-550c-445e-8d6c-bec0b3f12af8

push

circleci

Nic30
docs

50 of 78 branches covered (64.1%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

2 existing lines in 1 file now uncovered.

348 of 416 relevant lines covered (83.65%)

0.84 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.09
/pyDigitalWaveTools/vcd/value_format.py
1
from io import StringIO
1✔
2
from typing import Optional
1✔
3

4

5
def bitVectorToStr(val: int, width: int, vld_mask: int, prefix: Optional[str], suffix: Optional[str]):
1✔
6
    buff = []
1✔
7
    if prefix is not None:
1!
8
        buff.append(prefix)
1✔
9

10
    for i in range(width - 1, -1, -1):
1✔
11
        mask = (1 << i)
1✔
12
        b = val & mask
1✔
13

14
        if vld_mask & mask:
1✔
15
            s = "1" if b else "0"
1✔
16
        else:
17
            s = "X"
1✔
18
        buff.append(s)
1✔
19

20
    if suffix is not None:
1✔
21
        buff.append(suffix)
1✔
22

23
    return ''.join(buff)
1✔
24

25

26
def bitToStr(val: int, vld_mask: int):
1✔
27
    if vld_mask:
1✔
28
        return "1" if val else "0"
1✔
29
    else:
30
        return "X"
1✔
31

32

33
class LogValueFormatter():
1✔
34

35
    def bind_var_info(self, varInfo: "VcdVarWritingInfo"):
1✔
36
        pass
×
37

38
    def format(self, newVal: "Value", updater, t: int, out: StringIO):
1✔
39
        pass
×
40

41

42
class VcdEnumFormatter(LogValueFormatter):
1✔
43
    """
44
    :attention: does not complay with the standard
45
    """
46

47
    def bind_var_info(self, varInfo: "VcdVarWritingInfo"):
1✔
48
        self.vcdId = varInfo.vcdId
×
49

50
    def format(self, newVal: "Value", updater, t: int, out: StringIO):
1✔
51
        if newVal.vld_mask:
×
52
            val = newVal.val
×
53
        else:
54
            val = "UNDEF"
×
55

56
        out.write(f"s{val:s} {self.vcdId:s}\n")
×
57

58

59
class VcdBitsFormatter(LogValueFormatter):
1✔
60

61
    def bind_var_info(self, varInfo: "VcdVarWritingInfo"):
1✔
62
        self.width = varInfo.width
1✔
63
        self.vcdId = varInfo.vcdId
1✔
64
        if self.width == 1:
1✔
65
            self.format = self._format_bit
1✔
66
            self.suffix = f"{self.vcdId:s}\n"
1✔
67
        else:
68
            self.format = self._format_bits
1✔
69
            self.suffix = f" {self.vcdId:s}\n"
1✔
70

71
    def _format_bit(self, newVal: "Value", updater, t: int, out: StringIO):
1✔
72
        v = bitToStr(newVal.val, newVal.vld_mask)
1✔
73
        out.write(v + self.suffix)
1✔
74

75
    def _format_bits(self, newVal: "Value", updater, t: int, out: StringIO):
1✔
76
        out.write(bitVectorToStr(newVal.val, self.width, newVal.vld_mask, "b", self.suffix))
1✔
77

78
    def format(self, newVal: "Value", updater, t: int, out: StringIO):
1✔
79
        raise AssertionError("Should have been replaced in bind_var_info")
80

81

82
class VcdFloatFormatter(LogValueFormatter):
1✔
83
    """
84
    VcdRealFormatter
85
    """
86

87
    def bind_var_info(self, varInfo: "VcdVarWritingInfo"):
1✔
UNCOV
88
        self.vcdId = varInfo.vcdId
×
89

90
    def format(self, newVal: float, updater, t: int, out: StringIO):
1✔
UNCOV
91
        out.write(f"{newVal:.16g} {self.vcdId:s}\n")
×
92

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc