xsc Compiler - 2023.2 English

Vivado Design Suite User Guide: Logic Simulation (UG900)

Document ID
UG900
Release Date
2023-10-18
Version
2023.2 English

The xsc compiler helps you create a shared library (.a on Windows or .so on Linux) from one or more C files. Use xelab to bind the shared library generated by xsc into the rest of your design. You can create a shared library using the following processes:

One-step process
Pass all C files to xsc without using the -compile or -shared/shared_systemc/static switch.
Two-step process
xsc -compile <C files> 
xsc --shared or -shared_systemc or -static <object files>

Usage

xsc [options] <files...>

Switches

You can use a double dash (--) or a single dash (-) for switches.

Table 1. XSC Compiler Switches
Switch Description
-compile [c] Generate the object files only from the source C files. The link stage is not run.
-f [ -file ] <arg> Read additional options from the specified file.
-h [ -help ] Print this help message.
-i [ -input_file ] <arg> List of input files (one file per switch) for compiling or linking.
-mt <arg> (=auto)

Specifies the number of sub-compilation jobs that can be run in parallel. Choices are:

  • auto: automatic
  • n: where n is an integer greater than 1
  • off: turn off multi-threading

Default: auto

-o [ -output ] <arg> Specify the name of output shared library. Works with --shared, --shared_systemc, --exe options only. The default for shared library is <current_directory>/xsim.dir/work/xsc/dpi.so.
-work <arg> Specify the work directory in which to place the outputs (object files).

Default: <current_directory>/xsim.dir/xsc

-v [ -verbose ] <arg>

Specify verbosity level for printing messages.

Allowed values are: 0, 1

Default: 0

-gcc_compile_options <arg> Supply an additional option to the compiler. You can use multiple -gcc_compile_options switches.
-gcc_link_options <arg> Supply an additional option to the linker. You can use multiple -gcc_link_options switches.
-shared Run only the linking stage to generate the shared library (.so) from the object files.
-gcc_path Print path of the C compiler used internally.
-lib <arg> Specify the logical library directories that are read. Default is <current_directory>/xsim.dir/xs.
-cppversion <arg> Set the CPP version. Currently, CPP 11 and 14 are supported. The default is 11.
--shared_systemc Run only the linking stage to generate the shared library (.dll) for SystemC from the object files.
--static Run only the linking stage to generate a static library (.a) for SystemC from the object files.
--exe Create executable for standalone SystemC.
--version Print version of the Vivado Simulator xsc being used.
--debug Debug SystemC modules. This option is relevant only when used together with -exe option, otherwise is ignored.
--print_gcc_version Print version of the C compiler used internally.

Examples

xsc function1.c function2.c
xelab -svlog file.sv -sv_lib dpi
xsc -compile function1.c function2.c -work abc
xsc -shared abc/function1.lnx64.o abc/function2.lnx64.o -work abc
Note: By default, Linux uses the LD_LIBRARY_PATH for searching the DPI libraries. Hence, provide -dpi_absolute flag to xelab on Linux if the library name starts with lib*.
Note: You can use -additional_option to the compiler to pass an extra switch.
Example
xsc t1.c --additional_option "-I<path>"
Example to pass multiple path
xsc t1.c --additional_option "-I<path>" --additional_option "-I<path>"