Management Method, Device and Storage Medium for Register File Cache

By simplifying the management strategy and pipeline flushing mechanism of register heap cache, the problems of high hardware overhead and logic complexity in the existing technology are solved, and the efficient performance of the processor under high main frequency and large out of order width is achieved.

CN120011264BActive Publication Date: 2025-07-22RIVAI TECH (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510490663.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-18
Publication Date
2025-07-22
Estimated Expiration
2045-04-18

AI Technical Summary

Technical Problem

The existing register heap cache technology has high hardware overhead and high logic complexity when pipeline flushing, which affects processor performance and energy efficiency.

Method used

Using a simplified cache management strategy and pipeline flushing processing mechanism, the write back operation is reduced, hardware overhead and logic complexity is reduced through the collaborative management of the write back cache unit and the register cache unit.

Benefits of technology

While ensuring that the number of read and write ports meets the requirements, hardware overhead and dynamic power consumption are reduced, the complexity of cache coherence maintenance operations is reduced, and the timing and functional performance of the processor are improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120011264B_ABST
    Figure CN120011264B_ABST
Patent Text Reader

Abstract

The present invention is applicable to the field of processor technologies, and particularly relates to a management method, apparatus, and storage medium for a register file cache. The management method includes the following steps: obtaining an instruction to be executed through the processor front end for branch prediction processing and decoding processing, and sending the processed instruction to be executed to the processor back end; performing an operation on the instruction to be executed by the processor back end to obtain an operation result, and writing the operation result back to the register file module according to the storage state of the register file module of the processor back end and the cache management policy. Compared with the prior art, the present invention reduces the hardware overhead, logical complexity, and dynamic power consumption, and reduces the complexity brought by cache coherence maintenance operations under the condition of ensuring that the number of read / write ports of the register file module meets the requirements through the cache management policy and the corresponding processing mechanism during pipeline flushing. When pipeline flushing occurs, no time and hardware resources are spent flushing the cache.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention is applicable to the technical field of processors, and particularly relates to a management method, device and storage medium for a register file cache. Background Art

[0002] With the progress of semiconductor technology and the innovation of computer architectures, the performance of processors has been continuously increasing. Moore's Law has driven the rapid increase in the number of transistors, enabling the frequency of single-core processors to increase and the instruction throughput to increase significantly. The register file, as the core storage unit of the processor, directly interacts with the arithmetic logic unit, and its performance directly affects the instruction execution efficiency. The early simple register structures have gradually evolved into complex designs that support wider data widths and larger capacities to meet the requirements of high-performance computing.

[0003] To break through the performance bottleneck of the single-instruction pipeline, modern processors widely adopt multi-issue technologies, such as superscalar and very long instruction word architectures. Such processors can simultaneously issue and execute multiple instructions (e.g., 4-way or 6-way issue) per clock cycle, significantly improving instruction-level parallelism (ILP). However, the multi-issue architecture requires the register file to provide operands for multiple instructions in the same cycle, resulting in a sharp increase in the demand for read ports. For example, when an 8-way superscalar processor executes 8 instructions, if each instruction requires 2 source registers, the register file needs to support at least 16 read ports. This multi-port demand has led to a sharp increase in the structural complexity of the register file, becoming a key factor restricting the processor frequency and energy efficiency.

[0004] The current design of multi-port register files faces two core problems: timing risks and hardware overhead. Each read / write port needs to independently access the register cells, resulting in complex interconnection wiring and an extended signal transmission path. The introduction of multi-port multiplexing circuits and crossbars may make the register access latency become the critical path of the processor, restricting the increase in the main frequency. Traditional register files use multi-port memory cells (Multi-Ported SRAM), and their area increases quadratically with the number of ports. For example, for a register file of 32 registers × 64 bits, if it supports 10 read ports and 4 write ports, its area may account for more than 20% of the total area of the processor core. With the shrinkage of the process node and the increase in transistor density, the area optimization space of multi-port static random access memory (SRAM) is limited, resulting in an increase rather than a decrease in the cost ratio of the register file in advanced processes.

[0005] As a technology for optimizing processor performance, the Register File Cache has been widely studied and applied in recent years. The addition of the cache reduces the occupancy of the read ports of the main register file, enabling the main register file to use static memory with a low number of ports, thus reducing the hardware area and timing risks.

[0006] Existing register file cache technologies can be roughly divided into: hierarchical cache architectures and hybrid multi-port designs. Hierarchical cache architectures refer to caches integrated in the instruction issue stage, which are responsible for caching the source register values of recently issued instructions. They have a small capacity (8 - 16 entries), are fully associative or set associative designs, and support single-cycle access. The more common one is the hybrid multi-port design. In this type of design, instructions will access the main register file and the cache in parallel. Thus, the overall number of read ports is extended through the cache while the number of read ports of the main register file remains unchanged. The cache organization can be direct mapped, set associative, or fully associative. The cache content generally includes: valid bits, tags (used to identify the corresponding main register file entries), dirty bits (used to indicate whether the cache entry has been modified), and register data.

[0007] Similar to data caches, register file caches also need to use cache coherence protocols to ensure that the data in the cache is up-to-date. When a pipeline flush operation occurs, it is also necessary to invalidate the expired cache data. When the cache is full, different replacement strategies can be selected to determine the cache data that needs to be overwritten, such as the least recently used, first in first out, or random replacement strategies.

[0008] Although the hybrid multi-port design can effectively provide more read ports, the cache maintenance strategy is complex, with a large amount of logic and high power consumption in the case of pipeline flushes. It brings risks to the front-end design, verification, and back-end layout. In the existing technology, it is necessary to mark the dirty bits or invalidate the corresponding entries in the register file cache when the same register entry is overwritten. When a pipeline flush occurs, all the data in the cache needs to be written back to the main register file before the flush process can end and continue execution. This will cause a long delay and affect performance when the cache is relatively full. If an exact flush method is adopted, it is necessary to check each cache entry and determine whether it needs to be written back when a pipeline flush occurs. This method has high hardware complexity, large area and power consumption overhead, and may limit the processor clock frequency.

[0009] Therefore, there is an urgent need for a new management method, device, and storage medium for register file caches to solve the above technical problems. Summary of the Invention

[0010] The present invention provides a management method, device and storage medium for register file cache, aiming to retain the advantages of the hybrid multi-port register file cache design while reducing the timing and verification risks by simplifying the write-back and cache management strategies. When a pipeline flush occurs, the hardware overhead is reduced and performance loss is avoided.

[0011] In a first aspect, the present invention provides a management method for register file cache, and the management method includes the following steps:

[0012] S1. Obtain the to-be-executed instruction through the processor front-end for branch prediction processing and decoding processing, and send the processed to-be-executed instruction to the processor back-end;

[0013] S2. Perform an operation on the to-be-executed instruction by the processor back-end to obtain an operation result, and write back the operation result to the register file module according to the storage state of the register file module of the processor back-end and the cache management strategy; wherein, the register file module includes a write-back cache unit, a main register file unit and a register cache unit; the main register file unit is used to store and manage the register data in the processor, the register cache unit is used to cache the written-back operation result and provide an additional read port, and the write-back cache unit is used to cache the written-back operation result and write it back to the main register file unit;

[0014] The cache management strategy includes:

[0015] When the operation result in the write-back cache unit is written back to the main register file unit, find the corresponding first entry in the register cache unit according to the register number corresponding to the operation result, and update the state of the first entry to written-back;

[0016] When the storage state of the register cache unit is full and the write-back cache unit sends a write-back request to the register cache unit, generate a written-back entry mask according to the state of the entries in the register cache unit; select an entry as the second entry in the register cache unit according to the written-back entry mask, and overwrite and write the operation result and the register number corresponding to the operation result into the second entry.

[0017] Preferably, in step S2, the following sub-steps are included:

[0018] S21. Judge whether the storage state of the write-back cache unit is full: if so, return the operation result to the execution unit of the processor back-end; if not, perform step S22;

[0019] S22. The write-back cache unit allocates a write-back cache entry for the operation result and stores the operation result in the write-back cache unit;

[0020] S23. Determine whether the storage state of the register buffer unit is full:

[0021] If so, randomly select the first entry with a written-back flag in the register buffer unit as the replacement entry, write the operation result into the replacement entry, and mark the state of the replacement entry as not written back;

[0022] If not, write the operation result into the idle entry in the register buffer unit, and mark the state of the idle entry as not written back;

[0023] S24. The main register file performs write-back arbitration on the write-back cache entries in the write-back cache unit with a not-written-back flag, and determines whether the write-back cache entry is arbitration successful:

[0024] If so, write the data in the arbitration-successful write-back cache entry back to the main register file unit, and mark the state of the entry corresponding to the write-back cache entry in the register buffer unit as written back.

[0025] Preferably, when a pipeline flush occurs in the processor, the states of the entries in the register buffer unit and the entries in the write-back cache unit remain unchanged.

[0026] Preferably, after the pipeline flush occurs in the processor, when the front end of the processor sends a new instruction to the back end of the processor for register renaming processing:

[0027] Check the entries in the register buffer unit, and determine whether there is an entry in the register buffer unit that is the same as the current renamed target register: If so, invalidate the corresponding entry in the register buffer unit;

[0028] Check the entries in the write-back cache unit, and determine whether there is an entry in the write-back cache unit that is the same as the current renamed target register: If so, invalidate the corresponding entry in the write-back cache unit.

[0029] In a second aspect, the present invention further provides a management device for a register file cache, including:

[0030] A sending module, configured to obtain an instruction to be executed through the front end of the processor for branch prediction processing and decoding processing, and send the processed instruction to be executed to the back end of the processor;

[0031] An arithmetic module is used to perform arithmetic operations according to the instruction to be executed by the processor backend, obtain an arithmetic result, and write back the arithmetic result to the register file module according to the storage status of the register file module of the processor backend and the cache management policy; wherein, the register file module includes a write-back cache unit, a main register file unit, and a register cache unit; the main register file unit is used to store and manage register data in the processor, the register cache unit is used to cache the written-back arithmetic result and provide an additional read port, and the write-back cache unit is used to cache the written-back arithmetic result and write it back to the main register file unit;

[0032] The cache management policy includes:

[0033] When the arithmetic result in the write-back cache unit is written back to the main register file unit, find the corresponding first entry in the register cache unit according to the register number corresponding to the arithmetic result, and update the status of the first entry to written-back;

[0034] When the storage status of the register cache unit is full and the write-back cache unit sends a write-back request to the register cache unit, generate a written-back entry mask according to the status of the entries in the register cache unit; select an entry as the second entry in the register cache unit according to the written-back entry mask, and overwrite and write the arithmetic result and the register number corresponding to the arithmetic result into the second entry.

[0035] Preferably, the arithmetic module includes the following sub-units:

[0036] A judgment unit is used to judge whether the storage status of the write-back cache unit is full: if so, return the arithmetic result to the execution unit of the processor backend; if not, jump to the first write-back storage unit;

[0037] The first write-back storage unit is used for the write-back cache unit to allocate a write-back cache entry for the arithmetic result and store the arithmetic result in the write-back cache unit;

[0038] A second write-back judgment unit is used to judge whether the storage status of the register cache unit is full:

[0039] If so, arbitrarily select the first entry with a written-back mark in the register cache unit as the replacement entry, write the arithmetic result into the replacement entry, and mark the status of the replacement entry as not written-back;

[0040] If not, write the arithmetic result into the idle entry in the register cache unit and mark the status of the idle entry as not written-back;

[0041] An arbitration unit is used for the main register file to perform write-back arbitration on the write-back cache entries with unwritten-back tags in the write-back cache unit, and to determine whether the write-back arbitration of the write-back cache entries is successful:

[0042] If so, write the data in the successfully arbitrated write-back cache entry back to the main register file unit, and mark the status of the entry corresponding to the write-back cache entry in the register cache unit as written back.

[0043] Preferably, when a pipeline flush occurs in the processor, the status of the entries in the register cache unit and the entries in the write-back cache unit remains unchanged.

[0044] Preferably, when the processor front end sends new instructions to the processor back end for register renaming processing after the pipeline flush occurs in the processor:

[0045] Check the entries in the register cache unit to determine whether there is an entry in the register cache unit that is the same as the current renamed target register: if so, invalidate the corresponding entry in the register cache unit;

[0046] Check the entries in the write-back cache unit to determine whether there is an entry in the write-back cache unit that is the same as the current renamed target register: if so, invalidate the corresponding entry in the write-back cache unit.

[0047] In a third aspect, the present invention further provides a management device for a register file cache, including: a memory, a processor, and a management program for the register file cache stored on the memory and executable on the processor. When the processor executes the management program for the register file cache, the steps in the management method for the register file cache described in any one of the above embodiments are implemented.

[0048] In a fourth aspect, the present invention further provides a storage medium, on which a management program for a register file cache is stored. When the management program for the register file cache is executed by a processor, the steps in the management method for the register file cache described in any one of the above embodiments are implemented.

[0049] Compared with the prior art, through the cache management strategy and the corresponding processing mechanism during pipeline flushing, the present invention reduces the hardware overhead, logical complexity, and dynamic power consumption while ensuring that the number of read / write ports of the register file module meets the requirements, and reduces the complexity brought by cache coherence maintenance operations. When a pipeline flush occurs, instead of spending time and hardware resources flushing the cache, it detects write-after-write hazards during renaming and then precisely invalidates the entries that need to be overwritten to meet the timing and functional requirements of the processor at high frequencies and wide out-of-order widths. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] The present invention will be described in detail below with reference to the drawings. Through the following detailed description in conjunction with the drawings, the above or other aspects of the present invention will become clearer and easier to understand. In the drawings:

