2

I need to call a Perl script from an E test that I wrote. I need to create an ini file-invoke C script that will create a config file which I need for the test I'm writing. I want the test to invoke the Perl which will handle the ini->C->config process, and then proceed with the test. any ideas?

DVK
  • 126,886
  • 32
  • 213
  • 327
Chaggster
  • 2,441
  • 3
  • 21
  • 14
  • 1
    What is `E`? Do you **really** need E to call Perl, and Perl to call C (what is a C script?) to create a config file? **Simplify** is my suggestion. – pmg Nov 14 '10 at 16:29
  • 1
    "e" is a hardware verification language. Its most common implementation ( only, probably.. ) is Cadence's Specman. See http://en.wikipedia.org/wiki/Specman – Ross Rogers Nov 14 '10 at 22:20
  • FYI, there is no Perl API for Specman. Only a C and C++ API for compiling in your code with Specman. – Ross Rogers Nov 14 '10 at 22:22

1 Answers1

4

You can do system calls or shell commands with functions system or output_from. This can be used to execute arbitrary commands, including invocations of Perl. The system function returns the return value of the shell call, whereas output_from returns the standard out ( and maybe standard error... check your docs..).

Examples:

var ret := system("echo hello world");

prints to Specman screen/log file

hello world

Whereas output_from is used like:

var std_out := output_from("echo hello world");
print std_out;

and prints:

std_out = "hello world"

The functions take a string, so you can build up the arguments using the append() and appendf() functions.

Small aside: You can talk directly to the simulator command line interface using simulator_command(cmd_str). I've used this one before for talking with Synopsys' VCS

simulator_command("quit");
Ross Rogers
  • 23,523
  • 27
  • 108
  • 164
  • is there any way to get both the output and the return value at the same time? – Nathan Fellman Nov 16 '10 at 06:27
  • `output_from_check()` - it performs just like `output_from()`, except if the command returns non zero, it will throw an error. If you need to be able to handle the error condition, then you'll need to wrapper it with a `try { } else { }` exception handler. This wont allow you to get the exact return value, but it will allow you to detect and handle failed system calls. – Ross Rogers Nov 17 '10 at 17:50