A DRAM access processing method, cache control module and DRAM controller
By adopting a set-associative mapping cache control module in the DRAM controller, the problem of low DRAM access efficiency is solved and higher bandwidth utilization and access efficiency are achieved.
Patent Information
- Application Number
- CN202410085800.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-22
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2044-01-22
AI Technical Summary
In the existing technology, the access efficiency of DRAM is low and the bandwidth cannot be fully utilized. This is mainly due to the low access efficiency caused by frequent switching between multiple rows and the discrete addresses when data is written back under the Cache mechanism.
The cache control module uses set-associative mapping to store part of the data in the DRAM controller. By determining the target cache line during the write-back operation, the data in the same line in the DRAM is written back together, and the access requests are integrated to improve bandwidth utilization and access. efficiency.
Through the design of set-associative mapping and cache control modules, the access efficiency and bandwidth utilization of DRAM are improved, the pressure on DRAM is reduced, and the efficiency of write-back operations is optimized.
Smart Images

Figure CN117608498B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a DRAM access processing method, a cache control module, and a DRAM controller. Background Art
[0002] The industry usually uses DRAM (Dynamic Random Access Memory) as the system memory. DRAM is composed of multiple memory arrays (banks), and each memory array is composed of rows and columns. When reading and writing a certain address, you must first activate the row where the address is located and send a row activation command (Active) before sending the read and write commands. In the same memory array, if you need to switch to another row address for reading and writing, you need to close the currently activated row (Precharge), activate the new row, and finally read and write. At present, whether you access DRAM directly or use the cache mechanism to access DRAM, you usually need to switch between multiple rows, the access efficiency is low, and the bandwidth cannot be fully utilized. Summary of the invention
[0003] The purpose of the present disclosure is to provide a DRAM access processing method, a cache control module and a DRAM controller.
[0004] According to a first aspect of the present disclosure, a DRAM access processing method is provided, which is applied to a cache control module in a DRAM controller, wherein the DRAM controller further comprises a cache module; the cache module stores part of the data in the DRAM, and the mapping mode between the cache module and the DRAM is a group associative mapping, wherein the number of groups in the cache module is the same as the number of memory arrays in the DRAM, each group comprises a plurality of cache lines, the bit width of each cache line is the bit width of a line in the DRAM, data in the same memory array in the DRAM is mapped to the same group in the cache module, and data in the same line in the memory array is mapped to the same cache line; the method comprises:
[0005] When a write-back operation is performed on data in the cache module, a target cache line is determined from the cache module, triggering an operation of writing the data in the target cache line back to the DRAM.
[0006] In one embodiment, when performing a write-back operation on data in a cache module, determining a target cache line from the cache module includes:
[0007] When performing a write-back operation on a cache line in any target group in the cache module, determine whether there is an activated target line in the memory array mapped by the target group; if so, determine the cache line corresponding to the target line in the target group as the target cache line.
[0008] In one embodiment, performing a write-back operation on a cache line in any target group in a cache module includes:
[0009] When an access request sent by an upstream device hits any target group but misses a cache line in the target group, and the target group has no free cache lines, a write-back operation is performed on the cache lines in the target group.
[0010] In one embodiment, the DRAM controller further includes a command queue and a command queue monitoring module, wherein the command queue stores access commands generated by the cache control module; the command queue monitoring module is configured to monitor the command queue and generate command queue information; the command queue information includes: the total number of commands in the command queue, the number of commands sent to each memory array;
[0011] The performing a write-back operation on a cache line in any target group in the cache module includes:
[0012] The total number of commands in the command queue and the number of commands sent to each memory array are obtained from the command queue monitoring module; when the total number of commands in the command queue is less than a first preset threshold, the group of memory array mappings corresponding to the least number of commands is determined as the target group, and a write-back operation is performed on the cache lines in the target group.
[0013] In one embodiment, the method further comprises:
[0014] When the number of commands sent to any memory array is zero, the group mapped by the memory array is determined as the target group, and a write-back operation is performed on the cache lines in the target group.
[0015] In one embodiment, the DRAM controller further includes an address mapping module, and the address mapping module is configured to parse the address of any access request to obtain a memory array address, a row address, and a column address; the method further includes:
[0016] The group corresponding to the access request is determined according to the memory array address; whether the access request hits any cache line in the group is determined according to the row address; if it hits, the hit cache line is processed according to the access request.
[0017] In one embodiment, the method further comprises:
[0018] In case of a miss, the group has no free cache line, and the access request is a read request, not triggering an operation of allocating a cache line for the read request;
[0019] In case of a miss, the group has a free cache line, and the access request is a read request, obtaining the total number of commands in the command queue from the command queue monitoring module;
[0020] When the total number of commands is less than the second preset threshold, the operation of reading the data in the row targeted by the read request into any free cache row is triggered; when the total number of commands is not less than the second preset threshold, the operation of allocating cache rows for the read request is not triggered. In one embodiment, the cache module also records the length of dirty data in each cache row; the method further includes:
[0021] When there is no activated target row in the memory array mapped by the target group, or there is no cache row corresponding to the target row in the target group, the cache row storing the most dirty data in the target group is determined as the target cache row.
[0022] In one embodiment, each cache line in the cache module stores a plurality of data blocks, and each cache line also records a valid identifier and a dirty data identifier of each data block in the cache line;
[0023] The triggering operation of writing the data in the target cache line back to the DRAM includes:
[0024] According to the valid identification and dirty data identification of each data block in the target cache line, the valid and dirty target data blocks in the target cache line are filtered out, and the filtered target data blocks are triggered.
[0025] Write back to DRAM operation.
[0026] According to a second aspect of the present disclosure, a cache control module is provided, which is deployed in a DRAM controller, wherein the DRAM controller further includes a cache module; the cache module stores part of the data in the DRAM, and the mapping mode between the cache module and the DRAM is a group-associative mapping, wherein the number of groups in the cache module is the same as the number of memory arrays in the DRAM, each group includes a plurality of cache lines, the bit width of each cache line is the bit width of a row in the DRAM, data in the same memory array in the DRAM is mapped to the same group in the cache module, and data in the same row in the memory array is mapped to the same cache line;
[0027] The cache control module is configured to: when performing a write-back operation on data in the cache module, determine a target cache line from the cache module, and trigger an operation of writing the data in the target cache line back to the DRAM.
[0028] In one implementation, the cache control module is specifically configured to:
[0029] When performing a write-back operation on a cache line in any target group in the cache module, determine whether there is an activated target line in the memory array mapped by the target group; if so, determine the cache line corresponding to the target line in the target group as the target cache line.
[0030] In one implementation, the cache control module is specifically configured to:
[0031] When an access request sent by an upstream device hits any target group but misses a cache line in the target group, and the target group has no free cache lines, a write-back operation is performed on the cache lines in the target group.
[0032] In one embodiment, the DRAM controller further includes a command queue and a command queue monitoring module, wherein the command queue stores access commands generated by the cache control module; the command queue monitoring module is configured to monitor the command queue and generate command queue information; the command queue information includes: the total number of commands in the command queue, the number of commands sent to each memory array;
[0033] The cache control module is specifically configured to: obtain the total number of commands in the command queue and the number of commands sent to each memory array from the command queue monitoring module; when the total number of commands in the command queue is less than a first preset threshold, determine the group of memory array mappings corresponding to the least number of commands as the target group, and perform a write-back operation on the cache lines in the target group.
[0034] In one embodiment, the cache control module is specifically configured to: when the number of commands sent to any memory array is zero, determine the group mapped by the memory array as the target group, and perform a write-back operation on the cache lines in the target group.
[0035] In one embodiment, the DRAM controller further includes an address mapping module, and the address mapping module is configured to parse the address of any access request to obtain a memory array address, a row address, and a column address;
[0036] The cache control module is further configured to: determine the group corresponding to the access request according to the memory array address; determine whether the access request hits any cache line in the group according to the row address; and in the case of a hit, process the hit cache line according to the access request.
[0037] In one embodiment, the cache control module is further configured to: in the case of a miss, the group has no free cache line, and the access request is a read request, not trigger an operation of allocating a cache line for the read request;
[0038] In case of a miss, the group has a free cache line, and the access request is a read request, obtaining the total number of commands in the command queue from the command queue monitoring module;
[0039] When the total number of commands is less than a second preset threshold, an operation of reading the data in the row targeted by the read request into any free cache row is triggered; when the total number of commands is not less than the second preset threshold, an operation of allocating cache rows for the read request is not triggered.
[0040] In one implementation, the cache module also records the length of dirty data in each cache line;
[0041] The cache control module is further configured to: when there is no target row in an activated state in the memory array mapped by the target group, or there is no cache line corresponding to the target row in the target group, determine the cache line storing the most dirty data in the target group as the target cache line.
[0042] In one embodiment, each cache line in the cache module stores a plurality of data blocks, and each cache line also records a valid identifier and a dirty data identifier of each data block in the cache line;
[0043] The cache control module is specifically configured to: filter out valid and dirty target data blocks in the target cache line according to the valid flag and dirty data flag of each data block in the target cache line, and trigger an operation of writing the filtered target data blocks back to the DRAM.
[0044] According to a third aspect of the present disclosure, a DRAM controller is provided, comprising the cache control module of the second aspect.
[0045] According to a fourth aspect of the present disclosure, a chip is provided, comprising a DRAM controller of the cache control module of the third aspect.
[0046] According to a fifth aspect of the present disclosure, an electronic device is provided, comprising a chip of the cache control module of the fourth aspect.
[0047] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 A schematic diagram of the structure of a set-associative cache module provided by one embodiment of the present disclosure;
[0049] Figure 2 A schematic diagram of the structure of a Tag array provided by an embodiment of the present disclosure;
[0050] Figure 3 A schematic diagram of the structure of a DRAM controller provided by an embodiment of the present disclosure;
[0051] Figure 4 A logical schematic diagram of matching cache lines provided for one embodiment of the present disclosure;
[0052] Figure 5 A schematic diagram of the structure of a Tag array and a Data array provided in one embodiment of the present disclosure;
[0053] Figure 6 A schematic diagram of the structure of another DRAM controller provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0054] Before introducing the embodiments of the present disclosure, it should be noted that:
[0055] Some embodiments of the present disclosure are described as processing flows. Although the various operation steps of the flow may be given sequential step numbers, the operation steps therein may be implemented in parallel, concurrently or simultaneously.
[0056] In the embodiments of the present disclosure, the terms "first", "second", etc. may be used to describe various features, but these features should not be limited by these terms. These terms are used only to distinguish one feature from another.
[0057] The term “and / or” may be used in embodiments of the present disclosure. “And / or” includes any and all combinations of one or more of the associated features listed.
[0058] It should be understood that when describing the connection or communication relationship between two components, unless it is explicitly stated that the two components are directly connected or directly communicating, the connection or communication between the two components can be understood as direct connection or communication, or as indirect connection or communication through an intermediate component.
[0059] In order to make the technical solutions and advantages of the embodiments of the present disclosure more clearly understood, the exemplary embodiments of the present disclosure are further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than an exhaustive list of all the embodiments. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0060] DRAM is composed of multiple memory arrays (banks), each of which is composed of rows and columns. When reading and writing a certain address, you must first activate the row where the address is located and send a row activation command (Active) before you can send the read and write commands. In the same memory array, if you need to switch to another row address for reading and writing, you need to close the currently activated row (Precharge), activate the new row, and then read and write. When each upstream device directly accesses DRAM, since the data required by each upstream device is often different, the data will also be stored in different locations in DRAM. Therefore, the access requests sent by each upstream device often result in frequent switching between different rows in DRAM, which will lead to low access efficiency. After opening a row, only a small amount of data in the row is read and written, and then other rows are closed and opened. Reading and writing data from other rows cannot fully utilize the bandwidth of DRAM.
[0061] In addition, in order to improve access efficiency to a certain extent, each upstream device usually also uses the cache mechanism to access DRAM. However, when a cache miss requires the data in the cache to be replaced, that is, the data originally in the cache needs to be written back to DRAM, or when a large amount of data in the cache needs to be written back to DRAM together, the address of the data written back to DRAM is often discrete, which will also lead to low access efficiency and inability to fully utilize DRAM bandwidth.
[0062] In order to solve the above problems, the present disclosure proposes a DRAM access processing method, which is applied to a cache control module in a DRAM controller, and the DRAM controller also includes a cache module; the cache module stores part of the data in the DRAM, and the mapping mode of the cache module and the DRAM is group associative mapping, wherein the number of groups in the cache module is the same as the number of memory arrays in the DRAM, each group includes a plurality of cache lines, and the bit width of each cache line is the bit width of a row in the DRAM, and the same memory array in the DRAM is mapped to the same group in the cache module, and the data in the same row in the memory array is mapped to the same cache line in the cache module; the method comprises:
[0063] When a write-back operation is performed on data in the cache module, a target cache line is determined from the cache module, triggering an operation of writing the data in the target cache line back to the DRAM.
[0064] Using this mapping method, a cache module is configured in the DRAM controller to store part of the data in the DRAM. Since the data in the same row in the DRAM is mapped to the same cache row in the cache module, when the data in the cache module needs to be written back to the memory, the data belonging to the same row in the DRAM can be written back to the DRAM together. In this way, the discrete address access requests originally sent to the DRAM by the upstream device can be integrated into continuous address access requests through the cache module, thereby improving the bandwidth utilization and access efficiency of the DRAM.
[0065] In order to introduce this solution more clearly, the structure of the cache module in the DRAM controller is introduced below: The mapping relationship between the cache module in the DRAM controller and the DRAM is a set-associative mapping, such as Figure 1 As shown, the cache module may include N ways and M sets, where M is the same as the number of memory arrays in the DRAM. For example, if the DRAM includes 16 memory arrays, the cache module may include 16 sets. Each set includes N (the number of ways) cache lines. The present disclosure does not limit the value of N, and it can be set according to actual needs. In order to avoid resource waste, the value of N can be as long as it is not greater than the number of rows, also known as pages, in each memory array in the DRAM. By using set associative mapping, data in the same memory array in the DRAM is mapped to the same group in the cache module, and data in the same row in the memory array is mapped to the same cache row. Specifically, the memory array address of the data in the DRAM can be mapped to the group tag (Index) in the cache module, the row address (row address) of the data in the DRAM can be mapped to the tag bit (Tag) in the cache module, and the column address (column address) of the data in the DRAM can be mapped to the offset bit (Line offset) in the cache module. Therefore, the N cache lines in each group in the cache module (the N cache lines marked with dotted boxes in the figure) can be shared by the data in each row in a memory array. The implementation of the group associative mapping can refer to the relevant technology, which will not be described in detail in this disclosure. Figure 2As shown, in addition to storing cache lines, the cache module also records the dirty data mark (D in the figure), valid mark (V in the figure) and Tag mark of each cache line. Among them, the dirty data mark is used to identify whether the data in the corresponding cache line is consistent with the data in the DRAM. For example, if it is inconsistent, the dirty data mark is set to 1, and if it is consistent, the dirty data mark is set to 0. The valid mark is used to identify whether the corresponding cache line is valid. The Tag mark is used to determine whether the access request hits the cache line corresponding to the Tag mark after receiving an access request. The storage space for storing the dirty data mark, valid mark and Tag mark can be called the Tag array, and the storage space for storing the Cache line can be called the Data array. In addition, since the Tag array occupies less space, the Tag array can also be located in the cache control module in the form of a register.
[0066] like Figure 3 As shown, the DRAM controller is usually located between the upstream device and the DRAM, and is used to receive the access request sent by the upstream device and process the DRAM. The following describes the process of the DRAM controller processing after receiving the access request from the upstream device.
[0067] like Figure 3 As shown, the DRAM controller includes, in addition to the cache control module 310 and the cache module 320, an address mapping module 330. The address mapping module is configured to parse the address of any access request to obtain the memory array address, row address and column address. Since the DRAM controller needs to access the address in the DRAM according to the access request, after receiving any access request, it is necessary to parse the address of the access request to obtain the memory array address (Bank address), row address (Row address) and column address (Column address). The address of the DRAM can be accessed based on the parsed address. Different from the related art, after parsing the memory array address, row address and column address, the address mapping module does not directly access the DRAM based on the parsed address, but sends the parsed address to the cache control module.
[0068] The cache control module determines the group corresponding to the access request according to the memory array address; determines whether the access request hits any cache line in the group according to the row address; and in the case of a hit, processes the hit cache line according to the access request.
[0069] Specifically, Figure 4As shown, after the cache control module receives the memory array address, row address and column address of any access request, since the mapping method between the cache module and the DRAM is group-associative mapping, and the same memory array in the DRAM is mapped to the same group in the cache module, and the data in the same row in the memory array is mapped to the same cache line, the group corresponding to the access request can be determined according to the memory array address (Bank), and then the row address (Row) is matched with the Tag tags of each cache line in the group. If the row address is the same as the Tag tag of any cache line in the group, it means that the access request hits the cache line, and the hit cache line can be processed according to the access request. For example, if it is a write request, the hit cache line is directly written, and if it is a read, the hit cache line is read.
[0070] In addition, if the row address of the access request is different from the tag of each cache line in a group, it means that the access request does not hit the cache line, then the read-write allocation strategy can be executed, that is, if there is a free cache line in the currently hit group, the access request is directly processed using the free cache line, and for write requests, the data of the write request can be directly written to the free cache line, and for read requests, the data of the row corresponding to the access request can be read from DRAM and written to the free cache line, and the data of the access request can be further read from the free cache line and returned to the upstream device. In addition, if there is no free cache line in the currently hit group, a cache line can be selected from the hit group, and the cache line can be triggered to be written back to DRAM to obtain a free cache line, and the access request can be processed using the free cache line.
[0071] By adopting the above method, part of the data in the DRAM can be stored in the cache module by using group associative mapping. Moreover, since not all access requests sent from the upstream are sent directly to the DRAM, but part of the DRAM is processed by the cache module, the processing efficiency of the access request can be improved while reducing the pressure on the DRAM.
[0072] When the cache module stores some data and a write-back operation is performed on the data in the cache module, a target cache line is determined from the cache module, and the target cache line may be randomly determined for write-back.
[0073] In addition, in order to further improve the write-back efficiency and avoid the write-back operation causing the DRAM to perform inter-row switching, the target cache line can also be determined in the following manner.
[0074] When a write-back operation is performed on a cache line in any target group in the cache module, it is determined whether there is an activated target line in the memory array mapped by the target group; if so, the cache line corresponding to the target line in the target group is determined as the target cache line.
[0075] Specifically, as a device for controlling DRAM, the DRAM controller can monitor the activation status of each memory array and the activation status (Open status) of each row in each memory array, wherein at most only one row in each memory array is in the activation status (Open status) at the same time, and if no row is in the activation status, then the memory array is also in the closed status. The monitored information can be shown in Table 1, i.e., the storage information monitoring table.
[0076]
[0077] Table 1
[0078] That is, the first column is used to record the address or identification of each memory array, the second column is used to identify whether the corresponding memory array is in an activated state (1 indicates an activated state, and 0 indicates an inactivated state), and the third column is used to identify the address of the row in the corresponding memory array that is in an activated state.
[0079] The cache control module can determine whether there is an activated target row in the memory array mapped by the target group based on the information shown in Table 1. For example, if the memory array mapped by the target group is Bank0, and there is an activated row in Bank0, which is row 2, then the cache row corresponding to row 2 is determined as the target cache row, and the operation of writing the data in the target cache row back to the DRAM is triggered. Since row 2 in Bank0 is in an activated state, the cache row corresponding to row 2 in the cache module is preferentially written back to row 2 in Bank0, which can avoid executing the row activation command (Active) and the row closing command (Precharge), and can effectively improve the write-back efficiency. In addition, if there is no activated target row in the memory array mapped by the target group, or there is no cache row corresponding to the target row in the target group, a cache row can be randomly selected as the target cache row for write-back.
[0080] Still taking the content shown in Table 1 as an example, if the memory array mapped by the target group is Bank2, and Bank2 is in a closed state, a cache line can be directly randomly selected from the target group as the target cache line. Alternatively, if the memory array mapped by the target group is Bank0, the line in the active state is row 2, but there is no cache line corresponding to row 2 in the target group, so a cache line can be randomly selected from the target group as the target cache line.
[0081] In one embodiment, if Figure 5 As shown, the length of dirty data in each cache line can also be recorded in the cache module. In this case, when there is no activated target line in the memory array mapped by the target group, or there is no cache line corresponding to the target line in the target group, the cache line storing the most dirty data in the target group is determined as the target cache line.
[0082] For example, if there are N cache lines in the target group, and there is no active target line in the memory array mapped by the target group, or there is no cache line corresponding to the target line in the target group, and the first cache line in the target group has the most dirty data, then the first cache line can be determined as the target cache line. In this way, the cache line that needs to be written back to DRAM the most can be written back to DRAM first.
[0083] like Figure 5 As shown, a cache line usually stores several data blocks (8 data blocks data0-data7 in the figure), where the length of each data block is the data bit width of an access request, and the valid flag and dirty data flag of each data block in the cache line can also be recorded in each cache line. In this way, the cache controller can know whether each data block in the cache line is valid and whether it is dirty data by traversing the valid flags and dirty data flags of each data block.
[0084] After the cache line storing the most dirty data in the target group is determined as the target cache line, the valid and dirty target data blocks in the target cache line can be filtered out according to the valid flag and dirty data flag of each data block in the target cache line, triggering the operation of writing the filtered target data blocks back to DRAM.
[0085] Since the bit width of the cache line in the present disclosure is the bit width of a row in DRAM, which is relatively large, this approach can avoid writing all data blocks in a cache line back to DRAM when writing back. Only some valid and dirty data blocks in the cache line need to be written back, further improving the write-back efficiency.
[0086] The above describes a method for determining a target cache line from a target group. The following describes a triggering mechanism for the cache control module to perform a write-back operation.
[0087] In one implementation, when an access request sent by an upstream device hits any target group but misses a cache line in the target group, and the target group has no free cache lines, a write-back operation is performed on the cache lines in the target group.
[0088] That is, if there is no free cache line in the target group, one of the cache lines in the target group needs to be written back to the memory to obtain a free cache line, and then the free cache line is used to process the read and write requests. That is, when performing the operation of replacing the cache line, the write-back operation needs to be performed on the cache line in the target group.
[0089] In one embodiment, the present disclosure proposes that the cache control module can also actively monitor the busyness of the DRAM to trigger the operation of writing back the cache line.
[0090] Specifically, Figure 6 As shown, the DRAM controller further includes a command queue 340 , a command queue monitoring module 350 , an arbitration module 360 and a timing parameter control module 370 .
[0091] The command queue 340 stores access commands generated by the cache control module, that is, the cache control module can store access commands that need to be sent to the DRAM in the command queue. For example, when the cache control module performs a write-back operation on the data in the cache module, it determines the target cache line from the cache module and triggers an operation to write the data in the target cache line back to the DRAM. Specifically, it can generate an access command to write the data back to the target line and store the access command in the command queue. For example, for some read requests that do not hit the cache module, the cache control module will also generate a read command based on the read request and store it in the command queue.
[0092] The arbitration module 360 is configured to arbitrate the commands in the command queue module and select the best command to send to the DRAM. The present disclosure does not limit the arbitration strategy of the arbitration module.
[0093] The timing parameter control module 370 is configured to control the time interval between commands sent to the DRAM to meet the DRAM timing parameters.
[0094] The command queue monitoring module 350 is configured to monitor the command queue 340 and generate command queue information; wherein the command queue information may include: the total number of commands in the command queue, the number of commands sent to each memory array. For example, the command queue monitoring module can generate command queue information as shown in Table 2, i.e., the command queue monitoring table, by monitoring the command queue.
[0095]
[0096] Table 2
[0097] That is, the first column is used to identify the address or identification of each memory array, and the fourth column is used to identify the number of commands stored in the command queue and sent to each memory array. In addition, the activation state of each memory array (the second column) and the activation state (Open state) of each row in each memory array (the third column) can also be monitored by the command queue monitoring module, thereby generating information as shown in Table 2.
[0098] In this embodiment, the cache control module can obtain the total number of commands in the command queue and the number of commands sent to each memory array from the command queue monitoring module; when the total number of commands in the command queue is less than the first preset threshold, the group of memory array mapping corresponding to the least number of commands is determined as the target group, and a write-back operation is performed on the cache lines in the target group.
[0099] That is, when the total number of commands in the command queue is less than the first preset threshold, it is considered that the current DRAM is relatively idle, and executing the write-back operation will not have a significant impact on the processing of the access commands in the command queue, that is, the commands originally stored in the command queue will not be unable to be processed due to the execution of the write-back operation. Therefore, the write-back operation can be performed, and the write-back operation here can be understood as writing all the cache lines in the memory arrays in the cache module back to the DRAM. Therefore, when writing back, it is necessary to determine the write-back order of each memory array. The present disclosure proposes that the group mapped to the memory array with the least number of corresponding commands can be determined as the target group, and the group mapped to the memory array with the least number of corresponding commands is preferentially written back to the corresponding memory array of the DRAM. Here, the group mapped to the memory array with the least number of corresponding commands is preferentially written back to the corresponding memory array of the DRAM because the reading and writing of each memory array in the DRAM can be executed in parallel, and the reading and writing of each memory array will not conflict with each other. When reading and writing a certain memory array, the access requests corresponding to other memory arrays stored in the command queue will not affect the reading and writing of the memory array. When there are fewer commands for a certain memory array, the data in the target group mapped to the memory array in the cache module is written back to the memory array, and the operation of writing back the data does not affect the access commands originally stored in the command queue and sent to the memory array. Similarly, the groups mapped to each memory array can be determined as target groups in order from small to large according to the number of commands stored in the queue, and the data in the target group can be written back to the DRAM.
[0100] In addition, in addition to triggering the write-back operation of all cache lines in the cache module when the total number of commands in the command queue is less than the first preset threshold, the cache control module can also actively monitor and trigger all cache lines in a certain group in the cache module to be written back. It has been introduced above that the reading and writing of each memory array in DRAM can be performed in parallel, and the reading and writing of each memory array will not conflict with each other. Therefore, the cache control module can also obtain the number of commands sent to each memory array from the command queue monitoring module. If the number of commands sent to any memory array is zero, the group mapped by the memory array is determined as the target group, and the write-back operation is performed on the cache lines in the target group. That is, when it is determined that the number of commands sent to any memory array is zero, it means that the memory array is in an idle state, and the operation of writing back to the memory array will not affect the access command originally to be sent to the memory array. Therefore, it can be triggered to write the data in the group corresponding to the memory array in the cache back to the memory array.
[0101] As mentioned above, the cache control module determines the group corresponding to the access request based on the memory array address; determines whether the access request hits any cache line in the group based on the row address; in the case of a hit, processes the hit cache line according to the access request. If the access request row address is different from the tag tags of each cache line in a group, the read-write allocation strategy can be executed. If there is no free cache line in the current hit group, a cache line can be selected from the hit group, and the cache line is triggered to be written back to DRAM to obtain a free cache line, and the request is processed using the free cache line.
[0102] On this basis, the present disclosure proposes that the above strategy can be implemented for write requests, that is, a cache line in the hit group needs to be written to DRAM first, and then the write request is processed using the free cache line. In addition to the above method for read requests,
[0103] The cache control module may also determine whether to perform an operation of allocating a cache line for a read request by monitoring the busyness of the DRAM.
[0104] In one embodiment, the cache control module may not trigger the operation of allocating cache lines for an access request when the access request misses any cache line in the group, the group has no free cache lines, and the access request is a read request, but directly generates a read command for the read request and stores it in the command queue.
[0105] When there is no free cache line, if a cache line is allocated for the read request, the data in one of the cache lines in the group will be written back to the DRAM first, and then the data in the row targeted by the access request can be read into the free cache line. In this process, different rows must be switched in the same memory array (one row when writing back and another row when reading). In order to avoid the delay caused by such switching operations, the operation of allocating cache lines is not performed for the read request.
[0106] In addition, the cache control module may obtain the total number of commands in the command queue from the command queue monitoring module when the access request misses any cache line in the group, the group has an idle cache line, and the access request is a read request;
[0107] When the total number of commands is less than the second preset threshold, the operation of reading the data in the row targeted by the read request into any free cache row is triggered; when the total number of commands is not less than the second preset threshold, the operation of allocating cache rows for the read request is not triggered, and a read command is directly generated for the read request and stored in the command queue.
[0108] That is, if the total number of commands in the current command queue is greater than or equal to the second preset threshold, it means that the DRAM is relatively busy, and the read request is directly stored in the command queue as a read command, and the data corresponding to the read request is read from the DRAM and returned to the upstream device; if the total number of commands in the current command queue is less than the second preset threshold, it means that the DRAM is relatively idle, and the operation of allocating a cache line for the read request will not have a significant impact on the processing of the access commands originally stored in the command queue. The data in the entire row can be read from the DRAM and stored in the idle cache line, and the data corresponding to the read request can be read from the cache line and returned to the upstream device, thereby triggering the operation of allocating a cache line for the read request.
[0109] In another embodiment, the cache control module may also obtain the number of commands sent to each memory array from the command queue monitoring module when the access request misses any cache line in the group, the group has an idle cache line, and the access request is a read request;
[0110] When the number of commands sent to the memory array mapped by the group is less than a third preset threshold, an operation of reading the data in the row targeted by the read request into any free cache row is triggered; when the number of commands sent to the memory array mapped by the group is not less than the third preset threshold, an operation of allocating cache rows for the read request is not triggered, and a read command is directly generated for the read request and stored in the command queue.
[0111] In this embodiment, if the number of commands of the group-mapped memory array is less than the third preset threshold, it means that the memory array is relatively idle, and the operation of allocating cache lines for the access request will not have a significant impact on the commands originally stored in the command queue, and the data in the entire row can be read from the DRAM and stored in the idle cache line, so the operation of allocating cache lines for the access request can be triggered. If the number of commands of the group-mapped memory array is not less than the third preset threshold, it means that the memory array is relatively busy, and the read request is directly stored in the command queue as a read command, and the data corresponding to the read request is read from the DRAM and returned to the upstream device.
[0112] By adopting the above two implementation methods, when there are free cache lines, by monitoring the busyness of the DRAM to determine whether to perform the operation of allocating cache lines for read requests, the impact of the cache line allocation operation for read requests on other access commands in the command queue can be reduced, thereby improving the overall access processing performance of the DRAM.
[0113] Based on the same inventive concept, the present disclosure also proposes a cache control module, which is deployed in a DRAM controller, and the DRAM controller also includes a cache module; the cache module stores part of the data in the DRAM, and the mapping method between the cache module and the DRAM is group-associative mapping, wherein the number of groups in the cache module is the same as the number of memory arrays in the DRAM, each group includes a number of cache lines, and the bit width of each cache line is the bit width of a row in the DRAM, and data in the same memory array in the DRAM is mapped to the same group in the cache module, and data in the same row in the memory array is mapped to the same cache line;
[0114] The cache control module is configured to: when performing a write-back operation on data in the cache module, determine a target cache line from the cache module, and trigger an operation of writing the data in the target cache line back to the DRAM.
[0115] In one implementation, the cache control module is specifically configured to:
[0116] When performing a write-back operation on a cache line in any target group in the cache module, determine whether there is an activated target line in the memory array mapped by the target group; if so, determine the cache line corresponding to the target line in the target group as the target cache line.
[0117] In one implementation, the cache control module is specifically configured to:
[0118] When an access request sent by an upstream device hits any target group but misses a cache line in the target group, and the target group has no free cache lines, a write-back operation is performed on the cache lines in the target group.
[0119] In one embodiment, the DRAM controller further includes a command queue and a command queue monitoring module, wherein the command queue stores access commands generated by the cache control module; the command queue monitoring module is configured to monitor the command queue and generate command queue information; the command queue information includes: the total number of commands in the command queue, the number of commands sent to each memory array;
[0120] The cache control module is specifically configured to: obtain the total number of commands in the command queue and the number of commands sent to each memory array from the command queue monitoring module; when the total number of commands in the command queue is less than a first preset threshold, determine the group of memory array mappings corresponding to the least number of commands as the target group, and perform a write-back operation on the cache lines in the target group.
[0121] In one embodiment, the cache control module is specifically configured to: when the number of commands sent to any memory array is zero, determine the group mapped by the memory array as the target group, and perform a write-back operation on the cache lines in the target group.
[0122] In one embodiment, the DRAM controller further includes an address mapping module, and the address mapping module is configured to parse the address of any access request to obtain a memory array address, a row address, and a column address;
[0123] The cache control module is further configured to: determine the group corresponding to the access request according to the memory array address; determine whether the access request hits any cache line in the group according to the row address; and in the case of a hit, process the hit cache line according to the access request.
[0124] In one embodiment, the cache control module is further configured to: in the case of a miss, the group has no free cache line, and the access request is a read request, not trigger an operation of allocating a cache line for the read request;
[0125] In case of a miss, the group has a free cache line, and the access request is a read request, obtaining the total number of commands in the command queue from the command queue monitoring module;
[0126] When the total number of commands is less than a second preset threshold, an operation of reading the data in the row targeted by the read request into any free cache row is triggered; when the total number of commands is not less than the second preset threshold, an operation of allocating cache rows for the read request is not triggered.
[0127] In one implementation, the cache module also records the length of dirty data in each cache line;
[0128] The cache control module is further configured to: when there is no activated target row in the memory array mapped by the target group, or there is no cache row corresponding to the target row in the target group, determine the cache row storing the most dirty data in the target group as the target cache row.
[0129] In one embodiment, each cache line in the cache module stores a plurality of data blocks, and each cache line also records a valid identifier and a dirty data identifier of each data block in the cache line;
[0130] The cache control module is specifically configured to: filter out valid and dirty target data blocks in the target cache line according to the valid flag and dirty data flag of each data block in the target cache line, and trigger an operation of writing the filtered target data blocks back to the DRAM.
[0131] The disclosed embodiment also provides a DRAM controller, comprising the cache control module in any of the above implementations.
[0132] The embodiment of the present disclosure further provides a chip, which includes the above-mentioned DRAM controller. The chip can be a GPU, a TPU, a CPU, etc., which is not limited in the present disclosure.
[0133] The disclosed embodiment also provides an electronic device, which includes the above-mentioned chip. In some usage scenarios, the product form of the electronic device is a portable electronic device, such as a smart phone, a tablet computer, a VR device, etc.; in some usage scenarios, the product form of the electronic device is a personal computer, a game console, etc.
[0134] Although the preferred embodiments of the present disclosure have been described above, those skilled in the art may make additional changes and modifications to these embodiments once they are aware of the basic creative concepts. Therefore, the attached claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present disclosure, and those skilled in the art, without departing from the spirit and scope of the present disclosure, should also be regarded as the scope of protection of the embodiments of the present disclosure.
Claims
1. A DRAM access processing method is applied to a cache control module in a DRAM controller, wherein the DRAM controller further comprises a cache module; the cache module stores part of the data in the DRAM, and the mapping method between the cache module and the DRAM is a set associative mapping, wherein: The number of groups in the cache module is the same as the number of memory arrays in the DRAM, each group includes a number of cache lines, the bit width of each cache line is the bit width of a row in the DRAM, the memory array address of the data in the DRAM is mapped to the group tag in the cache module, the row address is mapped to the tag bit in the cache module, and the column address is mapped to the offset bit in the cache module, so that the data in the same memory array in the DRAM is mapped to the same group in the cache module, and the data in the same row in the memory array is mapped to the same cache line; the DRAM controller also includes a command queue and a command queue monitoring module, and the command queue stores the access commands generated by the cache control module; The command queue monitoring module is configured to monitor the command queue and generate command queue information; The command queue information includes: the total number of commands in the command queue, the number of commands sent to each memory array, and the method includes: Obtaining the total number of commands in the command queue and the number of commands sent to each memory array from the command queue monitoring module; when the total number of commands in the command queue is less than a first preset threshold, determining the group mapped to the memory array with the least number of corresponding commands as the target group; A target cache line is determined from the target group, and an operation of writing the data in the target cache line back to the DRAM is triggered, so that the data stored in the cache module corresponding to the same row in the DRAM is written back to the DRAM together.
2. The method according to claim 1, wherein determining a target cache line from the target group comprises: Determine whether there is an activated target row in the memory array mapped by the target group; If it exists, a cache line in the target group corresponding to the target line is determined as the target cache line.
3. The method according to claim 2, further comprising: When an access request sent by an upstream device hits any target group but misses a cache line in the target group, and the target group hit by the access request has no free cache line, a write-back operation is performed on the cache line in the target group hit by the access request.
4. The method according to claim 1, further comprising: When the number of commands sent to any memory array is zero, the group mapped by the memory array is determined as the target group, and a write-back operation is performed on the cache lines in the target group mapped by the memory array.
5. The method according to claim 1, wherein the DRAM controller further comprises an address mapping module, wherein the address mapping module is configured to parse the address of any access request to obtain a memory array address, a row address, and a column address; the method further comprises: Determining a group corresponding to the access request according to the memory array address; determining, according to the row address, whether the access request hits any cache row in the group; In the case of a hit, the hit cache line is processed according to the access request.
6. The method according to claim 5, further comprising: In case of a miss, the group has no free cache line, and the access request is a read request, not triggering an operation of allocating a cache line for the read request; In case of a miss, the group has a free cache line, and the access request is a read request, obtaining the total number of commands in the command queue from the command queue monitoring module; When the total number of commands is less than a second preset threshold, an operation of reading the data in the row targeted by the read request into any free cache row is triggered; when the total number of commands is not less than the second preset threshold, an operation of allocating cache rows for the read request is not triggered.
7. The method according to claim 2, wherein the cache module further records the length of dirty data in each cache line; the method further comprises: When there is no activated target row in the memory array mapped by the target group, or there is no cache row corresponding to the target row in the target group, the cache row storing the most dirty data in the target group is determined as the target cache row.
8. The method according to claim 7, wherein each cache line in the cache module stores a plurality of data blocks, and each cache line also records a valid identifier and a dirty data identifier of each data block in the cache line; The triggering operation of writing the data in the target cache line back to the DRAM includes: According to the valid identification and dirty data identification of each data block in the target cache line, the valid and dirty target data blocks in the target cache line are filtered out, and the filtered target data blocks are triggered. Write back to DRAM operation.
9. A cache control module, deployed in a DRAM controller, the DRAM controller further comprising a cache module; the cache module stores part of the data in the DRAM, the mapping method between the cache module and the DRAM is a set associative mapping, wherein: The number of groups in the cache module is the same as the number of memory arrays in the DRAM, each group includes a number of cache lines, the bit width of each cache line is the bit width of a row in the DRAM, the memory array address of the data in the DRAM is mapped to the group tag in the cache module, the row address is mapped to the tag bit in the cache module, and the column address is mapped to the offset bit in the cache module, so that the data in the same memory array in the DRAM is mapped to the same group in the cache module, and the data in the same row in the memory array is mapped to the same cache line; the DRAM controller also includes a command queue and a command queue monitoring module, and the command queue stores the access commands generated by the cache control module; The command queue monitoring module is configured to monitor the command queue and generate command queue information; the command queue information includes: the total number of commands in the command queue, the number of commands sent to each memory array; The cache control module is configured to: obtain the total number of commands in the command queue and the number of commands sent to each memory array from the command queue monitoring module; when the total number of commands in the command queue is less than a first preset threshold, determine the group mapped to the memory array with the least number of corresponding commands as the target group; A target cache line is determined from the target group, and an operation of writing the data in the target cache line back to the DRAM is triggered, so that the data stored in the cache module corresponding to the same row in the DRAM is written back to the DRAM together.
10. The cache control module according to claim 9, wherein the cache control module is specifically configured as follows: Determine whether there is an activated target row in the memory array mapped by the target group; if so, determine the cache row corresponding to the target row in the target group as the target cache row.
11. The cache control module according to claim 10, wherein the cache control module is further configured to: When an access request sent by an upstream device hits any target group but misses a cache line in the target group, and the target group hit by the access request has no free cache line, a write-back operation is performed on the cache line in the target group hit by the access request.
12. The cache control module according to claim 9, The cache control module is specifically configured to: when the number of commands sent to any memory array is zero, determine the group mapped by the memory array as the target group, and perform a write-back operation on the cache lines in the target group mapped by the memory array.
13. The cache control module according to claim 9, wherein the DRAM controller further comprises an address mapping module, wherein the address mapping module is configured to parse the address of any access request to obtain a memory array address, a row address, and a column address; The cache control module is further configured to: determine the group corresponding to the access request according to the memory array address; determine whether the access request hits any cache line in the group according to the row address; and in the case of a hit, process the hit cache line according to the access request.
14. The cache control module according to claim 13, The cache control module is further configured to: in case of a miss, the group has no free cache line, and the access request is a read request, not trigger an operation of allocating a cache line for the read request; In case of a miss, the group has a free cache line, and the access request is a read request, obtaining the total number of commands in the command queue from the command queue monitoring module; When the total number of commands is less than a second preset threshold, an operation of reading the data in the row targeted by the read request into any free cache row is triggered; when the total number of commands is not less than the second preset threshold, an operation of allocating cache rows for the read request is not triggered.
15. The cache control module according to claim 10, wherein the cache module further records the length of dirty data in each cache line; The cache control module is further configured to: when there is no target row in an activated state in the memory array mapped by the target group, or there is no cache line corresponding to the target row in the target group, determine the cache line storing the most dirty data in the target group as the target cache line.
16. The cache control module according to claim 15, wherein each cache line in the cache module stores a plurality of data blocks, and each cache line also records a valid identifier and a dirty data identifier of each data block in the cache line; The cache control module is specifically configured to: filter out valid and dirty target data blocks in the target cache line according to the valid flag and dirty data flag of each data block in the target cache line, and trigger an operation of writing the filtered target data blocks back to the DRAM.
17. A DRAM controller, comprising the cache control module according to any one of claims 9 to 16.
18. A chip comprising the DRAM controller according to claim 17.
19. An electronic device comprising the chip according to claim 18.
Citation Information
Patent Citations
Cache management method and device, processor and computer device
CN113342265A
Memory access method and device for system-on-chip and electronic equipment
CN115878507A
Cache system, cache write-back method, system on chip and electronic equipment
CN117389914A