[0051] Figure 1 is a flowchart of a method for managing a register file cache provided in the first embodiment of the present invention;

[0052] Figure 2 is a schematic diagram of a processor architecture of a method for managing a register file cache provided in the first embodiment of the present invention;

[0053] Figure 3 is a schematic diagram of the structure of a device for managing a register file cache provided in the second embodiment of the present invention;

[0054] Figure 4 is a schematic diagram of the structure of a device for managing a register file cache provided in the third embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0055] In order to make the objectives, technical solutions and advantages of the present invention clearer and more understandable, the present invention will be further described in detail below with reference to the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0056] Embodiment 1

[0057] Please refer to Figures 1-2 , the present invention provides a method for managing a register file cache, and the method for managing the register file cache includes the following steps:

[0058] S1. Obtain an instruction to be executed through the processor front end for branch prediction processing and decoding processing, and send the processed instruction to be executed to the processor back end.

[0059] In the embodiment of the present invention, the processor includes a processor front end and a processor back end. The processor front end is responsible for obtaining and preprocessing instructions to prepare for subsequent execution. It includes an instruction fetch unit (Fetch), an instruction decoder (Decode), a branch predictor (Branch Predictor), and an instruction cache (Instruction Cache). The instruction fetch unit is used to read instructions from memory and place them in the instruction queue in sequence; the instruction decoder is used to convert binary instructions into micro-operations that the CPU can understand; the branch predictor is used to predict the direction of branches in the program (such as if statements) to reduce pipeline stalls; the instruction cache is used to cache frequently used instructions to accelerate the instruction fetch process.

