Skip to content

Commit 74db7f3

Browse files
committed
add jsDoc
1 parent 7d825de commit 74db7f3

1 file changed

Lines changed: 30 additions & 2 deletions

File tree

js/core/VCDParser.js

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@ export class VCDParser {
77
this.vcdcontent = opts.vcdcontent || "";
88
this.data = null;
99
if (this.vcdcontent) {
10-
this.data = this.parse(this.vcdcontent);
10+
this.parse(this.vcdcontent);
1111
}
1212
}
1313

14+
/**
15+
*
16+
* @param {string} bin
17+
* @param {number} width
18+
* @returns {string}
19+
*/
1420
_padBin(bin, width) {
1521
bin = bin.toLocaleLowerCase();
1622
// if starts with b or B, remove it before padding:
@@ -27,6 +33,14 @@ export class VCDParser {
2733
return bin.padStart(width, "0");
2834
}
2935

36+
/**
37+
*
38+
* Convert hex string to binary string, e.g. "1A3F" -> "0001101000111111"
39+
* If the hex string contains non-hex characters (e.g. "x", "z"), repeat them into 4 bits, e.g. "xz" -> "xxxxzzzz"
40+
*
41+
* @param {string} hex
42+
* @returns {string}
43+
*/
3044
_hexToBin(hex) {
3145
bin = hex
3246
.split("")
@@ -42,6 +56,18 @@ export class VCDParser {
4256
return bin;
4357
}
4458

59+
/**
60+
*
61+
* @typedef {Object} VarType
62+
* @property {string} type
63+
* @property {number} width
64+
* @property {string} id
65+
* @property {string} name
66+
* @property {string} dimension
67+
*
68+
* @param {string} line
69+
* @returns {VarType}
70+
*/
4571
_parseVAR(line) {
4672
line = line.trim();
4773
if (!line.startsWith("$var")) {
@@ -78,6 +104,7 @@ export class VCDParser {
78104
* Parse the VCD content and return a structured object.
79105
* This is a minimal parser for signal hierarchy and value changes.
80106
* @param {string} vcdcontent
107+
* @param {boolean} [duplicate_repeted_values=false]
81108
* @returns {Object}
82109
*/
83110
parse(vcdcontent, duplicate_repeted_values = false) {
@@ -256,13 +283,14 @@ export class VCDParser {
256283
}
257284
}
258285

259-
return {
286+
this.data = {
260287
signals,
261288
variables,
262289
now: endtime,
263290
name: "dduummyy",
264291
type: "struct"
265292
};
293+
return this.data;
266294
}
267295

268296
/**

0 commit comments

Comments
 (0)