Skip to main content

Convert Gowin GAO CSV captures to VCD waveform format.

Project description

gowin2vcd

Convert Gowin GAO CSV captures to VCD waveform format.

Tests PyPI version Python versions

Features

  • Single-pass streaming parser — opens the file exactly once, no matter how large
  • Automatic GAO format detection — handles all known CSV variants
  • Real GAO capture validated
  • Hierarchical signal reconstruction — scope walker, no tree in memory
  • Deterministic VCD output — same input always produces identical output
  • Gzip-compressed output — use .vcd.gz to save space automatically
  • Signal filtering--include and --exclude options
  • JSON output
  • GTKWave save files — generates .gtkw files with groups and expanded scopes
  • Signal aliases — preserves aliases from path/to/sig=alias_name CSV columns
  • X/Z value propagation — handles unknown and high-impedance states
  • Progress callback — for large captures
  • Conversion statistics
  • Zero runtime dependencies — pure Python 3.10+
  • Golden regression tests

Supported outputs

  • VCD
  • JSON
  • GTKWave save files

Installation

pip install gowin2vcd

Or from source:

git clone https://github.com/TSltd/gowin2vcd.git
cd gowin2vcd
pip install .

Usage

Command line

# Basic conversion
gowin2vcd capture.csv output.vcd

# Compressed output
gowin2vcd capture.csv output.vcd.gz

# Include only selected signals
gowin2vcd capture.csv output.vcd \
    --include top/clk top/rst

# Exclude selected signals
gowin2vcd capture.csv output.vcd \
    --exclude top/debug_state

# Override the VCD timescale
gowin2vcd capture.csv output.vcd \
    --timescale ns

# Omit the VCD date/version headers
gowin2vcd capture.csv output.vcd \
    --no-date --no-version

# Diagnostic mode
gowin2vcd capture.csv output.vcd \
    --verify

# Quiet mode
gowin2vcd capture.csv output.vcd \
    --quiet

# Verbose logging
gowin2vcd capture.csv output.vcd \
    --verbose

Python library

from gowin2vcd import GowinCSVParser
from gowin2vcd import VCDWriter

# Parse a capture
parser = GowinCSVParser("capture.csv")

# Access metadata
print(f"Time unit: {parser.metadata.time_unit}")
print(f"Signals: {[s.fullname for s in parser.signals]}")
print(f"Groups: {[g.name for g in parser.groups]}")

# Print stats
print(f"Signals: {stats.signals}")
print(f"Samples: {stats.samples}")
print(f"Changes: {stats.value_changes}")
print(f"Runtime: {stats.runtime:.2f}s")
print(f"Output:  {stats.output_path}")

# Convert to VCD
writer = VCDWriter("output.vcd")
stats = writer.write(parser)
print(f"Wrote {stats.num_samples} samples with {stats.num_changes} changes")

# Or iterate lazily
for sample in parser.iter_samples():
    print(f"t={sample.timestamp} clk={sample.values.get('top/clk')}")

JSON

from gowin2vcd import JSONWriter

writer = JSONWriter("capture.json")
writer.write(parser)

GTKWave save files

from gowin2vcd import GowinCSVParser
from gowin2vcd import GTKWSaveWriter

parser = GowinCSVParser("capture.csv")
capture = parser.parse()

writer = GTKWSaveWriter("output.gtkw")
writer.write(capture)

Architecture

See docs/architecture.md for details.


CSV
 │
 ▼             ┌──────────► VCD
Scanner ─► Parser ─┬──────► JSON
                   ├──────► GTKWave
                   └──────► FST (planned)

File Format

See docs/file_format.md for the GAO CSV format specification.

Status

The project is feature-complete for VCD conversion and has been validated against real Gowin GAO captures.

Current outputs:

  • VCD
  • JSON
  • GTKWave save files

Python 3.10+ Zero runtime dependencies

Roadmap

Planned for v1.0:

  • VCD reader
  • Round-trip verification
  • Fuzz testing
  • Performance benchmarks

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gowin2vcd-0.9.0.tar.gz (28.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gowin2vcd-0.9.0-py3-none-any.whl (25.9 kB view details)

Uploaded Python 3

File details

Details for the file gowin2vcd-0.9.0.tar.gz.

File metadata

  • Download URL: gowin2vcd-0.9.0.tar.gz
  • Upload date:
  • Size: 28.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for gowin2vcd-0.9.0.tar.gz
Algorithm Hash digest
SHA256 fd647d10893e1a9337d5964b7212e334e3a3f78b35a3d142d26ec93ccb1bf2ab
MD5 6d80aa6314960aee64f76c7649e19017
BLAKE2b-256 05b582047d7402eac242ec8346a1894c0f800fe2405b7ab274ff7c843016d916

See more details on using hashes here.

File details

Details for the file gowin2vcd-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: gowin2vcd-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 25.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for gowin2vcd-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d0437219db9988a4c0c5f2db48b5577a5314b4ecc5f8c2798004562d9fb90d7e
MD5 428486d3e9af6c3ca3897baf43d37b0e
BLAKE2b-256 fe31c0929c885f30a183072bb2fb9775ee46494f84cbaf31714c2dfbd0f3d87d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page