Call Perl in Verilog or SV?

S

Shenli

Guest
Hi all,

Sometimes, I want to do some sophisticated text operation in Verilog or
SystemVerilog testbench. And we all know that Verilog and SV is like
C/C++ and not very good at text manipulation.

Is there any method to call Perl routine in Verilog or SV? Pass
argument to Perl routine can be better. BTW, I use Cadence NC tools.

Best regards,
Davy
 
"Shenli" <zhushenli@gmail.com> writes:

Is there any method to call Perl routine in Verilog or SV?
Libperl has a C API that will allow you to link a Perl interpreter into
your app and call Perl functions from C.

Have a look at the following:

perldoc perlembed
perldoc perlxs
perldoc perlguts
perldoc perlcall
perldoc perlapi

Whether that's useful to you or not will depend on Verilog or SV's ability
to link against external libraries and call C functions.

sherm--

--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
 
One of the simplest (and of limited capability as well) is to use:

$system ("perl my_script.pl");

Ajeetha, CVC
www.noveldv.com
Shenli wrote:
Hi all,

Sometimes, I want to do some sophisticated text operation in Verilog or
SystemVerilog testbench. And we all know that Verilog and SV is like
C/C++ and not very good at text manipulation.

Is there any method to call Perl routine in Verilog or SV? Pass
argument to Perl routine can be better. BTW, I use Cadence NC tools.

Best regards,
Davy
 
Hi Ajeetha,

Thanks a lot for the help :)
I have tried your suggestion and it work OK.

But when I try to pass a string to $system(), the ncvlog said "Using
String without index is not supported in the given context."

The code I write like below,
//---------------------
string perl_cmd_str = "";

$sformat(perl_cmd_str,"perl ./perl/test_opt_file.pl -a %0d -b 4",
data_a);
$display("string is %s\n", perl_cmd_str);

$system (perl_cmd_str);
//---------------------

Any suggestion on how to input a string to $system()?

Best regards,
Shenli


Ajeetha (www.noveldv.com) wrote:
One of the simplest (and of limited capability as well) is to use:

$system ("perl my_script.pl");

Ajeetha, CVC
www.noveldv.com
Shenli wrote:
Hi all,

Sometimes, I want to do some sophisticated text operation in Verilog or
SystemVerilog testbench. And we all know that Verilog and SV is like
C/C++ and not very good at text manipulation.

Is there any method to call Perl routine in Verilog or SV? Pass
argument to Perl routine can be better. BTW, I use Cadence NC tools.

Best regards,
Davy
 
You can also communicate with external program using $system, $fdislpay
and $readmemh tasks.

I have such example interconnecting Verilog with simple TCL/TK gui:
http://www.tclforeda.org/tclforeda/sim_gui.htm

Regards,
-Alex

Shenli wrote:
Hi Ajeetha,

Thanks a lot for the help :)
I have tried your suggestion and it work OK.

But when I try to pass a string to $system(), the ncvlog said "Using
String without index is not supported in the given context."

The code I write like below,
//---------------------
string perl_cmd_str = "";

$sformat(perl_cmd_str,"perl ./perl/test_opt_file.pl -a %0d -b 4",
data_a);
$display("string is %s\n", perl_cmd_str);

$system (perl_cmd_str);
//---------------------

Any suggestion on how to input a string to $system()?

Best regards,
Shenli


Ajeetha (www.noveldv.com) wrote:
One of the simplest (and of limited capability as well) is to use:

$system ("perl my_script.pl");

Ajeetha, CVC
www.noveldv.com
Shenli wrote:
Hi all,

Sometimes, I want to do some sophisticated text operation in Verilog or
SystemVerilog testbench. And we all know that Verilog and SV is like
C/C++ and not very good at text manipulation.

Is there any method to call Perl routine in Verilog or SV? Pass
argument to Perl routine can be better. BTW, I use Cadence NC tools.

Best regards,
Davy
 

Welcome to EDABoard.com

Sponsor

Back
Top