A source code valid range determination system for chip verification code debugging

By determining the target instance and module in chip verification code debugging, and combining the source code ranges of subtasks and subfunctions, accurately dividing the categories of each line in the source code file, the problem of inaccurate debugging effective scope in the existing technology is solved and the user's debugging experience is improved.

CN118210728BActive Publication Date: 2025-05-06SHANGHAI UNIVISTA IND SOFTWARE GRP CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410436083.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-11
Publication Date
2025-05-06
Estimated Expiration
2044-04-11

AI Technical Summary

Technical Problem

In the Verilog syntax of chip verification, some of the content of the module may be defined outside the module scope, making it difficult for the prior art to accurately determine the effective scope of debugging, and treating lines without actual content as invalid lines, resulting in a scattered display of the effective scope of debugging, reducing the user's debugging experience.

Method used

By obtaining the current concern in the source code file, determining the target instance and its corresponding target module, combining the source code ranges of the target module and its subtasks and subfunctions, determining the valid and invalid ranges, and then accurately dividing the categories of each line in the source code file and determining the target valid range.

Benefits of technology

It realizes the accurate division of the effective range of the source code, avoids the decentralized display of the effective range caused by lines without actual content, and improves the user's debugging experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118210728B_ABST
    Figure CN118210728B_ABST
Patent Text Reader

Abstract

The present application relates to the field of code debugging technology, and in particular to a source code valid range determination system for chip verification code debugging, the system comprising: a source code file, a processor and a memory storing a computer program, wherein the source code file comprises a plurality of modules, a plurality of subtasks and a plurality of subfunctions, and when the computer program is executed by the processor, the following steps are implemented: determining a target module corresponding to a current focus point in the source code file, treating modules other than the target module as non-target modules, obtaining a third valid range according to the source code range of the target module and its subtasks and subfunctions, determining a third invalid range according to the source code ranges of each non-target module and other subtasks and subfunctions, determining a category of each line in the source code file according to the third valid range and the third invalid range, determining the source code range corresponding to the line having the valid category as the target valid range, and improving the accuracy and consistency of the effective range division.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of code debugging, and in particular to a source code effective range determination system for chip verification code debugging. Background Art

[0002] In the scenario of chip verification code debugging, chip designers and verifiers usually have the need to jump from a selected instance or sub-range to the module content corresponding to the instance to view related source code. The existing technology usually only uses the module range corresponding to the instance as the effective debugging range.

[0003] However, in the Verilog syntax of chip verification, part of the content of the module may be defined outside the module scope, which makes it difficult to accurately determine the effective debugging range using existing methods. Moreover, the existing technology usually regards lines with no actual content as invalid lines, resulting in that when the effective debugging range is displayed to the user, the effective debugging range may be scattered due to the existence of lines with no actual content, thereby reducing the user's debugging experience.

[0004] Therefore, how to more accurately determine the effective range of the source code and make the display of the effective range of the source code more reasonable to improve the user debugging experience has become an urgent problem to be solved. Summary of the invention

[0005] In view of the above technical problems, the technical solution adopted by the present invention is:

[0006] A system for determining the effective range of source code for debugging chip verification code, the system comprising: a source code file, a processor and a memory storing a computer program, wherein the source code file comprises a plurality of modules, a plurality of subtasks and a plurality of subfunctions, and when the computer program is executed by the processor, the following steps are implemented:

[0007] Step S101, obtaining a current focus point in a source code file, and determining a target instance corresponding to the current focus point.

[0008] Step S102: determine the target module corresponding to the target instance from all modules included in the source code file, and determine the modules other than the target module as non-target modules.

[0009] Step S103, obtaining a source code range corresponding to the target module as a first valid range.

[0010] Step S104: The source code ranges corresponding to all subtasks and subfunctions included in the target module are taken as the second valid range.

[0011] Step S105: The source code range corresponding to each non-target module in the source code file is taken as a first invalid range.

[0012] Step S106: The source code ranges corresponding to the subtasks and subfunctions in the source code file except for all the subtasks and subfunctions included in the target module content are all taken as the second invalid range.

[0013] Step S107: determine a third effective range according to the first effective range and the second effective range.

