Verification method for interaction between hardware accelerator and python

Through the simulation and result comparison of python script automation hardware accelerator, the problem of low manual comparison efficiency and error prone in the existing technology is solved, and the automated verification process is realized, efficiency and accuracy are improved, and it is suitable for complex verification scenarios.

CN120196522APending Publication Date: 2025-06-24JIANGSU HUACHUANG MICROSYSTEM CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510063274.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-15
Publication Date
2025-06-24

AI Technical Summary

Technical Problem

In the existing hardware accelerator verification technology, manual comparison test results are inefficient, prone to errors, and cannot compare complex forms of simulation content, so the simulation process is time-consuming and uncontrollable.

Method used

Automatically start the hardware accelerator simulation through a python script, automatically grab the input data, start the python equivalent program for synchronous simulation, automatically grab the simulation test results, and automatically compare the simulation results of the hardware accelerator with the synchronous simulation results of the python equivalent program.

Benefits of technology

The automated hardware accelerator verification process is realized, which improves efficiency, reduces the error rate, can compare complex forms of simulation content, and greatly speed up the verification speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120196522A_ABST
    Figure CN120196522A_ABST
Patent Text Reader

Abstract

The invention discloses a verification method for interaction between a hardware accelerator and python. The verification method comprises the steps that S1, a python script starts the hardware accelerator for simulation; the python script reads a signal of an input interface of the hardware accelerator, obtains input data and writes the input data into a document 1; running a python equivalent program to carry out synchronous simulation; s2, writing a synchronous simulation result into a document 2; judging whether the simulation of the hardware accelerator is finished or not by using a python script, if so, monitoring an output interface signal of the hardware accelerator in real time, capturing a simulation result and writing the simulation result into a document 3; if not, re-judging whether the simulation of the hardware accelerator is finished or not; and S3, result comparison is carried out, and verification is completed. According to the method, the hardware accelerator simulation and the python equivalent program are automatically started through the python script, two results can be quickly compared, manual operation is not needed, waiting for software simulation is also omitted, and efficiency is greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of hardware accelerator verification, and particularly relates to a verification method for the interaction between a hardware accelerator and Python. Background Art

[0002] With the continuous growth of computing requirements, especially the increasing demands for high-performance computing in fields such as artificial intelligence, machine learning, and big data processing, traditional general-purpose processors such as CPUs are gradually difficult to meet the needs of these applications. For this reason, hardware accelerators, such as graphics processing units, field-programmable gate arrays, application-specific integrated circuits, etc., have received extensive attention due to their high efficiency and parallel processing capabilities in specific tasks. Hardware accelerators can significantly improve the computing speed, reduce power consumption, and optimize resource utilization, becoming an indispensable part of modern computing systems.

[0003] Although hardware accelerators bring many advantages, their design complexity has also increased accordingly, especially facing huge challenges in the verification stage. In a server, when a hardware accelerator interacts with a Python script, the process for verifying whether the simulation results of the hardware accelerator are correct is as follows: manually call a command script in the server to start the hardware accelerator for testing. After waiting for the simulation to end, use the UART serial port of the hardware accelerator to print the test results; then manually start a software simulation test program. After waiting for the test to end, print the test results through the serial port, and manually compare the simulation test results of the hardware accelerator with the results of the software simulation program.

[0004] However, the above measures have at least the following three problems: 1) Low efficiency and slow speed of manual comparison; 2) The applicable scenario range of the simulation is small, and manual comparison cannot process simulation contents in complex forms such as picture encoding / decoding and FFT operations; 3) When using software simulation, it is also necessary to wait for the test results of the software simulation program, and the time consumption of the simulation process cannot be guaranteed. Summary of the Invention

[0005] Aiming at the above three problems, the purpose of the present invention is to propose a verification method for the interaction between a hardware accelerator and Python, which automatically starts the hardware accelerator simulation through a Python script, automatically captures input data, starts a Python equivalent program, then automatically captures the simulation test results of the hardware accelerator, and automatically compares them with the test results of the Python equivalent program, so as to solve the problems of low efficiency, easy error, and inability to compare complex results in the existing hardware accelerator verification technology.

