Using GTKWave on MacOS with command line parameters

Motivation

GTKWave is an excellent open source wave viewer. It is easy to install on MacOS:

1
2
brew tap homebrew/cask
brew cask install gtkwave

In this way, you will get the gtkwave.app in the /Applications directory. The problem is that there is no way to pass command line arguments to the application. After some search on the Internet, I found a workaround.

Installing Perl Switch

The executable is in the directory of /Applications/gtkwave.app/Contents/Resources/bin/. But it won't work by simply typing in /Applications/gtkwave.app/Contents/Resources/bin/gtkwave in terminal.

First we need to install Perl’s Switch module:

1
cpan install Switch

When installing Perl’s Switch module, there are several options. Just go with default.

And then using this command to check if Switch is installed in the correct location(/Library/Perl/5.*/):

1
perl -V:'installsitelib'

If it's not, please copy Switch.pm to the correct location.

At last, runing this command:

1
sudo cpan -f Switch

Adding alias

Put this line into ~/.bashrc or other shell configuration files:

1
alias gtkwave=/Applications/gtkwave.app/Contents/Resources/bin/gtkwave

Then run source ~/.bashrc to refresh the configuration. Now the gtkwave command works just as it is on Linux.

Makefile

If you want to using gtkwave in makefile like this tutorial, you have to define a variable containing full path in the makefile. Because make don't care about aliases. For example, you can do this:

1
2
3
gtkwave:=/Applications/gtkwave.app/Contents/Resources/bin/gtkwave
main:
$(gtkwave) your_wave_file.vcd

Reference

  • https://ughe.github.io/2018/11/06/gtkwave-osx
  • https://stackoverflow.com/a/48948046
  • http://inf-server.inf.uth.gr/~konstadel/resources/Icarus_Verilog_GTKWave_guide.pdf