User guide
18-54
DirectC Interface
void vc_get4stVector(vc_handle, vec32 *)
void vc_put4stVector(vc_handle, vec32 *)
Passes a four state vector by reference to a vc_handle to and from
an array in C/C++ function. vc_get4stVector receives the vector
from Verilog and passes it to the array and vc_put4stVector
passes the array to Verilog.
These routines work only if there are enough elements in the array
for all the bits in the vector. The array must have an element for every
32 bit in the vector plus an additional element for any remaining bits.
For example:
extern void copier (input reg [67:0] r1,
output reg [67:0] r2);
module top;
reg [67:0] r1,r2;
initial
begin
r1 [67:65] = 3’b111;
r1 [64:33] = 32’bzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz;
r1 [32:0] = 32’b00000000000000000000000000000000;
copier(r1,r2);
$display("r1=%0b\n",r1);
$display("r2=%0b\n",r2);
end
endmodule
Here there are two 68-bit regs. Values are assigned to all the bits of
one reg and both of these regs are parameters to the C/C++ function
named copier.
copier(vc_handle h1, vc_handle h2)
{
vec32 holder[3];
vc_get4stVector(h1,holder);
vc_put4stVector(h2,holder);