[0060] The processor backend is responsible for executing instructions, processing data, and writing the results back to memory or registers. It includes execution units for performing operations on instructions and a register file module for implementing functions such as storing and managing register data.

[0061] S2. Perform operations on the to-be-executed instruction by the processor backend to obtain an operation result, and write the operation result back to the register file module according to the storage status of the register file module of the processor backend and the cache management policy; wherein, the register file module includes a write-back cache unit, a main register file unit, and a register cache unit; the main register file unit is used for storing and managing register data in the processor, the register cache unit is used for caching the written-back operation result and providing an additional read port, and the write-back cache unit is used for caching the written-back operation result and writing it back to the main register file unit.

[0062] The cache management policy includes:

[0063] When the operation result in the write-back cache unit is written back to the main register file unit, look up the first entry corresponding to the operation result in the register cache unit according to the register number corresponding to the operation result, and update the status of the first entry to written-back (that is, update the write-back status of the first entry from 0 to 1, indicating that the data has been written back).

[0064] When the storage status of the register cache unit is full and the write-back cache unit issues a write-back request to the register cache unit, generate a written-back entry mask according to the status of the entries in the register cache unit (the written-back entry mask is a binary mask mechanism for marking which data blocks in the cache have been successfully written back to the main memory); select an entry as the second entry in the register cache unit according to the written-back entry mask, and overwrite and write the operation result and the register number corresponding to the operation result into the second entry.

