1.0.1 • Published 4 years ago

vcd-parser v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

vcd-parser

A Node.js parsing tool for Value Change Dump (VCD) files and generating a readable JSON document. It can be used with different hardware simulation tools such as Icarus Iverilog.

Installation

npm install --save vcd-parser

Usage 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);
	});

API Documentation

VCDParser.parse(content, opts, cb) ⇒ Promise.<ParsedData>

Parse VCD text content and generate a valid JSON representation. The function returns a promise unless a callback is provided.

Returns: Promise.<ParsedData> - that resolves with the parsed data

ParamTypeDefaultDescription
contentstringThe text content of the VCD file
optsOptions{}Optional configuration to customize the parsing process
cbParseCallbackOptional callback if you don't prefer to use promises

VCDParser:Options : Object

The optional configuration for the VCD parser

Properties

NameTypeDescription
compressbooleanCompress the output wave by ignoring the unchanged values
expandAmbigousBusbooleanIf the bus has some ambigous value (z or x), it gets expanded to represent the whole bus signal

VCDParser:ParsedData : Object

The parsed VCD object generated by the parser

Properties

NameTypeDescription
...metastringThe values of different initial meta-data, e.g. date, timescale..etc
endtimestringThe endtime of the simulation
scalestringThe time-scale unit of the simulation
signalArray.<Signal>The signal values of the simulation

VCDParser:Signal : Object

The object representing one signal data

Properties

NameTypeDescription
namestringThe full name of the signal
typestringThe type of the signal, e.g. wire, reg,..etc
sizenumberThe size/width of the signal in bits
refNamestringThe reference for this signal used inside the VCD file
modulestringThe name of the top module for which this signal belongs
waveArray.<SignalValue>The values of the signal at different points of time

VCDParser:SignalValue : Array.<number>

The value of a signal at a specific point of time, represnted as a tuple time, value

Properties

NameTypeDescription
0numberThe time of the event
1numberThe value of the signal at that event

VCDParser:ParseCallback : function

The callback for the parsing function.

ParamTypeDescription
errerrorThe error generated while parsing
parsedJSONParsedDataThe JSON document generated by the parser