npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vcd-parser

v1.0.1

Published

Node.js VCD Parsing Tool

Downloads

49

Readme

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

| Param | Type | Default | Description | | ------- | ------------------------------------------------------- | --------------- | ------------------------------------------------------- | | content | string | | The text content of the VCD file | | [opts] | Options | {} | Optional configuration to customize the parsing process | | [cb] | ParseCallback | | Optional callback if you don't prefer to use promises |

VCDParser:Options : Object

The optional configuration for the VCD parser

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 or x), it gets expanded to represent the whole bus signal |

VCDParser:ParsedData : Object

The parsed VCD object generated by the parser

Properties

| Name | Type | Description | | --------- | ------------------------------------------------------- | -------------------------------------------------------------------- | | [...meta] | string | 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.<Signal> | The signal values of the simulation |

VCDParser:Signal : Object

The object representing one signal data

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.<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

| Name | Type | Description | | ---- | ------------------- | ------------------------------------- | | 0 | number | The time of the event | | 1 | number | The value of the signal at that event |

VCDParser:ParseCallback : function

The callback for the parsing function.

| Param | Type | Description | | ---------- | ------------------------------------------------- | ----------------------------------------- | | err | error | The error generated while parsing | | parsedJSON | ParsedData | The JSON document generated by the parser |