Shenzhen ZTRON Microelectronics Co., Ltd
Telephone
0755-8299 4126

Software

Python software and hardware collaboration


Many modern system designs are completed by high-level languages such as C/C++ and Python, and these systems are becoming more and more complex, and the calculation volume of the algorithms involved is also increasing. Many algorithms need to be implemented by hardware to meet the real-time requirements of the algorithm. sexual demands. FPGA is a programmable logic device, which is easy to modify, debug, and can complete a large number of operations in parallel, thereby improving the real-time performance of the algorithm, and with the continuous improvement of hardware manufacturing level, FPGA resources are getting larger and larger. , the working frequency is getting higher and higher, making the algorithms that can be completed on it more and more complex. However, the traditional method of separate design of software and hardware, because software and hardware designers use different design languages, has problems such as difficulty in communication between software and hardware designers, resulting in long design cycles. This design method can no longer meet the rapidly growing market requirements. How to quickly convert the algorithms in these system designs into corresponding hardware for realization requires a new software-hardware co-design method. Currently based on C/C++ software and hardware co-design, there is a SystemC standardization organization that has been working on this work, which can convert C/C++ algorithms into corresponding hardware. Python is an easy-to-learn and powerful programming language. Many algorithms are implemented by Python, and many of these algorithms are free and open source. Similar to C/C++, it is necessary to complete the software-hardware co-design based on Python.


1. Development of software and hardware collaborative design based on Python


Due to Python's powerful software and hardware description capabilities, many researchers have done a lot of research on Python's software and hardware co-design in recent years, one of which is called MyHDL Python extension package for software and hardware co-design, using MyHDL to complete a Interface design example. Each of these development tools has its own characteristics, but they have one thing in common, which is the use of Python for software and hardware co-design. The following takes MyHDL as an example to introduce the software-hardware co-design based on Python.


2. Introduction to Python-based MyHDL package


MyHDL adopts the form of Python extension package so that it can support hardware design and simulation, and can automatically convert the software algorithm to the corresponding hardware description using Verilog or VHDL after the simulation results meet the requirements. Since the MyHDL package is a hardware extension based on Python, the following is mainly Briefly introduce some main features of MyH⁃DL hardware.


1. Data type: The int type of standard Python already has many features required for hardware design, but because of many bit operations and processing in hardware design, MyHDL designed the intbv class to provide index and slice operations to support bit operations and processing .


2. Modules, ports and signals: MyHDL uses functions to model hardware modules. My⁃HDL also has signal objects, which are similar to signals in VHDL language. Signals are used as parameters of functions to define the ports of modules.


3. Generator: The generator is a key concept of MyHDL, which is used to establish a concurrency model, corresponding to the always block of Verilog or the process of VHDL.


4. Automatic conversion: Under certain restrictions, MyHDL uses the toVerilog() or toVHDL() function to automatically convert the MyHDL design into the corresponding Veril⁃og or VHDL code. If it meets the requirements of MyHDL's synthesizable subset, MyHDL can be used Complete the hardware-synthesizable code and implement it on FPGA.


5. Simulation: MyHDL supports simulation through the Cosimulation object. For automatically converted Verilog code or VHDL code, MyHDL can also be used as a hardware verification language to perform co-simulation and verification on the converted Verilog or VHDL.


3. Advantages of hardware design using MyHDL


Verilog and VHDL are the current mainstream hardware design languages, but using Python-based MyHDL for hardware design also has many advantages, making it another good choice for designers, especially beginners in hardware design.


1. Low cost of using MyHDL: MyHDL is free and open source. You can also use a large number of free tools such as ICArus, IVERILOG simulation tools, and GTKWAVE to view simulation waveforms in the tool chain designed using MyHDL, thereby reducing design costs.


2. Use advanced software development technology in hardware design: Since Python itself is a software development language, advanced methods of modern software development such as rapid application development and test-driven development are all reflected in Python. Design and software development have a certain similarity, and MyHDL can use the latest software development technology.


3. Software and hardware design can use the same development environment: Python is an ideal language for algorithm implementation. Many algorithms are implemented by Python. Usually, the software and hardware implementation of the algorithm is implemented by different engineers. Software engineers use Python, and hardware engineers use Python. General-purpose hardware description languages, such as Verilog or VHDL, have a gap between hardware engineers and software engineers. With MyHDL, algorithm design, simulation and verification can be realized in the same Python environment.


4. Other advantages: For designers who do not have certain experience in hardware design, usually using Verilog design will confuse blocking and non-blocking assignments, do not know the symbolic operation of Verilog, use VHDL to design and do not understand the signal concept of VHDL, they will feel that VHDL Type and bit width conversion is cumbersome, but if the Python-based MyHDL package is used as the design language, these will not be a problem.


4. Software and hardware design process based on Python


In modern system design, software engineers use high-level languages such as Python, while hardware system design mostly uses Verilog and VHDL hardware description languages. On how to map the software described by Python to corresponding hardware, the communication between software and hardware developers exists. There is a natural gap, and using Python for hardware-software co-design can solve this problem. The process of software-hardware co-design based on Python is shown in Figure 1.


Firstly, Python is used for system design, and then software and hardware are divided according to system performance requirements. The part with relatively high system performance requirements is implemented by hardware in the form of Python's MyHDL extension package, and Python is used to write a hardware test platform. If the test simulation does not meet the system design requirements, software and hardware can be re-divided. If the test simulation result is incorrect, it can be re-modified. After the simulation is passed, the MyHDL extension package can be used to automatically convert Python to Verilog code. At this time, the Python test platform can be mixed with the converted Verilog code without modification. If the simulation is passed, the hardware can be synthesized, downloaded, and tested. phase, which is the same as the traditional hardware design process.


epilogue


From the above analysis, it can be seen that MyHDL based on Python is not only a software-hardware co-design method, but also an extension package of Python, so that the entire development process uses only one Python language, and it is very convenient to quickly convert a software algorithm Its corresponding hardware realizes, thus completes a software and hardware system design. Due to the limitations of Python's current synthesizable subset and its own development stage, the software and hardware design based on Python is mainly used for system modeling, and there are not many applications for chip design. Some researchers Comparing the implementation of MyHDL and traditional hardware design languages, the advantages for small-scale applications are not obvious. However, as the algorithms of modern systems become more and more complex, and the scale of the system continues to increase, the advantages of using Python for software and hardware collaborative design compared to traditional software and hardware design methods will be reflected. System design, simulation, verification The speed will be greatly improved, and products using Python for system design can enter the market faster. With the development of Python-based system design methods and tools, the software-hardware co-design method based on Python will have broad application prospects.

  • TOP