I'm currently writing a test bench for a VHDL design I made and I need to write a message to a text file. The message is of the format
[instance_name];[simulation_time]
(i.e. U0;700 ns
) and the filename must be [instance_name].log
. Getting the instance name and simulation time is no problem, but writing to a custom filename has been problematic. Under simulation, the instance name will be given in the format:
"U0\ComponentX\test\"
and I would like to replace the slashes with underscores. Is there an easy way to do this?
Simple replace character function that is a bit more versatile and does the same job would be (nothing wrong with @Paebbels's answer)
If there are more than one character to replace, one can always stack the function:
or function call:
So for example:
gives:
Our PoC Library has quite a big collection on string operations/functions. There is a
str_replace
function in PoC.strings that should solve your question. There is also the PoC.utils package with non string related functions, that could also be helpful in handling strings and file I/O.A simple implementation:
Usage: