User guide
18-48
DirectC Interface
end
endmodule
This Verilog code passes the string "abc" to the C/C++ function
passback by reference, and that function passes it by reference to
reg r2. The Verilog code then passes it by reference to the C/C++
function printer from reg r2.
passback(vc_handle h1, vc_handle h2)
{
vc_putPointer(h1, vc_getPointer(h2));
}
printer(vc_handle h)
{
printf("Procedure printer prints the string value %s\n\n",
vc_getPointer (h));
}
The function named printer prints the following:
Procedure printer prints the string value abc
void vc_StringToVector(char *, vc_handle)
Converts a C string (a pointer to a sequence of ASCII characters
terminated with a null character) into a Verilog string (a vector with
8-bit groups representing characters). For example:
extern "C" string FullPath(string filename);
// find full path to the file
// C string obtained from C domain
extern "A" void s2v(string, output reg[]);
// string-to-vector
// wrapper for vc_StringToVector().
`define FILE_NAME_SIZE 512