A memory allocation management method, system and medium for simulating a host
By introducing application credit verification and segment randomization mechanisms into the memory management component, the problem of low efficiency in frequent applications and releases of traditional memory management components is solved, and the effect of avoiding address conflicts and improving memory allocation efficiency in a multi-process environment is achieved.
Patent Information
- Application Number
- CN202311710934.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-13
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2043-12-13
AI Technical Summary
Traditional memory management components are extremely inefficient in scenarios where applications and releases are frequent. They cannot apply for a specified address memory space, and multi-process applications and releases can easily cause address conflicts.
Add an application credit verification mechanism during the execution of space application instructions, space release instructions and space access instructions, and configure a segment randomization mechanism before or during the execution of space application instructions to avoid address conflicts and efficiency reduction, and achieve designated addresses and continuous memory Application for space.
It avoids address conflicts in multi-process use and improves the efficiency of frequent applications and releases. It can specify space applications for special addresses and apply for multiple consecutive memory spaces, which significantly improves the efficiency of memory allocation and recycling.
Smart Images

Figure CN117667418B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of memory allocation management, and in particular to a memory allocation management method, system and medium for simulating a host. Background Art
[0002] In chip verification, space application and release of simulated host memory is a common operation. In complex business processes, there are many problems with memory application and release, which are mainly reflected in the following aspects: address conflicts caused by multi-process application and release; reduced efficiency caused by frequent application and release; solution failure caused by application and release of special addresses, etc. The commonly available memory management component is uvm_men_man, which has the following shortcomings during use: extremely low efficiency in scenarios with frequent application and release; unable to apply for specified address memory space. Therefore, it is an urgent problem to realize an efficient memory allocation and recycling component that can meet various verification scenarios. Summary of the invention
[0003] The technical problem to be solved by the present invention is that the traditional memory management component is extremely inefficient in scenarios where applications and releases are frequent; it is impossible to apply for a specified address memory space; the present solution provides a memory allocation management method, system and medium for simulating a host, which is improved on the basis of the traditional memory management component by adding an application credit verification mechanism during the execution of space application instructions, space release instructions and space access instructions, and configuring a segment random mechanism before or during the execution of space application instructions; address conflicts caused in the use of multiple processes are avoided, and efficiency will not be reduced during frequent applications and releases, and space applications for special addresses can be specified, the memory space range to which the component belongs can be specified, and multiple continuous memory spaces can be applied.
[0004] The present invention is achieved through the following technical solutions:
[0005] This solution provides a memory allocation management method for a simulated host, the method is implemented based on a memory management component; the memory management component includes: an available space segment structure, an occupied space segment structure and a data segment structure;
[0006] The method comprises:
[0007] Obtaining memory allocation instructions; the memory allocation instructions include: space application instructions, space release instructions and space access instructions;
[0008] Execute memory allocation instructions in the simulated host: add an application credit verification mechanism during the execution of space application instructions, space release instructions, and space access instructions, and configure a segment random mechanism before or during the execution of space application instructions.
[0009] Working principle of this scheme: In chip verification, multiple processes apply for and release the space of the simulated host memory, which is easy to cause address conflicts, and the frequent application and release will reduce the efficiency; the traditional memory management component uvm_men_man is extremely inefficient in scenarios with frequent application and release; it is impossible to apply for the specified address memory space; this scheme provides a memory allocation management method, system and medium for a simulated host, by adding an application credit verification mechanism in the process of executing space application instructions, space release instructions and space access instructions, and configuring a segment random mechanism before executing space application instructions or in the process of executing space application instructions; it will not cause address conflicts in the use of multiple processes, and will not cause efficiency reduction when applying and releasing frequently, and it can specify the space application of special addresses, specify the memory space range to which the component belongs, and can apply for multiple continuous memory spaces.
[0010] The further optimization plan is that the execution process of the space application instruction includes:
[0011] S1, parsing the space application instruction. If the space application instruction is to apply for a single space, proceed to step S2; if the space application instruction is to apply for multiple continuous spaces, convert the space application instruction into a single space application according to the number and length of the applied spaces, and then proceed to step S2;
[0012] S2, if the application credit of the current space application instruction is successful, determine whether the current space application instruction specifies an address range; if so, proceed to step S3; otherwise, after obtaining the application length and alignment requirements of the current space application instruction, proceed to step S4;
[0013] S3, obtaining the available space segment within the specified address range, and determining whether the length of the available space segment is greater than the length of the requested space. If so, proceed to step S4; otherwise, return the specified address and available space segment information;
[0014] S4, based on the requested length and alignment requirements, applies for occupied space segments under the segment randomization mechanism;
[0015] S5, if the space application instruction is to apply for a single space, the available space segment structure and the occupied space segment structure are maintained according to the single space segment, and then the credit is released; if the space application instruction is to apply for multiple continuous spaces, the available space segment structure and the occupied space segment structure are maintained according to multiple space segments;
[0016] S6, release the credit and return the occupied segment address requested.
[0017] A further optimization scheme is that step S4 specifically includes:
[0018] In step S2, when the current space application instruction does not specify an address range, first select a target space segment according to the segment random mode, and then apply for an occupied space segment within the target space segment according to the segment random mode;
[0019] When the length of the available space segment is greater than the requested space length in step S3, an occupied space segment is requested within the target space segment according to a segment random mode.
[0020] A further optimization scheme is that the execution process of the space release instruction includes:
[0021] T1, parsing space release instruction;
[0022] T2, if the application credit of the current space release instruction is successful, determine whether the space information is queried after the occupied segment, if so, go to step T3, otherwise return an error message;
[0023] T3, maintain the available segment structure and occupied segment structure according to the released space;
[0024] T4, release the credit and return the release result information.
[0025] A further optimization scheme is that the execution process of the space access instruction includes:
[0026] G1, parsing space access instructions;
[0027] G2, when the application credit of the current space access instruction is successful, query the access space in the occupied segment structure. If the access space is not found, an error message is returned; if the access space is found, go to step G3;
[0028] G3, determine whether the space access instruction is a read operation, if so, take out the data of the corresponding space in the data segment structure and enter step G4; otherwise, write the data to the corresponding space in the data segment structure;
[0029] G4 releases the credit and returns the access result.
[0030] A further optimization scheme is that the available space segment structure is used to store available memory information; the occupied space segment structure is used to store occupied memory information; and the data segment structure is used to store written data.
[0031] A further optimization solution is that the memory management component also includes an interface module and a configuration module.
[0032] The present solution also provides a memory allocation management system for a simulated host, which is used to implement the above-mentioned memory allocation management method for a simulated host, wherein the memory management component includes: an available space segment structure, an occupied space segment structure and a data segment structure;
[0033] The system comprises:
[0034] The acquisition module is used to obtain memory allocation instructions; the memory allocation instructions include: space application instructions, space release instructions and space access instructions;
[0035] The execution module is used to execute memory allocation instructions in the simulated host: add an application credit verification mechanism in the process of executing space application instructions, space release instructions and space access instructions, and configure a segment random mechanism before executing space application instructions or during the execution of space application instructions.
[0036] A further optimization solution is that the memory management component also includes an interface module and a configuration module.
[0037] The present solution also provides a computer-readable medium on which a computer program is stored. The computer program is executed by a processor to implement the memory allocation management method of a simulated host as described above.
[0038] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0039] The present invention provides a memory allocation management method, system and medium for simulating a host. By adding an application credit verification mechanism during the execution of space application instructions, space release instructions and space access instructions, a segment random mechanism is configured before or during the execution of space application instructions. In the use of multiple processes, address conflicts will not be caused, and efficiency will not be reduced during frequent applications and releases. In addition, space applications for special addresses and the memory space range to which components belong can be specified, and multiple continuous memory spaces can be applied. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and should not be regarded as limiting the scope. For those of ordinary skill in the art, other relevant drawings can be obtained based on these drawings without creative work. In the drawings:
[0041] Figure 1 A flowchart of a memory allocation management method for a simulated host;
[0042] Figure 2 This is a schematic diagram of the memory management component structure;
[0043] Figure 3 This is a schematic diagram of the memory management component structure;
[0044] Figure 4Schematic diagram of the execution process of the space application instruction;
[0045] Figure 5 It is a schematic diagram of the execution process of the space release instruction;
[0046] Figure 6 Schematic diagram of the execution process of space access instructions. DETAILED DESCRIPTION
[0047] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with embodiments and drawings. The exemplary embodiments of the present invention and their description are only used to explain the present invention and are not intended to limit the present invention.
[0048] In chip verification, multiple processes apply and release the space of the simulated host memory, which easily causes address conflicts, and the efficiency is reduced due to frequent application and release; the traditional memory management component uvm_men_man is extremely inefficient in scenarios where application and release are frequent; it is impossible to apply for a specified address memory space; to solve the above technical problems, the present invention provides the following embodiments:
[0049] Example 1
[0050] This embodiment provides a method for managing memory allocation of a simulated host, and the method is implemented based on a memory management component; Figure 2 As shown, the memory management component includes: an available space segment structure, an occupied space segment structure and a data segment structure; the available segment structure stores available memory information, including information such as the start address, the end address and the length; the occupied segment structure stores occupied memory information, including the occupied base address, the occupied length, the real occupied base address and the real occupied length; the data segment structure stores data written by the write method; the memory management component also includes an interface module, which is a collection of methods within the component, including memory reading, memory writing, memory application, memory release, continuous memory application, special address memory application, etc.; the configuration module stores configuration parameters and configuration methods, such as configuration segment random method, intra-segment random method, memory base address and memory length, etc.
[0051] like Figure 1 As shown, the method includes:
[0052] Obtaining memory allocation instructions; the memory allocation instructions include: space application instructions, space release instructions and space access instructions;
[0053] Execute memory allocation instructions in the simulated host: add an application credit verification mechanism during the execution of space application instructions, space release instructions, and space access instructions, and configure a segment random mechanism before or during the execution of space application instructions.
[0054] like Figure 3 As shown in the figure, the execution process of the space application instruction includes:
[0055] S1, parse the space application instruction. If the space application instruction is to apply for a single space, go to step S2; if the space application instruction is to apply for multiple continuous spaces, convert the space application instruction into a single space application according to the number and length of the applied spaces, and then go to step S2; when applying for a single memory space, first apply for credit. A credit will be allocated when the component is initialized. When multiple processes operate the component at the same time, each operator must first apply for credit. The operator who obtains the credit obtains the operation permission. The operator who does not obtain the credit is blocked in s1, waiting for other operators to return the credit;
[0056] S2, if the application credit of the current space application instruction is successful, determine whether the current space application instruction specifies an address range; if so, proceed to step S3; otherwise, after obtaining the application length and alignment requirements of the current space application instruction, proceed to step S4;
[0057] S3, obtaining the available space segment within the specified address range, and determining whether the length of the available space segment is greater than the length of the requested space. If so, proceeding to step S4, otherwise, returning the specified address and available space segment information;
[0058] S4, based on the requested length and alignment requirements, applies for occupied space segments under the segment randomization mechanism;
[0059] S5, if the space application instruction is to apply for a single space, the available space segment structure and the occupied space segment structure are maintained according to the single space segment, and then the credit is released; if the space application instruction is to apply for multiple continuous spaces, the available space segment structure and the occupied space segment structure are maintained according to multiple space segments;
[0060] S6, release the credit and return the occupied segment address requested.
[0061] Step S4 specifically includes:
[0062] In step S2, when the current space application instruction does not specify an address range, first select a target space segment according to the segment random mode, and then apply for an occupied space segment within the target space segment according to the segment random mode;
[0063] When the length of the available space segment is greater than the requested space length in step S3, an occupied space segment is requested within the target space segment according to a segment random mode.
[0064] like Figure 4 As shown, the execution process of the space release instruction includes:
[0065] T1, parsing space release instruction;
[0066] T2, if the application credit of the current space release instruction is successful, determine whether the space information is queried after the occupied segment, if so, go to step T3, otherwise return an error message;
[0067] T3, maintain the available segment structure and occupied segment structure according to the released space;
[0068] T4, release the credit and return the release result information.
[0069] like Figure 5 As shown, the execution process of the space access instruction includes:
[0070] G1, parsing space access instructions;
[0071] G2, when the application credit of the current space access instruction is successful, query the access space in the occupied segment structure. If the access space is not found, an error message is returned; if the access space is found, go to step G3;
[0072] G3, determine whether the space access instruction is a read operation, if so, take out the data of the corresponding space in the data segment structure and enter step G4; otherwise, write the data to the corresponding space in the data segment structure;
[0073] G4 releases the credit and returns the access result.
[0074] The available space segment structure is used to store available memory information; the occupied space segment structure is used to store occupied memory information; and the data segment structure is used to store written data.
[0075] The memory management component also includes an interface module and a configuration module.
[0076] Compared with the traditional uvm_mem_man component, this solution solves the problem of multi-process address application conflicts based on the credit mechanism: the credit is initialized when the new component is created, and each process first requests credit when applying for an address. If the credit is requested, the operation can continue; if the credit is not applied for, it is blocked until other processes return the credit.
[0077] When applying for an address, this solution sorts all available segment addresses and spaces and selects the available segment address closest to the requested length. This reduces fragmented space and facilitates the solution of subsequent address applications, thereby significantly reducing the time spent on address application and release.
[0078] The address application for the specified address segment is the highlight of this solution. During use, a component can be conveniently divided into multiple segments, and each segment of space is managed independently. When an address is specified when applying for memory, the corresponding memory space is first searched in the available segment to see if it is available. If it is not available, an address in a similar address segment that can meet the length requirement is returned as a suggestion. Existing components can only implement similar functions by instantiating multiple copies, which increases the simulation resources and time consumed exponentially.
[0079] This solution also supports multiple continuous memory space applications. When multiple continuous memory space applications are identified, the total application length is calculated first, and the address segment that satisfies the requirements is found in the available segment structure. When maintaining the occupied segment structure, multiple address segments are maintained separately, and then the first addresses of multiple address segments are returned. When releasing, multiple address segments can be released separately. However, existing components can only apply for one continuous space, not multiple continuous spaces, which limits the usage scenarios.
[0080] Example 2
[0081] This embodiment provides a memory allocation management system for a simulated host, which is used to implement a memory allocation management method for a simulated host in Embodiment 1, wherein the memory management component includes: an available space segment structure, an occupied space segment structure, and a data segment structure;
[0082] The system comprises:
[0083] The acquisition module is used to obtain memory allocation instructions; the memory allocation instructions include: space application instructions, space release instructions and space access instructions;
[0084] The execution module is used to execute memory allocation instructions in the simulated host: add an application credit verification mechanism in the process of executing space application instructions, space release instructions and space access instructions, and configure a segment random mechanism before executing space application instructions or during the execution of space application instructions.
[0085] The memory management component also includes an interface module and a configuration module.
[0086] Example 3
[0087] This embodiment provides a computer-readable medium on which a computer program is stored. The computer program is executed by a processor to implement a memory allocation management method for a simulated host as in Embodiment 1.
[0088] This embodiment tests the memory allocation management method of the simulated host in a real simulation business, such as Figure 6As shown in the figure, with the increase of the number of memory applications and releases, the time consumed by this solution increases basically linearly. When the number of applications and releases is in the order of millions, the efficiency is nearly 10 times higher than that of the existing solution. The application for special addresses and continuous space also fully meets the scenario requirements. No address conflict or solution failure occurs in multi-process operation, and the results of the read and write operations on the applied memory are correct. The implementation process of this solution is simple and efficient, and basically meets the requirements of all application scenarios.
[0089] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A memory allocation management method for simulating a host, characterized in that: The method is implemented based on a memory management component; The memory management component includes: an available space segment structure, an occupied space segment structure and a data segment structure; The method comprises: Obtaining memory allocation instructions; the memory allocation instructions include: space application instructions, space release instructions and space access instructions; Execute memory allocation instructions in the simulated host: add an application credit verification mechanism during the execution of space application instructions, space release instructions, and space access instructions, and configure a segment random mechanism before or during the execution of space application instructions; The execution process of the space application instruction includes: S1, parsing the space application instruction. If the space application instruction is to apply for a single space, proceed to step S2; if the space application instruction is to apply for multiple continuous spaces, convert the space application instruction into a single space application according to the number and length of the applied spaces, and then proceed to step S2; S2, if the application credit of the current space application instruction is successful, determine whether the current space application instruction specifies an address range; if so, proceed to step S3; otherwise, after obtaining the application length and alignment requirements of the current space application instruction, proceed to step S4; the application credit includes operation authority; S3, obtaining the available space segment within the specified address range, and determining whether the length of the available space segment is greater than the length of the requested space. If so, proceeding to step S4, otherwise, returning the specified address and available space segment information; S4, based on the application length and alignment requirements, applying for the occupied space segment under the segment random mechanism; step S4 specifically includes: In step S2, when the current space application instruction does not specify an address range, first select a target space segment according to the segment random mode, and then apply for an occupied space segment within the target space segment according to the segment random mode; When the length of the available space segment in step S3 is greater than the length of the applied space segment, apply for an occupied space segment in the target space segment according to the segment random mode; S5, if the space application instruction is to apply for a single space, the available space segment structure and the occupied space segment structure are maintained according to the single space segment, and then the credit is released; if the space application instruction is to apply for multiple continuous spaces, the available space segment structure and the occupied space segment structure are maintained according to multiple space segments; S6, release the credit and return the occupied segment address applied for; The execution process of the space release instruction includes: T1, parsing space release instruction; T2, if the application credit of the current space release instruction is successful, determine whether the occupied segment structure has queried the space information, if so, go to step T3, otherwise return an error message; T3, maintain the available segment structure and occupied segment structure according to the released space; T4, release the credit and return the release result information; The execution process of the space access instruction includes: G1, parsing space access instructions; G2, when the application credit of the current space access instruction is successful, query the access space in the occupied segment structure. If the access space is not found, an error message is returned; if the access space is found, go to step G3; G3, determine whether the space access instruction is a read operation, if so, take out the data of the corresponding space in the data segment structure and enter step G4; otherwise, write the data to the corresponding space in the data segment structure; G4 releases the credit and returns the access result.
2. The memory allocation management method of a simulated host according to claim 1, characterized in that: The available space segment structure is used to store available memory information; the occupied space segment structure is used to store occupied memory information; and the data segment structure is used to store written data.
3. The memory allocation management method of a simulated host according to claim 1, characterized in that: The memory management component also includes an interface module and a configuration module.
4. A memory allocation management system for simulating a host, characterized in that: A method for managing memory allocation of a simulated host computer according to any one of claims 1 to 3, wherein the memory management component comprises: an available space segment structure, an occupied space segment structure and a data segment structure; The system comprises: The acquisition module is used to obtain memory allocation instructions; the memory allocation instructions include: space application instructions, space release instructions and space access instructions; The execution module is used to execute memory allocation instructions in the simulated host: add an application credit verification mechanism in the process of executing space application instructions, space release instructions and space access instructions, and configure a segment random mechanism before or during the execution of space application instructions.
5. A memory allocation management system for simulating a host according to claim 4, characterized in that: The memory management component also includes an interface module and a configuration module.
6. A computer readable medium having a computer program stored thereon, characterized in that: The computer program is executed by a processor to implement a memory allocation management method for a simulated host as described in any one of claims 1 to 3.