[0006] It is achieved through the following technical solutions: First, a verification method for the interaction between a hardware accelerator and Python is proposed, including the following steps: S1. Start a Python script, which automatically starts the hardware accelerator for simulation; the Python script then reads the signals of the input interface of the hardware accelerator in real time to obtain input data, and writes the input data into Document 1; based on the input data in Document 1, run the Python equivalent program for synchronous simulation; S2. Write the synchronous simulation results after the Python equivalent program in step S1 completes synchronous simulation into Document 2; use the Python script in step S1 to determine whether the simulation of the hardware accelerator has ended. If so, monitor the output interface signal of the hardware accelerator in real time, capture the simulation results and write them into Document 3; if not, re-determine whether the simulation of the hardware accelerator has ended; S3. Compare the simulation results in Document 3 and the synchronous simulation results in Document 2 in step S2 to complete the verification.

[0007] Using the Python script to automatically start the hardware accelerator simulation and capture the simulation results eliminates the tediousness of manual operations and improves efficiency; at the same time, the Python equivalent program is also used for synchronous simulation, and then the results are compared to determine whether the verification is correct. There is no need for manual use of simulation software, nor waiting for the simulation software to end, which greatly improves the verification speed.

[0008] Preferably, a log file is set in step S1 to record each operation of the Python script, the hardware accelerator, and the Python simulation program. Setting the log file can record each operation in an orderly manner, which is convenient for subsequent positioning and analysis.

[0009] Preferably, when comparing the results in step S3, if the comparison results are consistent, stop the operation; if the comparison results are inconsistent, query each operation in the log file for error correction. When the comparison results are incorrect, the location of the error can be analyzed based on the operations recorded in the log file.

[0010] Secondly, an electronic device is proposed, including a coprocessor and a memory. The memory is used to store the Python equivalent program or the Python script in any one of the above methods, and the coprocessor is used to interact with the memory to implement the steps of any one of the above methods.

[0011] In addition, a readable storage medium is also proposed, which is used to store the Python equivalent program or the Python script in any one of the above methods.

[0012] The beneficial effects of the present invention compared with the prior art are: The technical solution of the present invention is that the Python script can automatically start the hardware accelerator simulation without manual startup of the hardware accelerator and simulation software, simplifying the hardware accelerator simulation process. It also uses a Python equivalent program to replace the simulation software for verification and automatically captures the output data through the Python script, eliminating the need to wait for the test results to be output through the UART serial port, which is more convenient and speeds up the verification. In addition, the Python script automatically compares the simulation results of the hardware accelerator with the synchronous simulation results of the Python equivalent program, with higher efficiency, lower error rate, and applicability to complex verification scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] Figure 1 It is a flowchart of a verification method for the interaction between a hardware accelerator and Python. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0014] The technical solutions in the embodiments of the present invention will be described in detail below with reference to the accompanying drawings in the embodiments of the present invention.

[0015] As Figure 1 shown, it is a flowchart of a verification method for the interaction between a hardware accelerator and Python. The Python script automatically starts the hardware accelerator simulation, automatically captures the input data, starts the Python equivalent program, then automatically captures the hardware accelerator simulation test results, and automatically compares them with the Python equivalent program test results, solving the problems of low efficiency, easy error, and inability to compare complex results in the existing hardware accelerator verification technology. The method specifically includes the following steps: S1. Start the Python script in the server. The Python script can automatically start the corresponding command script of the hardware accelerator in the server, thereby automatically starting the hardware accelerator to start the simulation. The Python script then reads the signals of the input interface of the hardware accelerator in real time, obtains the input data, writes the input data into Document 1, and runs the Python equivalent program for synchronous simulation based on the input data in Document 1.

[0016] In this embodiment, a log file can be set in step S1 to record each operation of the Python script, the hardware accelerator, and the Python simulation program. The log file can be stored and used using an SSD solid-state drive or an HDD local hard disk drive or a NAS network-attached storage. Setting the log file can orderly record each operation and facilitate subsequent positioning and analysis.

[0017] S2. Write the synchronous simulation result after the synchronous simulation of the Python equivalent program in step S1 into Document 2; use the Python script in step S1 to determine whether the simulation of the hardware accelerator has ended. If so, monitor the output interface signal of the hardware accelerator in real time, capture the simulation result and write it into Document 3; if not, re-determine whether the simulation of the hardware accelerator has ended.

