2022-05-26 11:10:10 -07:00
2024-02-20 21:01:11 +08:00
2024-02-20 21:01:11 +08:00
2020-09-28 00:28:50 -07:00
2024-02-20 21:01:11 +08:00
2024-02-20 21:01:11 +08:00
2022-05-31 18:30:32 -07:00
2024-02-20 21:01:11 +08:00
2019-10-23 13:50:49 -07:00
2023-03-11 19:36:41 -08:00
2024-02-20 21:01:11 +08:00
2024-02-20 21:01:11 +08:00
2024-02-20 21:01:11 +08:00
2024-02-20 21:01:11 +08:00
2022-05-31 18:30:32 -07:00
2023-03-11 19:28:58 -08:00
2023-03-11 19:28:58 -08:00

Value Change Dump (VCD) parser using llparse based on wavedrom.

Prepare

  1. Install emcc compiler

  2. clone https://github.com/Digital-EDA/digital-vcd-parser

Build

source $EMCC_HOME/emsdk_env.sh
# once only
npm install browserify terser -g
# once only
node bin/build.js
# build
make -j 12
# adjust to browser environment
browserify ./bin/vcd.js | terser --compress -o ./out/vcd.js

production are :

  • ./out/vcd.js
  • ./out/vcd.wasm

move them to your development worksapce.

Usage

Only stream of Uint8 is supported as input. e.g. we want to parse a certain *.vcd read in browser-like environment. Mount vcd to window in your index.html:

<!DOCTYPE html>
<html lang="">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
    <link rel="stylesheet" href="./vcd.css">
    <title>
        <%= htmlWebpackPlugin.options.title %>
    </title>
    <script src="./vcd.js"></script>
</head>

<body>
    <noscript>
        <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled.
                Please enable it to continue.</strong>
    </noscript>
    <div id="app"></div>
</body>

</html>

In your main workspace (App.vue for example), goes like this:

const uint8array = await readVcdFile();
const vcdstream = await getVcdStream();

// level size diagram data
const values = {};

vcdstream.change.any((id, time, cmd, value, mask) => {
    if (values[id] === undefined) {
        values[id] = [];
    }
    values[id].push({time, cmd, value, mask});
})

const maxChunkLength = 1 << 17;
for (let i = 0; i < uint8array.length; i += maxChunkLength) {
    const piece = uint8array.slice(i, i + maxChunkLength);
    vcdstream.write(piece);
}

// structure info of wires in vcdstream.info
console.log(vcdstream.info);


License

MIT LICENSE

Description
No description provided
Readme 7.5 MiB
Languages
C 72.2%
JavaScript 19.5%
Makefile 3.1%
Shell 2.8%
C++ 1.9%
Other 0.4%