RISC-V Chip Dynamic Library Mechanism Implementation System, Chip and Related Methods
By setting the entry function of the dynamic module in the RISC-V chip and building the mapping relationship, the problem that the N300 chip cannot be updated dynamically is solved, and efficient dynamic update of the functional module is achieved.
Patent Information
- Application Number
- CN202510438442.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-09
- Publication Date
- 2025-07-01
- Estimated Expiration
- 2045-04-09
AI Technical Summary
The N300 chip is not compatible with Linux dynamic libraries, resulting in inefficient update efficiency for functional modules and inability to achieve dynamic updates.
The RISC-V chip dynamic library mechanism is adopted, and the entry function of the dynamic module is set to the preset memory address through the address setting module, and a separate mapping relationship between the entry function input parameters and the dynamic library function is constructed, and the location-independent loading process is performed to ensure that the data in the dynamic module can be loaded to any storage address of the volatile memory module.
Dynamic update of functional modules is realized, update efficiency is improved, and the limitation of static library updates is avoided.
Smart Images

Figure CN119938175B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of embedded systems, and in particular, to a system, a chip, and related methods for implementing a dynamic library mechanism for RISC-V chips. Background Art
[0002] The Nuclei N300 chip is a processor core based on the RISC-V instruction set architecture. When updating its internal functional modules, since the N300 chip cannot be compatible with the Linux dynamic library running on the Linux operating system, it can only update the functional modules through static libraries. The problem with this is that whenever a new functional module is updated, the system code needs to be recompiled and updated uniformly, resulting in low update efficiency of the functional modules and inability to achieve dynamic updates. Summary of the Invention
[0003] Based on the above problems, in order to improve the update efficiency of the functional modules in the N300 chip and achieve dynamic updates of the functional modules, the embodiments of this application provide a system, a chip, and related methods for implementing a dynamic library mechanism for RISC-V chips.
[0004] The embodiments of this application disclose the following technical solutions:
[0005] In a first aspect, the embodiments of this application provide a system for implementing a dynamic library mechanism for RISC-V chips, which is characterized by including a non-volatile storage module, a volatile storage module, an address setting module, a mapping construction module, and a position-independent loading processing module; the non-volatile storage module includes: a dynamic module, and the dynamic module includes: dynamic library functions, function variables, and global variables;
[0006] The address setting module is used to set the entry function address of the dynamic module to a preset memory address;
[0007] The mapping construction module is used to construct a separate mapping relationship between the input parameters of the entry function and the dynamic library functions based on the preset memory address;
[0008] The position-independent loading processing module is used to perform position-independent loading processing on the function variables, the global variables, and the dynamic library functions, so that the data in the dynamic module has the ability to be loaded to any storage address in the volatile storage module.
[0009] In a possible implementation manner, the address setting module is specifically used for:
[0010] Construct a link script for the non-volatile storage module;
[0011] Through the link script, set the entry function address to the preset memory address, and set the addresses of all the dynamic library functions and variables in the dynamic module to offsets relative to the entry function address, so as to generate an executable file.
[0012] In a possible implementation manner, the position-independent loading processing module includes: a global variable processing unit; the global variable processing unit is specifically configured to:
[0013] Through program counter relative addressing, determine the absolute entry function address when the entry function runs in memory;
[0014] Through the executable file, obtain the relative global variable address of the global variable in the dynamic module; the relative global variable address is used to represent the address offset of the entry function address;
[0015] Determine the sum of the relative global variable address and the absolute entry function address as the absolute memory address of the global variable in the dynamic module, so that the global variable has the ability to be loaded to any storage address in the volatile storage module.
[0016] In a possible implementation manner, the position-independent loading processing module includes: a function variable processing unit; the function variable processing unit is specifically configured to:
[0017] Compile the function variable based on the -fPIE compilation option to generate position-independent code for the function variable; the position-independent code is used for the call to the function;
[0018] Wherein, the position-independent code is used to complete the call to the function by means of program counter relative addressing, so that the function has the ability to be loaded to any storage address in the volatile storage module.
[0019] In a possible implementation manner, the program counter relative addressing method is implemented through the combination of the auipc instruction and the address offset addition instruction in the RISC-V instruction set.
[0020] In a possible implementation manner, the system further includes: an external function call module;
[0021] The external function call module is used to implement the call of the dynamic module to the external function through an indirect address passing mechanism.
[0022] In a possible implementation manner, the preset memory address is the memory starting address; the non-volatile storage module is a flash module, and the volatile storage module is an SRAM module or a DDR module.
[0023] In a second aspect, an embodiment of the present application provides a method for updating a functional module of a RISC-V chip, which is applied to a central processing unit of the RISC-V chip. The RISC-V chip includes: a non-volatile storage module and a volatile storage module. The non-volatile storage module includes a dynamic module; the dynamic module includes: dynamic library functions. The method includes:
[0024] In response to a functional module update instruction, write the module file data of the dynamic module to the volatile storage module; the functional module update instruction includes: a target call function and a target functional module;
[0025] Set the entry function address of the dynamic module to a preset memory address, and based on the preset memory address, construct a separate function call mapping relationship between the entry function input parameters and the dynamic library functions;
[0026] Based on the target call function, determine the target input parameters from multiple function call mapping relationships;
[0027] Perform dynamic library function calls according to multiple function call mapping relationships and the target input parameters to dynamically update the target functional module.
[0028] In a possible implementation, the preset memory address is the memory start address; the non-volatile storage module is a flash module, and the volatile storage module is an SRAM module or a DDR module.
[0029] In a third aspect, an embodiment of the present application provides a RISC-V chip, including any possible RISC-V chip dynamic library mechanism implementation system in the first aspect.
[0030] Compared with the prior art, the present application has the following beneficial effects: The embodiment of the present application provides a system, a chip and related methods for implementing a dynamic library mechanism of a RISC-V chip. In the system, functions in the dynamic library are stored in a dynamic module and stored in the non-volatile storage module of the system as the basic call of the dynamic library functions. First, the address setting module sets the entry function of the dynamic module to a preset memory address, so that no matter where the dynamic module is loaded into the memory subsequently, the dynamic module can be accessed through the logical address represented by the preset memory address, so as to call the functions therein. Subsequently, the mapping construction module constructs a separate mapping relationship between the input parameters of the entry function and the dynamic library functions based on the preset memory address, so as to ensure the accurate call of the dynamic library functions in the dynamic module. Finally, the position-independent loading processing module performs unified position-independent loading processing on the function variables, global variables and dynamic library functions in the dynamic module, so that the dynamic library functions and data in the dynamic module can be loaded to any storage address in the volatile storage module, thereby realizing the dynamic library function mechanism based on the RISC-V chip, and the update efficiency of the functional module is no longer restricted by the static library. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0032] Figure 1 FIG. is a schematic structural diagram of a system for implementing a dynamic library mechanism of a RISC-V chip provided by an embodiment of the present application;
[0033] Figure 2 FIG. is a schematic structural diagram of a dynamic library implementation system of a RISC-V N300 chip provided by an embodiment of the present application;
[0034] Figure 3 FIG. is a schematic flow diagram of a position-independent loading process performed by a global variable processing unit provided by an embodiment of the present application;
[0035] Figure 4 FIG. is a schematic flow diagram of a method for updating a functional module of a RISC-V chip provided by an embodiment of the present application;
[0036] Figure 5 FIG. is a schematic flow diagram of a process for a N300 chip to call a dynamic module function in an actual application scenario provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0037] To make the objectives, technical solutions, and advantages of this application clearer and more understandable, the following further elaborates on this application in detail with reference to specific embodiments and the accompanying drawings. It should be particularly noted that the embodiments described in the embodiments of this application are only a part of the embodiments of this application, rather than all of them. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in this application without creative efforts belong to the scope protected by this application.
[0038] It should be noted that unless otherwise defined, the technical terms or scientific terms used in the embodiments of this application should have the ordinary meaning understood by those with ordinary skills in the field to which this application belongs. The "first", "second", and similar terms used in the embodiments of this application do not indicate any order, quantity, or importance, but are only used to distinguish different components. Words such as "including" or "comprising" mean that the elements or objects appearing before this word cover the elements or objects listed after this word and their equivalents, without excluding other elements or objects. The terms "connected" or "coupled" and the like are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The terms "upper", "lower", "left", "right", etc. are only used to represent relative positional relationships, and when the absolute position of the object being described changes, the relative positional relationship may also change accordingly.
[0039] As described above, the Nuclei N300 chip is a processing core based on the RISC-V instruction set architecture. When the current N300 chip updates its internal functional modules, since the N300 chip cannot be compatible with the Linux dynamic library running on the Linux operating system, it can only update the functional modules through static libraries. The problem thus exists that whenever a new functional module is updated, the system code needs to be uniformly compiled and updated, resulting in low update efficiency of the functional modules and inability to achieve dynamic updates.
[0040] To solve the above problems, the embodiments of the present application provide a system, a chip, and related methods for implementing a dynamic library mechanism of a RISC-V chip. In the system, functions in the dynamic library are stored in a dynamic module and stored in the non-volatile storage module of the system as the basic call of the dynamic library functions. First, the address setting module sets the entry function of the dynamic module to a preset memory address, so that no matter where the dynamic module is loaded into the memory subsequently, the dynamic module can be accessed through the logical address represented by the preset memory address, thereby calling the functions therein. Subsequently, the mapping construction module constructs a separate mapping relationship between the input parameters of the entry function and the dynamic library functions based on the preset memory address, so as to ensure the accurate call of the dynamic library functions in the dynamic module. Finally, the position-independent loading processing module performs unified position-independent loading processing on the function variables, global variables, and dynamic library functions in the dynamic module, so that the dynamic library functions and data in the dynamic module can be loaded to any storage address in the volatile storage module, thereby implementing the dynamic library function mechanism based on the RISC-V chip, and the update efficiency of the functional module is no longer restricted by the static library.
[0041] It should be noted in advance that the systems and methods provided by the embodiments of the present application can be applied to any type of RISC-V chip. Similarly, they can also be applied to the RISCV Nuclei N300 chip involved in the background technology. In the following description, the N300 chip will be used as an example of a RISC-V chip for introduction to deepen the understanding.
[0042] In order to enable those skilled in the art to better understand the solution of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0043] See Figure 1 and Figure 2 , Figure 1 is a schematic structural diagram of a system for implementing a dynamic library mechanism of a RISC-V chip provided by an embodiment of the present application. Figure 2 is a schematic structural diagram of a dynamic library implementation system of a RISC-V N300 chip provided by an embodiment of the present application. In Figure 1 it includes an address setting module 100, a mapping construction module 200, a position-independent loading processing module 300, a non-volatile storage module 400, a dynamic module 500, and a volatile storage module 600. In Figure 2Among them, Flash represents the non-volatile storage module in the embodiments of the present application, which internally stores multiple dynamic module files, and each dynamic module file contains dynamic library functions, function variables, and global variables. SRAM / DDR represents the volatile storage module, and N300 serves as the central processing unit (CPU) in its chip, which is used to interact with Flash and SRAM / DDR for data.
[0044] During the research process, it is found that if you want to implement the mechanism of the dynamic library on a RISC-V chip that cannot be compatible with the dynamic library, the following four problems need to be solved:
[0045] (1) Regarding the problem of position-independent loading and addressing of function symbols and global data symbols. Position-independent loading requires ensuring that the dynamic module can run at any address in the memory. Addressing means that when the dynamic module is loaded to any address in the memory, it is ensured that the function calls for it can correctly find the corresponding memory address.
[0046] (2) Regarding the problem of obtaining the function symbols inside the dynamic module. This problem is to ensure that the main program can accurately access and call the dynamic library functions inside the module.
[0047] (3) Regarding the problem of how to pass external symbols to the dynamic module. This problem is to ensure that the dynamic module can access and call the functions inside the main program or other modules.
[0048] (4) Regarding the problem of how to call the dynamic module in a resource-constrained embedded system. This problem is to ensure that the effective calls to the functions inside the dynamic module can still be made under the condition of limited memory.
[0049] For the above four problems, the embodiments of the present application provide corresponding systems and methods. Next, the RISC-V chip dynamic library mechanism implementation system provided in the embodiments of the present application will be introduced in combination with Figure 1 The RISC-V chip dynamic library mechanism implementation system provided in the embodiments of the present application will be introduced.
[0050] The address setting module 100 is used to set the entry function address of the dynamic module to a preset memory address.
[0051] The address setting module is used to fix the entry function address of the dynamic module to a specific preset memory address. By fixing the entry function at a specific memory address, it can be ensured that no matter where the module is loaded in the memory, the main program can access the entry function through this memory address, and then call the functions inside the dynamic module, thus solving the addressing problem existing in the above four problems.
[0052] Specifically, in this embodiment, the preset memory address is the starting address 0x0 of the memory. This address is the starting address of the memory and also the only entry point of the module. During the process of fixing the entry function address, it is necessary to construct a link script for the non-volatile storage module and force the entry function to be linked to the preset memory address 0x0 through the link script. Taking the non-volatile storage module as Flash as an example, based on the components of Flash, construct the corresponding link script flash.ld. The compiler uses the link script flash.ld to allocate the address space and set the address of the rom to the memory starting address 0x00000000. Among them, it is necessary to add the entry functions.text.startup and.text.startup.* to the first line in the.text segment, indicating that the function addresses modified by.text.startup are 0x00000000, so as to achieve the fixed operation of the entry function address.
[0053] After setting the entry function address to the preset memory address, in order to ensure that the functions in the dynamic module can be loaded to any address in the memory, it is also necessary to further set the addresses of all dynamic library functions and function variables in the dynamic module to the offset of the entry function address, and generate the executable file of the dynamic module based on this address offset. In this way, when accessing any dynamic library function in the dynamic module, through the entry function address recorded in the executable file and the address offsets of each function, the required dynamic library functions can be normally accessed and called.
[0054] For example, assuming that the entry function address is 0x80000000 and the address offset of the init function is 0x100, then the actual memory address of the init function can be determined as 0x80000000 + 0x100 = 0x80000100. Through the offset mechanism, the function code in the dynamic module can be loaded and run at any position in the memory. When the dynamic module is loaded to different base addresses, only the runtime base address (i.e., the actual address of the entry function) needs to be added to the compile-time offset to correctly access all functions in the dynamic module.
[0055] The mapping construction module 200 is used to construct a separate mapping relationship between the input parameters of the entry function and the dynamic library function based on the preset memory address.
[0056] The mapping construction module is mainly used to address the problem of obtaining the internal function symbols of the dynamic module mentioned in the above problems. Its purpose is to enable external programs to accurately call the dynamic library functions in the dynamic module through pre-set input parameters.
[0057] The input parameters of the entry function are used to identify the specific types of dynamic library functions, such as init functions, run functions, uninit functions, and so on. In one possible implementation, the input parameters of the entry function can be set as symbolic identifiers of integer type. For example, identifier 1 corresponds to the init function, identifier 2 corresponds to the run function, and identifier 3 corresponds to the uninit function. By inputting specific input parameters of the entry function, the address offset of the function relative to the entry function can be queried, and then the absolute address of each function in memory can be determined.
[0058] The position-independent loading processing module 300 is used to perform position-independent loading processing on the function variables, the global variables, and the dynamic library functions, so that the data in the dynamic module has the ability to be loaded to any storage address in the volatile storage module.
[0059] The position-independent loading processing module is used to ensure that the dynamic module can run at any address in memory. As can be seen from the previous text, in the dynamic module, there are dynamic library functions, function variables, and global variables. Correspondingly, if it is necessary to ensure that the dynamic module can run at any address in memory, it is necessary to perform position-independent loading processing on the function variables and the global variables respectively.
[0060] Among them, the global variable is a variable defined inside the dynamic module, and its scope is the entire module and can be accessed by all functions within the module. It is usually used to store the internal state or data of the module, and this data needs to be shared among multiple functions. The global variable always exists during the program execution, even if it is not used by any function. However, the function variable is different. The function variable is only created when the function is called, and it exists during the execution of the function. The function variable will be automatically destroyed after the function exits.
[0061] Therefore, based on the differences between the global variable and the function variable, the position-independent loading processing module in the embodiment of the present application is divided into a global variable processing unit and a function variable processing unit, which are respectively used to perform position-independent loading processing on the global variable and the function variable. Next, both will be introduced in combination with the specific embodiment drawings.
[0062] First, the global variable processing unit will be introduced. Refer to Figure 3 , which is a schematic flowchart of a position-independent loading process performed by a global variable processing unit provided in an embodiment of the present application, and specifically includes the following steps:
[0063] S101: Determine the absolute address of the entry function when it runs in memory through program counter relative addressing.
[0064] First, although the address setting module specifies the entry address of the entry function, since the dynamic module can be loaded to any location in memory and the load base address of the dynamic module is unknown at the compilation stage, it is necessary to calculate the absolute address of the entry function when the dynamic module is running.
[0065] Program Counter (PC) relative addressing, also known as relative PC addressing, is a common addressing mode in computer architecture. It calculates the target address based on the current value of the program counter. The program counter is usually used to store the address of the next instruction to be executed. The core idea of relative PC addressing is that the offset between the target address and the current instruction address is fixed, so the target address can be obtained by adding an offset to the current PC value.
[0066] Thus, through the pre-fixed address of the entry function and the relative PC addressing method, the absolute address of the entry function when running in memory can be calculated.
[0067] S102: Obtain the relative global variable address of the global variable in the dynamic module through the executable file; the relative global variable address is used to represent the address offset of the entry function address.
[0068] S103: Determine the absolute memory address of the global variable in the dynamic module by adding the relative global variable address and the absolute address of the entry function, so that the global variable has the ability to be loaded to any storage address in the volatile storage module.
[0069] As can be seen from the previous text, in the executable file, the address offsets of all dynamic library functions and variables (including function variables and global variables) relative to the entry function are stored. In this step, through the executable file, the address offset of the global variable relative to the entry function address can be obtained. Subsequently, the address offset of the global variable relative to the entry function address is added to the absolute address of the entry function, and the sum of the two is determined as the absolute memory address of the global variable, so that the global variable has the ability to be loaded to any storage address in memory.
[0070] The assembly code for the calculation method of the global variable address is as follows:
[0071] auipc a4,0x0
[0072] addi a4,a4,-46 #0 (start)
[0073] li a5,144
[0074] add a5, a5, a4
[0075] In this assembly code, the first line represents obtaining the current PC pointer. The second line represents obtaining the absolute address of the entry function star in memory through relative addressing of pc + offset. The third line represents obtaining the relative address of the global variable in the dynamic module. The fourth line represents calculating the absolute address of the global variable in the dynamic module.
[0076] Next, the function variable processing unit in the position-independent loading processing module will be introduced. The function variable processing unit mainly performs the following steps:
[0077] Step 1: Compile the function variable based on the -fPIE compilation option to generate position-independent code for the function variable; the position-independent code is used to enable the call to the function.
[0078] Among them, the position-independent code is used to enable the call to the function to be completed by using program counter relative addressing, enabling the function to have the ability to be loaded to any storage address in the volatile storage module.
[0079] The position-independent loading processing for function variables needs to be implemented through a specific -fPIE compilation option. fPIE (Position Independent Executable) is a compilation option provided by compilers such as GCC, used to generate position-independent executable files. Its core purpose is to enable the program to be loaded and run at any address in memory without relying on a fixed base address. The working principle of -fPIE is to modify the function call from an absolute address jump to a relative PC offset jump. When linking, the addresses of code and data are recorded in relative offset form. At runtime, the loader or dynamic linker combines the load base address to complete the address calculation.
[0080] Among them, the program counter relative addressing method is implemented through the combination of the auipc instruction and the address offset addition instruction in the RISC-V instruction set. For the specific process of assembling function variables, please refer to the following assembly code using the run function as an example:
[0081] auipc a0, 0x0
[0082] addi a0, a0, 134 #8c (run)
[0083] In this assembly code, the first line represents obtaining the current PC pointer. The second line represents that the absolute address of the run function in memory realizes function call through relative addressing of pc + offset, where 134 is the relative address offset of the run function in the memory module.
[0084] In a possible implementation manner, an external function call module is further provided in the system of the embodiments of the present application. The external function call module is used to implement the call of the external function by the dynamic module through an indirect address passing mechanism.
[0085] The key to the dynamic module calling an external function lies in decoupling the compile-time address binding and the run-time address resolution. The absolute address of the external function is not directly used inside the module, but the indirect address access is implemented through an intermediate layer (such as the global offset table GOT). All calls to the external function in the dynamic module execute the entries in the intermediate layer (global offset table GOT), rather than a fixed address. This is used to solve the problem of how to pass the external symbol to the dynamic module in the above problem.
[0086] The embodiments of the present application provide a system, a chip, and related methods for implementing a dynamic library mechanism of a RISC-V chip. In the system, the functions in the dynamic library are stored in the dynamic module and stored in the non-volatile storage module of the system as the basic call of the dynamic library function. First, the address setting module sets the entry function of the dynamic module to a preset memory address, so that no matter where the dynamic module is loaded into the memory subsequently, the dynamic module can be accessed through the logical address represented by the preset memory address, so as to call the functions therein. Subsequently, the mapping construction module constructs a separate mapping relationship between the input parameters of the entry function and the dynamic library function based on the preset memory address, so as to ensure the accurate call of the dynamic library function in the dynamic module. Finally, the position-independent loading processing module performs unified position-independent loading processing on the function variables, global variables, and dynamic library functions in the dynamic module, so that the dynamic library functions and data in the dynamic module can be loaded to any storage address in the volatile storage module, thereby realizing the dynamic library function mechanism based on the RISC-V chip, and the update efficiency of the functional module is no longer restricted by the static library.
[0087] Next, a method for updating the functional module of a RISC-V chip provided by the embodiments of the present application will be introduced. The method for updating the functional module of a RISC-V chip described below can be mutually referred to with the system for implementing the dynamic library mechanism of a RISC-V chip described above.
[0088] See Figure 4 and Figure 5 , Figure 4 is a schematic flowchart of a method for updating the functional module of a RISC-V chip provided by the embodiments of the present application, Figure 5 is a schematic flowchart of a N300 chip calling a dynamic module function in an actual application scenario provided by the embodiments of the present application. Specifically, it includes the following steps: Figure 4 Specifically, it includes the following steps:
[0089] S301: In response to a function module update instruction, write the module file data of the dynamic module to the volatile storage module; the function module update instruction includes: a target call function and a target function module.
[0090] When receiving a function module update instruction, it is necessary to determine the physical memory to be applied according to the module file data of the dynamic module, and apply for the corresponding physical memory from the volatile storage module, so as to write the file data of the dynamic module to the volatile storage module. Figure 5 It can be seen that the N300 processing unit needs to apply for a memory of a specified size in the SRAM / DDR according to the actual size of the dynamic module, so as to verify whether the memory space of the volatile storage module is sufficient. At the same time, by combining the non-volatile storage module and the volatile storage module, the memory occupancy can be reduced, thus solving the problem of how to call dynamic modules in a resource-constrained embedded system mentioned in the above problem.
[0091] S302: Set the entry function address of the dynamic module to a preset memory address, and based on the preset memory address, construct a separate function call mapping relationship between the input parameters of the entry function and the dynamic library function;
[0092] S303: Based on the target call function, determine the target input parameters from multiple function call mapping relationships;
[0093] S304: Perform dynamic library function calls according to multiple function call mapping relationships and the target input parameters to dynamically update the target function module.
[0094] In a possible implementation manner, the preset memory address is the starting memory address; the non-volatile storage module is a flash module, and the volatile storage module is an SRAM module or a DDR module.
[0095] Based on the same inventive concept, corresponding to the method of any of the above embodiments, an embodiment of the present application further provides a RISC-V chip, which includes the system for implementing a dynamic library mechanism based on a RISC-V chip described in any of the above embodiments, and can implement the function module update method of the corresponding RISC-V chip.
[0096] The computer-readable media of the embodiments of the present application include permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory, or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD), or other optical storage, magnetic cassette tapes, magnetic tape magnetic disk storage, or other magnetic storage devices, or any other non-transmission medium that can be used to store information accessible by a computing device.
[0097] The computer instructions stored in the storage medium of the above embodiments are used to cause the computer to execute the method for compensating the gain flatness of the millimeter wave signal as described in any one of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be elaborated here.
[0098] It should be noted that the various embodiments in this specification are described in a progressive manner. For the same or similar parts among the various embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. In particular, for systems, methods, and chips, since they are basically similar to the method embodiments, the description is relatively simple. For the relevant parts, reference can be made to the partial description of the method embodiments. The systems, methods, and chips described above are only illustrative. The units described as separate components may or may not be physically separated. The components indicated as units may or may not be physical units, that is, they may be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art can understand and implement it without creative efforts.
[0099] As described above, this is only a specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by those skilled in the art within the technical scope disclosed in the present application should be covered by the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A RISC-V chip dynamic library mechanism implementation system, characterized in that: It includes a non-volatile storage module, a volatile storage module, an address setting module, a mapping construction module and a position-independent loading processing module; The non-volatile storage module includes: a dynamic module, and the dynamic module includes: a dynamic library function, a function variable and a global variable; The address setting module is used to set the entry function address of the dynamic module to a preset memory address; The mapping construction module is used to construct a separate mapping relationship between the entry function input parameter and the dynamic library function based on the preset memory address; The position-independent loading processing module is used to perform position-independent loading processing on the function variables, the global variables and the dynamic library functions, so that the data in the dynamic module has the ability to be loaded into any storage address in the volatile storage module; The address setting module is specifically used for: Constructing a link script for the non-volatile storage module; By means of the link script, the entry function address is set to the preset memory address, and the addresses of all the dynamic library functions and variables in the dynamic module are set to the offset relative to the entry function address, so as to generate an executable file; The position-independent loading processing module includes: a global variable processing unit; the global variable processing unit is specifically used to: Determine the absolute address of the entry function when the entry function is running in the memory through relative addressing of the program counter; Obtaining, through the executable file, a global variable relative address of the global variable in the dynamic module; the global variable relative address is used to represent the address offset of the entry function address; The sum of the relative address of the global variable and the absolute address of the entry function is determined as the absolute memory address of the global variable in the dynamic module, so that the global variable has the ability to be loaded to any storage address in the volatile storage module.
2. The system according to claim 1, characterized in that The position-independent loading processing module includes: a function variable processing unit; the function variable processing unit is specifically used to: Compiling the function variables based on the -fPIE compilation option to generate position-independent codes for the function variables; The position-independent code is used to complete the call to the function variable by program counter relative addressing, so that the function variable has the ability to be loaded to any storage address in the volatile storage module.
3. The system according to claim 2, characterized in that The program counter relative addressing method is implemented by combining the auipc instruction and the address offset addition instruction in the RISC-V instruction set.
4. The system according to claim 1, characterized in that The system also includes: an external function calling module; The external function calling module is used to implement the calling of the external function by the dynamic module through an indirect address transfer mechanism.
5. The system according to claim 1, characterized in that The preset memory address is a memory start address; the non-volatile storage module is a flash module, and the volatile storage module is an SRAM module or a DDR module.
6. A method for updating a functional module of a RISC-V chip, applied to a central processing unit of a RISC-V chip, wherein the RISC-V chip comprises: A non-volatile storage module and a volatile storage module, wherein the non-volatile storage module includes a dynamic module; The dynamic module includes: dynamic library functions, function variables and global variables; the method includes: In response to a function module update instruction, the module file data of the dynamic module is written into the volatile storage module; the function module update instruction includes: a target calling function and a target function module; The entry function address of the dynamic module is set as a preset memory address, and based on the preset memory address, a function call mapping relationship corresponding to each other between the entry function input parameter and the dynamic library function is constructed; Based on the target calling function, determining a target input parameter from a plurality of the function calling mapping relationships; Performing a dynamic library function call according to the plurality of function call mapping relationships and the target input parameters to dynamically update the target functional module; The step of setting the entry function address of the dynamic module to a preset memory address includes: Constructing a link script for the non-volatile storage module; By means of the link script, the entry function address is set to the preset memory address, and the addresses of all the dynamic library functions and variables in the dynamic module are set to the offset relative to the entry function address, so as to generate an executable file; The method further comprises: Determine the absolute address of the entry function when the entry function is running in the memory through relative addressing of the program counter; Obtaining, through the executable file, a global variable relative address of the global variable in the dynamic module; the global variable relative address is used to represent the address offset of the entry function address; The sum of the relative address of the global variable and the absolute address of the entry function is determined as the absolute memory address of the global variable in the dynamic module, so that the global variable has the ability to be loaded to any storage address in the volatile storage module.
7. The method according to claim 6, characterized in that The preset memory address is a memory start address; the non-volatile storage module is a flash module, and the volatile storage module is an SRAM module or a DDR module.
8. A RISC-V chip, characterized in that: A RISC-V chip dynamic library mechanism implementation system comprising any one of claims 1-5.