您现在可以准备将 IP 核集成到周围的 FPGA 设计中。这基本上意味着在目标硬件的数据通信协议与 IP 核接口的协议之间实现并连接转换器。特别是,您需要负责连接诸如内存控制器、传感器接口和数据输出等外部接口。

在生成 IP core 黑盒时(如“为 IP core 生成 VHDL 代码”一节中所述),生成的不仅仅是 IP core 黑盒本身。在同一步骤中,还会生成一个完整的测试平台(test bench),该平台已针对在将 IP core 集成到 HDL 设计中时测试其各个接口进行了定制。
该测试平台可在 HDL 集成期间模拟通过 IP core 接口的数据通信。为 HDL 仿真生成的工具专注于测试接口协议,并为顶层架构中连接到该核心的电路(您的 HDL 设计)生成激励。
在测试平台中,稍后可能通过相应的 VisualApplets 算子连接的每个独立接口端口都由文件 I/O 驱动并进行独立仿真。仿真实体由以下元素组成:
-
用于寄存器访问的从接口仿真:通过文件配置,仿真模块提供了一组可读写的寄存器。有专用寄存器连接到启用和复位信号。您可以配置不同的进程。图像处理应用的实际进程数稍后(集成后)在 VisualApplets 设计中定义。对于仿真,您可以如“从接口仿真”一节中所述定义进程数。启用和复位是仅有的两个连接到其他仿真模块的信号,您可以通过仿真实体参数(见下文)指定这些仿真模块所属的进程。寄存器接口仿真器提供了根据激励文件随时间更改寄存器值的选项。在激励文件中,您可以设置一个值并定义何时更改该值(例如,设置为 1,经过 10,000 个时钟周期后设置为 0)。
-
连接到 ImgOut 端口的图像源仿真器。在文件的激励下,此类模块向 IP core 的 ImgOut 接口输出图像数据。您可以根据为图像输出端口指定的图像协议来配置图像协议 ID。
-
连接到 ImgIn 端口的帧汇聚(frame sink)仿真器。此类模块仿真连接到 IP core 的 ImgIn 接口的算子。您可以根据为图像输入端口指定的图像协议来配置图像协议 ID。该模块将接收到的数据写入文件。
-
内存端口仿真器,其行为类似于连接了使用 RAM 的模块。读写访问序列由文件激励,读取的数据则输出到文件中。
-
GPIO 仿真器。每个用于输出的 GPIO 信号均由通过文件配置的信号发生器驱动。每个 GPIO 信号输入都会受到监控,信号的变化会被写入报告文件。
For RTL level simulation, a VHDL file eVA_Design.vhdl has been created. This file contains a package with name eVA_<PLATFORMNAME> ( <PlatformName> is the platform name you defined as described in 'Entering Platform Details'). This package contains two components:
-
eVA_Design:Visual Applets IP Core 的黑盒
-
eVA_Design_Emulator:Visual Applets IP Core 的仿真器:该仿真器为仿真测试平台实现基于文件的激励生成。
以下显示了文件 eVA_Design.vhdl 中的代码,该代码将为仅由用于寄存器访问的从接口组成的最简单的 VA IP Core 生成:
component eVA_Design
generic(
RegIFDataWidth : integer := 32;
RegIFAddrWidth : integer := 16);
port(
iDesignClk: in std_logic := '0';
iDesignClk2x: in std_logic := '0';
ivRegWrData: in std_logic_vector(RegIFDataWidth-1 downto 0) := (others=>'0');
ivRegWrAddr: in std_logic_vector(RegIFAddrWidth-1 downto 0) := (others=>'0');
iRegWrValid: in std_logic := '0';
ivRegRdAddr: in std_logic_vector(RegIFAddrWidth-1 downto 0) := (others=>'0');
iRegRdValid: in std_logic := '0';
ovRegRdData: out std_logic_vector(RegIFDataWidth-1 downto 0) := (others=>'0');
oRegRdDataValid: out std_logic := '0'
);
end component;
component eVA_Design_Emulator
generic(
RegIFDataWidth : integer := 32;
RegIFAddrWidth : integer := 16;
NrOfProcesses: integer := 2;
RegisterDefinitionFile: string := ""
);
port(
iDesignClk: in std_logic := '0';
iDesignClk2x: in std_logic := '0';
ivRegWrData: in std_logic_vector(RegIFDataWidth-1 downto 0) := (others=>'0');
ivRegWrAddr: in std_logic_vector(RegIFAddrWidth-1 downto 0) := (others=>'0');
iRegWrValid: in std_logic := '0';
ivRegRdAddr: in std_logic_vector(RegIFAddrWidth-1 downto 0) := (others=>'0');
iRegRdValid: in std_logic := '0';
ovRegRdData: out std_logic_vector(RegIFDataWidth-1 downto 0) := (others=>'0');
oRegRdDataValid: out std_logic := '0'
);
end component;
有关仿真各类 IP core 接口的更多详细信息,请参见以下小节。
eVA 设计仿真器具有一个参数 NrOfProcesses。此参数是一个介于 1 到 16 之间的整数。该参数的作用是创建一组用于重置和启用设计的预定义寄存器。将配置以下地址:
-
0x00:全局复位
-
0x01:全局启用
-
0x02 * (i+1): Process Reset for process i (i < NrOfProcesses).
-
0x02 * (i+1) + 0x01: Process Enable for process i (i < NrOfProcesses).
因此,当 NrOfProcesses = 2 时,从接口地址空间的前 6 个地址将用于控制仿真设计的复位和启用。每个图像端口将关联到由上述寄存器控制的一对复位和启用信号。集成后,VisualApplets 用户会将接口关联到进程,因为他将实例化一个算子作为进程的组件,并将此算子实例连接到接口。
用于寄存器访问的从接口仿真器由文本文件进一步配置,该文本文件由上述 VHDL 代码中提供的实体参数 RegisterDefinitionFile 设置。在黑盒和测试平台生成期间,该参数会自动设置,如“为 IP core 生成 VHDL 代码”一节中所述。
寄存器定义文件中可能存在以下命令:
|
命令 |
描述 |
|---|---|
|
REM |
行其余部分为注释 |
|
DEF |
定义寄存器。此命令具有以下语法: DEF <addr> <width> <write_read> <init_value>
带有以下参数: <init_value>: hexadecimal initial value <addr>: hexadecimal value of register address <width>: bit width of register <write_read>: 1 for write register, 0 for read register |
|
CON |
将写入寄存器连接到读取寄存器。此命令的语法如下: CON <wrRegAddr> <rdRegAddr>
带有以下参数: <wrRegAddr>: address of write register (hex) <rdRegAddr>: address of read register (hex) |
|
WCK |
等待一定数量的时钟周期。语法如下: WCK <clock_ticks>
with <clock_ticks> giving the number of clock ticks in hexadecimal format. |
|
SET |
设置读取寄存器的值 SET <rdRegAddr> <value>
带有以下参数: <rdRegAddr>: address of read register (hex) <value>: hexadecimal register value |
在任何命令的最后一个参数之后,可以添加以“#”开头的注释。
以下代码是一个寄存器定义文件的示例,该文件配置了两个写入寄存器和两个读取寄存器,其中一个读取寄存器在 16 个时钟周期后预置(地址为 0x7),另一个读取寄存器(地址为 0x6)由地址为 0x6 的写入寄存器驱动:
REM ************************************************************
REM Command formats: DEF <addr> <width> <write_read> <init_value>
REM CON <wrRegAddr> <rdRegAddr>
REM WCK <clock_ticks>
REM SET <rdRegAddr> <value>
REM ************************************************************
DEF 0006 10 1 00000000 #define write reg with width 0x10 at address 0x6
CON 0006 0006 #create read reg with addr 0x6 connected to
REM write register with address 0x6
DEF 0007 20 1 00000000 #define write reg with width 0x20 at address 0x7
DEF 0007 10 0 00000000 #define read register at address 0x7
WCK 0010 #wait for 16 clock cycles
SET 0007 0000000C #set read register value
ImgOut 类型图像通信接口的仿真由刺激文件驱动,该文件提供有关数据输出序列的信息。
For any present ImgOut port, the eVA_Design_Emulator entity has a generic <PORTIDX>_StimuliFileName where <PORTIDX> is the name of the corresponding image output port class followed by the port number. Each line within the given file must follow the syntax
<Command> <Data> <EndOfLine> <EndOfFrame> <DataValid>
where <Command> is a three letter command, <Data> provides an hexadecimal data word, and the three remaining parameters correspond to the image protocol flags.
下表描述了可用命令:
|
命令 |
描述 |
|---|---|
|
DAT |
数据命令。此命令提供将在端口上输出的数据
|
|
WCK |
等待命令。参数 |
|
FID |
设置 FID 输出。参数 |
|
PDX |
将第 X 个端口参数输出设置为随
|
可以在任何命令行中添加以“#”开头的注释。
以下代码是一个刺激文件示例,它会导致输出一个 3x2 图像,随后进行参数更改(包括 FID),并输出尺寸为 3x1 的第二个图像:
DAT 00000000 0 0 0 #Format: Cmd Data(hex) EndOfLine EndOfFrame DataValid
DAT 0000001a 0 0 1
DAT 0000001b 0 0 1
DAT 0000001c 0 0 1
DAT 00000000 1 0 1
DAT 0000002a 0 0 1
DAT 0000002b 0 0 1
DAT 0000002c 0 0 1
DAT 00000000 1 1 1
WCK 00000004 0 0 0
FID 00000001 0 0 0
PD0 00000011 0 0 0
PD1 00000022 0 0 0
PD2 00000033 0 0 0
WCK 00000001 0 0 0
DAT 0000003a 0 0 1
DAT 0000003b 0 0 1
DAT 0000003c 1 1 1
DAT 00000000 0 0 0
DAT 00000000 0 0 0
DAT 00000000 0 0 0
The reset and enable ports of the concerning image communication interface are connected to dedicated registers of the slave interface where the affiliation to a process is done according to a parameter <PORTIDX>_ProcessID.
ImgIn 类型的图像通信接口仿真由激励文件驱动,该文件提供有关参数状态序列的信息。
For any present ImgIn port, the eVA_Design_Emulator entity has a generic <PORTIDX>_StimuliFileName where <PORTIDX> is the name of the corresponding image input port class followed by the port number. The syntax is exactly the same as in the case of the stimuli for ImgOut interfaces except that no DAT command is available. A simple stimuli file may look like,
WCK 00000010 0 0 0 #Format: Command Data(hex) EndOfLine EndOfFrame DataValid
FID 00000001 0 0 0
PD0 00000111 0 0 0
PD1 00000222 0 0 0
PD2 00000333 0 0 0
WCK 00000001 0 0 0
where the parameters <EndOfLine>,<EndOfFrame> and <DataValid> are actually meaningless.
The ImgIn interface emulator writes the received data to file. For that purpose the eVA_Design_Emulator entity has a generic <PORTIDX>_DumpFileName. During simulation, a file with the given name is created and the data is written using DAT and WCK commands in a format which exactly corresponds to the stimuli file format for an ImgOut interface emulator.
The reset and enable ports of the concerning image communication interface are connected to dedicated registers of the slave interface where the affiliation to a process is done according to a parameter <PORTIDX>_ProcessID.
内存通信的仿真由激励文件驱动,该文件提供有关访问序列的信息。
For any present memory port, the eVA_Design_Emulator entity has a generic Mem<X>_StimuliFileName where <X> is the port number. The stimuli file consists of lines with following syntax,
<WrData> <WrAddr> <WrFlag> <WrReq> <RdAddr> <RdFlag> <RdReq>
其中各元素具有以下含义:
<WrData>: hexadecimal data word intended for port ovMemWrDataX
<WrAddr>: hexadecimal write address (for ovMemWrAddrX)
<WrFlag>: hexadecimal write flag (for ovMemWrFlagX)
<WrReq>: write request (oMemWrReqX)
<RdAddr>: hexadecimal read address (for ovMemRdAddrX)
<RdFlag>: hexadecimal read flag (for ovMemRdFlagX)
<RdReq>: read request (oMemRdReqX)
您可以在任何命令行中添加以“#”开头的注释。
以下代码是一个示例激励文件,它会输出两幅图像,每幅图像由四个数据字组成:
0000000000000000 000000 0 0 000000 00 0
0000000000000000 000000 0 0 000000 00 0
0000000000000000 000000 0 0 000000 00 0
0000000000000000 000000 0 0 000000 00 0
000000000000000a 000000 0 1 000000 00 0 #Write 0xa to address 0x0
000000000000000b 000001 0 1 000000 00 0 #Write 0xb to address 0x1
000000000000000c 000002 0 1 000000 00 0 #Write 0xc to address 0x2
000000000000000d 000003 1 1 000000 00 0 #Write 0xd to address 0x3
0000000000000000 000000 0 0 000000 00 0
0000000000000000 000000 0 0 000000 00 0
0000000000000000 000000 0 0 000000 00 0
0000000000000000 000000 0 0 000000 00 0
0000000000000000 000000 0 0 000000 00 0
0000000000000000 000000 0 0 000000 00 0
000000000000000e 000104 1 1 000000 00 0 #Write 0xe to address 0x10a
00000000000000bb 000001 0 1 000000 00 0 #Write 0xbb to address 0x1
0000000000000000 000000 0 0 000000 00 1 #Read from address 0x0
0000000000000000 000000 0 0 000001 00 1 #Read from address 0x1
0000000000000000 000000 0 0 000002 00 1 #Read from address 0x2
0000000000000000 000000 0 0 000003 01 1 #Read from address 0x3
000000000000000e 000000 0 0 000104 00 1 #Read from address 0x104
0000000000000000 000000 0 0 000000 00 0
0000000000000000 000000 0 0 000000 00 0
0000000000000000 000000 0 0 000000 00 0
Read data returned from the memory to the emulator is written to a file. For providing the file name the eVA_Design_Emulator entity has a generic Mem<X>_DumpFileName. The dump lines have the following format,
<RdData> <RdFlag>
其中各元素具有以下含义:
<RdData>: hexadecimal data word according to port ivMemRdDataX
<RdFlag>: hexadecimal value of read flag according to port ivMemRdFlagX
专用输出信号的仿真由激励文件驱动,对每个信号独立进行。其中提供了有关信号状态序列的信息。
The stimuli file may consist of a number of commands which are described below. For any present output signal port the eVA_Design_Emulator entity has a generic oSig_<NAME>_StimuliFileName where <NAME> is the concerning port name.
下表描述了可用命令:
|
命令 |
描述 |
|---|---|
|
SET |
Set 信号。此命令提供端口 oSig_NAME 上的输出将被设置到的信号状态。下一条命令将在一个时钟周期后执行。其语法为 SET <value>
where <value> may be 0 or 1. |
|
WCK |
Wait 命令。其语法为 WCK <ticks
where the parameter <ticks> provides the number of clock ticks for which the signal will be held constant. |
|
RST |
从头重新开始。命令解释器将从激励文件的第一行重新开始。此命令没有任何参数。该命令将在同一时钟周期执行文件的第一条命令,从而能够构建无缝循环。 |
|
STP |
停留在当前状态。命令解释器将停止,并且当前信号状态将保持不变,直至仿真结束。此命令没有任何参数。 |
您可以在任何命令行中添加以“#”开头的注释。
以下代码是一个示例激励文件,它使输出信号产生翻转,保持低电平 5 个时钟周期,保持高电平 7 个时钟周期(与 iDesignClk 同步):
SET 0 # deassert output
WCK 0004 # wait for 4 clock cycles
SET 1 # assert output
WCK 0006 # wait for 6 clock cycles
RST # restart from begin
Dedicated input signals are monitored writing a dump file iSig_<NAME>_DumpFileName where <NAME> is the concerning port name. The file is composed of SET and WCK commands exactly corresponding to the commands of the stimuli file for a dedicated output signal.
要嵌入 IP 核:
-
将 IP 核黑盒的所有接口集成到您的顶层 HDL 设计中。为了在逐步实现接口的同时进行测试,请使用与黑盒一起生成的测试平台(如“仿真框架”一节中所述)。
-
将所有黑盒接口完全集成到您的 HDL 设计中后,生成您的设计的网表。
-
创建一个约束文件。
在实际生成 eVA Plugin(该插件会将具有所有接口规范的硬件特定 IP 核引入 VisualApplets)之前,您需要通过*.xml 或
*.eva的 GUI 在您的硬件描述文件( eVA Designer:
-
启动 VisualApplets 并打开 。

-
转到 选项卡。

-
在 下,输入您创建的文件路径:
指定您的顶层网表路径(包含包装好的 VisualApplets 核黑盒的整个 FPGA 设计的网表)。
指定顶级网表(包含封装的 VisualApplets 核心黑盒的整体 FPGA 设计网表)的用户约束文件路径。如果您使用的是 Xilinx ISE 工具链,这是一个
*.ucf文件;如果您使用的是 Xilinx Vivado 工具链,这是一个*.xdc文件。 -
在 下,按需指定这些文件的路径。此类文件可能包含带约束文件的其他 IP 核的更多网表等内容。

在 下,您现在需要指定将要使用的工具链。比特流综合需要第三方软件:根据所使用的 FPGA,该软件为 Xilinx Vivado WebPACK(免费)、Xilinx Vivado Design Suite、Xilinx ISE WebPACK(免费)或 Xilinx ISE Design Suite(均为 Xilinx 公司的注册商标)。
-
根据用于合成 FPGA 比特流的 Xilinx 工具链,选择 或 选项卡。

-
输入您的工具链详细信息。
:

如果您使用 Xilinx Vivado,请提供以下详细信息:
Vivado 实现流程中 link_design 步骤的命令行。
Vivado 实现流程中 opt_design 步骤的命令行。
Vivado 实现流程中 place_design 步骤的命令行。
Vivado 实现流程中 route_design 步骤的命令行。
Vivado 实现流程中 write_bitstream 步骤的命令行。
:

如果您使用 Xilinx ISE,请提供以下详细信息:
ISE 实现流程中 translate 步骤的命令行。
ISE 实现流程中 map 步骤的命令行。
ISE 实现流程中布局布线 (place and route) 步骤的命令行。
ISE 实现流程中配置比特流生成步骤的命令行。
-
在 下,输入您希望在 VisualApplets 硬件特定目录中可用的其他文件(如有必要)。此类文件可能是用户文档、构建流程插件、脚本、文档、帮助工具等。

输入有关构建流程的所有详细信息后,即可为您的目标硬件生成 eVA 插件安装程序。
VisualApplets 的硬件特定 eVA 插件由以下文件创建:
-
必填:
-
硬件描述文件(
*.xml),包含算子定义(参见 “定义特定于硬件的算子”) -
顶级网表,包含封装的 IP 核黑盒 (
*.ngc/*.edn)(参见下方的方框) -
约束文件(
*.ucf格式(如果您使用 Xilinx ISE),*.xdc格式(如果您使用 Xilinx Vivado)(参见下方的方框)
-
-
可选:
-
硬件设备的图标文件(
*.png),用于在 VisualApplets 图形用户界面中图形化 表示硬件 -
各个特定于硬件的算子的图标文件 (
*.png),用于在 VisualApplets 图形用户界面中图形化表示算子 -
平台特定算子的帮助文件(
*.html)
-
您在完成“定义 IP 核属性”和 “输入构建流详细信息”小节中描述的步骤时,已经在 eVA Designer 中输入了所有这些文件。
![]() |
VisualApplets IP 核网表生成 |
|---|---|
|
您也可以在没有顶级网表和约束文件的情况下创建插件安装程序。 安装后,您将能够在 VisualApplets 中查看集成效果 (可用的特定于硬件的算子等)。 但是,对于不包含顶级网表和约束文件的插件, 您无法构建可在您的硬件平台上运行的小程序 (applet)。 |
要为 VisualApplets 构建实际的 eVA Plugin,您有两种选择。您可以
-
构建并立即将 eVA Plugin 安装到您计算机上的 VisualApplets 安装目录中。
-
构建可执行的 eVA 插件安装程序,您可以将其提供给同事和/ 或客户。
如果您想直接在开发该插件的计算机上 测试或使用它:
-
在 中,打开 菜单。

-
选择菜单项
-
输入您的 VisualApplets 安装目录的路径,或者确认 建议的安装目录。

系统会通知您安装成功:

您可以在 VisualApplets 安装目录的 子目录中找到该插件的文件
eVA/platforms/<devicename>:
要创建一个可转发给 VisualApplets 开发人员(他们将为您的硬件设计图像处理应用程序)的可执行文件:
-
在 中,打开 菜单。

-
选择菜单项
-
选择您要保存插件的目标文件夹。
一旦选择目标文件夹,将立即创建 eVA Plugin。您将通过消息得知构建成功:

该插件可在指定的文件夹中找到:

现在您可以分发该插件了。
安装完成后,您可以在 VisualApplets 中为您的平台设计新的图像处理应用程序:
-
打开 VisualApplets。
-
从“文件”菜单中选择 。
现在,您可以选择您的硬件平台并开始在 VisualApplets 中进行设计:

有关如何使用 VisualApplets 设计图像采集和处理应用程序的信息,请参阅 Getting Started 上的全面 VisualApplets 在线文档。


![[注意]](../common/images/admon/note.png)

上一页