[0014] Step S108, determining a third invalid range according to the first invalid range and the second invalid range.

[0015] Step S109, traverse each line in the source code file, and determine the category of the corresponding line according to the third valid range and the third invalid range, where the category includes a valid category and an invalid category.

[0016] Step S110 , determining the source code range corresponding to all rows of the valid category as the target valid range.

[0017] Compared with the prior art, the present invention has obvious beneficial effects. By means of the above technical solution, a system for determining the effective range of source code for debugging chip verification code provided by the present invention can achieve considerable technical progress and practicality, and has wide industrial utilization value, and has at least the following beneficial effects:

[0018] The present invention provides a source code effective range determination system for chip verification code debugging, the system comprising: a source code file, a processor and a memory storing a computer program, wherein the source code file comprises a plurality of modules, a plurality of subtasks and a plurality of subfunctions, and when the computer program is executed by the processor, the following steps are implemented: obtaining a current focus point in the source code file, determining a target instance corresponding to the current focus point, determining a target module corresponding to the target instance from all modules included in the source code file, determining modules other than the target module as non-target modules, obtaining a source code range corresponding to the target module as a first effective range, and determining the source code range corresponding to all subtasks and subfunctions included in the target module as a first effective range. The source code range is taken as the second valid range, the source code range corresponding to each non-target module in the source code file is taken as the first invalid range, the source code range corresponding to all subtasks and subfunctions except all subtasks and subfunctions contained in the target module content in the source code file is taken as the second invalid range, the third valid range is determined according to the first valid range and the second valid range, the third invalid range is determined according to the first invalid range and the second invalid range, each line in the source code file is traversed, and the category of the corresponding line is determined according to the third valid range and the third invalid range, the category includes valid category and invalid category, and the source code range corresponding to all lines of valid category is determined as the target valid range.

[0019] It can be seen that by taking the source code ranges corresponding to all subtasks and subfunctions contained in the target module as the second valid range, and then combining them with the first valid range corresponding to the target module, the third valid range is determined, so that the subfunctions or subtasks defined outside the target module range can also be accurately divided into the valid range, and, in combination with the third valid range and the third invalid range, each line in the source code file is judged, so that lines without actual content can also accurately obtain their corresponding categories, thereby making the target valid range more coherent and improving the user's debugging experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] 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.

[0021] Figure 1 A flowchart of a computer program executed by a processor in a source code effective range determination system for chip verification code debugging provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0022] 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.

[0023] This embodiment provides a source code effective range determination system for chip verification code debugging, the system comprising: a source code file, a processor and a memory storing a computer program, wherein the source code file comprises a plurality of modules, a plurality of subtasks and a plurality of subfunctions, see Figure 1 , is a flow chart of a computer program executed by a processor in a source code effective range determination system for chip verification code debugging provided by an embodiment of the present invention. When the computer program is executed by the processor, the following steps are implemented:

[0024] Step S101, obtaining a current focus point in the source code file, and determining a target instance corresponding to the current focus point;

[0025] Step S102, determining a target module corresponding to the target instance from all modules included in the source code file, and determining modules other than the target module as non-target modules;

[0026] Step S103, obtaining a source code range corresponding to the target module as a first valid range;

[0027] Step S104, taking the source code ranges corresponding to all subtasks and subfunctions contained in the target module as the second valid range;

[0028] Step S105, taking the source code range corresponding to each non-target module in the source code file as a first invalid range;

[0029] Step S106, taking the source code ranges corresponding to the subtasks and subfunctions in the source code file except for all the subtasks and subfunctions included in the target module content as the second invalid range;

[0030] Step S107, determining a third effective range according to the first effective range and the second effective range;

[0031] Step S108, determining a third invalid range according to the first invalid range and the second invalid range;

[0032] Step S109, traversing each line in the source code file, and determining the category of the corresponding line according to the third valid range and the third invalid range, wherein the category includes a valid category and an invalid category;

[0033] Step S110: determining the source code range corresponding to all rows of the valid category as the target valid range.

