集成完后,在SOPCBuilder面板中单独列出该指令,提示需要为指令指令clk,我们将其指定为与CPU相同的clk,此时指令在面板中消失,已经集成进了CPU。
为了测试该指令,我们建立如下SOPC系统。

l 软件调用
建立基于上述硬件系统的软件工程,在软件中分别用自定义指令进行CRC运算以及用纯软件进行CRC运算,比较两个所需的时间。运行结果如下:
+-----------------------------------------------------------+
| Comparison between software and custom instruction CRC32 |
+-----------------------------------------------------------+
System specification
--------------------
System clock speed = 50.0 MHz
Number of buffer locations = 8
Size of each buffer = 256 bytes
Initializing all of the buffers with pseudo-random data
-------------------------------------------------------
Initialization completed
Running the software CRC
------------------------
Completed
Running the optimized software CRC
----------------------------------
Completed
Running the custom instruction CRC
----------------------------------
Completed
Validating the CRC results from all implementations
----------------------------------------------------
All CRC implementations produced the same results
Processing time for each implementation
---------------------------------------
Software CRC = 22.93 ms
Optimized software CRC = 15.01 ms
Custom instruction CRC = 0.35 ms
Processing throughput for each implementation
---------------------------------------------
Software CRC = 0.71 Mbps
Optimized software CRC = 1.09 Mbps
Custom instruction CRC = 47.09 Mbps
Speedup ratio
-------------
Custom instruction CRC vs software CRC = 65.9
Custom instruction CRC vs optimized software CRC = 43.1
Optimized software CRC vs software CRC= 1.5
结果显示自定义指令运行速度是纯软件的65.9倍,是优化后软件的43.1倍,体现出了自定义指令明显的优势。
下面是该自定义指令的源代码
