cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Visitor
Visitor
255 Views
Registered: ‎02-07-2019

xelab Bug when Using DPI and Overriding String Parameters

Jump to solution
xelab 2020.1 and earlier appear to be generating incorrect C code when a design uses DPI and overrides a string parameter. This can be recreated with the following SystemVerilog:

module tb #(
    parameter GREETING = "Hello"
)
();

    import "DPI-C" function void sum(
        input bit [7:0] a, input bit [7:0] b, output bit [7:0] c
    );

    bit [7:0] a, b, c;

    initial
    begin
        a = $random; b = $random;
        sum(a, b, c);

        $display("%s. %d + %d = %d", GREETING, a, b, c);

        $finish;
    end

endmodule

The basic xelab command works:

xelab -svlog tb.sv

However, overriding the parameter from the command line with

xelab -v 1 -svlog tb.sv --generic_top GREETING="Hola"

gives the error

/usr/bin/gcc  -fPIC -c -Wa,-W -fPIC -m64  -I"/opt/fpga/Xilinx/Vivado/2020.1/data/xsim/include" "xsim.dir/work.tb/obj/xsim_1.c" -O1  -o "xsim.dir/work.tb/obj/xsim_1.lnx64.o" -DXILINX_SIMULATOR
/usr/bin/gcc  -fPIC  -x c++ -c -Wa,-W -fPIC -m64  -I"/opt/fpga/Xilinx/Vivado/2020.1/data/xsim/include" "xsim.dir/work.tb/obj/xsim_2.c" -O1  -o "xsim.dir/work.tb/obj/xsim_2.lnx64.o" -DXILINX_SIMULATOR
xsim.dir/work.tb/obj/xsim_2.c: In function ‘void XILINX_DPI::dpiInitialize()’:
xsim.dir/work.tb/obj/xsim_2.c:113:48: error: unable to find string literal operator ‘operator""Hola’ with ‘const char [14]’, ‘long unsigned int’ arguments
   DPISetDPIScopeHierarchy(0, "tb(GREETING="Hola")") ;
                                                ^~~
ERROR: [XSIM 43-3409] Failed to compile generated C file xsim.dir/work.tb/obj/xsim_2.c.
ERROR: [XSIM 43-3915] Encountered a fatal error. Cannot continue. Exiting...

The compiler error shows the quotes are not being properly escaped in the DPI call. If the line in the C file is changed to

DPISetDPIScopeHierarchy(0, "tb(GREETING=\"Hola\")") ;

it compiles correctly.

Is this a known issue, or if not can it be filed as a bug?
Tags (3)
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Xilinx Employee
Xilinx Employee
234 Views
Registered: ‎05-01-2019

Hi,

Thanks for providing test case. yes, this is a bug and we will file it as an issue and will fix it.

Thanks,

Harika.

View solution in original post

0 Kudos
1 Reply
Highlighted
Xilinx Employee
Xilinx Employee
235 Views
Registered: ‎05-01-2019

Hi,

Thanks for providing test case. yes, this is a bug and we will file it as an issue and will fix it.

Thanks,

Harika.

View solution in original post

0 Kudos