[0065] In the embodiment of the present invention, in step S2, the following sub-steps are included:

[0066] S21. Judge whether the storage status of the write-back cache unit is full: if so, return the operation result to the execution unit of the processor backend; if not, proceed to step S22;

[0067] S22. The write-back cache unit allocates a write-back cache entry for the operation result and stores the operation result in the write-back cache unit;

[0068] S23. Judge whether the storage status of the register cache unit is full:

[0069] If so, arbitrarily select the first entry with a written-back flag in the register buffer unit as the replacement entry, write the operation result into the replacement entry, and mark the status of the replacement entry as not written back;

[0070] If not, write the operation result into an idle entry in the register buffer unit, and mark the status of the idle entry as not written back (i.e., not written back to the main register file unit);

[0071] S24. The main register file performs write-back arbitration on the write-back cache entries in the write-back cache unit with a not-written-back flag (when performing write-back arbitration, it is processed according to conditions such as the number of write ports and conflicts. Write-back arbitration refers to the conflict resolution mechanism in the processor cache system for coordinating multiple cache units, such as multi-level caches or multi-core caches, to write back data to the main memory simultaneously), and determines whether the write-back cache entry is successfully arbitrated:

[0072] If so, write the data in the successfully arbitrated write-back cache entry back to the main register file unit, and mark the status of the corresponding entry in the register buffer unit as written back.

[0073] In the embodiments of the present invention, when a pipeline flush occurs, the existing method needs to write all cache data back to the main register file to avoid write-after-write hazards. When the cache load is high, it takes a long time to complete the write-back of all data. Therefore, the present invention improves and optimizes the operations required for pipeline flushing through the register renaming mechanism of the out-of-order processor, reduces additional operations and lowers the hardware dynamic power consumption. Specifically:

[0074] When a pipeline flush occurs in the processor, the status of the entries in the register buffer unit and the entries in the write-back cache unit remains unchanged. Specifically, Pipeline Flush refers to the process in which, during the pipeline execution of the processor, due to certain reasons (such as incorrect branch prediction, interrupt, or exception), the subsequent instructions that have entered the pipeline are terminated and cleared in advance, and then the correct instructions are restarted for execution.