[0034] Among them, the source code file may refer to the source code file that needs to be debugged, and the source code file may use Verilog syntax. In this embodiment, the current focus may be the part of the module call, so it is necessary to determine the target instance corresponding to the current focus, and then jump to the target module corresponding to the target instance, that is, jump from the module call part to the module definition part.

[0035] In one embodiment, the current focus may also be the part defined by the module. In this case, the module corresponding to the current focus is needed, and then jump to the target instance corresponding to the module, and then determine the target module corresponding to the target instance, that is, jump from the module definition part to the module call part.

[0036] Specifically, each module, subtask and subfunction in the source code file has a corresponding unique identifier, which can be regarded as a pointer for finding the corresponding identification information in the database. The identification information may include the name, the start line of the code, the end line of the code, the parent scope, etc. Obviously, the source code scope can be determined by the start line of the code and the end line of the code.

[0037] In a specific implementation, step S101 also includes the following steps:

[0038] S1011, obtaining the current focus point in the source code file;

[0039] S1012, if the current focus point is an instance, determining the current focus point to be the target instance;

[0040] S1013, if the current focus is a sub-scope, iteratively execute the step of obtaining a parent scope corresponding to the sub-scope, and using the obtained parent scope as the sub-scope, until the obtained parent scope is an instance, which is determined as the target instance.

[0041] Among them, since the current focus point is selected by the user, the current focus point may be an instance or a sub-range. If the current focus point is a sub-range, the parent range of the sub-range is obtained according to the identification information, and it is determined whether the parent range is an instance. If the parent range is still not an instance, the parent range is used as the sub-range, and the parent range of the sub-range is continued to be obtained according to the identification information until the obtained parent range is an instance.

[0042] In a specific implementation manner, the source code file corresponds to a file unique identifier;

[0043] Step S103 also includes the following steps:

[0044] Step S1031, obtaining the source code range corresponding to the target module;

[0045] Step S1032: If the file unique identifier corresponding to the source code range corresponding to the target module is the same as the file unique identifier of the source code file, it is determined that the source code range corresponding to the target module is the first valid range.

[0046] Among them, when the file unique identifier corresponding to the source code range corresponding to the target module is the same as the file unique identifier of the source code file, it means that the source code range corresponding to the target module is in the source code file, so the source code range corresponding to the target module is determined to be the first valid range.

[0047] In a specific implementation manner, the source code file corresponds to a file unique identifier;

[0048] Step S104 also includes the following steps:

[0049] Step S1041, obtaining source code ranges corresponding to all subtasks and subfunctions contained in the target module;

[0050] Step S1042: If the file unique identifier corresponding to the source code range corresponding to any subtask or subfunction is the same as the file unique identifier of the source code file, then the corresponding source code range is determined to be the second valid range.

[0051] Among them, there may be subtasks or subfunctions in the target module that are defined in other source code files, and this embodiment only determines the valid range in the source code file. When the file unique identifier corresponding to the source code range corresponding to any subtask or subfunction is the same as the file unique identifier of the source code file, it means that the source code range corresponding to the subtask or subfunction is in the source code file, and therefore the corresponding source code range is the second valid range.

[0052] In a specific implementation manner, the source code file corresponds to a file unique identifier;

[0053] Step S105 also includes the following steps:

[0054] Step S1051, obtaining the source code range corresponding to each non-target module in the source code file;

[0055] Step S1052: If the file unique identifier corresponding to the source code range corresponding to any non-target module is the same as the file unique identifier of the source code file, it is determined that the source code range corresponding to the non-target module is the first invalid range.

[0056] In a specific implementation manner, the source code file corresponds to a file unique identifier;

[0057] Step S106 also includes the following steps:

[0058] Step S1061, obtaining source code ranges corresponding to other subtasks and subfunctions in the source code file except for all subtasks and subfunctions included in the target module content;

[0059] Step S1062: If the file unique identifier corresponding to any subtask and subfunction in the source code file except all subtasks and subfunctions included in the target module content is the same as the file unique identifier of the source code file, the corresponding source code range is determined to be the second invalid range.

[0060] In a specific implementation, determining a third valid range according to the first valid range and the second valid range includes:

[0061] A first intersection of the first valid range and the second valid range is calculated, and the first intersection is used as the third valid range.

