How many times did you have the task of creating a new UVC or testbench based on the old one?
The task is simple:
Rename all the files in all relevant directories and then replace some strings in all of them.
Yet, I’ve seen more than once people using an ‘mv’ command to rename each file, open it in an editor and perform search-and-replace.
Instead, you can you two simple and extremely useful commands:
- rename
rename
Example:
rename uvc1 uvc2 source/sv/*.sv
This will rename all files that have ‘uvc1’ in their name to contain ‘uvc2’ instead
For example vtool_uvc1_slave_driver.sv will be renamed to vtool_uvc2_slave_driver.sv
- sed
The sed command can do many things. In its most basic form it can simply search and replace:
sed -i ‘s/ahb/axi/g’ source/sv/*.sv
This will search and replace the string ‘ahb’ with ‘axi’ in all the provided files.
Check out some complex examples in:
https://linuxhint.com/50_sed_command_examples/
Most importantly, never settle for tedious manual work. Automate!