[0075] In the embodiments of the present invention, after the pipeline flush occurs in the processor, when the front end of the processor sends a new instruction to the back end of the processor for register renaming processing:

[0076] Check the entries in the register buffer unit, and determine whether there is an entry in the register buffer unit that is the same as the current renamed target register: If so, invalidate the corresponding entry in the register buffer unit, that is, invalidate the corresponding entry; If not, it means there is no matching entry and no operation needs to be performed.

[0077] Check the entries in the write-back cache unit to determine whether there is an entry in the write-back cache unit that is the same as the current renamed target register. If so, invalidate the corresponding entry in the write-back cache unit, that is, invalidate the corresponding entry. If not, it means there is no matching entry and no operation is required.

[0078] According to the above pipeline flush process, when a new write-back request is generated, there should be no cache entry with the same register number, and new data is written normally. Based on the above method steps, the cache process of the register file module is optimized to reduce cache conflicts and the latency and complexity of write-back operations.

[0079] Compared with the prior art, the present invention reduces the hardware overhead, logical complexity, and dynamic power consumption, and reduces the complexity brought by cache coherence maintenance operations by means of a cache management strategy and a corresponding processing mechanism during pipeline flushing, while ensuring that the number of read / write ports of the register file module meets the requirements. When a pipeline flush occurs, instead of spending time and hardware resources flushing the cache, it detects write-after-write hazards during renaming and then precisely invalidates the entries that need to be overwritten to meet the timing and functional requirements of the processor at high operating frequencies and wide out-of-order widths.

[0080] Embodiment 2

[0081] The embodiment of the present invention further provides a management device for a register file cache. Please refer to Figure 3 , Figure 3 which is a schematic structural diagram of a management device 200 for a register file cache provided by an embodiment of the present invention, and includes:

[0082] 201. A sending module, configured to obtain an instruction to be executed through the front end of the processor for branch prediction processing and decoding processing, and send the processed instruction to be executed to the back end of the processor;

[0083] 202. An arithmetic module, configured to perform arithmetic operations on the instruction to be executed through the back end of the processor to obtain an arithmetic result, and write back the arithmetic result to the register file module according to the storage state of the register file module and the cache management strategy in the back end of the processor. Among them, the register file module includes a write-back cache unit, a main register file unit, and a register cache unit. The main register file unit is used to store and manage register data in the processor, the register cache unit is used to cache the written-back arithmetic result and provide an additional read port, and the write-back cache unit is used to cache the written-back arithmetic result and write it back to the main register file unit;

[0084] The cache management strategy includes:

[0085] When the operation result in the write-back cache unit is written back to the main register file unit, the first entry corresponding thereto in the register cache unit is found according to the register number corresponding to the operation result, and the status of the first entry is updated to written-back;

[0086] When the storage status of the register cache unit is full and the write-back cache unit issues a write-back request to the register cache unit, a written-back entry mask is generated according to the status of the entries in the register cache unit; a second entry is selected in the register cache unit according to the written-back entry mask, and the operation result and the register number corresponding to the operation result are overwritten and written into the second entry.

[0087] In the embodiment of the present invention, the operation module 202 includes the following sub-units:

[0088] 2021. A judgment unit, configured to judge whether the storage status of the write-back cache unit is full: if so, return the operation result to the execution unit at the back end of the processor; if not, jump to 2022, the first write-back storage unit;

[0089] 2022. The first write-back storage unit is configured to allocate a write-back cache entry for the operation result by the write-back cache unit, and store the operation result in the write-back cache unit;

[0090] 2023. A second write-back judgment unit, configured to judge whether the storage status of the register cache unit is full:

[0091] If so, arbitrarily select the first entry with a written-back mark in the register cache unit as a replacement entry, write the operation result into the replacement entry, and mark the status of the replacement entry as not written-back;

[0092] If not, write the operation result into the idle entry in the register cache unit, and mark the status of the idle entry as not written-back;

[0093] 2024. An arbitration unit is configured to perform write-back arbitration on the write-back cache entries with unwritten-back marks in the write-back cache unit by the main register file, and judge whether the write-back cache entries are successfully arbitrated:

[0094] If so, write the data in the successfully arbitrated write-back cache entry back to the main register file unit, and mark the status of the entry corresponding to the write-back cache entry in the register cache unit as written-back.

[0095] In an embodiment of the present invention, when a pipeline flush occurs in the processor, the entries in the register cache unit and the status of the entries in the write-back cache unit remain unchanged.

[0096] In an embodiment of the present invention, after a pipeline flush occurs in the processor, when the front end of the processor sends a new instruction to the back end of the processor for register renaming processing:

[0097] Check the entries in the register cache unit to determine whether there is an entry in the register cache unit that is the same as the current rename target register: If so, invalidate the corresponding entry in the register cache unit;

