Adaptive signal annotation method, electronic device and medium
By placing annotation information according to the starting position and length of the signal value in the signal annotation method, the problem of low utilization efficiency of signal annotation space in the prior art is solved, and a more reasonable and beautiful annotation effect is achieved.
Patent Information
- Application Number
- CN202510414166.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-03
- Publication Date
- 2025-05-02
- Estimated Expiration
- 2045-04-03
AI Technical Summary
The existing signal annotation methods are low in space utilization efficiency, poor in rationality, and not beautiful enough. Especially when the signal annotation text is long, it is easy to have incomplete display or occupy a large amount of space.
By obtaining the signal values of the signal to be annotated in the code lines to be annotated one by one, and placing the signal annotation information in one or more annotation lines according to the starting position and length of the signal value, reducing the amount of annotation information required to be truncated, improving the utilization efficiency of the annotation space, and making the annotation information clearer and more beautiful.
This has achieved the improvement of spatial utilization efficiency of signal annotations, making the annotation information more reasonable and beautiful, reducing the number of annotation information that needs to be cut off, and improving the clarity of the annotation information displayed.
Smart Images

Figure CN119918482A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to an adaptive signal annotation method, electronic equipment and medium. Background Art
[0002] In electronic design automation (EDA) software, in order to quickly obtain the numerical values of design signals at different simulation times in the source code view, the method of inserting signal value annotations in the source code view is usually adopted. Signal annotations are generally inserted above or below the code line where the signal name of the original design code is located to improve readability. Usually, a line of code contains a large number of signal names that are close in physical space and need to be annotated. Since the text value length of the signal annotation is different from the length of the original signal name, when the signal annotation text is long, if the annotation content of one line is used, it is easy to cause the annotation text to be incompletely displayed. If the method of multiple lines of annotation is used, it may cause the annotation line in the visible range to occupy a large amount of space, squeezing out the display space of the original design code. It can be seen that the existing signal annotation method has low space utilization efficiency, poor rationality, and is not beautiful enough. Summary of the invention
[0003] The object of the present invention is to provide an adaptive signal annotation method, electronic device and medium, which can effectively improve the spatial utilization efficiency of signal annotation and make the signal annotation more reasonable and beautiful.
[0004] A first aspect of the present invention provides an adaptive signal annotation method, comprising: Step S1, obtain the list of signals to be annotated in the code line to be annotated {A1, A2, ..., A n ,…,A N},A n is the nth signal to be annotated in the code line to be annotated, where n ranges from 1 to N, A1, A2, …, A n ,…,A N Arrange them in the order of the lines of code to be annotated; Step S2: Set M strings {R1, R2, ..., R m ,…,R M}, R m is the mth string, the value range of m is 1 to M, M is the maximum number of annotation lines, and each R m Initially empty, n=1, m=1 are set initially; Step S3: Get A n The signal value V n , if V n If it is empty, execute step S8, otherwise, obtain A nThe starting position B of the text column n , perform step S4; Step S4. Compare the current R m with the length L m of B n minus 1. If L m is greater than or equal to B n minus 1, then perform step S5; otherwise, perform step S7; Step S5. If m < M, then set m = m + 1 and return to perform step S4. If m = M, then perform step S6; Step S6. Truncate R1 to the position of B n minus 2, and set m = 1; Step S7. First, fill R m with a preset delimiter character to the position of B n minus 1, and then set R m = R m + V n ; Step S8. If n < N, then set n = n + 1, m = 1, and return to perform step S3; otherwise, perform step S9; Step S9. Based on the current {R1, R2, …, R m , …, R M}, display the signal annotation of the to-be-annotated code line on the source code interface. Each non-empty R m occupies one code line, and the smaller the m value, the closer the line corresponding to R m is to the to-be-annotated code line.
[0005] The second aspect of the present invention 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, and the instructions are configured to execute the method described in the first aspect of the present invention.
[0006] The third aspect of the present invention provides a computer-readable storage medium storing computer-executable instructions, and the computer instructions are used to execute the method described in the first aspect of the present invention.
[0007] Compared with the prior art, the present invention has obvious advantages and beneficial effects. By means of the above technical solutions, an adaptive signal annotation method, an electronic device, and a medium provided by the present invention can achieve considerable technical progress and practicality, and have wide industrial utilization value. It has at least the following beneficial effects: The present invention obtains the signal values of the signals to be annotated in the code lines to be annotated one by one, and places the signal annotation information in one or more annotation lines according to the starting position and length of the signal values, thereby reducing the amount of annotation information that needs to be truncated, improving the utilization efficiency of the annotation space, and making the displayed annotation information clearer and more beautiful. BRIEF DESCRIPTION OF THE DRAWINGS
[0008] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0009] Figure 1 A flow chart of an adaptive signal annotation method provided by an embodiment of the present invention; Figure 2 A schematic diagram of adaptive signal annotation display provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0010] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0011] The embodiment of the present invention provides an adaptive signal annotation method, such as Figure 1 As shown, including: Step S1, obtain the list of signals to be annotated in the code line to be annotated {A1, A2, ..., A n ,…,A N},A n is the nth signal to be annotated in the code line to be annotated, where n ranges from 1 to N, A1, A2, …, A n ,…,A N Arrange them in the order in which they appear in the code lines to be annotated.
[0012] The code line to be annotated may be any code line in the source code that contains a signal to be annotated, and the signal to be annotated is a signal that needs to display a signal value.
[0013] Step S2: Set M strings {R1, R2, ..., R m ,…,R M}, R m is the mth string, the value range of m is 1 to M, M is the maximum number of annotation lines, and each Rm It is initially empty, and initially set n = 1, m = 1.
[0014] Among them, R m is used to store the annotation information of the m-th line of the code line to be annotated. Each R m is initially empty. The number of annotation lines that the code line to be annotated finally needs to present changes adaptively according to the required annotation information, but the maximum number of annotation lines cannot exceed M.
[0015] Step S3, obtain the signal value V n of A n , if V n is empty, then execute step S8; otherwise, obtain the starting position B n of the text column of A n , and execute step S4.
[0016] Among them, if the signal value V n of A n is empty, it means that the signal value of A n at the current moment is empty, and there is no need to annotate. Just operate on the next signal to be annotated directly.
[0017] Step S4, compare the length L m of the current R m with B n -1. If L m ≥ B n -1, then execute step S5; otherwise, execute step S7.
[0018] Among them, the smaller the value of m, the closer the line corresponding to R m is to the code line to be annotated when displayed on the source code interface. Therefore, try to place the annotation information as close as possible to the code line to be annotated. So start judging from m = 1. It should be noted that in the same annotation line, there should be at least one character interval between two adjacent signal annotation information to clearly display the annotation information. Therefore, it is necessary to judge L m ≥ B n -1, rather than L m ≥ B n . If L m ≥ B n -1, it means that if V n is directly placed in R m , then part of the content of V n will be blocked by the existing content in R m . Therefore, it is necessary to judge whether the next R m meets the placement requirements.
[0019] Step S5, if m < M, then set m = m + 1, and return to execute step S4; if m = M, then execute step S6.
[0020] Among them, if m = M, it indicates that there is no R currently. m Meet the condition to directly place V n , in this case, it is necessary to truncate the nearest R1 to the line of code to be annotated, and place V n in R1.
[0021] Step S6: Truncate R1 to position B n -2, and set m = 1.
[0022] Step S7: First, fill the preset delimiter characters in R m to position B n -1, and then set R m = R m + V n .
[0023] It should be noted that by filling the preset delimiter characters in R m to position B n -1, the starting position of the text column of each signal in the annotation line is aligned with the starting position of the text column of the signal to be annotated, and it can make the annotation information between adjacent two signals in the same annotation line have a space character interval, so as to clearly display the annotation information. The preset delimiter character can be specifically set as a space character.
[0024] Step S8: If n < N, then set n = n + 1, m = 1, and return to execute Step S3; otherwise, execute Step S9.
[0025] Step S9: Based on the current {R1, R2,..., R m ,…, R M}, display the signal annotation of the line of code to be annotated on the source code interface. Each non-empty R m occupies one line of code, and the smaller the m value, the closer the line corresponding to R m is to the line of code to be annotated.
[0026] Among them, each non-empty R m occupies one line of code, forming an annotation line. It should be noted that the empty R m does not generate an annotation line on the source code interface, that is, the total number of the last non-empty R m is the number of annotation lines of the line of code to be annotated.
[0027] In order to avoid the signal value of some signals to be annotated being too long and affecting the distribution of the signal values of other signals to be annotated subsequently, for the signal values of the signals to be annotated that are too long, a truncation operation can be performed in advance. As an embodiment, in Step S3, if V n is not empty, before executing Step S4, it is also necessary to execute: Step S31: Compare V n The length P n and the preset length threshold Q, if P n >Q, then V n Truncated to the length of Q.
[0028] Through step S31, the length of the signal value of each signal to be annotated in the annotation row is within Q.
[0029] As an embodiment, in step S31, V n Truncated to the length of Q, inclusive: Step S311: convert the original V n Stored in the preset cache area, and then V n Delete the Qth and subsequent characters in V n The Qth character in is set as the preset truncation character.
[0030] It should be noted that V n Truncated to the length of Q, except that a truncated V is rendered in the directly rendered annotation line n , but at the same time, the original V n Stored in the preset cache area, when the original V n When the preset truncation mark is obtained from the preset cache area and displayed. The preset truncation mark can be specifically " ", it is understandable that other identifiers may also be set as truncation identifiers.
[0031] Similarly, when the truncation operation is performed in step S6, it is also necessary to ensure that the original value of the truncated signal value is stored in the preset cache area, and step S6 includes: Step S61, determine whether the last signal value in the current R1 already has a preset truncation mark, if so, execute step S63, otherwise, execute step S62.
[0032] Among them, if the preset truncation mark already exists in the last signal value in the current R1, it means that the truncation operation has been performed on the last signal value in R1. The original value of the last signal value in R1 has been stored in the preset cache area, so it is sufficient to directly continue to perform the second stage operation without repeatedly storing the original value of the last signal value in R1 in the preset cache area. If the preset truncation mark does not exist in the last signal value in the current R1, it is necessary to first store the original value of the last signal value in R1 in the preset cache area before performing the stage operation.
[0033] Step S62, store the original value of the last signal value in the current R1 in a preset cache area, and execute step S63.
[0034] Step S63: Delete the characters with column number B in the current R1 n -2 and those with column numbers greater than B n -2, and set the character with column number B n -2 in R1 as the preset truncation character.
[0035] As an embodiment, step S9 includes: Step S91: The signal annotation string W of the initial line of code to be annotated is empty. Initially set m = 1, and execute step S92.
[0036] Step S92: Determine whether R m is an empty string. If so, execute step S95; otherwise, execute step S93.
[0037] Step S93: Determine whether W is empty. If it is empty, set W = R m , otherwise, set W = W + line feed + R m , and execute step S94.
[0038] Step S94: If m < M, set m = m + 1, return and execute step S92; otherwise, execute step S95.
[0039] Step S95: Generate W below the line of code to be annotated in the source code interface.
[0040] It should be noted that through steps S91 - S95, the non-empty R m of the line of code to be annotated can be concatenated into a signal annotation string W, and line breaks during display are achieved through line feeds, realizing multi-line display of the annotation information of the line of code to be annotated.
[0041] As an embodiment, after step S6, it further includes: Step C7: Trigger the preset truncation identifier, obtain the target signal identifier corresponding to the triggered preset truncation identifier, obtain the target original signal value corresponding to the target signal identifier in the preset cache area, and present the target original signal value in the source code interface.
[0042] Specifically, the target original signal value corresponding to the target signal identifier can be obtained from the preset cache area and presented by clicking and selecting the preset truncation identifier in the source code interface.
[0043] As a specific example, the code line to be processed is "int s1,t,s,s4,s5,s6,s7,s8,s9;", and the list of signals to be annotated in the line of code to be annotated is {A1, A2,..., A n ,..., A N}={t,s,s4,s5,s6,s7,s8,s9}, the signal annotation result presented by executing steps S1 to S6 is as follows Figure 2 As shown, the annotation information of each signal is aligned with the starting position of the signal column. After executing steps S1 to S6, the annotation information of signal S1 is "5f6d7 ", displayed in the first comment line of the code line to be processed, is the preset truncation mark. The annotation information of t is "45339bbf", which is displayed in the second annotation line of the code line to be processed. The annotation information of signal "s" is "41ec5fff", which is displayed in the third annotation line of the code line to be processed. The annotation information of signal "s4" is "4 ", displayed in the first comment line of the code line to be processed, is a preset truncation mark. The annotation information of signal "s5" is "41a0d80f", which is displayed in the second annotation line of the code line to be processed. The annotation information of signal "s6" is "41a02c2f", which is displayed in the second annotation line of the code line to be processed. The annotation information of signal "s7" is "41a016b3", which is displayed in the third annotation line of the code line to be processed. The annotation information of signal "s8" is "41a014f1", which is displayed in the first annotation line of the code line to be processed. The annotation information of signal "S9" is "41a014c4" which is displayed in the second annotation line of the code line to be processed. Based on the method described in the embodiment of the present invention, only two of the eight signals to be annotated perform the truncation operation, which satisfies the requirement that the annotation information of all signals is not blocked, greatly reducing the number of signal annotation information that needs to be truncated when only one line is displayed, and making the display more intuitive and more beautiful.
[0044] It should be noted that some exemplary embodiments are described as processes or methods depicted as flow charts. Although the flow charts describe the steps as sequential processes, many of the steps can be implemented in parallel, concurrently or simultaneously. In addition, the order of the steps can be rearranged. The process can be terminated when its operation is completed, but it can also have additional steps not included in the accompanying drawings. The process can correspond to a method, function, procedure, subroutine, subprogram, etc.
[0045] An embodiment of the present invention also provides an electronic device, 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, and the instructions are configured to execute the method described in the embodiment of the present invention.
[0046] The embodiment of the present invention further provides a computer-readable storage medium storing computer-executable instructions, wherein the computer instructions are used to execute the method described in the embodiment of the present invention.
[0047] The embodiment of the present invention obtains the signal values of the signals to be annotated in the code lines to be annotated one by one, and places the signal annotation information in one or more annotation lines according to the starting position and length of the signal values, thereby reducing the amount of annotation information that needs to be truncated, improving the utilization efficiency of the annotation space, and making the displayed annotation information clearer and more beautiful.
[0048] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any form. Although the present invention has been disclosed as a preferred embodiment as above, it is not used to limit the present invention. Any technician familiar with this profession can make some changes or modifications to equivalent embodiments of equivalent changes using the technical contents disclosed above without departing from the scope of the technical solution of the present invention. However, any simple modification, equivalent change and modification made to the above embodiments based on the technical essence of the present invention without departing from the content of the technical solution of the present invention still falls within the scope of the technical solution of the present invention.
Claims
1. An adaptive signal annotation method, characterized in that: Including: Step S1, obtain the list of signals to be annotated in the code line to be annotated {A1, A2, ..., A n ,…,A N },A n is the nth signal to be annotated in the code line to be annotated, where n ranges from 1 to N, A1, A2, …, A n ,…,A N Arrange them in the order of the lines of code to be annotated; Step S2: Set M strings {R1, R2, ..., R m ,…,R M }, R m is the mth string, the value range of m is 1 to M, M is the maximum number of annotation lines, and each R m Initially empty, n=1, m=1 are set initially; Step S3: Get A n The signal value V n , if V n If it is empty, execute step S8, otherwise, obtain A n The text column starts at position B n , execute step S4; Step S4: Compare the current R m Length L m and B n -1, if L m ≥B n -1, then execute step S5, otherwise, execute step S7; Step S5: If m < M, then set m = m + 1 and return to execute Step S4; if m = M, then execute Step S6; Step S6: truncate R1 to B n -2 position; Step S7: First, R m Fill the default separator character to B n -1 position, then set R m =R m +V n ; Step S8: If n < N, then set n = n + 1, m = 1, and return to execute Step S3; otherwise, execute Step S9; Step S9: Based on the current {R1, R2, ..., R m ,…,R M } Display the signal annotation of the code line to be annotated on the source code interface, and each non-empty R m It occupies one code line, and the smaller the m value is, the closer the line corresponding to R is to the code line to be annotated.
2. The method according to claim 1, wherein In step S3, if V n is not empty. Before executing step S4, you need to execute: Step S31: Compare V n The length P n and the preset length threshold Q, if P n >Q, then V n Truncated to the length of Q.
3. The method according to claim 2, wherein In step S31, V n Truncated to the length of Q, inclusive: Step S311: convert the original V n Stored in the preset cache area, and then V n Delete the Qth and subsequent characters in V n The Qth character in is set as the preset truncation character.
4. The method according to claim 3, wherein The said Step S6 includes: Step S61: Judge whether a preset truncation identifier already exists in the last signal value in the current R1. If so, execute Step S63; otherwise, execute Step S62; Step S62: Store the original value of the last signal value in the current R1 in a preset cache area, and execute Step S63; Step S63: set the column number of the current R1 to B n -2 and the column number is greater than B n -2 characters are deleted, and the column number B in R1 is n The character -2 is set as the default truncation character.
5. The method according to claim 1, wherein The said Step S9 includes: Step S91: Initialize the signal annotation string W of the code line to be annotated as empty, initialize m = 1, and execute Step S92; Step S92: Determine R m Is it an empty string? If so, execute step S95; otherwise, execute step S93; Step S93: Determine whether W is empty. If so, set W=R. m Otherwise, set W=W+newline+R m , execute step S94; Step S94: If m < M, then set m = m + 1 and return to execute Step S92; otherwise, execute Step S95; Step S95: Generate W below the code line to be annotated in the source code interface.
6. The method according to claim 3 or 4, wherein Step C7: Trigger a preset truncation identifier, obtain the target signal identifier corresponding to the triggered preset truncation identifier, obtain the target original signal value corresponding to the target signal identifier in the preset cache area, and present the target original signal value in the source code interface.
7. An electronic device, characterized in that: 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, and the instructions are configured to execute the method described in any one of the foregoing claims 1 - 6.
8. A computer-readable storage medium, characterized in that: Store computer - executable instructions, and the computer - executable instructions are used to execute the method described in any one of the foregoing claims 1 - 6.
Citation Information
Patent Citations
Source code processing method and device
CN104699467A
Visualized drifting algorithm of Gif warehouse file annotation system
CN108228231A
Adaptive display method for chip design code annotations, electronic equipment and medium
CN117236270A
Code annotation generation method and related device
CN118605936A