xsc 编译器可帮助您从一个或多个 C 语言文件创建共享库(Windows 上的 .a 或 Linux 上的 .so)。xelab 可用于将 xsc 生成的共享库绑定到设计的其余部分。您可使用以下进程创建共享库:
- 单步进程
- 不使用
-compile
或-shared/shared_systemc/static
开关,直接将所有 C 语言文件传递到xsc
。 - 双步进程
-
xsc -compile <C files> xsc --shared or -shared_systemc or -static <object files>
用法
xsc [options] <files...>
Switches(开关)
您可为开关使用双连字符 (--) 或单连字符 (-)。
开关 | 描述 |
---|---|
-compile
[c]
|
仅从 C 语言源文件生成对象文件。不运行链接阶段。 |
-f [ -file ]
<arg>
|
从指定文件读取其他选项。 |
-h [ -help
]
|
打印此帮助消息。 |
-i [ -input_file ]
<arg>
|
用于编译或链接的输入文件(每个开关对应一个文件)列表。 |
-mt <arg>
(=auto)
|
指定可并行运行的子编译作业数量。选项包括:
默认值: |
-o [ -output ]
<arg>
|
指定输出共享库的名称。仅适用于 --shared 、--shared_systemc 和 --exe 选项。默认共享库是 <current_directory>/xsim.dir/work/xsc/dpi.so。 |
-work
<arg>
|
指定用于放置输出(对象文件)的工作目录。 默认值:<current_directory>/xsim.dir/xsc |
-v [ -verbose ]
<arg>
|
指定打印消息的详细程度。 允许的值包括: 默认值: |
-gcc_compile_options
<arg>
|
向编译器提供一个额外选项。您可使用多个 -gcc_compile_options 开关。 |
-gcc_link_options
<arg>
|
向连接器提供一个额外选项。您可使用多个 -gcc_link_options 开关。 |
-shared
|
仅运行链接阶段,以从对象文件生成共享库 (.so )。 |
-gcc_path
|
打印内部使用的 C 语言编译器路径。 |
-lib
<arg>
|
指定读取的逻辑库目录。默认设为 <current_directory>/xsim.dir/xs 。 |
-cppversion
<arg>
|
设置 CPP 版本。当前支持 CPP 11 和 14。默认值为 11。 |
--shared_systemc
|
仅运行链接阶段,以从对象文件生成共享库 (.dll) 供 SystemC 使用。 |
--static
|
仅运行链接阶段,以从对象文件生成静态库 (.a) 供 SystemC 使用。 |
--exe
|
为独立 SystemC 创建可执行文件。 |
--version
|
打印当前使用的 Vivado 仿真器 xsc 的版本。 |
--debug
|
调试 SystemC 模块。该选项仅在搭配 -exe 选项使用时才有效,否则会被忽略。 |
--print_gcc_version
|
打印内部使用的 C 语言编译器版本。 |
示例
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
注释: 默认情况下,Linux 使用
LD_LIBRARY_PATH
搜索 DPI 库。因此,如果库名以 lib*
开头,请向 Linux 上的 xelab 提供 -dpi_absolute
标志。注释: 您可向编译器使用
-additional_option
来传递额外开关。- 示例
-
xsc t1.c --additional_option "-I<path>"
- 传递多条路径的示例
-
xsc t1.c --additional_option "-I<path>" --additional_option "-I<path>"