[0098] Check the entries in the write-back cache unit to determine whether there is an entry in the write-back cache unit that is the same as the current rename target register: If so, invalidate the corresponding entry in the write-back cache unit.

[0099] The management device 200 of the register file cache can implement the steps in the management method of the register file cache in the above embodiment, and can achieve the same technical effects. Refer to the description in the above embodiment, and details are not described herein again.

[0100] Embodiment Three

[0101] An embodiment of the present invention further provides a management device for a register file cache. Please refer to Figure 4 , Figure 4 which is a schematic structural diagram of the management device for the register file cache provided by an embodiment of the present invention. The management device 300 of the register file cache includes: a memory 302, a processor 301, and a management program for the register file cache stored on the memory 302 and executable on the processor 301.

[0102] The processor 301 calls the management program for the register file cache stored in the memory 302 and executes the steps in the management method for the register file cache provided by an embodiment of the present invention. Please refer to Figures 1-2 , and specifically includes the following steps:

[0103] S1. Obtain an instruction to be executed through the front end of the processor for branch prediction processing and decoding processing, and send the processed instruction to be executed to the back end of the processor.

[0104] In an embodiment of the present invention, the processor includes a processor front end and a processor back end. The processor front end is responsible for fetching and preprocessing instructions to prepare for subsequent execution. It includes an instruction fetch unit (Fetch), an instruction decoder (Decode), a branch predictor (Branch Predictor), and an instruction cache (Instruction Cache). The instruction fetch unit is used to read instructions from memory and place them in the instruction queue in order; the instruction decoder is used to convert binary instructions into micro-operations that the CPU can understand; the branch predictor is used to predict the branches (such as if statements) in the program to reduce pipeline stalls; the instruction cache is used to cache frequently used instructions to accelerate the instruction fetch process.

[0105] The processor back end is responsible for executing instructions, processing data, and writing the results back to memory or registers. It includes execution units (Execution Units) for performing operations on instructions and a register file module for implementing functions such as storing and managing register data.

[0106] S2. The processor back end performs operations according to the to-be-executed instructions to obtain an operation result, and writes the operation result back to the register file module according to the storage state of the register file module of the processor back end and the cache management policy; wherein, the register file module includes a write-back cache unit, a main register file unit, and a register cache unit; the main register file unit is used to store and manage register data in the processor, the register cache unit is used to cache the written-back operation result and provide an additional read port, and the write-back cache unit is used to cache the written-back operation result and write it back to the main register file unit.

[0107] The cache management policy includes:

[0108] When the operation result in the write-back cache unit is written back to the main register file unit, the corresponding first entry in the register cache unit is found according to the register number corresponding to the operation result, and the state of the first entry is updated to written-back (that is, the write-back state of the first entry is updated from 0 to 1, indicating that the data has been written back).

[0109] When the storage state of the register cache unit is full and the write-back cache unit issues a write-back request to the register cache unit, an already-written-back entry mask is generated according to the states of the entries in the register cache unit (the already-written-back entry mask is a binary mask mechanism used to mark which data blocks in the cache have been successfully written back to the main memory); according to the already-written-back entry mask, an entry in the register cache unit is selected as the second entry, and the operation result and the register number corresponding to the operation result are overwritten and written into the second entry.

[0110] In the embodiment of the present invention, in step S2, the following sub-steps are included:

[0111] S21. Determine whether the storage state of the write-back cache unit is full: If so, return the operation result to the execution unit at the back end of the processor; if not, proceed to step S22;

[0112] S22. The write-back cache unit allocates a write-back cache entry for the operation result and stores the operation result in the write-back cache unit;

[0113] S23. Determine whether the storage state of the register cache unit is full:

[0114] If so, arbitrarily select the first entry with a written-back flag in the register cache unit as the replacement entry, write the operation result into the replacement entry, and mark the state of the replacement entry as not written back;

[0115] If not, write the operation result into the idle entry in the register cache unit and mark the state of the idle entry as not written back (i.e., not written back to the main register file unit);

[0116] S24. The main register file performs a write-back arbitration on the write-back cache entries with a not-written-back flag in the write-back cache unit (when performing the write-back arbitration, it is processed according to conditions such as the number of write ports and conflicts. The write-back arbitration refers to the conflict resolution mechanism in the processor cache system for coordinating multiple cache units, such as multi-level caches or multi-core caches, when writing back data to the main memory at the same time), and determine whether the write-back cache entry is successfully arbitrated:

[0117] If so, write the data in the successfully arbitrated write-back cache entry back to the main register file unit, and mark the state of the entry corresponding to the write-back cache entry in the register cache unit as written back.

[0118] In the embodiment of the present invention, when a pipeline flush occurs, the existing method needs to write back all cache data to the main register file to avoid write-after-write hazards. When the cache load is high, it takes a long time to complete the write-back of all data. Therefore, the present invention improves and optimizes the operations required for pipeline flushing through the renaming mechanism of the out-of-order processor, reducing additional operations and lowering the hardware dynamic power consumption. Specifically:

