pyDigitalWaveTools.vcd package

A module for parsing and writing of Value Change Dump (VCD) files

Submodules

pyDigitalWaveTools.vcd.common module

class pyDigitalWaveTools.vcd.common.VCD_SIG_TYPE

Bases: object

ARRAY = 'array'
ENUM = 'enum'
REAL = 'real'
WIRE = 'wire'
class pyDigitalWaveTools.vcd.common.VcdVarInfo(vcdId: str | VcdVarInfo, name: str, width, sigType, parent)

Bases: object

Common part of VcdParsingVarInfo and VcdVarWritingInfo Container of informations about variable in VCD

Variables:
  • ~.vcdId – id in VCD file or the first VcdVarInfo which uses the same id (in this case this var is just reference to it)

  • ~.name – name in VCD file

  • ~.width – width in VCD file (int)

  • ~.sigType – VCD var type name (from VCD_SIG_TYPE)

  • ~.parent – parent VcdSignalScope object

class pyDigitalWaveTools.vcd.common.VcdVarScope(name, parent=None)

Bases: object

VCD module - container for variables

Variables:
  • ~.name – name of this scope

  • ~.parent – parent scope of this scope or None

  • ~.children – dict {name: <VcdVarScope or VcdVarInfo instance>}

toJson()

pyDigitalWaveTools.vcd.parser module

note:

inspired by https://github.com/GordonMcGregor/vcd_parser/blob/master/vcd/parser.py

A basic self contained VCD parser object

Walks through the definitions constructing the appropriate signal references. Caches XMR paths if and when the signal value changes in the dump for future reference. Needs some hooks for callbacks on signal changes and methods to allow sampling of a signal with an appropriate clock reference

Refer to IEEE SystemVerilog standard 1800-2009 for VCD details Section 21.7 Value Change Dump (VCD) files

exception pyDigitalWaveTools.vcd.parser.VcdDuplicatedVariableError

Bases: Exception

This is when multiple definition to one variable happens. E.g. $scope module testbench $end $var reg 3 ! x [2:0] $end $upscope $end $scope module testbench $end $var wire 8 ” x [7:0] $end $upscope $end

class pyDigitalWaveTools.vcd.parser.VcdParser

Bases: object

A parser object for VCD files. Reads definitions and walks through the value changes https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=954909&tag=1

Variables:
  • ~.keyword_dispatch – dictionary {keyword: parse function}

  • ~.scope – actual VcdSignalInfo

  • ~.now – actual time (int)

  • ~.idcode2var – dictionary mapping vcd id to VcdVarParsingInfo

  • ~.idcode2series – dictionary {idcode: series} where series are list of tuples (time, value), the list commes from VcdVarParsingInfo object

  • ~.signals – dict {topName: VcdSignalInfo instance}

SCOPE_TYPES = {'begin', 'fork', 'function', 'module', 'task'}
VECTOR_VALUE_CHANGE_PREFIX = {'B', 'R', 'b', 'r'}
drop_while_end(tokeniser, keyword)
on_error(lineNo, vcdId)
parse(file_handle)

Tokenize and parse the VCD file

Variables:

~.file_handle – opened file with vcd string

parse_error(tokeniser, keyword)
parse_str(vcd_string: str)

Same as parse() just for string

read_while_end(tokeniser)
save_declaration(tokeniser, keyword)
setNow(value)
value_change(vcdId, value, lineNo)

append change from VCD file signal data series

vcd_dumpall(tokeniser, keyword)

specifies current values of all variables dumped

vcd_simulation_dumpall ::= $dumpall { value_changes } $end

$dumpall   1*@  x*#   0*$   bx   (k $end
vcd_dumpoff(tokeniser, keyword)

all variables dumped with X values

vcd_simulation_dumpoff ::= $dumpoff { value_changes } $end

$dumpoff  x*@  x*#   x*$   bx   (k $end
vcd_dumpon(tokeniser, keyword)

resumption of dumping and lists current values of all variables dumped.

vcd_simulation_dumpon ::= $dumpon { value_changes } $end

$dumpon   x*@  0*#   x*$   b1   (k $end
vcd_dumpvars(tokeniser, keyword)

lists initial values of all variables dumped

vcd_simulation_dumpvars ::= $dumpvars { value_changes } $end

$dumpvars   x*@   z*$   b0   (k $end
vcd_end(tokeniser, keyword)
vcd_enddefinitions(tokeniser, keyword)
vcd_scope(tokeniser, keyword)
vcd_upscope(tokeniser, keyword)
vcd_value_change(lineNo, token, tokenizer)
vcd_var(tokeniser, keyword)
exception pyDigitalWaveTools.vcd.parser.VcdSyntaxError

Bases: Exception

class pyDigitalWaveTools.vcd.parser.VcdVarParsingInfo(vcdId: str | VcdVarInfo, name: str, width, sigType, parent)

Bases: VcdVarInfo

Container of informations about variable in VCD for parsing of VCD file

toJson()

pyDigitalWaveTools.vcd.value_format module

class pyDigitalWaveTools.vcd.value_format.LogValueFormatter

Bases: object

bind_var_info(varInfo: VcdVarWritingInfo)
format(newVal: Value, updater, t: int, out: StringIO)
class pyDigitalWaveTools.vcd.value_format.VcdBitsFormatter

Bases: LogValueFormatter

bind_var_info(varInfo: VcdVarWritingInfo)
format(newVal: Value, updater)
class pyDigitalWaveTools.vcd.value_format.VcdEnumFormatter

Bases: LogValueFormatter

bind_var_info(varInfo: VcdVarWritingInfo)
format(newVal: Value, updater, t: int, out: StringIO)
pyDigitalWaveTools.vcd.value_format.bitToStr(val: int, vld_mask: int)
pyDigitalWaveTools.vcd.value_format.bitVectorToStr(val: int, width: int, vld_mask: int, prefix: str | None, suffix: str | None)

pyDigitalWaveTools.vcd.writer module

exception pyDigitalWaveTools.vcd.writer.VarAlreadyRegistered

Bases: Exception

class pyDigitalWaveTools.vcd.writer.VcdVarIdScope

Bases: dict

registerVariable(sig: object, name: str, parent: VcdVarScope, width: int, sigType: VCD_SIG_TYPE, valueFormatter: LogValueFormatter)
class pyDigitalWaveTools.vcd.writer.VcdVarWritingInfo(vcdId, name, width, sigType, parent, valueFormatter: LogValueFormatter)

Bases: VcdVarInfo

Container of informations about variable in VCD for VCD file generating

class pyDigitalWaveTools.vcd.writer.VcdVarWritingScope(name, writer, parent=None)

Bases: VcdVarScope

Vcd module - container for variables

Variables:
  • ~.oFile – output file to write vcd to

  • ~.name – name of scope

  • ~.vars – subscopes or signals

addVar(sig: object, name: str, sigType: VCD_SIG_TYPE, width: int, valueFormatter: LogValueFormatter)

Add variable to scope

Variables:
  • ~.sig – user specified object to keep track of VcdVarInfo in change()

  • ~.sigType – vcd type name

  • ~.valueFormatter – value which converts new value in change() to vcd string

varScope(name)

Create sub variable scope with defined name

class pyDigitalWaveTools.vcd.writer.VcdWriter(oFile=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>)

Bases: object

date(text)
enddefinitions()
logChange(time, sig, newVal, valueUpdater)
setTime(t)
timescale(picoSeconds)
varScope(name) VcdVarWritingScope

Create sub variable scope with defined name

version(text)