[0062] The process of calculating the first intersection may be as follows:

[0063] Sort the first valid range and all second valid ranges according to the size of the starting row. The smaller the starting row, the higher the sorting. Obtain a valid range sequence. Add the first valid range in the valid range sequence to the first valid range set. i is initially set to 2. Take the i-th valid range as the first merged item. If the starting row of the first merged item is less than or equal to the ending row of the last item in the first valid set, then set the ending row of the last item in the first valid set to the maximum value of the ending row of the first merged item and the ending row of the last item in the first valid set. Otherwise, add the first merged item to the end of the first valid set, update i=i+1, and return to execute the step of taking the i-th valid range as the first merged item until i=I+1, where I is the sum of the number of the first valid range and all second valid ranges.

[0064] In a specific implementation manner, determining a third invalid range according to the first invalid range and the second invalid range includes:

[0065] A second intersection of the first invalid range and the second invalid range is calculated, and the second intersection is used as the third invalid range.

[0066] The process of calculating the second intersection may be as follows:

[0067] Sort all first invalid ranges and all second invalid ranges according to the size of the starting row. The smaller the starting row, the higher the sorting. Obtain an invalid range sequence. Add the first invalid range in the invalid range sequence to the first invalid range set. Initially, j is set to 2. Take the jth invalid range as the second merged item. If the starting row of the second merged item is less than or equal to the ending row of the last item in the first invalid set, then set the ending row of the last item in the first invalid set to the maximum value of the ending row of the second merged item and the ending row of the last item in the first invalid set. Otherwise, add the second merged item to the end of the first invalid set, update j=j+1, and return to execute the step of taking the jth invalid range as the second merged item until j=J+1, where J is the total number of all first invalid ranges and all second invalid ranges.

[0068] In a specific implementation, step S109 also includes the following steps:

[0069] Step S1091, traversing each line in the source code file, and if the line is in a third valid range, determining that the category corresponding to the line is a valid category;

[0070] Step S1092, if the row is in the third invalid range, determining that the category corresponding to the row is an invalid category;

[0071] Step S1093, otherwise, determine the row that is closest to the row and has a corresponding category among the rows before the row as the first relevant row of the row, determine the row that is closest to the row and has a corresponding category among the rows after the row as the second relevant row of the row, if the first relevant row and the second relevant row are both valid categories, determine the category corresponding to the row as a valid category;

[0072] Step S1094: If both the first related row and the second related row are invalid categories, determine that the category corresponding to the row is an invalid category.

[0073] In this embodiment, the source code ranges corresponding to all subtasks and subfunctions contained in the target module are taken as the second valid range, and then combined with the first valid range corresponding to the target module to determine the third valid range, so that subfunctions or subtasks defined outside the target module range can also be accurately divided into the valid range, and, in combination with the third valid range and the third invalid range, each line in the source code file is judged, so that lines without actual content can also accurately obtain their corresponding categories, thereby making the target valid range more coherent and improving the user's debugging experience.

[0074] Although some specific embodiments of the present invention have been described in detail by way of example, it will be appreciated by those skilled in the art that the above examples are for illustration only and are not intended to limit the scope of the present invention. It will also be appreciated by those skilled in the art that various modifications may be made to the embodiments without departing from the scope and spirit of the present invention. The scope of the present invention is defined by the appended claims.

Claims

