https://github.com/mattvenn/animatevcd
animate an SVG with a VCD file
https://github.com/mattvenn/animatevcd
Last synced: 2 months ago
JSON representation
animate an SVG with a VCD file
- Host: GitHub
- URL: https://github.com/mattvenn/animatevcd
- Owner: mattvenn
- License: lgpl-3.0
- Created: 2019-01-30T15:51:29.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-08-03T05:00:43.000Z (almost 3 years ago)
- Last Synced: 2025-03-14T21:04:33.449Z (2 months ago)
- Language: Python
- Size: 11.1 MB
- Stars: 12
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Animate an SVG with a VCD
This is a tool for generating animations useful for teaching digital logic.
A VCD file is created by simulating a Verilog file with iverilog and vvp.
Here's a [10 segment counter](https://github.com/mattvenn/icestick-multisegment/blob/master/seg10.v) counting from 0 to 15 as displayed by GTKWave:
An animated gif can be created from an [SVG template](examples/10seg/10seg.svg) file and animated over a number of frames.

# Instructions
Create the SVG file by drawing your picture in Inkscape or similar, and then setting each object you want to animate with a unique ID.
So far, the only animations supported are changing text and changing style (contributions welcome!)
Then create/modify the [configuration file](examples/10seg/config.py). There are some helper functions to do some basic conversion and comparisons:
# add the animators. The svg_id matches the ID in the SVG file, and the vcd_id is the name of the data in the VCD file
animators.append(
TextReplacer(svg_id='count', vcd_id='counter', conversion=convertBinStrToInt()))# 1 for each segment in the display
for bit in range(10):
animators.append(
StyleReplacer(svg_id='seg%d' % bit, vcd_id='segs', replace=('fill:none', 'fill:red'), compare=compareBitField(bit)))# how many frames
frames = 16# files
svg_file = "10seg.svg"
vcd_file = "test.vcd"Simulate your verilog and dump your VCD file (don't compress the VCD):
iverilog -o seg10 seg10.v seg10_tb.v
vvp seg10Then run the animation and use ImageMagick's convert to convert to an animated gif:
./animateVCD.py --config examples/10seg
convert -delay 50 -morph 1 frames/*svg animation.gif# Acknowledgements
Thanks to Gene Sullivan, Sameer Gauria for [Verilog_VCD](https://pypi.org/project/Verilog_VCD/)