Vivado HLS可以实现对C、C++等高级编程语言的高层次综合,极大地方便了从现有C/C++的算法快速转换为综合后的RTL模型。正好我所测试的ZedBoard中的器件7020已经被Vivado HLS极好地支持,所以做了一些简单的验证:模拟一个PI调节器,一个传递函数描述的阻感负载,测试信号使用阶跃给定模拟电流给定,测试结果则是看反馈的电流信号。 打开Vivado HLS 14.3,新建一个基于C/C++的工程,如图1所示
图1 新建工程 然后便是添加/新建文件、指定测试文件、选择器件类型等步骤,这些与传统ISE的开发流程基本一致。建好的工程在项目管理器中也是分为头文件、源程序等,与一般的IDE类似,如图2所示。
图2 项目文件夹 然后在Test.C里编写了一个电流给定与电流反馈送入PI调节器,产生电压加在阻感负载上面,然后产生新的电流反馈这么一个简单的闭环系统,测试信号则是Step.C里给定阶跃。为了充分测试VivadoHLS的能力,直接使用float类型,没有花力气去各种各样的浮点转定点。在以前编程的时候,除非直接使用System Generator生成,否则这些数**算会非常复杂;但是在System Generator编程时,又需要为每一个浮点数指定整数位和小数位的宽度,还是比较麻烦。
在写C代码时,如果程序有语法错误,会直接提示,如图3所示。
图3 代码提示 代码编写完成后,可以用debug进行调试,其界面、操作与一般的IDE无异,便不需多说。切换到Vivado HLS的Synthesis选项卡进行综合,经过一堆提示,很快就完成了RTL级的综合:
Starting synthesis ... C:/Xilinx/Vivado_HLS/2012.3/Win_x86/bin/vivado_hls_bin.exe C:/Users/FU/PIwithRL/PIwithRLload/script.tcl @I [LIC-101] Checked out feature [VIVADO_HLS] @W [HLS-40] Vivado and/or ISE in the PATH variable are not from the same build as Vivado HLS. The mismatch may result in unexpected behaviors. @I [HLS-10] Running 'C:/Xilinx/Vivado_HLS/2012.3/Win_x86/bin/vivado_hls_bin.exe' @I [HLS-10] On platform 'Windows NT_intel version 6.1' @I [HLS-10] Vivado HLS Tcl shell started on Sat Nov 10 17:38:32 +0800 2012 for user 'FU' at host 'fu-pc' @I [HLS-10] Current directory: C:/Users/FU @I [HLS-10] Opening project 'C:/Users/FU/PIwithRL'. @I [HLS-10] Adding design file '../../ZedBoard/Ceping5/Test.c' to the project. @I [HLS-10] Adding test bench file '../../ZedBoard/Ceping5/Step.c' to the project. @I [HLS-10] Opening solution 'C:/Users/FU/PIwithRL/PIwithRLload'. @I [SYN-201] Setting up clock with a period of 10ns. @I [HLS-10] Setting target device to 'xc7z020clg484-1' @I [HLS-10] Importing test bench file '../../ZedBoard/Ceping5/Step.c' ... @I [HLS-10] Importing design file '../../ZedBoard/Ceping5/Test.c' ... @I [HLS-10] Analyzing the design file ... @I [HLS-10] Validating synthesis directives ... @I [HLS-10] Checking synthesizability ... @I [HLS-10] Starting code transformations ... @I [HLS-111] Elapsed time: 2.153 seconds; current memory usage: 16.2 MB. @I [HLS-10] Starting hardware synthesis ... @I [HLS-10] Synthesizing 'Test' ... @I [HLS-10] ---------------------------------------------------------------- @I [HLS-10] -- Scheduling module 'Test' @I [HLS-10] ---------------------------------------------------------------- @I [SCHED-11] Starting scheduling ... @I [SCHED-11] Finished scheduling. @I [HLS-111] Elapsed time: 0.047 seconds; current memory usage: 16.5 MB. @I [HLS-10] ---------------------------------------------------------------- @I [HLS-10] -- Exploring micro-architecture for module 'Test' @I [HLS-10] ---------------------------------------------------------------- @I [BIND-100] Starting micro-architecture binding ... @I [BIND-101] Performing variable lifetime analysis. @I [BIND-101] Exploring resource sharing. @I [BIND-101] Binding resource limited operations ... @I [BIND-100] Finished micro-architecture binding. @I [HLS-111] Elapsed time: 0.031 seconds; current memory usage: 16.5 MB. @I [HLS-10] ---------------------------------------------------------------- @I [HLS-10] -- Generating RTL for module 'Test' @I [HLS-10] ---------------------------------------------------------------- @I [RTGEN-500] Setting IO mode on port 'Test|igive' to 'ap_none'. @I [RTGEN-500] Setting IO mode on port 'Test|iback' to 'ap_none'. @W [RTGEN-101] Global scalar 'error' will not be exposed as RTL port. @W [RTGEN-101] Global scalar 'voltagelast' will not be exposed as RTL port. @W [RTGEN-101] Global scalar 'errorlast' will not be exposed as RTL port. @W [RTGEN-101] Global scalar 'voltage' will not be exposed as RTL port. @W [RTGEN-101] Global scalar 'temp1' will not be exposed as RTL port. @W [RTGEN-101] Global scalar 'ibacklast' will not be exposed as RTL port. @W [RTGEN-101] Global scalar 'temp2' will not be exposed as RTL port. @I [RTGEN-100] Module generated: Test_grp_fu_84_ACMP_faddfsub_1|Test_grp_fu_84_ACMP_faddfsub_1_U. @I [RTGEN-100] Module generated: Test_grp_fu_94_ACMP_fptrunc_2|Test_grp_fu_94_ACMP_fptrunc_2_U. @I [RTGEN-100] Module generated: Test_grp_fu_99_ACMP_fptrunc_3|Test_grp_fu_99_ACMP_fptrunc_3_U. @I [RTGEN-100] Module generated: Test_grp_fu_104_ACMP_fpext_4|Test_grp_fu_104_ACMP_fpext_4_U. @I [RTGEN-100] Module generated: Test_grp_fu_108_ACMP_fpext_5|Test_grp_fu_108_ACMP_fpext_5_U. @I [RTGEN-100] Module generated: Test_grp_fu_111_ACMP_fpext_6|Test_grp_fu_111_ACMP_fpext_6_U. @I [RTGEN-100] Module generated: Test_grp_fu_114_ACMP_fpext_7|Test_grp_fu_114_ACMP_fpext_7_U. @I [RTGEN-100] Module generated: Test_grp_fu_118_ACMP_dadddsub_8|Test_grp_fu_118_ACMP_dadddsub_8_U. @I [RTGEN-100] Module generated: Test_grp_fu_123_ACMP_dmul_9|Test_grp_fu_123_ACMP_dmul_9_U. @I [RTGEN-100] Finished creating RTL model for 'Test'. |