Namespace: VCDParser

VCDParser

A namespace.
Source:

Methods

(inner) parse(content, optsopt, cbopt) → {Promise.<VCDParser~ParsedData>}

Parse VCD text content and generate a valid JSON representation. The function returns a promise unless a callback is provided.
Parameters:
Name Type Attributes Default Description
content string The text content of the VCD file
opts VCDParser~Options <optional>
{} Optional configuration to customize the parsing process
cb VCDParser~ParseCallback <optional>
null Optional callback if you don't prefer to use promises
Source:
Returns:
Promise object that resolves with the parsed data
Type
Promise.<VCDParser~ParsedData>
Example
const VCDParser = require('vcd-parser');
VCDParser.parse(`
	$date
	Tue Feb 12 14:01:15 2019
	$end
	$version
	Icarus Verilog
	$end
	$timescale
	1ns
	$end
	$scope module test_tb $end
	$var reg 1 ! clk $end
	$var wire 1 " rst $end
	$upscope $end
	$enddefinitions $end
	#0
	$dumpvars
	0"
	0!
	$end
	#15
	1"
	#20
	1!
	#40
	0!
	#60
	1!
	#80
	0!
	#100
	1!
	#115
`).then(parsedData => {
	console.log(parsedData);
// {
// 	"date": "Tue Feb 12 14:01:15 2019",
// 	"version": "Icarus Verilog",
// 	"timescale": "1ns",
// 	"endtime": "115",
// 	"scale": "1ns",
// 	"signal": [
// 		{
// 			"type": "reg",
// 			"size": 1,
// 			"refName": "!",
// 			"signalName": "clk",
// 			"module": "test_tb",
// 			"name": "test_tb.clk",
// 			"wave": [
// 				[
// 					"0",
// 					"0"
// 				],
// 				[
// 					"20",
// 					"1"
// 				],
// 				[
// 					"40",
// 					"0"
// 				],
// 				[
// 					"60",
// 					"1"
// 				],
// 				[
// 					"80",
// 					"0"
// 				],
// 				[
// 					"100",
// 					"1"
// 				]
// 			]
// 		},
// 		{
// 			"type": "wire",
// 			"size": 1,
// 			"refName": "\"",
// 			"signalName": "rst",
// 			"module": "test_tb",
// 			"name": "test_tb.rst",
// 			"wave": [
// 				[
// 					"0",
// 					"0"
// 				],
// 				[
// 					"15",
// 					"1"
// 				]
// 			]
// 		}
// 	]
// }
}).catch(err => {
	console.error(err);
}).

Type Definitions

Options

The optional configuration for the VCD parser
Type:
  • Object
Properties:
Name Type Description
compress boolean Compress the output wave by ignoring the unchanged values
expandAmbigousBus boolean If the bus has some ambigous value (z | x), it gets expanded to represent the whole bus signal
Source:

ParseCallback(err, parsedJSON)

The callback for the parsing function.
Parameters:
Name Type Description
err error The error generated while parsing
parsedJSON ParsedData The JSON document generated by the parser
Source:

ParsedData

The parsed VCD object generated by the parser
Type:
  • Object
Properties:
Name Type Attributes Description
<"meta"> string <optional>
The values of different initial meta-data, e.g. date, timescale..etc
endtime string The endtime of the simulation
scale string The time-scale unit of the simulation
signal Array.<VCDParser~Signal> The signal values of the simulation
Source:

Signal

The object representing one signal data
Type:
  • Object
Properties:
Name Type Description
name string The full name of the signal
type string The type of the signal, e.g. wire, reg,..etc
size number The size/width of the signal in bits
refName string The reference for this signal used inside the VCD file
module string The name of the top module for which this signal belongs
wave Array.<VCDParser~SignalValue> The values of the signal at different points of time
Source:

SignalValue

The value of a signal at a specific point of time, represnted as a tuple [time, value]
Type:
  • Array.<number>
Properties:
Name Type Description
0 number The time of the event
1 number The value of the signal at that event
Source: