Naming Ports and Signals
The SystemC kernel cannot read the C++ names of ports and channels during elaboration. By default SystemC assigns unique made-up names to each port and channel. However, SystemC names may be provided for ports and channels as constructor arguments. Debugging is made easier if user supplied names are available for tracing and waveforms.
This utility uses Perl to add names to ports and signals inside sc_modules. It makes some assumptions about the SystemC coding style used:
- Ports and signals are declared at top of module
- Initialiser list in same order as declarations
- One sc_module per file
- Does not support derived modules
Here's an online demonstration to illustrate how it works. Type your SystemC code in this window then click the "Run Perl Script" button. An example is already typed for you, perhaps you'd like to experiment with it. Try adding ports, signals and partially naming some ports in a constructor initialiser list. You must provide a complete SC_MODULE declaration including }; at the end.
Download Perl Script
This script requires Perl 5.6 or newer. If you have not got Perl installed on your system then you can download it for free. More details Here.
This script relies heavily on pattern matching using Perl's powerful regular expression engine. Without help, developing complicated regular expressions is very error prone. The Doulos Perl Regular Expression viewer was used extensively while writing this script. Find out more and download your free copy from our Perl Regular Expressions page.
If you would like to learn Perl to improve your design productivity then consider joining our 3 day Perl course written for design engineers like you.
One final point. This Perl script works with standard SystemC port types and sc_signals. If you need more functionality then you should be able to study and modify the script.