Skip to content

Commit

Permalink
Merge pull request #55 from yihuajack/evcd
Browse files Browse the repository at this point in the history
Add Extended VCD (EVCD) support
  • Loading branch information
yihuajack authored Sep 1, 2022
2 parents 040f862 + 3aecf0d commit 1572c9b
Show file tree
Hide file tree
Showing 8 changed files with 496 additions and 71 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ build
dist
sootty.egg-info
.private
.vscode
26 changes: 18 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,38 @@ python3 -m pip install sootty
To use, run:

```bash
sootty -f "waveform.vcd" > image.svg
sootty "waveform.vcd" -o > image.svg
```

with a vcd file to produce an svg waveform diagram. Optional arguments include:
- `-f | --filename FILENAME` Specify the vcd file name.
- `-s | --start FORMULA` Specify the start of the window.
with a Value Change Dump (VCD) or Extended VCD (EVCD) file to produce an svg waveform diagram. Optional arguments include:
- `-b | --break FORMULA` Specify the formula for the points in time to be highlighted.
- `-e | --end FORMULA` Specify the end of the window.
- `-h | --help` Show the help message and exit.
- `-l | --length N` Specify the number of ticks in the window (mutually exclusive with `-e`).
- `-d` Display the output to the terminal (requires viu).
- `-o | --output` Print to `stdout` rather than display on terminal.
- `-r | --radix N` Display values in radix N (default 10).
- `-R | --reload SAVENAME` Loads a saved query. Requires query name as string.
- `-s | --start FORMULA` Specify the start of the window.
- `-w | --wires LIST` Comma-separated list of wires to include in the visualization (default to all wires).

### Examples

Display all wires starting at time 4 and ending at wire `clk`'s tenth tick:

```bash
sootty -f "example/example3.vcd" -s "time 4" -e "acc clk == const 10" -w "clk,rst_n,pc,inst" -d
sootty "example/example3.vcd" -s "time 4" -e "acc clk == const 10" -w "clk,rst_n,pc,inst"
```

Display wires `Data` and `D1` for 8 units of time starting when `Data` is equal to 20:

```bash
sootty -f "example/example1.vcd" -l 8 -s "Data == const 20" -w "D1,Data" -d
sootty "example/example1.vcd" -l 8 -s "Data == const 20" -w "D1,Data"
```

Saving a query for future use:

```bash
sootty -f "example/example2.vcd" -s "rdata && wdata == const 22" -l 10 -w "rdata, wdata" -S "save.txt" -d
sootty "example/example2.vcd" -s "rdata && wdata == const 22" -l 10 -w "rdata, wdata" -S "save.txt"
```

Reloading a saved query:
Expand All @@ -58,6 +61,7 @@ How to run in python (using the repl):

```python
from sootty import WireTrace, Visualizer, Style
from sootty.utils import evcd2vcd

# Create wiretrace object from vcd file:
wiretrace = WireTrace.from_vcd_file("example/example1.vcd")
Expand All @@ -67,6 +71,12 @@ image = Visualizer(Style.Dark).to_svg(wiretrace, start=0, length=8)

# Display to stdout:
image.display()

# Manually convert EVCD file to VCD file:
with open('myevcd.evcd', 'rb') as evcd_stream:
vcd_reader = evcd2vcd(evcd_stream)
with open('myvcd.vcd', 'wb') as vcd_stream:
vcd_stream.write(vcd_reader.read())
```

