Cross-platform code transplantation method and device, equipment and storage medium
Through the cross-platform code migration method, the problems of ASIC code migration complexity and resource limitation in FPGA prototype verification are solved, and the automated, accurate and simplified code migration process is realized.
Patent Information
- Application Number
- CN202510100254.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-22
- Publication Date
- 2025-05-06
AI Technical Summary
In FPGA prototype verification, ASIC code needs to be ported from the physical structure based on the standard unit library to the lookup table-based FPGA structure, and special processing is required according to the limitations of the prototype verification platform, resulting in the complex code porting of single-chip FPGAs with limited resources cannot meet the needs of prototype verification.
It provides a cross-platform code migration method, which generates target files by reading and parsing the first platform code file, identifying and processing file paths, directories, comments and file types, and generates constraint files based on the annotations added by the user, and finally porting the target files and constraint files to the second platform.
Automatic code migration from the first platform to the second platform is realized, saving time, ensuring the accuracy of the migration, avoiding omissions, and simplifying constraint settings through annotation methods.
Smart Images

Figure CN119938139A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of prototype verification technology, and in particular to a cross-platform code transplantation method, device, equipment and storage medium. Background Art
[0002] FPGA (Field-Programmable Gate Array) prototype verification is currently a mainstream and mature chip verification method. The function of ASIC (Application Specific Integrated Circuit) is verified by transplanting ASIC code into FPGA, and the driver development can begin after the basic function of the chip is verified. At present, the design of ASIC is becoming larger and more complex. In many cases, the resources of a single FPGA are limited and can no longer meet the needs of prototype verification. Therefore, a verification method using multiple FPGAs working together has emerged. The prototype verification platform provides a transplantation method for integrating a single FPGA IP module into a system of multiple FPGA modules. Therefore, it is necessary to transplant the ASIC code to the prototype verification platform.
[0003] When using the FPGA prototyping platform to verify the ASIC design, the ASIC design must first be converted to the FPGA design. ASIC is based on the standard cell library, and FPGA is based on the lookup table. Due to the difference in physical structure, the ASIC code needs to be modified before it can be transplanted to the FPGA. In addition, for the prototype verification platform, some special processing is also required when transplanting the code according to the limitations of the prototype verification platform. And, for FPGA, constraints are also a very important part. Constraints can make the project more smoothly complete the synthesis and implementation, and can ensure the normal function of the project.
[0004] Therefore, in view of the shortcomings of the prior art solutions, the present invention provides a cross-platform code transplantation method. Summary of the invention
[0005] Based on this, it is necessary to provide a cross-platform code transplantation method, device, equipment and storage medium to address the above technical problems.
[0006] On the one hand, a cross-platform code transplantation method is provided, the method comprising reading a first platform code file, wherein the first platform code file comprises a first file path and a file path corresponding to a file list; reading the file list according to the file path corresponding to the file list, parsing the file list, and obtaining a plurality of second file paths included in the file list; writing the first file path and the plurality of second file paths into a blank file to obtain a first file; traversing the file paths in the first file, processing the first file according to a second platform code file template to obtain a target file, and outputting the target file; receiving a target file annotated by a user, and generating a constraint file corresponding to the target file according to the annotation; and transplanting the constraint file and the target file to the second platform.
[0007] Optionally, parsing the file list to obtain multiple second file paths included in the file list includes: detecting each second file path in turn to determine whether the second file path includes the file path corresponding to the sub-file list; if it includes the file path corresponding to the sub-file list, reading the file list according to the file path corresponding to the file list, parsing the sub-file list to obtain multiple third file paths included in the sub-file list.
[0008] Optionally, the first file is processed according to the second platform code file template to obtain the target file, including: identifying the file directory, file comments and file type of the file path in the first file in sequence according to the second platform code file template; processing the file directory, file comments and file type of the file path in the first file to obtain the target file.
[0009] Optionally, the processing of the file directory, file comment and file type of the file path in the first file to obtain the target file includes: traversing the file path in the first file, detecting the file directory in each file path, comparing the file directory with a first preset identifier, determining whether the file directory corresponding to the file path is the first directory or the second directory, storing the file path corresponding to the first directory in a first partition of the first file, and storing the file path corresponding to the second directory in a second partition of the first file to obtain a second file, wherein the first preset identifier is a directory identifier; traversing the file path in the second file, detecting whether there is a second preset identifier in the file path, and if the second preset identifier exists, deleting the content corresponding to the second preset identifier to obtain a third file, wherein the second preset identifier is an identifier corresponding to the comment line; traversing the file path in the third file, detecting the file type in each file path, comparing each file type with a third preset identifier, and when the file type and the third preset identifier are the same, adding a preset code to the file path corresponding to the file type to obtain the target file, wherein the third preset identifier is a file extension.
[0010] Optionally, the receiving a target file with comments added by a user and generating a constraint file corresponding to the target file based on the comments include: receiving a target file with comments added by a user and obtaining a top-level file in the target file with comments added; traversing each port signal of the top-level file and generating a constraint statement corresponding to the port signal based on the comments of the port signal; and generating the constraint file based on the constraint statement.
[0011] Optionally, traversing each port signal of the top-level file and generating a constraint statement corresponding to the port signal according to the comments of the port signal includes: determining the type and constraint target of the port signal according to the comments of the port signal; and generating a constraint statement corresponding to the port signal according to the type and constraint target of the port signal.
[0012] Optionally, generating a constraint statement corresponding to the port signal according to the type and constraint target of the port signal includes: when the port signal is a clock signal, generating a clock frequency constraint corresponding to the clock signal according to the clock frequency of the clock signal; generating an asynchronous clock constraint corresponding to the clock signal according to user requirements; determining a global clock manager corresponding to the clock signal according to the clock frequency of the clock signal, and generating a generation source constraint corresponding to the clock signal according to the global clock manager; generating a clock constraint statement corresponding to the clock signal according to the clock frequency constraint, the asynchronous clock constraint and the generation source constraint.
[0013] On the other hand, a cross-platform code transplantation device is provided, which includes: a reading module for reading a first platform code file, wherein the first platform code file includes a first file path and a file path corresponding to a file list; a parsing module for reading the file list according to the file path corresponding to the file list, parsing the file list, and obtaining multiple second file paths included in the file list; a writing module for writing the first file path and the multiple second file paths into a blank file to obtain a first file; a processing module for traversing the file paths in the first file, processing the first file according to a second platform code file template to obtain a target file, and outputting the target file; a constraint module for receiving a target file annotated by a user, and generating a constraint file corresponding to the target file according to the annotation; and a transplantation module for transplanting the constraint file and the target file to the second platform.
[0014] On the other hand, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program: reading a first platform code file, wherein the first platform code file comprises a first file path and a file path corresponding to a file list; reading the file list according to the file path corresponding to the file list, parsing the file list, and obtaining a plurality of second file paths included in the file list; writing the first file path and the plurality of second file paths into a blank file to obtain a first file; traversing the file paths in the first file, processing the first file according to a second platform code file template to obtain a target file, and outputting the target file; receiving a target file annotated by a user, and generating a constraint file corresponding to the target file according to the annotation; and transplanting the constraint file and the target file to the second platform.
[0015] On the other hand, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented: reading a first platform code file, wherein the first platform code file includes a first file path and a file path corresponding to a file list; reading the file list according to the file path corresponding to the file list, parsing the file list, and obtaining multiple second file paths included in the file list; writing the first file path and the multiple second file paths into a blank file to obtain a first file; traversing the file paths in the first file, processing the first file according to a second platform code file template to obtain a target file, and outputting the target file; receiving a target file with comments added by a user, and generating a constraint file corresponding to the target file according to the comments; and transplanting the constraint file and the target file to the second platform.
[0016] The above-mentioned cross-platform code transplantation method, device, equipment and storage medium, the method includes: reading a first platform code file, wherein the first platform code file includes a first file path and a file path corresponding to a file list; reading the file list according to the file path corresponding to the file list, parsing the file list, and obtaining multiple second file paths included in the file list; writing the first file path and the multiple second file paths into a blank file to obtain a first file; traversing the file paths in the first file, processing the first file according to a second platform code file template to obtain a target file, and outputting the target file; receiving a target file annotated by a user, and generating a constraint file corresponding to the target file according to the annotation; transplanting the constraint file and the target file to the second platform; in this way, the code transplantation from the first platform to the second platform is automatically completed, which can save time, ensure the accuracy of the transplantation, and avoid omissions. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 A schematic diagram of a process of a cross-platform code transplantation method in one embodiment;
[0018] Figure 2 A schematic diagram of a target file generation process of a cross-platform code transplantation method in one embodiment;
[0019] Figure 3 A schematic diagram of a signal constraint flow chart of a cross-platform code transplantation method in one embodiment;
[0020] Figure 4 A schematic diagram of a prototype verification process of a cross-platform code transplantation method in one embodiment;
[0021] Figure 5 is a structural block diagram of a cross-platform code transplantation device in an embodiment;
[0022] Figure 6 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0023] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0024] It should be understood that in the description of the present application, unless the context clearly requires otherwise, words such as "include", "comprises", and the like throughout the specification should be interpreted as including rather than being exclusive or exhaustive; that is, as including but not limited to.
[0025] It should also be understood that the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of this application, unless otherwise specified, "plurality" means two or more.
[0026] It should be noted that the terms "S1", "S2", etc. are only used for the purpose of describing the steps, and do not specifically refer to the order or sequence, nor are they used to limit the present application. They are only for the convenience of describing the method of the present application, and cannot be understood as indicating the order of the steps. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in this field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection required by the present application.
[0027] In one embodiment, Figure 1 As shown, a cross-platform code transplantation method is provided, comprising the following steps:
[0028] S101: Read a first platform code file, wherein the first platform code file includes a first file path and a file path corresponding to a file list.
[0029] Here, the first platform code file may be an ASIC code file. The ASIC code file includes multiple file paths. The file path may include directory name, file name, extension name, comment and other contents.
[0030] The first file path is a file path corresponding to other file types in the first platform code file except the file list, such as a header file, a source file, etc.
[0031] S102: Read the file list according to the file paths corresponding to the file list, parse the file list, and obtain a plurality of second file paths included in the file list.
[0032] Among them, the first file includes a first file path and a second file path, wherein the first file path is the file path in the integrated circuit code file, which may include the file path corresponding to the header file, the file path corresponding to the source file, and the file path corresponding to the file list, etc., and the second file path is the sub-file path after the file path corresponding to the file list is expanded.
[0033] Specifically, the file list is expanded to obtain all file paths under the file list.
[0034] S103: Write the first file path and the multiple second file paths into a blank file to obtain a first file.
[0035] Here, the first file includes a first file path and a second file path, wherein the first file path is the file path in the first platform code file, which may include the file path corresponding to the header file, the file path corresponding to the source file, and the file path corresponding to the file list, etc. The second file path is the sub-file path after the file path corresponding to the file list is expanded.
[0036] Specifically, the file list is expanded to obtain all file paths under the file list, and the file paths corresponding to all file lists and the file lists corresponding to other file types are sequentially written into the same file to obtain the first file.
[0037] S104: traverse the file path in the first file, process the first file according to the second platform code file template to obtain a target file, and output the target file.
[0038] Here, the second platform code file template may be a code file template that can be processed by the second platform, such as a file format that can be processed by the second platform, and the target file includes a file path that can be identified and processed by the second platform.
[0039] Furthermore, the second platform may be a HAPS80 (High-Performance ASIC Prototyping System 80) prototype verification platform.
[0040] Specifically, each file path in the first file is detected in turn, and when content that cannot be processed by the second platform is detected, the file path is processed into a file path that can be recognized by the second platform, thereby obtaining the target file.
[0041] S105: receiving a target file annotated by a user, and generating a constraint file corresponding to the target file according to the annotation.
[0042] Here, constraints may include not-null constraints, unique constraints, primary key constraints, check constraints, default constraints, and foreign key constraints, etc.
[0043] Specifically, the user annotates the code in the target file to obtain the target file with annotations, and generates corresponding constraint statements according to the annotations.
[0044] S106: Porting the constraint file and the target file to the second platform.
[0045] It should be noted that this application can save time and ensure the accuracy of the migration through automatic migration without omissions. Automatically setting constraints through annotations not only saves time, but is also simple and easy to manage.
[0046] In some specific implementations, parsing the file list to obtain multiple second file paths included in the file list includes:
[0047] Detecting each second file path in turn to determine whether the second file path includes the file path corresponding to the sub-file list;
[0048] If the file path corresponding to the sub-file list is included, the file list is read according to the file path corresponding to the file list, and the sub-file list is parsed to obtain multiple third file paths included in the sub-file list.
[0049] Here, the third file path is a file path obtained after the file list in the second file path is expanded.
[0050] Specifically, it is identified whether a sub-file list exists for a sub-file in each file path. If so, the sub-file list is expanded to obtain at least one sub-file path, and the sub-file path corresponding to the sub-file is written into a blank file.
[0051] In one embodiment, when the third file path also includes the file path corresponding to the file list, it is also expanded and written into a blank file until the file path does not include the file path corresponding to the file list.
[0052] In this way, all file lists are expanded into one file so that the second platform can process it.
[0053] In some specific implementations, the processing of the first file according to the second platform code file template to obtain the target file includes:
[0054] According to the second platform code file template, sequentially identifying a file directory, a file comment, and a file type of a file path in the first file;
[0055] The file directory, file comment and file type of the file path in the first file are processed to obtain the target file.
[0056] Here, the second platform code file template may be a standard file type, a standard file format, or the like.
[0057] In some specific implementations, the processing of the file directory, file comment and file type of the file path in the first file to obtain the target file includes:
[0058] Traversing the file paths in the first file, detecting the file directories in each file path, comparing the file directories with a first preset identifier, determining whether the file directory corresponding to the file path is the first directory or the second directory, storing the file path corresponding to the first directory in a first partition of the first file, and storing the file path corresponding to the second directory in a second partition of the first file, to obtain a second file, wherein the first preset identifier is a directory identifier;
[0059] Traversing the file path in the second file, detecting whether a second preset identifier exists in the file path, and if the second preset identifier exists, deleting the content corresponding to the second preset identifier to obtain a third file, wherein the second preset identifier is an identifier corresponding to the comment line;
[0060] Traverse the file paths in the third file, detect the file type in each file path, compare each file type with a third preset identifier, and when the file type and the third preset identifier are the same, add a preset code to the file path corresponding to the file type to obtain a target file, wherein the third preset identifier is a file extension.
[0061] Here, the first identifier may be include and source, the second identifier may be a comment symbol, such as double slashes, and the third identifier may be a file extension, such as .hdl.
[0062] Among them, when include is found in the file directory retrieved in the file path, the file path is stored in inclist, and the file corresponding to the file path is the header file. When source is found in the file directory retrieved in the file path, the file path is stored in srclist, and the file corresponding to the file path is the RTL (Register transfer Level) code file.
[0063] In one embodiment, when a comment symbol is found in the retrieved file path, the comment symbol may be replaced with other comment symbols that can be processed by the second platform, such as a pound sign.
[0064] Specifically, when the first identifier is recognized, the file path is classified into two categories; when the second identifier is recognized, the comment line of the file path corresponding to the second identifier is deleted; when the third identifier is recognized, a preset primitive is added before the file path corresponding to the third identifier. Assuming that the second platform is the HAPS80 prototype verification platform, the file path in the first file is traversed, and according to the include or source in the file path, the content corresponding to the file is identified as a header file or an RTL file, and the header file and the RTL file are stored separately to obtain the second file after the file classification, the file path in the second file is traversed, and it is identified whether there are double slashes in the file path. If so, the comment line is deleted to obtain the third file after the comment line is deleted, and the file path in the third file is traversed to identify whether the file extension in the file path is .hdl. If so, the primitive "-type Verilog" is added before the file path.
[0065] For example, Figure 2 Schematic diagram of the process of generating a target file in the embodiment of the present application, such as Figure 2 As shown, the target file generation process includes: S201: ASIC file list; S202: expand all file lists in one file; S203: automatically identify header files and RTL files and separate them; S204: automatically identify comment lines and delete them; S205: automatically identify .hdl files and add primitives; S206: output the required srclist and inclist.
[0066] In this way, the first platform code can be automatically processed into a code that can be recognized and processed by the second platform through a script.
[0067] In some specific implementations, the receiving of a target file annotated by a user and generating a constraint file corresponding to the target file according to the annotations include:
[0068] Receive a target file annotated by a user, and obtain a top-level file in the target file annotated by a user;
[0069] Traversing each port signal of the top-level file, and generating a constraint statement corresponding to the port signal according to the annotation of the port signal;
[0070] The constraint file is generated according to the constraint statement.
[0071] Here, the top-level file includes the input and output port information between each functional module and the external devices of the FPGA.
[0072] Specifically, according to the user's comments, a corresponding constraint statement is generated and written into the constraint file, and the constraint file is obtained by combining the constraint statements of each port signal. Exemplarily, when the port signal is identified as a reset signal, the following constraint can be set for the reset signal:
[0073] assign_port{RESETN}-trace{mb1.A_USER_RESETN}
[0074] In this way, by constraining the port signals, it can be ensured that the design can meet the predetermined timing, performance, and physical layout requirements during actual operation.
[0075] In some specific implementations, traversing each port signal of the top-level file and generating a constraint statement corresponding to the port signal according to the annotation of the port signal includes:
[0076] Determining the type and constraint target of the port signal according to the annotation of the port signal;
[0077] A constraint statement corresponding to the port signal is generated according to the type and constraint target of the port signal.
[0078] Here, the types of port signals may include clock signals, reset signals, external interface signals of DDR (Double Data Rate Synchronous Dynamic Random Access Memory), PCIe (peripheral component interconnect express, high-speed serial computer expansion bus standard) related signals, etc.
[0079] Among them, the constraint target can be the clock frequency and the corresponding position of the port signal. For example, when the port signal is the external interface signal of DDR, the corresponding constraint statement is used to connect the DDR external interface signal to the DDR daughter board; when the port signal is a PCIe related signal, the corresponding constraint statement is used to connect the PCIe related signal to the PCIe port; when the port signal is a GPIO signal, the corresponding constraint statement is used to constrain the GPIO signal to the corresponding position.
[0080] For example, the following code is found in the top-level file:
[0081] input GPIO1; / *other TEST[0]* /
[0082] According to the comment line, the constraint content is obtained, and the input signal GPIO1 is constrained to the TEST[0] port on the FPGA. The constraints are automatically added as follows:
[0083] assign_port{GPIO1}-trace{TEST[0]}
[0084] In some specific implementations, generating a constraint statement corresponding to the port signal according to the type of the port signal and the constraint target includes:
[0085] When the port signal is a clock signal, generating a clock frequency constraint corresponding to the clock signal according to the clock frequency of the clock signal;
[0086] Generate asynchronous clock constraints corresponding to the clock signal according to user requirements;
[0087] Determine a global clock manager corresponding to the clock signal according to the clock frequency of the clock signal, and generate a generation source constraint corresponding to the clock signal according to the global clock manager;
[0088] A clock constraint statement corresponding to the clock signal is generated according to the clock frequency constraint, the asynchronous clock constraint and the generation source constraint.
[0089] Specifically, according to the content of the comment statement, determine that the port signal is a clock signal, and according to the frequency content in the comment statement, constrain the clock frequency, set the clock and other clocks as asynchronous clocks, and constrain the source of the clock. For example, assuming that the second platform is HAPS80, mark this signal as a clock and the clock frequency by commenting after the clock signal:
[0090] input DesignClk; / *clock 5MHz* /
[0091] When the annotation is retrieved and the port signal is determined to be a clock signal, add a constraint statement:
[0092] create_clock-name DesignClk-period 200[get_ports DesignClk]
[0093] Among them, DesignClk is the name of the clock port, -period 200 is the clock period in nanoseconds, corresponding to a clock frequency of 5 MHz. Different clocks have different clock periods.
[0094] Set this clock to be asynchronous with other clocks and add constraint statements:
[0095] set_clock_groups-asynchronous-group{DesignClk}
[0096] After constraining the clock frequency, you need to constrain the source of the clock. In HAPS80, most clocks are generated by GCLK (global colock). HAPS80 has 6 pairs of GCLKs, and the frequency of each pair of GCLKs must be the same, that is, GCLK1 = GCLK7, GCLK2 = GCLK8, and so on. According to the comments, the frequency of each clock can be automatically constrained and allocated according to the clock frequency, so that each pair of GCLKs has the same frequency. Add the constraint statement as follows:
[0097] net_attribute{DesignClk}-function{GCLK}-diffsingle-is_clock 1
[0098] assign_global_net{DesignClk}{mb1.GCLK1}
[0099] For example, Figure 3 Schematic diagram of the signal constraint flow in the embodiment of the present application. Figure 3 As shown, the signal constraint process in the present application includes: traversing all port signals, determining whether the signal is a clock signal, a reset signal or other signal; when the port signal is a clock signal, setting the clock frequency, setting the asynchronous clock, and setting the GCLK; when the port signal is a reset signal, connecting to the reset of HAPS80; when the port signal is other signals, specifically determining whether the signal is a specific signal such as DDR, GPIO, PCIe, etc., and assigning it to the corresponding port.
[0100] In this way, the timing behavior of the design is specified through timing constraints to meet the required timing requirements.
[0101] In some specific implementations, the step of porting the constraint file and the target file to the second platform includes:
[0102] determining a transmission rate according to a data volume of a transplant file, a complexity of the transplant file, a number of external interfaces, a network bandwidth, and a processing rate of the second platform, wherein the transplant file includes the constraint file and the target file;
[0103] The constraint file and the target file are transplanted to the second platform at the transmission rate.
[0104] In this way, by generating a transmission rate and controlling the rate of file migration, we can avoid the situation where the migration quality is reduced due to too fast a transmission speed, so that the migrated code cannot work properly. We can also avoid the situation where the subsequent prototype verification is affected due to too slow a transmission speed.
[0105] In one embodiment, Figure 4 Schematic diagram of the prototype verification process in the embodiment of the present application, such as Figure 4 As shown, the prototype verification process includes: S401: resource and performance evaluation; S402: simulator platform selection; S403: multi-chip partitioning; S404: source code migration; S405: file migration adapted to HAPS80; S406: HAPS80 constraint setting; S407: logic synthesis and physical implementation; S408: verification of the transplanted design; S409: system integration and functional verification; after executing S408 and / or S409, return to execute S403.
[0106] It should be understood that although Figure 1-4 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1-4 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0107] In one embodiment, Figure 5 As shown, a cross-platform code transplantation device is provided, which includes: a reading module 501, used to read a first platform code file, wherein the first platform code file includes a first file path and a file path corresponding to a file list; a parsing module 502, used to read the file list according to the file path corresponding to the file list, parse the file list, and obtain multiple second file paths included in the file list; a writing module 503, writing the first file path and the multiple second file paths into a blank file to obtain a first file; a processing module 504, used to traverse the file paths in the first file, process the first file according to a second platform code file template, obtain a target file, and output the target file; a constraint module 505, used to receive a target file annotated by a user, and generate a constraint file corresponding to the target file according to the annotation; a transplantation module 506, used to transplant the constraint file and the target file to the second platform.
[0108] As a preferred implementation manner, in an embodiment of the present application, the parsing module 502 is specifically used to: detect each second file path in turn, and determine whether the second file path includes the file path corresponding to the sub-file list; if it includes the file path corresponding to the sub-file list, read the file list according to the file path corresponding to the file list, parse the sub-file list, and obtain multiple third file paths included in the sub-file list.
[0109] As a preferred implementation, in an embodiment of the present application, the processing module 504 is specifically used to: identify the file directory, file comments and file type of the file path in the first file in sequence according to the second platform code file template; process the file directory, file comments and file type of the file path in the first file to obtain the target file.
[0110] As a preferred implementation mode, in the embodiment of the present application, the processing module 504 is specifically used to: traverse the file path in the first file, detect the file directory in each file path, compare the file directory with the first preset identifier, determine whether the file directory corresponding to the file path is the first directory or the second directory, store the file path corresponding to the first directory in the first partition of the first file, and store the file path corresponding to the second directory in the second partition of the first file to obtain the second file, wherein the first preset identifier is a directory identifier; traverse the file path in the second file, detect whether there is a second preset identifier in the file path, if the second preset identifier exists, delete the content corresponding to the second preset identifier, and obtain the third file, wherein the second preset identifier is the identifier corresponding to the comment line; traverse the file path in the third file, detect the file type in each file path, compare each file type with the third preset identifier, and when the file type and the third preset identifier are the same, add a preset code to the file path corresponding to the file type to obtain the target file, wherein the third preset identifier is the file extension.
[0111] As a preferred implementation mode, in the embodiment of the present application, the constraint module 505 is specifically used to: receive a target file to which a user adds annotations, and obtain a top-level file in the target file to which the annotations are added; traverse each port signal of the top-level file, and generate a constraint statement corresponding to the port signal according to the annotation of the port signal; and generate the constraint file according to the constraint statement.
[0112] As a preferred implementation manner, in an embodiment of the present application, the constraint module 505 is specifically further used for: traversing each port signal of the top-level file, and generating a constraint statement corresponding to the port signal according to the annotation of the port signal, including: determining the type and constraint target of the port signal according to the annotation of the port signal; generating a constraint statement corresponding to the port signal according to the type and constraint target of the port signal.
[0113] As a preferred implementation mode, in the embodiment of the present application, the constraint module 505 is also specifically used for: when the port signal is a clock signal, generating a clock frequency constraint corresponding to the clock signal according to the clock frequency of the clock signal; generating an asynchronous clock constraint corresponding to the clock signal according to user requirements; determining the global clock manager corresponding to the clock signal according to the clock frequency of the clock signal, and generating a source constraint corresponding to the clock signal according to the global clock manager; generating a clock constraint statement corresponding to the clock signal according to the clock frequency constraint, the asynchronous clock constraint and the source constraint.
[0114] For the specific definition of the cross-platform code transplantation device, please refer to the definition of the cross-platform code transplantation method above, which will not be repeated here. Each module in the above-mentioned cross-platform code transplantation device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0115] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 6 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a cross-platform code transplantation method is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covered on the display screen, or a key, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.
[0116] Those skilled in the art will understand that Figure 6The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0117] In one embodiment, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program: S1: reading a first platform code file, wherein the first platform code file comprises a first file path and a file path corresponding to a file list; S2: reading the file list according to the file path corresponding to the file list, parsing the file list, and obtaining a plurality of second file paths included in the file list; S3: writing the first file path and the plurality of second file paths into a blank file to obtain a first file; S4: traversing the file paths in the first file, processing the first file according to a second platform code file template to obtain a target file, and outputting the target file; S5: receiving a target file annotated by a user, and generating a constraint file corresponding to the target file according to the annotation; S6: porting the constraint file and the target file to the second platform.
[0118] In one embodiment, when the processor executes the computer program, the following steps are also implemented: detecting each second file path in turn to determine whether the second file path includes the file path corresponding to the sub-file list; if it includes the file path corresponding to the sub-file list, reading the file list according to the file path corresponding to the file list, parsing the sub-file list, and obtaining multiple third file paths included in the sub-file list.
[0119] In one embodiment, when the processor executes the computer program, the following steps are also implemented: according to the second platform code file template, the file directory, file comments and file type of the file path in the first file are identified in sequence; the file directory, file comments and file type of the file path in the first file are processed to obtain the target file.
[0120] In one embodiment, when the processor executes the computer program, the following steps are also implemented: traversing the file path in the first file, detecting the file directory in each file path, comparing the file directory with the first preset identifier, determining whether the file directory corresponding to the file path is the first directory or the second directory, storing the file path corresponding to the first directory in the first partition of the first file, and storing the file path corresponding to the second directory in the second partition of the first file, to obtain a second file, wherein the first preset identifier is a directory identifier; traversing the file path in the second file, detecting whether there is a second preset identifier in the file path, if the second preset identifier exists, deleting the content corresponding to the second preset identifier, to obtain a third file, wherein the second preset identifier is an identifier corresponding to the comment line; traversing the file path in the third file, detecting the file type in each file path, comparing each file type with the third preset identifier, and when the file type and the third preset identifier are the same, adding a preset code to the file path corresponding to the file type, to obtain a target file, wherein the third preset identifier is a file extension.
[0121] In one embodiment, when the processor executes the computer program, the following steps are also implemented: receiving a target file annotated by a user, and obtaining a top-level file in the target file with the annotations added; traversing each port signal of the top-level file, and generating a constraint statement corresponding to the port signal based on the annotation of the port signal; and generating the constraint file based on the constraint statement.
[0122] In one embodiment, when the processor executes the computer program, the following steps are also implemented: determining the type and constraint target of the port signal according to the annotation of the port signal; and generating a constraint statement corresponding to the port signal according to the type and constraint target of the port signal.
[0123] In one embodiment, when the processor executes the computer program, the following steps are also implemented: when the port signal is a clock signal, a clock frequency constraint corresponding to the clock signal is generated according to the clock frequency of the clock signal; according to user requirements, an asynchronous clock constraint corresponding to the clock signal is generated; according to the clock frequency of the clock signal, a global clock manager corresponding to the clock signal is determined, and according to the global clock manager, a generation source constraint corresponding to the clock signal is generated; according to the clock frequency constraint, the asynchronous clock constraint and the generation source constraint, a clock constraint statement corresponding to the clock signal is generated.
[0124] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented: S1: reading a first platform code file, wherein the first platform code file includes a first file path and a file path corresponding to a file list; S2: reading the file list according to the file path corresponding to the file list, parsing the file list, and obtaining a plurality of second file paths included in the file list; S3: writing the first file path and the plurality of second file paths into a blank file to obtain a first file; S4: traversing the file paths in the first file, processing the first file according to a second platform code file template to obtain a target file, and outputting the target file; S5: receiving a target file annotated by a user, and generating a constraint file corresponding to the target file according to the annotation; S6: porting the constraint file and the target file to the second platform.
[0125] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented: detecting each second file path in turn to determine whether the second file path includes the file path corresponding to the sub-file list; if it includes the file path corresponding to the sub-file list, reading the file list according to the file path corresponding to the file list, parsing the sub-file list, and obtaining multiple third file paths included in the sub-file list.
[0126] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: according to the second platform code file template, the file directory, file comments and file type of the file path in the first file are identified in sequence; the file directory, file comments and file type of the file path in the first file are processed to obtain the target file.
[0127] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: traversing the file path in the first file, detecting the file directory in each file path, comparing the file directory with the first preset identifier, determining whether the file directory corresponding to the file path is the first directory or the second directory, storing the file path corresponding to the first directory in the first partition of the first file, and storing the file path corresponding to the second directory in the second partition of the first file, to obtain a second file, wherein the first preset identifier is a directory identifier; traversing the file path in the second file, detecting whether there is a second preset identifier in the file path, if the second preset identifier exists, deleting the content corresponding to the second preset identifier, to obtain a third file, wherein the second preset identifier is an identifier corresponding to the comment line; traversing the file path in the third file, detecting the file type in each file path, comparing each file type with the third preset identifier, and when the file type and the third preset identifier are the same, adding a preset code to the file path corresponding to the file type, to obtain a target file, wherein the third preset identifier is a file extension.
[0128] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented: receiving a target file annotated by a user, and obtaining a top-level file in the annotated target file; traversing each port signal of the top-level file, and generating a constraint statement corresponding to the port signal based on the annotation of the port signal; and generating the constraint file based on the constraint statement.
[0129] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented: determining the type and constraint target of the port signal according to the annotation of the port signal; and generating a constraint statement corresponding to the port signal according to the type and constraint target of the port signal.
[0130] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented: when the port signal is a clock signal, a clock frequency constraint corresponding to the clock signal is generated according to the clock frequency of the clock signal; according to user requirements, an asynchronous clock constraint corresponding to the clock signal is generated; according to the clock frequency of the clock signal, a global clock manager corresponding to the clock signal is determined, and according to the global clock manager, a generation source constraint corresponding to the clock signal is generated; according to the clock frequency constraint, the asynchronous clock constraint and the generation source constraint, a clock constraint statement corresponding to the clock signal is generated.
[0131] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0132] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0133] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A cross-platform code transplantation method, characterized in that: The method comprises: Reading a first platform code file, wherein the first platform code file includes a first file path and a file path corresponding to the file list; Reading the file list according to the file paths corresponding to the file list, parsing the file list, and obtaining a plurality of second file paths included in the file list; Writing the first file path and the plurality of second file paths into a blank file to obtain a first file; Traversing the file path in the first file, processing the first file according to the second platform code file template to obtain a target file, and outputting the target file; Receive a target file annotated by a user, and generate a constraint file corresponding to the target file according to the annotation; The constraint file and the target file are ported to the second platform.
2. The cross-platform code transplantation method according to claim 1, characterized in that: The parsing of the file list to obtain a plurality of second file paths included in the file list includes: Detecting each second file path in turn to determine whether the second file path includes the file path corresponding to the sub-file list; If the file path corresponding to the sub-file list is included, the file list is read according to the file path corresponding to the file list, and the sub-file list is parsed to obtain multiple third file paths included in the sub-file list.
3. The cross-platform code transplantation method according to claim 1, characterized in that: The step of processing the first file according to the second platform code file template to obtain a target file includes: According to the second platform code file template, sequentially identifying a file directory, a file comment, and a file type of a file path in the first file; The file directory, file comment and file type of the file path in the first file are processed to obtain the target file.
4. The cross-platform code transplantation method according to claim 3, characterized in that: The processing of the file directory, file comment and file type of the file path in the first file to obtain the target file includes: Traversing the file paths in the first file, detecting the file directories in each file path, comparing the file directories with a first preset identifier, determining whether the file directory corresponding to the file path is the first directory or the second directory, storing the file path corresponding to the first directory in a first partition of the first file, and storing the file path corresponding to the second directory in a second partition of the first file, to obtain a second file, wherein the first preset identifier is a directory identifier; Traversing the file path in the second file, detecting whether a second preset identifier exists in the file path, and if the second preset identifier exists, deleting the content corresponding to the second preset identifier to obtain a third file, wherein the second preset identifier is an identifier corresponding to the comment line; Traverse the file paths in the third file, detect the file type in each file path, compare each file type with a third preset identifier, and when the file type and the third preset identifier are the same, add a preset code to the file path corresponding to the file type to obtain a target file, wherein the third preset identifier is a file extension.
5. The cross-platform code transplantation method according to claim 1, characterized in that: The receiving of the target file annotated by the user and generating a constraint file corresponding to the target file according to the annotation include: Receive a target file annotated by a user, and obtain a top-level file in the target file annotated by a user; Traversing each port signal of the top-level file, and generating a constraint statement corresponding to the port signal according to the annotation of the port signal; The constraint file is generated according to the constraint statement.
6. The cross-platform code transplantation method according to claim 5, characterized in that: The traversing each port signal of the top-level file and generating a constraint statement corresponding to the port signal according to the annotation of the port signal includes: Determining the type and constraint target of the port signal according to the annotation of the port signal; A constraint statement corresponding to the port signal is generated according to the type and constraint target of the port signal.
7. The cross-platform code transplantation method according to claim 6, characterized in that: The step of generating a constraint statement corresponding to the port signal according to the type of the port signal and the constraint target includes: When the port signal is a clock signal, generating a clock frequency constraint corresponding to the clock signal according to the clock frequency of the clock signal; Generate asynchronous clock constraints corresponding to the clock signal according to user requirements; Determine a global clock manager corresponding to the clock signal according to the clock frequency of the clock signal, and generate a generation source constraint corresponding to the clock signal according to the global clock manager; A clock constraint statement corresponding to the clock signal is generated according to the clock frequency constraint, the asynchronous clock constraint and the generation source constraint.
8. A cross-platform code transplantation device, characterized in that: The device comprises: A reading module, configured to read a first platform code file, wherein the first platform code file includes a first file path and a file path corresponding to a file list; A parsing module, configured to read the file list according to the file paths corresponding to the file list, parse the file list, and obtain a plurality of second file paths included in the file list; A writing module is used to write the first file path and the plurality of second file paths into a blank file to obtain a first file; A processing module, used for traversing the file path in the first file, processing the first file according to the second platform code file template, obtaining a target file, and outputting the target file; A constraint module, used for receiving a target file annotated by a user, and generating a constraint file corresponding to the target file according to the annotation; A transplantation module is used to transplant the constraint file and the target file to the second platform.
9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.