[0119] When a pipeline flush occurs in the processor, the entries in the register cache unit and the status of the entries in the write-back cache unit remain unchanged. Specifically, pipeline flush refers to the process in which, during the pipeline execution of the processor, due to certain reasons (such as incorrect branch prediction, interrupt, or exception), the subsequent instructions that have entered the pipeline are terminated and cleared in advance, and then the correct instructions are restarted for execution.

[0120] In an embodiment of the present invention, after the pipeline flush occurs in the processor, when the front end of the processor sends a new instruction to the back end of the processor for register renaming processing:

[0121] Check the entries in the register cache unit to determine whether there is an entry in the register cache unit that is the same as the current rename target register: If so, invalidate the corresponding entry in the register cache unit, that is, invalidate the corresponding entry; if not, it means there is no matching entry and no operation needs to be performed.

[0122] Check the entries in the write-back cache unit to determine whether there is an entry in the write-back cache unit that is the same as the current rename target register: If so, invalidate the corresponding entry in the write-back cache unit, that is, invalidate the corresponding entry; if not, it means there is no matching entry and no operation needs to be performed.

[0123] According to the above pipeline flush process, when a new write-back request is generated, there should be no cache entries with the same register number, and new data is written normally. Based on the above method steps, the cache process of the register file module is optimized, thereby reducing cache conflicts and the latency and complexity of the write-back operation.

[0124] The register file cache management device 300 provided in the embodiment of the present invention can implement the steps in the register file cache management method in the above embodiment and can achieve the same technical effect. Refer to the description in the above embodiment, and details are not described here again.

[0125] Embodiment 4

[0126] The embodiment of the present invention further provides a storage medium. The storage medium is a computer-readable storage medium, and a register file cache management program is stored on the storage medium. When the register file cache management program is executed by a processor, it implements each process and step in the register file cache management method provided in the embodiment of the present invention and can achieve the same technical effect. To avoid repetition, details are not described here again.

[0127] Those of ordinary skill in the art can understand that all or part of the processes of implementing the methods in the above embodiments can be completed by instructing relevant hardware through a computer program. The management program for the register file cache can be stored in a computer-readable storage medium. When the management program for the register file cache is executed, it can include the processes of the embodiments of the above methods. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM, for short), etc.

[0128] It should be noted that in this document, the term "including", "comprising" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or further includes elements inherent to such a process, method, article or device. Without further limitation, an element defined by the statement "including one..." does not exclude the existence of another identical element in the process, method, article or device including that element.

[0129] Through the description of the above embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus a necessary general hardware platform. Of course, it can also be implemented by hardware, but in many cases the former is a better implementation. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to enable a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in the various embodiments of the present invention.

[0130] The embodiments of the present invention have been described above in conjunction with the accompanying drawings. What is disclosed is only the preferred embodiments of the present invention, but the present invention is not limited to the above specific embodiments. The above specific embodiments are merely illustrative and not restrictive. Under the inspiration of the present invention, those of ordinary skill in the art can also make many equivalent changes in form without departing from the purpose of the present invention and the scope protected by the claims, and all belong to the protection scope of the present invention.

Claims

1. A management method for a register file cache, characterized in that The described management method includes the following steps: S1. Obtain the instruction to be executed through the front end of the processor for branch prediction processing and decoding processing, and send the processed instruction to be executed to the back end of the processor; S2. Perform operations on the instruction to be executed through the back end of the processor to obtain an operation result, and write back the operation result to the register file module according to the storage state of the register file module in the back end of the processor and the cache management policy; wherein, the register file module includes a write-back cache unit, a main register file unit, and a register cache unit; the main register file unit is used to store and manage the register data in the processor, the register cache unit is used to cache the written-back operation result and provide an additional read port, and the write-back cache unit is used to cache the written-back operation result and write it back to the main register file unit; The cache management policy includes: When the operation result in the write-back cache unit is written back to the main register file unit, look up the first entry corresponding to the register cache unit according to the register number corresponding to the operation result, and update the state of the first entry to written-back; When the storage state of the register cache unit is full and the write-back cache unit sends a write-back request to the register cache unit, generate a written-back entry mask according to the state of the entries in the register cache unit; select an entry in the register cache unit as the second entry according to the written-back entry mask, and overwrite and write the operation result and the register number corresponding to the operation result into the second entry; When a pipeline flush occurs in the processor, the states of the entries in the register cache unit and the entries in the write-back cache unit remain unchanged; When a new instruction is sent from the front end of the processor to the back end of the processor for register renaming processing after a pipeline flush in the processor: Check the entries in the register cache unit to determine whether there is an entry in the register cache unit that is the same as the current renaming target register: if so, invalidate the corresponding entry in the register cache unit; Check the entries in the write-back cache unit to determine whether there is an entry in the write-back cache unit that is the same as the current renaming target register: if so, invalidate the corresponding entry in the write-back cache unit.

