A prime product encoding-based EDA simulator scope control management method
By assigning numbers to the scopes of the EDA simulator and generating a stack number table through prime number product encoding, the problems of resource waste and high time complexity in large-scale chip design are solved, achieving efficient scope control and management, and improving the performance and stability of the simulator.
Patent Information
- Application Number
- CN202610562908.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-04-27
- Publication Date
- 2026-06-23
- Estimated Expiration
- 2046-04-27
AI Technical Summary
Existing EDA simulators suffer from significant resource waste, high time complexity, and stability risks when managing the scope control of large-scale chip designs, affecting simulation speed and performance.
During the compilation phase, a unique number is assigned to each scope using prime number product encoding, and a stack number table is generated. The compilation phase identifies the scope and calculates the stack number. During the simulation phase, the scope is controlled through table lookup operations, avoiding the dynamic creation and traversal of the scope tree.
It significantly reduces memory usage and runtime overhead, improves the performance and stability of the simulator, and simplifies scope control management.
Smart Images

Figure CN122088138B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of electronic design automation technology, and in particular to a domain control and management method for EDA simulators based on prime number product encoding. Background Technology
[0002] In electronic design automation (EDA) simulators, the SystemVerilog language defines statements corresponding to specific functions to be executed during the simulation run. These statements often correspond to a certain scope. At the same time, the SystemVerilog language also provides tasks to control these specific functions, allowing users to dynamically enable or disable specific functions within a scope and its sub-scopes during the simulation run.
[0003] In existing technologies, it is usually necessary to allocate independent memory space for each scope instance to store control information. When executing control statements, the target scope instance is found through a global mapping table, and all its child scope instances are recursively traversed, with their states modified one by one. Then, when executing a specific function, the control state of the current scope is queried.
[0004] However, due to the massive scale of modern chip designs, the number of scope instances can reach millions or even higher. Allocating state memory for each scope instance would lead to significant resource waste, and control statements and specific functions are typically used very infrequently. Furthermore, the execution of control statements requires dynamic lookups and recursive traversals of the scope tree, resulting in high time complexity and impacting simulation speed. Additionally, the simulator needs to dynamically maintain the creation, destruction, and parent-child relationship trees of scope instances, increasing the implementation difficulty and stability risks of the simulator.
[0005] Therefore, improving the convenience of EDA simulator scope control management and reducing memory usage have become urgent problems to be solved. Summary of the Invention
[0006] To address the aforementioned technical problems, the technical solution adopted by this invention is as follows:
[0007] A method for scope control and management of an EDA simulator based on prime number product encoding, the method comprising the following steps:
[0008] S1, during the compilation phase, the obtained abstract syntax tree is traversed to identify all first scopes and second scopes, where the first scope corresponds to control parameters and the second scope does not correspond to control parameters;
[0009] S2, for any first scope, assign a unique prime number to the first scope as the reference number corresponding to the first scope;
[0010] S3, assign a first preset value to each second scope as a reference number corresponding to each second scope;
[0011] S4, Identify all positions containing preset statements from the abstract syntax tree, and for any position, enumerate all call stacks containing that position;
[0012] S5. For any call stack, determine the stack number corresponding to the call stack based on the reference numbers corresponding to all first scopes and all second scopes traversed by the call stack.
[0013] S6, a stack number table is formed by all stack numbers that are not the first preset value and their corresponding control information;
[0014] S7. After the target parameter is executed during the simulation phase, the target scope corresponding to the target parameter is parsed and the target number corresponding to the target scope is determined, wherein the target parameter belongs to the control parameter;
[0015] S8. Based on the target number and the stack number table, determine a number of stack numbers associated with the target number. For any stack number associated with the target number, adjust the control information corresponding to that stack number in the stack number table according to the target parameter.
[0016] S9. After the target statement is executed during the simulation phase, the execution number corresponding to the call path of the target statement is determined. According to the control information corresponding to the execution number in the stack number table, the execution of the target statement is controlled. The target statement belongs to the preset statement.
[0017] Compared with the prior art, the present invention has significant advantages. Through the above technical solution, the EDA simulator scope control management method based on prime number product encoding provided by the present invention achieves considerable technical progress and practicality, and has broad industrial application value. It has at least the following advantages:
[0018] In this invention, scope identification, number allocation, and stack number calculation are performed during the compilation phase to generate a stack number table. Only each scope and its corresponding reference number, as well as the stack number table, need to be stored in memory. The memory requirement is much smaller than the number of scope instances, significantly reducing memory usage. During the simulation phase, only integer multiplication and division operations and table lookup operations are needed to achieve scope control, significantly reducing runtime overhead and avoiding the complexity of dynamically creating, maintaining, and traversing the scope tree, thereby improving the performance and stability of the simulator. Attached Figure Description
[0019] 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.
[0020] Figure 1 This is a flowchart illustrating an EDA simulator scope control management method based on prime number product encoding, provided as an embodiment of the present invention. Detailed Implementation
[0021] 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.
[0022] This embodiment provides a scope control and management method for an EDA simulator based on prime number product encoding. See [link to documentation]. Figure 1 The above is a flowchart illustrating an EDA simulator scope control management method based on prime number product encoding, provided by an embodiment of the present invention. The method includes the following steps:
[0023] S1, during the compilation phase, the obtained abstract syntax tree is traversed to identify all first scopes and second scopes, where the first scope corresponds to control parameters and the second scope does not correspond to control parameters;
[0024] S2, for any first scope, assign a unique prime number to the first scope as the reference number corresponding to the first scope;
[0025] S3, assign a first preset value to each second scope as a reference number corresponding to each second scope;
[0026] S4, Identify all positions containing preset statements from the abstract syntax tree, and for any position, enumerate all call stacks containing that position;
[0027] S5. For any call stack, determine the stack number corresponding to the call stack based on the reference numbers corresponding to all first scopes and all second scopes traversed by the call stack.
[0028] S6, a stack number table is formed by all stack numbers that are not the first preset value and their corresponding control information;
[0029] S7. After the target parameter is executed during the simulation phase, the target scope corresponding to the target parameter is parsed and the target number corresponding to the target scope is determined, wherein the target parameter belongs to the control parameter;
[0030] S8. Based on the target number and the stack number table, determine a number of stack numbers associated with the target number. For any stack number associated with the target number, adjust the control information corresponding to that stack number in the stack number table according to the target parameter.
[0031] S9. After the target statement is executed during the simulation phase, the execution number corresponding to the call path of the target statement is determined. According to the control information corresponding to the execution number in the stack number table, the execution of the target statement is controlled. The target statement belongs to the preset statement.
[0032] The processing of an EDA simulator typically includes a compilation stage and a simulation stage. The compilation stage is used to parse the source code and generate intermediate files, while the simulation stage is used to execute the compilation results.
[0033] Scope refers to the visible range of identifiers such as variables, tasks, and functions in the source code. The first scope corresponds to the control parameter, that is, the scope referenced by the control parameter. The second scope does not correspond to the control parameter, that is, the scope not referenced by the control parameter.
[0034] Different prime numbers correspond to different first scopes, and the first preset value is set to 1.
[0035] Preset statements refer to statements that execute specific functions. The call stack refers to the execution path to the position corresponding to the preset statement.
[0036] The stack number is used to uniquely identify the corresponding call stack, the control information is used to indicate the control state of the corresponding call stack, the control parameters are used to adjust the control state of the corresponding scope, and the control state of the call stack can be determined based on the control state of the scope through which the call stack passes.
[0037] The target parameter is one of several control parameters specified by the user, and the target scope is the scope of the control state that the target parameter can adjust.
[0038] The target statement is one of several preset statements used for specification. The call path refers to the call stack corresponding to the target statement, and the execution number is the stack number of the call stack corresponding to the target statement.
[0039] Specifically, each scope and its corresponding reference number can form a mapping table of scopes and reference numbers. This mapping table is stored in memory and is read-only during the simulation phase. It should be noted that in this embodiment, the control parameters should be syntax with low usage frequency. Therefore, the actual number of scopes that need to be allocated reference numbers is extremely limited, usually within the 32-bit range, and the number of prime numbers can cover the design scenario requirements.
[0040] For example, suppose there are scopes a1, a1.b1, a1.b2 referenced by control parameters, and scope a1.b1.c1 not referenced by control parameters. Then, a1, b1, and b2 are used as the first scope, and a prime number is assigned to each of them as a reference number. For example, the reference number corresponding to a1 is 2, the reference number corresponding to b1 is 3, and the reference number corresponding to b2 is 5. c1 is the second scope, and the reference number corresponding to c1 is 1.
[0041] In one specific implementation, determining the stack number corresponding to any call stack based on the reference numbers corresponding to all first scopes traversed by the call stack and the reference numbers corresponding to all second scopes includes:
[0042] For any call stack, multiply the reference numbers corresponding to all first scopes and all second scopes that the call stack passes through by the multiplication, and use the result as the stack number corresponding to the call stack.
[0043] Among them, the reference number of the first scope is a unique prime number. Therefore, due to the mathematical properties of prime number multiplication, different call stacks will have different corresponding stack numbers, and the stack number can uniquely identify the call stack.
[0044] In one specific implementation, determining the target number corresponding to the target scope includes:
[0045] Multiply the reference numbers corresponding to all first scopes and all second scopes contained in the target scope, and use the result of the multiplication as the target number corresponding to the target scope.
[0046] The target scope corresponding to the passed scope parameter is usually the basic function of the simulator, which will not be elaborated here.
[0047] In one specific implementation, determining several stack numbers associated with the target number based on the target number and the stack number table includes:
[0048] Traverse each stack number in the stack number table. For the currently traversed stack number, if the stack number is divisible by the target number, then determine that the stack number is associated with the target number.
[0049] If the stack number is divisible by the target number, then each prime factor of the target number (i.e., each reference number contained in the target scope) appears in the set of prime factors of the stack number. In other words, the call stack corresponding to the stack number must be prefixed with the target scope, and the call stack corresponding to the stack number is contained in the target scope or a subscope of the target scope.
[0050] For example, let the target scope be a1.b1, the reference number corresponding to a1 is 2, and the reference number corresponding to b1 is 3. Then the target number corresponding to the target scope is 2 × 3 = 6. Let the reference number corresponding to c1 be 5. The stack number of the call stack a1.b1.c1 is 2 × 3 × 5 = 30. 30%6 = 0. The % operator is the modulo operator. When the modulo result is 0, it means that it is divisible, and thus it means that the call stack a1.b1.c1 is located in the sub-scope of the target scope. Let the reference number corresponding to b2 be 7. The stack number corresponding to the call stack a1.b2 is 2 × 7 = 14. 14%6 = 2. The modulo result is not 0, which means that it is not divisible. Therefore, the call stack a1.b2 is not located in the target scope or the sub-scope of the target scope.
[0051] In one specific implementation, determining the execution number corresponding to the call path of the target statement includes:
[0052] Multiply the reference numbers corresponding to all first scopes and all second scopes contained in the call path of the target statement, and use the result of the multiplication as the execution number corresponding to the call path.
[0053] The execution number is the stack number corresponding to the call path of the target statement executed in the current simulation phase.
[0054] Specifically, the calculation of the execution number can reuse the mapping table of scope and reference number stored in memory during the compilation phase.
[0055] In one specific implementation, after the target statement is executed during the simulation phase, determining the execution number corresponding to the call path of the target statement, and controlling the execution of the target statement according to the control information corresponding to the execution number in the stack number table, includes:
[0056] After the target statement is executed during the simulation phase, the execution number corresponding to the call path of the target statement is determined.
[0057] If the execution number is a first preset value, then the execution of the target statement is controlled by the preset default information;
[0058] If the execution number is not a first preset value, the execution of the target statement is controlled according to the control information corresponding to the execution number in the stack number table.
[0059] The default information is the user-preset control state; for example, the default information is "on".
[0060] After the target statement is executed during the simulation phase, the simulator can obtain the complete call path of the current execution point and then calculate the execution number of the call path.
[0061] Specifically, when the execution number is the first preset value, it means that there is no first scope on the corresponding call stack, that is, there is no scope on the corresponding call stack that can be controlled in terms of state. The user cannot dynamically control the state of the call stack, and the call stack is executed in the state corresponding to the default information.
[0062] As can be seen, this embodiment only requires a simple table lookup operation to confirm the control information, with minimal overhead, effectively improving the performance of the simulator.
[0063] In one specific implementation, the control parameter is a switch control parameter;
[0064] Accordingly, the control information is either an on or off state, and the target parameter is either a control on parameter or a control off parameter.
[0065] Among them, the control on parameter is used to start a specific function, and the control off parameter is used to turn off a specific function. The on and off states can be represented by Boolean values.
[0066] In one specific implementation, the preset statement is a check statement.
[0067] The switch status in the stack number table directly determines whether the check statement is executed in the current call path.
[0068] As an example, the check statement can use the unique, unique0, or priority-case statement. Correspondingly, the parameter controlling whether it's enabled is `$uniq_prior_checkon(scope)`, and the parameter controlling whether it's disabled is `$uniq_prior_checkoff(scope)`. It should be noted that the control parameter allows the user to disable / enable checks corresponding to check statements within a specific scope (only modules) or scope instance. The parameter `scope` represents which scope's check needs to be disabled / enabled. For an instantiated module, it can only point to a specific instance. For ease of explanation, this embodiment will refer to both scope and instance simply as "scope".
[0069] In this embodiment, scope identification, number allocation, and stack number calculation are performed during the compilation phase to generate a stack number table. Only each scope and its corresponding reference number, as well as the stack number table, need to be stored in memory. The memory requirement is much smaller than the number of scope instances, which significantly reduces memory usage. During the simulation phase, only integer multiplication and division operations and table lookup operations are needed to achieve scope control, which significantly reduces runtime overhead and avoids the complexity of dynamically creating, maintaining, and traversing the scope tree, thereby improving the performance and stability of the simulator.
[0070] While specific embodiments of the invention have been described in detail by way of example, those skilled in the art should understand that the examples are for illustrative purposes only and not intended to limit the scope of the invention. Those skilled in the art should also understand that various modifications can be made to the embodiments without departing from the scope and spirit of the invention. The scope of this invention is defined by the appended claims.
Claims
1. A prime product based encoding EDA simulator scope control management method, characterized in that, The method includes the following steps: S1, during the compilation phase, the obtained abstract syntax tree is traversed to identify all first scopes and second scopes, where the first scope corresponds to control parameters and the second scope does not correspond to control parameters; S2, for any first scope, assign a unique prime number to the first scope as the reference number corresponding to the first scope; S3, assign a first preset value to each second scope as a reference number corresponding to each second scope; S4, Identify all positions containing preset statements from the abstract syntax tree, and for any position, enumerate all call stacks containing that position; S5. For any call stack, determine the stack number corresponding to the call stack based on the reference numbers corresponding to all first scopes and all second scopes traversed by the call stack. S6, a stack number table is formed by all stack numbers that are not the first preset value and their corresponding control information; S7. After the target parameter is executed during the simulation phase, the target scope corresponding to the target parameter is parsed and the target number corresponding to the target scope is determined, wherein the target parameter belongs to the control parameter; S8. Based on the target number and the stack number table, determine a number of stack numbers associated with the target number. For any stack number associated with the target number, adjust the control information corresponding to that stack number in the stack number table according to the target parameter. S9. After the target statement is executed during the simulation phase, the execution number corresponding to the call path of the target statement is determined. According to the control information corresponding to the execution number in the stack number table, the execution of the target statement is controlled. The target statement belongs to the preset statement.
2. The prime product encoding based EDA simulator scope control management method of claim 1, wherein, For any call stack, determining the stack number corresponding to the call stack based on the reference numbers corresponding to all first scopes traversed by the call stack and the reference numbers corresponding to all second scopes traversed by the call stack includes: For any call stack, multiply the reference numbers corresponding to all first scopes and all second scopes that the call stack passes through by the multiplication, and use the result as the stack number corresponding to the call stack.
3. The prime product based encoding EDA simulator scope control management method of claim 1, wherein, Determining the target number corresponding to the target scope includes: Multiply the reference numbers corresponding to all first scopes and all second scopes contained in the target scope, and use the result of the multiplication as the target number corresponding to the target scope.
4. The prime product based encoding EDA simulator scope control management method of claim 1, wherein, The step of determining several stack numbers associated with the target number based on the target number and the stack number table includes: Traverse each stack number in the stack number table. For the currently traversed stack number, if the stack number is divisible by the target number, then determine that the stack number is associated with the target number.
5. The prime product based encoding EDA simulator scope control management method of claim 1, wherein, Determining the execution number corresponding to the call path of the target statement includes: Multiply the reference numbers corresponding to all first scopes and all second scopes contained in the call path of the target statement, and use the result of the multiplication as the execution number corresponding to the call path.
6. The prime product based encoding EDA simulator scope control management method of claim 1, wherein, After the target statement is executed during the simulation phase, the execution number corresponding to the call path of the target statement is determined, and the execution of the target statement is controlled according to the control information corresponding to the execution number in the stack number table, including: After the target statement is executed during the simulation phase, the execution number corresponding to the call path of the target statement is determined. If the execution number is a first preset value, then the execution of the target statement is controlled by the preset default information; If the execution number is not a first preset value, the execution of the target statement is controlled according to the control information corresponding to the execution number in the stack number table.
7. The prime product based encoding EDA simulator scope control management method of claim 1, wherein, The control parameters are switch control parameters; Accordingly, the control information is either an on or off state, and the target parameter is either a control on parameter or a control off parameter.
8. The prime product encoding based EDA simulator scope control management method of claim 7, wherein, The preset statement is a check statement.
Citation Information
Patent Citations
Embedded database programming method
CN121722840A
Optimizing compilation of program code
US20250328325A1