1. A source code effective range determination system for chip verification code debugging, characterized in that: The system comprises: a source code file, a processor and a memory storing a computer program, wherein the source code file comprises a plurality of modules, a plurality of subtasks and a plurality of subfunctions, and when the computer program is executed by the processor, the following steps are implemented: Step S101, obtaining a current focus point in the source code file, and determining a target instance corresponding to the current focus point; Step S102, determining a target module corresponding to the target instance from all modules included in the source code file, and determining modules other than the target module as non-target modules; Step S103, obtaining a source code range corresponding to the target module as a first valid range; Step S104, taking the source code ranges corresponding to all subtasks and subfunctions contained in the target module as the second valid range; Step S105, taking the source code range corresponding to each non-target module in the source code file as a first invalid range; Step S106, taking the source code ranges corresponding to the subtasks and subfunctions in the source code file except for all the subtasks and subfunctions included in the target module content as the second invalid range; Step S107, determining a third effective range according to the first effective range and the second effective range; Step S108, determining a third invalid range according to the first invalid range and the second invalid range; Step S109, traversing each line in the source code file, and determining the category of the corresponding line according to the third valid range and the third invalid range, wherein the category includes a valid category and an invalid category, wherein step S109 also includes the following steps: Step S1091, traversing each line in the source code file, and if the line is in a third valid range, determining that the category corresponding to the line is a valid category; Step S1092, if the row is in the third invalid range, determining that the category corresponding to the row is an invalid category; Step S1093, otherwise, determine the row that is closest to the row and has a corresponding category among the rows before the row as the first relevant row of the row, determine the row that is closest to the row and has a corresponding category among the rows after the row as the second relevant row of the row, if the first relevant row and the second relevant row are both valid categories, determine the category corresponding to the row as a valid category; Step S1094, if both the first related row and the second related row are invalid categories, determining that the category corresponding to the row is an invalid category; Step S110: determine the source code range corresponding to all rows of the valid category as the target valid range.

2. The source code effective range determination system for chip verification code debugging according to claim 1, characterized in that: Step S101 also includes the following steps: S1011, obtaining the current focus point in the source code file; S1012, if the current focus point is an instance, determining the current focus point to be the target instance; S1013, if the current focus is a sub-scope, iteratively execute the step of obtaining a parent scope corresponding to the sub-scope, and using the obtained parent scope as the sub-scope, until the obtained parent scope is an instance, which is determined as the target instance.

3. The source code effective range determination system for chip verification code debugging according to claim 1, characterized in that: The source code file corresponds to a unique file identifier; Step S103 also includes the following steps: Step S1031, obtaining the source code range corresponding to the target module; Step S1032: If the file unique identifier corresponding to the source code range corresponding to the target module is the same as the file unique identifier of the source code file, it is determined that the source code range corresponding to the target module is the first valid range.

4. The system for determining the effective range of source code for debugging chip verification code according to claim 1, characterized in that: The source code file corresponds to a unique file identifier; Step S104 also includes the following steps: Step S1041, obtaining source code ranges corresponding to all subtasks and subfunctions contained in the target module; Step S1042: If the file unique identifier corresponding to the source code range corresponding to any subtask or subfunction is the same as the file unique identifier of the source code file, then the corresponding source code range is determined to be the second valid range.

5. The source code effective range determination system for chip verification code debugging according to claim 1, characterized in that: The source code file corresponds to a unique file identifier; Step S105 also includes the following steps: Step S1051, obtaining the source code range corresponding to each non-target module in the source code file; Step S1052: If the file unique identifier corresponding to the source code range corresponding to any non-target module is the same as the file unique identifier of the source code file, it is determined that the source code range corresponding to the non-target module is the first invalid range.

6. The source code effective range determination system for chip verification code debugging according to claim 1, characterized in that: The source code file corresponds to a unique file identifier; Step S106 also includes the following steps: Step S1061, obtaining source code ranges corresponding to other subtasks and subfunctions in the source code file except for all subtasks and subfunctions included in the target module content; Step S1062: If the file unique identifier corresponding to any subtask and subfunction in the source code file except all subtasks and subfunctions included in the target module content is the same as the file unique identifier of the source code file, the corresponding source code range is determined to be the second invalid range.

7. The source code effective range determination system for chip verification code debugging according to claim 1, characterized in that: The determining a third valid range according to the first valid range and the second valid range includes: A first intersection of the first valid range and the second valid range is calculated, and the first intersection is used as the third valid range.

8. The source code effective range determination system for chip verification code debugging according to claim 1, characterized in that: The determining of a third invalid range according to the first invalid range and the second invalid range includes: A second intersection of the first invalid range and the second invalid range is calculated, and the second intersection is used as the third invalid range.

Citation Information

Patent Citations

  • Method, device and system for determining effective partition in database

    CN110019337A

  • Method for determining position information of target calling identifier, electronic equipment and medium

    CN116627846A