2. The management method of the register file cache according to claim 1, characterized in that, In step S2, the following sub-steps are included: S21. Determine whether the storage state of the write-back cache unit is full: if so, return the operation result to the execution unit at the back end of the processor; if not, perform step S22; S22. The write-back cache unit allocates a write-back cache entry for the operation result and stores the operation result in the write-back cache unit; S23. Determine whether the storage state of the register cache unit is full: If so, arbitrarily select the first entry with a written-back mark in the register cache unit as the replacement entry, write the operation result into the replacement entry, and mark the state of the replacement entry as not written-back; Otherwise, write the operation result to an idle entry in the register buffer unit, and mark the status of the idle entry as not written back; S24. The main register file performs write-back arbitration on the write-back cache entries with the not-written-back mark in the write-back cache unit, and determines whether the write-back cache entry is arbitration successful: If so, write the data in the arbitration successful write-back cache entry back to the main register file unit, and mark the status of the entry corresponding to the write-back cache entry in the register buffer unit as written back.

3. A management device for a register file cache, characterized in that Including: A sending module, configured to obtain an instruction to be executed through a processor front end, perform branch prediction processing and decoding processing, and send the processed instruction to be executed to a processor back end; An operation module, configured to perform an operation on the instruction to be executed through the processor back end to obtain an operation result, and write back the operation result to the register file module according to the storage status of a register file module and a cache management policy in the processor back end; wherein, the register file module includes a write-back cache unit, a main register file unit, and a register buffer unit; the main register file unit is configured to store and manage register data in the processor, the register buffer unit is configured to cache the written-back operation result and provide an additional read port, and the write-back cache unit is configured to cache the written-back operation result and write it back to the main register file unit; The cache management policy includes: When the operation result in the write-back cache unit is written back to the main register file unit, find the first corresponding entry in the register buffer unit according to the register number corresponding to the operation result, and update the status of the first entry to written back; When the storage status of the register buffer unit is full and the write-back cache unit sends a write-back request to the register buffer unit, generate a written-back entry mask according to the status of the entries in the register buffer unit; select an entry in the register buffer unit as the second entry according to the written-back entry mask, and overwrite and write the operation result and the register number corresponding to the operation result into the second entry; When a pipeline flush occurs in the processor, the status of the entries in the register buffer unit and the status of the entries in the write-back cache unit remain unchanged; When a new instruction is sent from the processor front end to the processor back end for register renaming processing after a pipeline flush occurs in the processor: Check the entries in the register buffer unit, and determine whether there is an entry in the register buffer unit that is the same as the current rename target register: if so, invalidate the corresponding entry in the register buffer unit; Check the entries in the write-back cache unit, and determine whether there is an entry in the write-back cache unit that is the same as the current rename target register: if so, invalidate the corresponding entry in the write-back cache unit.

4. The management device for the register file cache according to claim 3, characterized in that, The operation module includes the following sub-units: A judgment unit, configured to judge whether the storage state of the write-back cache unit is full: if so, return the operation result to the execution unit at the back end of the processor; if not, jump to the first write-back storage unit; The first write-back storage unit is configured to allocate a write-back cache entry for the operation result by the write-back cache unit, and store the operation result in the write-back cache unit; A second write-back judgment unit, configured to judge whether the storage state of the register cache unit is full: if so, arbitrarily select the first entry with a written-back flag in the register cache unit as a replacement entry, write the operation result into the replacement entry, and mark the state of the replacement entry as not written back; if not, write the operation result into the idle entry in the register cache unit, and mark the state of the idle entry as not written back; An arbitration unit, configured to perform write-back arbitration on the write-back cache entries with unwritten-back flags in the write-back cache unit by the main register file, and judge whether the write-back cache entries are successfully arbitrated: if so, write the data in the successfully arbitrated write-back cache entry back to the main register file unit, and mark the state of the entry corresponding to the write-back cache entry in the register cache unit as written back.

5. A management device for a register file cache, characterized in that, including: a memory, a processor, and a management program of a register file cache stored on the memory and executable on the processor, wherein when the processor executes the management program of the register file cache, the steps in the management method of the register file cache according to any one of claims 1-2 are implemented.

6. A storage medium, characterized in that, A management program of a register file cache is stored on the storage medium, and when the management program of the register file cache is executed by a processor, the steps in the management method of the register file cache according to any one of claims 1-2 are implemented.

Citation Information

Patent Citations

  • Vector register file caching system based on RISC-V instruction set

    CN115964087A

  • Multi-level management method and system for registers of multi-thread processor

    CN116560729A