Intra-macro identifier position information acquisition method, electronic equipment and medium
By setting up macro virtual files for chip design code and calculating column and row position offsets, the problem of difficulty in identifying identifier position information within macros is solved, enabling fast and accurate acquisition of position information and supporting subsequent debugging operations.
Patent Information
- Application Number
- CN202511613510.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-06
- Publication Date
- 2026-01-09
- Estimated Expiration
- 2045-11-06
AI Technical Summary
In chip design code, it is difficult to identify the location information of macro identifiers. Existing technologies cannot accurately and quickly obtain the location information of macro identifiers in macro expanded text.
For each macro reference in the chip design code source file, a corresponding macro virtual file is set up. When loading, the initial position information is obtained. When expanding the text, the position information of the identifier within the macro in the expanded macro text is obtained based on the initial position information. Accurate position information is generated by calculating the column position offset and the row position offset.
It enables accurate and rapid acquisition of the position information of macro identifiers in the macro expanded text, improves the processing efficiency of macro identifier position information, and supports subsequent debugging operations.
Smart Images

Figure CN121300757A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of macro text processing technology, and in particular to a method, electronic device, and medium for obtaining the location information of identifiers within a macro. Background Technology
[0002] In chip design code, a large amount of macro text is typically used to facilitate text replacement. Macro text takes various forms, including identifiers within macros such as signals, parameters, models, functions, tasks, and instances. Macro complexity ranges from basic text replacement to the complete substitution of highly complex models or functions, and their reference locations are diverse. Furthermore, since macro text exists only as macro references in the original chip design code file, its replacement content needs to be dynamically loaded after macro expansion. Therefore, the positional information of the identifiers within these macros differs from that in the original chip design code file, and is relative, which makes identification of macro identifiers difficult. Thus, accurately and quickly obtaining the positional information of macro identifiers within the expanded macro text is a pressing technical problem that needs to be solved. Summary of the Invention
[0003] The purpose of this invention is to provide a method, electronic device, and medium for obtaining macro identifier location information, which can accurately and quickly obtain macro identifier location information.
[0004] According to a first aspect of the present invention, a method for obtaining macro identifier location information is provided, comprising: For each macro reference in the chip design code original file, a corresponding macro virtual file is set up. The macro virtual file includes a macro virtual file identifier, macro initial expanded text, macro internal identifier initial line number and macro internal identifier initial column number range. The macro internal identifier initial line number is the line number of the macro internal identifier in the macro initial expanded text, and the macro internal identifier initial column number range is the column number range of the macro internal identifier in the macro initial expanded text. Load the original chip design code file, and obtain the initial position information of the identifier within each macro based on the macro virtual file corresponding to each macro reference. The initial position information includes the macro virtual file identifier, the initial line number of the identifier within the macro, and the initial column number range of the identifier within the macro. Expand each target macro reference in the target code line of the original chip design code file to obtain the expanded target macro text; Based on the target macro expanded text and the macro initial expanded text of each target macro reference, obtain the column position offset and row position offset corresponding to each target macro reference. The column position offset is equal to the column offset of the first macro identifier of the target macro reference in the target macro expanded text and in the macro initial expanded text. Based on the column position offset, row position offset, and initial position information of the identifier within the macro in each target macro reference, the position information of the identifier within the macro in the expanded text of the target macro is generated.
[0005] Furthermore, if the target code line includes only one target macro reference, then based on the expanded text of the target macro and the initial expanded text of each target macro reference, the column position offset and row position offset corresponding to each target macro reference are obtained, including: Obtain the starting column number M of the target macro reference in the target code line; Set the column offset corresponding to the target macro reference to M-1; Set the line offset corresponding to the target macro reference to 0.
[0006] Furthermore, if the target code line includes N target macro references, and none of the target macro references contain newlines, where N is an integer greater than or equal to 2, then based on the expanded text of the target macro and the initial expanded text of each target macro reference, the column position offset and row position offset corresponding to each target macro reference are obtained, including: Obtain the starting column number M1 of the first target macro reference in the target code line; Set the column position offset F1 corresponding to the first target macro reference to M1-1; Retrieve the starting column number M of the nth target macro reference in the target code line. n n is an integer in the range of 2 to N; Obtain the length difference P between the initial expanded text of the i-th target macro reference and the macro reference text in the target code line. i and obtain all P i and Q n i is an integer from 1 to n-1; The column position offset F corresponding to the nth target macro reference. n Set to Q n +M n -1; Set the line position offset corresponding to each target macro reference to 0.
[0007] Furthermore, if the target code line includes N target macro references, and the target macro references contain newline characters, where N is an integer greater than or equal to 2, then based on the expanded text of the target macro and the initial expanded text of each target macro reference, the column position offset and row position offset corresponding to each target macro reference are obtained, including: Retrieve the starting column number M of the nth target macro reference in the target code line. n And the initial expanded text length R of the macro referenced by the nth target macro.n n is an integer in the range of 1 to N; If n=1, then the column position offset F corresponding to the nth target macro reference will be set. n Set to M n -1, which sets the line offset U corresponding to the nth target macro reference. n Set to 0; If n>1, then obtain the length difference P between the initial expanded text of the i-th target macro reference and the macro reference text in the target code line. i and obtain all P i and Q n i is an integer from 1 to n-1; If n>1, then obtain the length t of the text in the expanded target macro text from the starting point of the expanded target macro text to the newline character closest to the nth target macro reference. n The column offset F corresponding to the nth target macro reference. n Set to Q n +M n -1-t n-1 .
[0008] Furthermore, the step of generating the position information of the macro identifier within each target macro reference in the expanded text of the target macro reference based on the column position offset, row position offset, and initial position information of the macro identifier within each target macro reference includes: The column number range of the identifier in the first row of each macro within each target macro reference is generated by adding the boundary value of the initial column number range of the identifier in the first row of each target macro reference to the column position offset corresponding to the target macro reference. The initial column number range of the identifiers within the non-first line of the macro referenced by each target macro is directly determined as the column number range of the identifiers within the non-first line of the macro referenced by the target macro in the expanded text of the target macro. If the line position offset corresponding to the target macro reference is 0, then the initial line number of the macro identifier of the target macro reference is directly determined as the line number of the macro identifier of the target macro reference in the expanded text of the target macro. If the line position offset corresponding to the target macro reference is not 0, then the value of adding the initial line number of the macro identifier within the target macro reference to the corresponding line position offset is determined as the line number of the macro identifier within the target macro in the expanded text of the target macro.
[0009] Furthermore, if there is no newline character in the target macro reference in the target code line, the corresponding expanded target macro text is located on the same line.
[0010] Furthermore, the process of loading the original chip design code file also includes: Based on the macro virtual file corresponding to each macro reference, macro identifier storage information corresponding to the code region identifier is generated. The macro identifier storage information corresponding to the code region includes the code region identifier and the corresponding first-level mapping information. The first-level mapping information includes at least one second-level mapping information. The second-level mapping information includes the macro virtual file identifier and the third-level mapping information. The third-level mapping information includes the corresponding line number in the macro expanded text and the corresponding macro identifier list. The macro identifier list includes at least one macro identifier. The macro identifier information includes the binding object, first position information and second position information. The first position information includes the code region identifier where the macro corresponding to the macro is located, the line number of the macro corresponding to the macro in the chip design code original file, and the column number range of the macro corresponding to the macro in the chip design code original file. The second position information includes the macro virtual file identifier and the initial position information corresponding to the macro identifier.
[0011] Furthermore, after generating the position information of the macro identifier within the target macro reference in the expanded text of the target macro, it also includes: Update the initial position information of the macro identifier in the second position information of the corresponding macro identifier storage information in the target macro reference to the position information in the expanded text of the target macro.
[0012] According to a second aspect of the present invention, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being configured to perform the method described in the first aspect of the present invention.
[0013] According to a third aspect of the present invention, a computer-readable storage medium is provided, storing computer-executable instructions for performing the method described in the first aspect of the present invention.
[0014] Compared with existing technologies, this invention has significant advantages and beneficial effects. Through the above technical solution, the method, electronic device, and medium for obtaining macro identifier location information provided by this invention achieve considerable technological advancement and practicality, and have broad industrial application value. It has at least the following beneficial effects: This invention sets up a corresponding macro virtual file for each macro reference in the chip design code source file. When loading the chip design code source file, the initial position information of the identifier within each macro is obtained based on the macro virtual file. When expanding the macro text, the position information of the identifier within the macro in the expanded macro text is obtained based on the expanded text and the initial position information of the identifier within the macro, thus achieving accurate and fast acquisition of the position information of the identifier within the macro. Attached Figure Description
[0015] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0016] Figure 1 A flowchart illustrating the method for obtaining macro identifier location information provided in an embodiment of the present invention. Detailed Implementation
[0017] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0018] This invention provides a method for obtaining macro identifier location information, such as... Figure 1 As shown, it includes: Step S1: Set up a corresponding macro virtual file for each macro reference in the chip design code original file. The macro virtual file includes a macro virtual file identifier, macro initial expanded text, macro internal identifier initial line number and macro internal identifier initial column number range. The macro internal identifier initial line number is the line number of the macro internal identifier in the macro initial expanded text, and the macro internal identifier initial column number range is the column number range of the macro internal identifier in the macro initial expanded text.
[0019] The chip design code source file refers to the code file generated based on a hardware description language. Specific hardware description languages can be Verilog, SystemVerilog, VHDL, etc. Macro identifiers refer to the identifiers contained within the macro expanded text. Macro identifiers can specifically be signals, parameters, models, functions, tasks, and instances, etc. It's understood that macros with the same name can be used in different locations, corresponding to different macro references, and each macro reference requires a corresponding macro virtual file. The column number range refers to the range consisting of the starting and ending column numbers in the text.
[0020] Step S2: Load the original chip design code file, and obtain the initial position information of the identifier within each macro based on the macro virtual file corresponding to each macro reference. The initial position information includes the macro virtual file identifier, the initial line number of the identifier within the macro, and the initial column number range of the identifier within the macro.
[0021] It should be noted that the chip design code source file can be divided into multiple code regions. Loading the chip design code source file can be done through the display interface, and one or more code regions within the source file can be loaded. Processing the identifier position information within a macro according to code regions can improve the processing efficiency of this information.
[0022] Step S3: Expand each target macro reference in the target code line of the original chip design code file to obtain the expanded target macro text.
[0023] Here, a target code line refers to any line of code in the original chip design code file that contains macro references. A target code line may include one or more macro references. Macro references in a target code line are target macro references.
[0024] Step S4: Based on the target macro expanded text and the macro initial expanded text of each target macro reference, obtain the column position offset and row position offset corresponding to each target macro reference. The column position offset is equal to the column offset of the first macro identifier of the target macro reference in the target macro expanded text and in the macro initial expanded text.
[0025] It should be noted that after the macro reference in the target code line is expanded, since there may be multiple macro references and non-macro text in the target code line, the position information of the macro identifier in the expanded target code line will be offset relative to the initial expanded macro text. Therefore, it is necessary to obtain the column position offset and row position offset corresponding to each target macro reference in order to obtain the position information of the macro identifier in each target macro reference in the expanded target macro text.
[0026] When a macro reference in the target line of code is expanded, it only affects the column position information of the macro identifier in the first line (i.e., the first line) of the macro's initial expanded text. If the macro's initial expanded text contains multiple lines, the expansion of the macro reference in the target line of code will not affect the column position information of the macro identifiers in the non-first lines of the initial expanded text. Furthermore, the column offsets of the macro identifiers in the first line of the initial expanded text within the target macro expanded text and within the initial expanded text are both equal to the column offsets of the first macro identifier of the target macro reference within the target macro expanded text and within the initial expanded text. Therefore, the column position offset can be directly set to equal the column offsets of the first macro identifier of the target macro reference within the target macro expanded text and within the initial expanded text.
[0027] The line position offset of the macro identifier referenced by each target macro is equal to the line position offset in the target macro expanded text and the macro initial expanded text. Therefore, the line position offset can be directly set to be equal to the line offset of the first line macro identifier referenced by the target macro in the target macro expanded text and the macro initial expanded text.
[0028] Step S5: Generate the position information of the identifier within the macro in the expanded text of the target macro based on the column position offset, row position offset, and initial position information of the identifier within the macro in each target macro reference.
[0029] It should be noted that, based on the column position offset, row position offset, and initial position information of the identifier within each target macro reference, the accurate position information of the identifier within each target macro reference in the expanded text of the target macro can be obtained, providing a basis for subsequent location of the identifier within the target macro reference.
[0030] It should be noted that if there is no newline character in the target macro reference in the target code line, the corresponding expanded target macro text will be on the same line.
[0031] The following three examples further illustrate how to obtain the column position offset and row position offset corresponding to each target macro reference.
[0032] Example 1 If the target code line contains only one target macro reference, then step S4 includes: Step S41: Obtain the starting column number M of the target macro reference in the target code line.
[0033] Step S42: Set the column position offset corresponding to the target macro reference to M-1.
[0034] It should be noted that, for the case where the target code line contains only one target macro reference, the column offset of the first macro identifier of the target macro reference in the target macro expanded text and in the macro initial expanded text is only affected by the non-macro text before the target macro reference in the target code line. The column position offset setting corresponding to the target macro reference is the length of the non-macro text before the target macro reference, and the length of the non-macro text before the target macro reference is M-1.
[0035] Step S43: Set the line position offset corresponding to the target macro reference to 0.
[0036] It should be noted that if the target code line contains only one target macro reference, the identifier of the first line of the target macro reference remains unchanged in the expanded text of the target macro and in the initial expanded text of the macro. Therefore, the line position offset corresponding to the target macro reference is set to 0.
[0037] Example 2 If the target code line contains N target macro references, and none of the target macro references contain newlines, where N is an integer greater than or equal to 2, then step S4 includes: Step C41: Obtain the starting column number M1 of the first target macro reference in the target code line.
[0038] Step C42: Set the column position offset F1 corresponding to the first target macro reference to M1-1.
[0039] Step C43: Obtain the starting column number M of the nth target macro reference in the target code line. n n is an integer in the range of 2 to N.
[0040] Step C44: Obtain the length difference P between the initial expanded text of the i-th target macro reference and the macro reference text in the target code line. i and obtain all P i and Q n , where i is an integer from 1 to n-1.
[0041] Step C45: Set the column offset F corresponding to the nth target macro reference. n Set to Q n +M n -1.
[0042] It should be noted that if the target code line includes N target macro references, then for the i-th target macro reference, the column position offset needs to take into account not only the influence of non-macro text before the i-th target macro reference, but also the offset caused by the expansion of the target macro before the i-th target macro reference.
[0043] Step C46: Set the line position offset corresponding to each target macro reference to 0.
[0044] Since there are no newlines in any of the N target macro references, the line position offset for each target macro reference is 0.
[0045] Example 3 If the target code line includes N target macro references, and the target macro references contain newline characters, where N is an integer greater than or equal to 2, then step S4 includes: Step D41: Obtain the starting column number M of the nth target macro reference in the target code line. nAnd the initial expanded text length R of the macro referenced by the nth target macro. n n is an integer in the range of 1 to N.
[0046] Step D42: If n=1, then set the column offset F corresponding to the nth target macro reference. n Set to M n -1, which sets the line offset U corresponding to the nth target macro reference. n Set to 0.
[0047] Step D43: If n>1, then obtain the length difference P between the initial expanded text of the i-th target macro reference and the macro reference text in the target code line. i and obtain all P i and Q n , where i is an integer from 1 to n-1.
[0048] Step D44: If n>1, then obtain the length t of the text in the expanded target macro text from the starting point of the expanded target macro text to the newline character closest to the nth target macro reference. n The column offset F corresponding to the nth target macro reference. n Set to Q n +M n -1-t n-1 The offset U of the row position corresponding to the nth target macro reference. n Set W n W n Expand the target macro by the number of newline characters preceding the nth target macro reference in the text.
[0049] It should be noted that if there is no newline character before the nth target macro reference, then the corresponding t n =0. The column offset corresponding to the nth target macro reference is composed of the non-macro text before the nth target macro reference, the offset caused by the expansion of the target macro before the nth target macro reference, and the text length t of the nearest newline character to the nth target macro reference. n It was decided jointly.
[0050] As one embodiment, step S5 includes: Step S51: Add the boundary value of the initial column number range of the identifier in each macro within the first line of each target macro reference to the column position offset corresponding to the target macro reference to generate the column number range of the identifier in each macro within the first line of each target macro reference in the expanded text of the target macro.
[0051] Step S52: Directly determine the initial column number range of the non-first-line macro identifiers of each target macro reference as the column number range of the non-first-line macro identifiers in the expanded text of the target macro.
[0052] Step S53: If the line position offset corresponding to the target macro reference is 0, then directly determine the initial line number of the macro identifier of the target macro reference as the line number of the macro identifier of the target macro reference in the expanded text of the target macro.
[0053] Step S54: If the line position offset corresponding to the target macro reference is not 0, then the value of adding the initial line number of the macro identifier within the target macro reference to the corresponding line position offset is determined as the line number of the macro identifier within the target macro reference in the expanded text of the target macro.
[0054] It should be noted that through steps S51-S54, the accurate location information of the macro identifier in each target macro reference within the expanded text of the target macro can be obtained, providing a basis for subsequent location of the macro identifier in the target macro reference.
[0055] As one embodiment, step S2, during the loading of the chip design code source file, further includes: Step S20: Generate macro identifier storage information corresponding to the code region identifier based on the macro virtual file corresponding to each macro reference.
[0056] The macro identifier storage information corresponding to the code region includes a code region identifier and corresponding first-level mapping information. The first-level mapping information includes at least one second-level mapping information. The second-level mapping information includes a macro virtual file identifier and third-level mapping information. The third-level mapping information includes the corresponding line number in the macro expanded text and the corresponding macro identifier list. The macro identifier list includes at least one macro identifier. The macro identifier information includes a binding object, first position information, and second position information. The first position information includes the code region identifier where the macro corresponding to the macro is located, the line number of the macro corresponding to the macro in the chip design code original file, and the column number range of the macro corresponding to the macro in the chip design code original file. The second position information includes the macro virtual file identifier and the initial position information corresponding to the macro identifier.
[0057] As a preferred embodiment, the first-level mapping information, the second-level mapping information, and the third-level mapping information can all be implemented using hash tables. Hash tables support fast lookups, greatly improving lookup efficiency and providing strong support for the implementation of other functions in subsequent debugging tools.
[0058] Here, the bound object refers to an object that can be identified and supports debugging operations. Debugging operations specifically include searching, annotation, tracing links, and definition jumps. Annotation operations can take the form of highlighting and box selection. Location information specifically refers to the ability to accurately locate the position of identifiers within macros.
[0059] As one embodiment, the step S5 is followed by: Step S6: Update the initial position information of the macro identifier in the second position information of the corresponding macro identifier storage information in the target macro reference to the position information in the expanded text of the target macro.
[0060] As one embodiment, the step S7 is followed by: Step S8: Obtain the location information of the identifier within the macro to be processed, query the corresponding macro identifier storage information based on the location information of the identifier within the macro to be processed, and determine the binding object corresponding to the identifier within the macro to be processed. Step S9: Bind the identifier within the macro to be processed to the corresponding binding object. Based on the binding object corresponding to the identifier within the macro to be processed, perform debugging operations such as searching, marking, tracing link relationships, and defining jumps.
[0061] It should be noted that after binding the identifier within the macro to be processed to the corresponding binding object, the binding object is given attributes that allow it to perform debugging operations such as searching, annotation, tracing link relationships, and definition jumps. All existing methods for implementing debugging operations such as searching, annotation, tracing link relationships, and definition jumps based on the binding object corresponding to the identifier within the macro to be processed fall within the protection scope of this invention.
[0062] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein in the description of this invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.
[0063] It should be noted that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe the steps as sequential processes, many of these steps can be performed in parallel, concurrently, or simultaneously. Furthermore, the order of the steps can be rearranged. A process can be terminated when its operation is complete, but it may also have additional steps not included in the figures. A process can correspond to a method, function, procedure, subroutine, subroutine, etc.
[0064] This invention also provides an electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being configured to perform the method described in this invention.
[0065] This invention also provides a computer-readable storage medium storing computer-executable instructions for performing the methods described in this invention.
[0066] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make some modifications or alterations to the above-disclosed technical content to create equivalent embodiments without departing from the scope of the present invention. Any simple modifications, equivalent changes, and alterations made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the scope of the present invention.
Claims
1. A method for obtaining macro identifier location information, characterized in that, include: For each macro reference in the chip design code original file, a corresponding macro virtual file is set up. The macro virtual file includes a macro virtual file identifier, macro initial expanded text, macro internal identifier initial line number and macro internal identifier initial column number range. The macro internal identifier initial line number is the line number of the macro internal identifier in the macro initial expanded text, and the macro internal identifier initial column number range is the column number range of the macro internal identifier in the macro initial expanded text. Load the original chip design code file, and obtain the initial position information of the identifier within each macro based on the macro virtual file corresponding to each macro reference. The initial position information includes the macro virtual file identifier, the initial line number of the identifier within the macro, and the initial column number range of the identifier within the macro. Expand each target macro reference in the target code line of the original chip design code file to obtain the expanded target macro text; Based on the target macro expanded text and the macro initial expanded text of each target macro reference, obtain the column position offset and row position offset corresponding to each target macro reference. The column position offset is equal to the column offset of the first macro identifier of the target macro reference in the target macro expanded text and in the macro initial expanded text. Based on the column position offset, row position offset, and initial position information of the identifier within the macro in each target macro reference, the position information of the identifier within the macro in the expanded text of the target macro is generated.
2. The method according to claim 1, characterized in that, If the target code line contains only one target macro reference, then based on the expanded text of the target macro and the initial expanded text of each target macro reference, the column position offset and row position offset corresponding to each target macro reference are obtained, including: Obtain the starting column number M of the target macro reference in the target code line; Set the column offset corresponding to the target macro reference to M-1; Set the line offset corresponding to the target macro reference to 0.
3. The method according to claim 1, characterized in that, If the target code line includes N target macro references, and none of the target macro references contain newlines, where N is an integer greater than or equal to 2, then based on the expanded text of the target macro and the initial expanded text of each target macro reference, the column position offset and row position offset corresponding to each target macro reference are obtained, including: Obtain the starting column number M1 of the first target macro reference in the target code line; Set the column position offset F1 corresponding to the first target macro reference to M1-1; Retrieve the starting column number M of the nth target macro reference in the target code line. n n is an integer in the range of 2 to N; Obtain the length difference P between the initial expanded text of the i-th target macro reference and the macro reference text in the target code line. i and obtain all P i and Q n i is an integer from 1 to n-1; The column position offset F corresponding to the nth target macro reference. n Set to Q n +M n -1; Set the line position offset corresponding to each target macro reference to 0.
4. The method according to claim 1, characterized in that, If the target code line includes N target macro references, and the target macro references contain newline characters, where N is an integer greater than or equal to 2, then based on the expanded text of the target macro and the initial expanded text of each target macro reference, the column position offset and row position offset corresponding to each target macro reference are obtained, including: Retrieve the starting column number M of the nth target macro reference in the target code line. n And the initial expanded text length R of the macro referenced by the nth target macro. n n is an integer in the range of 1 to N; If n=1, then the column position offset F corresponding to the nth target macro reference will be set. n Set to M n -1, which sets the line offset U corresponding to the nth target macro reference. n Set to 0; If n>1, then obtain the length difference P between the initial expanded text of the i-th target macro reference and the length of the macro reference text in the target code line. i and obtain all P i and Q n i is an integer from 1 to n-1; If n>1, then obtain the length t of the text in the expanded target macro text from the starting point of the expanded target macro text to the newline character closest to the nth target macro reference. n The column offset F corresponding to the nth target macro reference. n Set to Q n +M n -1-t n-1 The offset U of the row position corresponding to the nth target macro reference. n Set W n W n Expand the target macro by the number of newline characters preceding the nth target macro reference in the text.
5. The method according to claim 1, characterized in that, The process of generating the position information of the macro identifier within each target macro reference in the expanded text of the target macro reference based on the column position offset, row position offset, and initial position information of the macro identifier within each target macro reference includes: The column number range of the identifier in the first row of each macro within each target macro reference is generated by adding the boundary value of the initial column number range of the identifier in the first row of each target macro reference to the column position offset corresponding to the target macro reference. The initial column number range of the identifiers within the non-first line of the macro referenced by each target macro is directly determined as the column number range of the identifiers within the non-first line of the macro referenced by the target macro in the expanded text of the target macro. If the line position offset corresponding to the target macro reference is 0, then the initial line number of the macro identifier of the target macro reference is directly determined as the line number of the macro identifier of the target macro reference in the expanded text of the target macro. If the line position offset corresponding to the target macro reference is not 0, then the value of adding the initial line number of the macro identifier within the target macro reference to the corresponding line position offset is determined as the line number of the macro identifier within the target macro in the expanded text of the target macro.
6. The method according to claim 1, characterized in that, If there is no newline character in the target macro reference in the target code line, the corresponding expanded target macro text is on the same line.
7. The method according to claim 1, characterized in that, The process of loading the chip design code source file also includes: Based on the macro virtual file corresponding to each macro reference, macro identifier storage information corresponding to the code region identifier is generated. The macro identifier storage information corresponding to the code region includes the code region identifier and the corresponding first-level mapping information. The first-level mapping information includes at least one second-level mapping information. The second-level mapping information includes the macro virtual file identifier and the third-level mapping information. The third-level mapping information includes the corresponding line number in the macro expanded text and the corresponding macro identifier list. The macro identifier list includes at least one macro identifier. The macro identifier information includes the binding object, first position information and second position information. The first position information includes the code region identifier where the macro corresponding to the macro is located, the line number of the macro corresponding to the macro in the chip design code original file, and the column number range of the macro corresponding to the macro in the chip design code original file. The second position information includes the macro virtual file identifier and the initial position information corresponding to the macro identifier.
8. The method according to claim 1, characterized in that, After generating the position information of the macro identifier within the target macro reference in the expanded text of the target macro, it also includes: Update the initial position information of the macro identifier in the second position information of the corresponding macro identifier storage information in the target macro reference to the position information in the expanded text of the target macro.
9. An electronic device, characterized in that, include: At least one processor; And, a memory communicatively connected to the at least one processor; The memory stores instructions that are executed by the at least one processor, the instructions being configured to perform the method of any one of claims 1-8.
10. A computer-readable storage medium, characterized in that, The device stores computer-executable instructions for performing the method of any one of claims 1-8.
Citation Information
Patent Citations
Code relocating method and system oriented to host system
CN105843661A
Association method of abstract syntax tree and source code coordinates, electronic equipment and medium
CN116954622A
Target text search method based on macro expanded text, electronic equipment and medium
CN117112730A
Method and device for determining corresponding original text column position after macro replacement and server
CN119166836A
Processing macro information and displaying via GUI in different tools
US20040221262A1
Cited By
Macro-containing cross-module reference identifier length acquisition method, electronic equipment and medium
CN121635900A