[0018] In this embodiment, the Python equivalent program is an equivalent program written in Python. Its function is to replace the simulation test of the simulation software. At the same time, it does not need to wait for the hardware accelerator simulation to complete before starting to run. Instead, it obtains the input data, so as to perform synchronous simulation with the hardware accelerator, reducing the waiting time and effectively improving the verification speed. Taking the fft simulation operation of the one-dimensional discrete Fourier transform by the hardware accelerator as an example, at this time, the Python equivalent program can use the numpy library as the function library and use scipy.fft for equivalent simulation. scipy.fft is a module in the scipy library, which can be used to perform the fast Fourier transform and its inverse transform. scipy is a powerful library for scientific computing in Python, and it can be built on top of the NumPy library to perform equivalent simulation. The actual databases and modules used by the Python equivalent program need to be selected according to the actual simulation content of the hardware accelerator. Here is just an example to prove the feasibility of the solution.

[0019] S3. Compare the simulation results in Document 3 and the synchronous simulation results in Document 2 in step S2 to complete the verification.

[0020] In this embodiment, when comparing the results in step S3, if the comparison results are consistent, stop the operation; if the comparison results are inconsistent, the staff can query each operation in the log file for error correction and find abnormal operations, such as abnormal operation time or abnormal data status before and after the operation.

[0021] Secondly, an electronic device is proposed, including a coprocessor and a memory. The memory is used to store the Python equivalent program or Python script of any one of the above methods, and the coprocessor is used to interact with the memory to implement the steps of the method of any one of the above methods.

[0022] In addition, a readable storage medium is also proposed, and this readable storage medium is used to store the Python equivalent program or Python script of any one of the above methods.

[0023] In summary, the Python script in the present invention can automatically start the hardware accelerator simulation without manual startup of the hardware accelerator and simulation software, simplifying the hardware accelerator simulation process. It also uses a Python equivalent program to replace the simulation software for verification and automatically captures the output data through the Python script, eliminating the need to wait for the test results to be output through the UART serial port, which is more convenient and speeds up the verification. In addition, it automatically compares the simulation results of the hardware accelerator with the synchronous simulation results of the Python equivalent program through the Python script, with higher efficiency, lower error rate, and applicability to complex verification scenarios, showing significant progressiveness.

[0024] The above embodiments are only used to illustrate the technical idea of the present invention and cannot be used to limit the protection scope of the present invention. Any changes made on the basis of the technical solution according to the technical idea proposed by the present invention fall within the protection scope of the present invention.

Claims

1. A verification method for hardware accelerator and Python interaction, characterized in that: The steps include: S1, start the python script, the python script automatically starts the hardware accelerator for simulation; the python script then reads the signal of the input interface of the hardware accelerator in real time, obtains input data, and writes the input data into document 1; Based on the input data in Document 1, run the Python equivalent program for synchronous simulation; S2, write the synchronous simulation results after the Python equivalent program in step S1 completes the synchronous simulation into document 2; Use the python script in step S1 to determine whether the simulation of the hardware accelerator has ended. If so, monitor the output interface signal of the hardware accelerator in real time, capture the simulation results and write them into document 3; If not, re-determine whether the simulation of the hardware accelerator has finished running; S3. In the python script, compare the simulation results of document 3 in step S2 with the synchronous simulation results in document 2 to complete the verification.

2. A verification method for interaction between a hardware accelerator and Python according to claim 1, characterized in that: In step S1, a log file is provided to record each operation of the python script, the hardware accelerator and the python simulation program.

3. A verification method for interaction between a hardware accelerator and Python according to claim 2, characterized in that: When the results are compared in step S3, if the comparison results are consistent, the operation is stopped; if the comparison results are inconsistent, each operation in the log file is queried for error correction.

4. An electronic device, characterized in that: The method comprises a coprocessor and a memory, wherein the memory is used to store a Python equivalent program or a Python script as claimed in any one of claims 1 to 3, and the coprocessor is used to interact with the memory to implement the steps of the method as claimed in any one of claims 1 to 5.

5. A readable storage medium, characterized in that: The readable storage medium is used to store a Python equivalent program or a Python script as claimed in any one of claims 1 to 3.