You can view and modify the save files for the queries in the `~/.config/sootty/save` directory.
Expand Down
37 changes: 37 additions & 0 deletions example/IEEE_std_example.evcd
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
$scope module testbench.adder_instance $end
$var port 1 <0 data0 $end
$var port 1 <1 data1 $end
$var port 1 <2 data2 $end
$var port 1 <3 data3 $end
$var port 1 <4 carry $end
$var port 1 <5 as $end
$var port 1 <6 rdn $end
$var port 1 <7 reset $end
$var port 1 <8 test $end
$var port 1 <9 write $end
$upscope $end
$enddefinitions $end
#0
$dumpports
pX 6 6 <0
pX 6 6 <1
pX 6 6 <2
pX 6 6 <3
pX 6 6 <4
pN 6 6 <5
pN 6 6 <6
pU 0 6 <7
pD 6 0 <8
pN 6 6 <9
$end
#18
pH 0 6 <4
#20
pD 6 0 <5
pU 0 6 <6
pD 6 0 <9
#25
pf 0 0 <0
pf 0 0 <1
pf 0 0 <2
pf 0 0 <3
68 changes: 68 additions & 0 deletions example/IEEE_std_example.vcd
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
$date June 26, 1989 10:05:41
$end
$version VERILOG-SIMULATOR 1.0a
$end
$timescale 1 ns
$end
$scope module top $end
$scope module m1 $end
$var trireg 1 *@ net1 $end
$var trireg 1 *# net2 $end
$var trireg 1 *$ net3 $end
$upscope $end
$scope task t1 $end
$var reg 32 (k accumulator[31:0] $end
$var integer 32 {2 index $end
$upscope $end
$upscope $end
$enddefinitions $end
$comment
$dumpvars was executed at time '#500'.
All initial values are dumped at this time.
$end
#500
$dumpvars
x*@
x*#
x*$
bx (k
bx {2
$end
#505
0*@
1*#
1*$
b10zx1110x11100 (k
b1111000101z01x {2
#510
0*$
#520
1*$
#530
0*$
bz (k
#535
$dumpall 0*@ 1*# 0*$
bz (k
b1111000101z01x {2
$end
#540
1*$
#1000
$dumpoff
x*@
x*#
x*$
bx (k
bx {2
$end
#2000
$dumpon
z*@
1*#
0*$
b0 (k
bx {2
$end
#2010
1*$
93 changes: 62 additions & 31 deletions example/example4.evcd
Original file line number Diff line number Diff line change
@@ -1,37 +1,68 @@
$scope module testbench.adder_instance $end
$var port 1 <0 data0 $end
$var port 1 <1 data1 $end
$var port 1 <2 data2 $end
$var port 1 <3 data3 $end
$var port 1 <4 carry $end
$var port 1 <5 as $end
$var port 1 <6 rdn $end
$var port 1 <7 reset $end
$var port 1 <8 test $end
$var port 1 <9 write $end
$comment
File created using the following command:
vcd file myevcdfile.evcd -dumpports
$end
$date
Wed Aug 31 09:48:03 2022
$end
$version
dumpports ModelSim Version 10.2c
$end
$timescale
1ns
$end

$scope module test_counter $end

$scope module dut $end
$var port [7:0] <0 count $end
$var port 1 <1 clk $end
$var port 1 <2 reset $end
$upscope $end
$upscope $end
$enddefinitions $end
#0
$dumpports
pX 6 6 <0
pX 6 6 <1
pX 6 6 <2
pX 6 6 <3
pX 6 6 <4
pN 6 6 <5
pN 6 6 <6
pU 0 6 <7
pD 6 0 <8
pN 6 6 <9
pD 6 0 <2
pD 6 0 <1
pXXXXXXXX 66666666 66666666 <0
$end
#18
pH 0 6 <4
#5
pU 0 6 <2
#8
pLLLLLLLL 66666666 00000000 <0
#9
pD 6 0 <2
#10
pU 0 6 <1
#12
pLLLLLLLH 66666660 00000006 <0
#20
pD 6 0 <5
pU 0 6 <6
pD 6 0 <9
#25
pf 0 0 <0
pf 0 0 <1
pf 0 0 <2
pf 0 0 <3
pD 6 0 <1
#30
pU 0 6 <1
#32
pLLLLLLHL 66666606 00000060 <0
#40
pD 6 0 <1
#50
pU 0 6 <1
#52
pLLLLLLHH 66666600 00000066 <0
#60
pD 6 0 <1
#70
pU 0 6 <1
#72
pLLLLLHLL 66666066 00000600 <0
#80
pD 6 0 <1
#90
pU 0 6 <1
#92
pLLLLLHLH 66666060 00000606 <0
#100
pD 6 0 <1
$vcdclose
#100
$end
4 changes: 2 additions & 2 deletions sootty/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

def parse_args():
parser = argparse.ArgumentParser(
description="Converts .vcd wiretraces to .svg format."
description="Converts .vcd or .evcd wiretraces to .svg format."
)
parser.add_argument(
"filename",
Expand Down Expand Up @@ -116,7 +116,7 @@ def main():
if filename is None:
raise SoottyError("Input file is required. See --help for more info.")

# Load vcd file into wiretrace object.
# Load vcd or evcd file into wiretrace object.
wiretrace = WireTrace.from_vcd(filename)

# Check that window bounds are well-defined.
Expand Down
Loading

0 comments on commit 1572c9b

Please sign in to comment.