[go: up one dir, main page]

CN107729263B - Replacement strategy of tree-structured improved LRU algorithm in high-speed Cache - Google Patents

Replacement strategy of tree-structured improved LRU algorithm in high-speed Cache Download PDF

Info

Publication number
CN107729263B
CN107729263B CN201710839187.8A CN201710839187A CN107729263B CN 107729263 B CN107729263 B CN 107729263B CN 201710839187 A CN201710839187 A CN 201710839187A CN 107729263 B CN107729263 B CN 107729263B
Authority
CN
China
Prior art keywords
status
line
replacement
replaced
stack
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CN201710839187.8A
Other languages
Chinese (zh)
Other versions
CN107729263A (en
Inventor
易清明
雷稳
石敏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Blockchain New Technology Guangzhou Co ltd
Guangzhou Jinan University Science Park Management Co ltd
Original Assignee
Jinan University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Jinan University filed Critical Jinan University
Priority to CN201710839187.8A priority Critical patent/CN107729263B/en
Publication of CN107729263A publication Critical patent/CN107729263A/en
Application granted granted Critical
Publication of CN107729263B publication Critical patent/CN107729263B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/12Replacement control
    • G06F12/121Replacement control using replacement algorithms
    • G06F12/123Replacement control using replacement algorithms with age lists, e.g. queue, most recently used [MRU] list or least recently used [LRU] list
    • G06F12/125Replacement control using replacement algorithms with age lists, e.g. queue, most recently used [MRU] list or least recently used [LRU] list being generated by decoding an array or storage
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/12Replacement control
    • G06F12/121Replacement control using replacement algorithms
    • G06F12/126Replacement control using replacement algorithms with special data handling, e.g. priority of data or instructions, handling errors or pinning
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/10Providing a specific technical effect
    • G06F2212/1016Performance improvement
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/10Providing a specific technical effect
    • G06F2212/1016Performance improvement
    • G06F2212/1021Hit rate improvement

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

The invention discloses a replacement strategy of a tree-structured improved LRU algorithm in a high-speed Cache, which is based on a program locality principle and adopts the replacement strategy of the tree-structured improved LRU algorithm to improve the replacement efficiency and the hit rate. In the invention, when the cache needs to be updated, the decoding circuit judges the valid bit, when the valid bits are all 1, the value of the replacement state memory is decoded according to the improved LRU algorithm of the tree structure to determine the replaced line, and when the valid bits are not all 1, the line needing to be replaced is obtained according to the priority decoding circuit, thereby completing the whole replacement process. The replacement method can further improve the data replacement hit speed of the high-speed Cache and improve the performance of the high-speed Cache while completing data read-write operation.

Description

高速Cache中一种树状结构的改进型LRU算法的替换策略A Replacement Strategy of an Improved LRU Algorithm with Tree Structure in High-speed Cache

技术领域technical field

本发明涉及嵌入式微处理器设计技术领域,具体涉及高速Cache中一种树状结构的改进型LRU算法的替换策略,进一步涉及如何提高嵌入式微处理器内核快速地从高速Cache中读写数据的方法。The invention relates to the technical field of embedded microprocessor design, in particular to a replacement strategy of an improved LRU algorithm with a tree-like structure in a high-speed cache, and further relates to a method for improving how an embedded microprocessor core can quickly read and write data from the high-speed cache .

背景技术Background technique

嵌入式微处理器的设计难题之一在于嵌入式微处理器的高速工作频率与片外存储器的低速读写速度相差很大,这在很大程度上限制了嵌入式微处理器的性能和效率。在现代微处理器中,在嵌入式微处理器内核与片外储器间设计一级或多级高速缓存Cache组成多层次存储体系已经成为了缩小存储器与嵌入式微处理器速度差距的有效解决方法。但是高速缓存在工作时,容易发生缺失,当在高速缓存缺失发生时,会从主存中读出一个line存储到高速缓存里。这时,如果高速缓存中已经没有空闲的line,那么就需要从中选择一个line作为替换对象替换掉,采用不同的替换算法替换的效率大大不同,不同的算法所占用的资源也不一样。当前主流的替换算法为LRU(Least Recently Used)算法,即最近最久未使用算法。LRU算法是一种统计的方法,根据各个way的使用情况,统计出近期最少被使用的那个line然后用作替换。这种方法能够比较好地反映程序的局部性原理,且有很好的命中率,但是从硬件实现上来说比其他的常规算法实现更困难,并且会消耗更多的资源。这样导致替换速度变慢,增加系统的功耗。One of the design problems of embedded microprocessors is that the high-speed operating frequency of embedded microprocessors is very different from the low-speed read/write speed of off-chip memory, which limits the performance and efficiency of embedded microprocessors to a large extent. In modern microprocessors, it has become an effective solution to narrow the speed gap between memory and embedded microprocessors by designing one or more levels of caches between the embedded microprocessor core and off-chip memory to form a multi-level storage system. However, when the cache is working, it is prone to misses. When a cache miss occurs, a line is read from the main memory and stored in the cache. At this time, if there is no free line in the cache, you need to select a line to replace it as a replacement object. The replacement efficiency of different replacement algorithms is greatly different, and the resources occupied by different algorithms are also different. The current mainstream replacement algorithm is the LRU (Least Recently Used) algorithm, that is, the algorithm that has not been used for the longest time recently. The LRU algorithm is a statistical method. According to the usage of each way, the line that has been used the least recently is counted and then used as a replacement. This method can better reflect the locality principle of the program and has a good hit rate, but it is more difficult to implement in hardware than other conventional algorithms and consumes more resources. This results in slower replacement and increased system power consumption.

因此亟待提出一种基于程序局部性原理,采用树状结构思想的改进型LRU算法的替换策略来提高替换效率以及命中率。Therefore, it is urgent to propose a replacement strategy of the improved LRU algorithm based on the principle of program locality and adopting the idea of tree structure to improve the replacement efficiency and hit rate.

发明内容SUMMARY OF THE INVENTION

本发明的目的是为了解决现有技术中的上述缺陷,提供高速Cache中一种树状结构的改进型LRU算法的替换策略。The purpose of the present invention is to provide a replacement strategy of an improved LRU algorithm with a tree structure in a high-speed cache in order to solve the above-mentioned defects in the prior art.

本发明的目的可以通过采取如下技术方案达到:The purpose of the present invention can be achieved by adopting the following technical solutions:

高速Cache中一种树状结构的改进型LRU算法的替换策略,所述的替换策略包括下列步骤:A replacement strategy for a tree-structured improved LRU algorithm in a high-speed Cache, the replacement strategy includes the following steps:

S1、完成四路组相连映射方式Set以及line的划分;S1. Complete the division of the four-way group connection mapping method Set and line;

S2、对所划分的每一个Set设置一个寄存器栈,其容量为高速Cache的Set数n,寄存器栈由栈顶到栈底依次记录最近被访问的Set_a和最久没有被访问的Set_b;S2. Set up a register stack for each of the divided Sets, the capacity of which is the Set number n of the high-speed Cache, and the register stack records the recently accessed Set_a and the longest unvisited Set_b from the top of the stack to the bottom of the stack in turn;

S3、当某一个Set被访问时,那么位于该Set号之上的栈内元素依次向下移动一行,而被访问的Set号则压入栈顶,通过上述操作实现栈内元素的重排,得到近期不常使用的Set号;S3. When a certain Set is accessed, the elements in the stack above the Set number move down one line in turn, and the accessed Set number is pushed to the top of the stack, and the elements in the stack are rearranged through the above operations. Get the Set number that is rarely used recently;

S4、在近期不常使用的Set号中采用一种基于树状结构的方法找出具体某一路中的line需要进行替换;S4. Use a tree-like structure-based method in the recently used Set number to find out that the line in a specific road needs to be replaced;

S5、从主存中读出一个line的数据存储到高速Cache中,完成数据替换。S5. Read out the data of a line from the main memory and store it in the high-speed Cache to complete the data replacement.

进一步地,所述的步骤S4具体如下:Further, the step S4 is specifically as follows:

S401、在Set中设计一个三位的寄存器,记做status[2:0],更新方式为:status[2:0]=00×时替换Way0,status[2:0]=01×时替换Way1,status[2:0]=1×0时替换Way2,status[2:0]=1×1时替换Way3,其中,“×”表示保持原值;S401. Design a three-bit register in Set, denoted as status[2:0], and the update method is: replace Way0 when status[2:0]=00×, replace Way1 when status[2:0]=01× , Way2 is replaced when status[2:0]=1×0, and Way3 is replaced when status[2:0]=1×1, where “×” means keep the original value;

S402、当发生访问缺失时,首先判断寄存器status[2:0]中status[2]位的数值,当status[2]=0时,则判断status[1]的数值,若status[1]=0时,则替换Way0中的Line,若status[1]=1时,则替换Way1中的Line;S402. When an access loss occurs, first determine the value of the status[2] bit in the register status[2:0], and when status[2]=0, determine the value of status[1], if status[1]= When 0, replace Line in Way0, if status[1]=1, replace Line in Way1;

当status[2]=1时,则判断status[0]的数值,若status[0]=0时,则替换Way2中的Line,若status[0]=1时,则替换Way3中的Line。When status[2]=1, judge the value of status[0], if status[0]=0, replace Line in Way2, and if status[0]=1, replace Line in Way3.

进一步地,所述的步骤S1具体如下:Further, the step S1 is specifically as follows:

S101、将高速缓存按照Cache的空间大小要求进行4等分,得到4路,即4个way,分别为way1、way2、way3和way4;S101. Divide the cache into 4 equal parts according to the space size of the Cache, and obtain 4 ways, that is, 4 ways, which are way1, way2, way3 and way4 respectively;

S102、将主存按照每一路的大小进行等分得到Page 0~Page n;S102, divide the main memory into equal parts according to the size of each way to obtain Page 0~Page n;

S103、将高速缓存中的每一个way和主存中的每一个Page重新进行等分得到每一个line,分别为line0~line n;S103, re-equally divide each way in the cache and each Page in the main memory to obtain each line, which are respectively line0-linen;

S104、所有的路way中相同的line分为一个Set,完成Set的设置后即完成四路组相连映射方式Set以及line的划分。S104 , the same line in all the ways is divided into a Set, and after the setting of the Set is completed, the division of the four-way group connection mapping mode Set and the line is completed.

本发明相对于现有技术具有如下的优点及效果:Compared with the prior art, the present invention has the following advantages and effects:

1)本发明基于程序局部性原理,采用树状结构的改进型LRU算法的替换策略来提高替换效率以及命中率。在本发明中,当高速缓存需要更新时,解码电路将对有效位进行判断,当有效位全为1时,将依据树状结构的改进型LRU算法对替换状态存储器的值进行译码,决定出被替换的line,当有效位不全为1时,则会根据优先译码电路得到需要替换的line,从而完成整个的替换过程。1) Based on the principle of program locality, the present invention adopts the replacement strategy of the improved LRU algorithm with tree structure to improve replacement efficiency and hit rate. In the present invention, when the cache needs to be updated, the decoding circuit will judge the valid bits, and when the valid bits are all 1, it will decode the value of the replacement state memory according to the improved LRU algorithm of the tree structure, and decide The replaced line is output. When the valid bits are not all 1, the line to be replaced will be obtained according to the priority decoding circuit, thereby completing the entire replacement process.

2)本发明完成高速缓存中页面的替换,并在解码电路中采用并行判断电路来完成解码,可显著提高高速缓存的替换速度。2) The present invention completes the replacement of pages in the cache, and uses a parallel judgment circuit in the decoding circuit to complete the decoding, which can significantly improve the replacement speed of the cache.

附图说明Description of drawings

图1是本发明中四路组相连中Set以及line的划分;Fig. 1 is the division of Set and line in the connection of four-way group among the present invention;

图2是本发明中寄存器栈法得到近期不常使用的Set号;Fig. 2 is that the register stack method in the present invention obtains the Set number that is not often used in the near future;

图3是本发明中树状结构的LRU算法替换策略流程图;Fig. 3 is the LRU algorithm replacement strategy flow chart of tree structure in the present invention;

图4是本发明中状态模块的结构图;Fig. 4 is the structural diagram of the state module in the present invention;

图5是本发明中解码电路的工作流程;Fig. 5 is the workflow of decoding circuit in the present invention;

图6是本发明中部分line处于空闲时的替换电路;Fig. 6 is the replacement circuit when part of line is idle in the present invention;

图7是本发明中基于树状结构的LRU算法的并行比较电路;Fig. 7 is the parallel comparison circuit of the LRU algorithm based on tree structure in the present invention;

图8是本发明中编码电路结构。Fig. 8 is the structure of the coding circuit in the present invention.

具体实施方式Detailed ways

为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。In order to make the purposes, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments These are some embodiments of the present invention, but not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

实施例Example

为了克服高速Cache中LRU替换算法的缺点与不足,本实施例提供一种高效快速以及高命中率的替换方法,该替换方法可在完成数据读写操作的同时进一步提高高速Cache的数据替换命中速度,提高高速Cache的性能。In order to overcome the shortcomings and deficiencies of the LRU replacement algorithm in the high-speed cache, this embodiment provides an efficient, fast and high hit rate replacement method, which can further improve the data replacement hit speed of the high-speed cache while completing data read and write operations. , to improve the performance of high-speed Cache.

一种树状结构的改进型LRU算法的替换策略,具体包括如下步骤:A replacement strategy for an improved LRU algorithm with a tree-like structure specifically includes the following steps:

S1、完成四路组相连映射方式Set以及line的划分。S1. Complete the division of the four-way group connection mapping mode Set and line.

该步骤S1中四路组相连映射方式Set以及line的划分的步骤如下:The steps of dividing the four-way group connection mapping mode Set and line in this step S1 are as follows:

S101、将高速缓存按照设计(Cache的空间大小)要求进行4等分,得到4路(4-way),分别为way1、way2、way3和way4;S101. Divide the cache into 4 equal parts according to the design (the space size of the Cache) to obtain 4-way (4-way), which are way1, way2, way3 and way4 respectively;

S102、将主存按照每一路(way)的大小进行等分得到Page 0~Page n;S102: Divide the main memory into equal parts according to the size of each way to obtain Page 0 to Page n;

S103、将高速缓存中的每一个way和主存中的每一个Page重新进行等分得到每一个line(line 0~line n);S103, re-equally divide each way in the cache and each Page in the main memory to obtain each line (line 0~line n);

S104、所有的路(way)中相同的line分为一个Set(组,如way 0与way1中的line 0即组成了Set_0,一共有Set_0~Set_n)。完成Set的设置后即完成四路组相连映射方式Set以及line的划分,划分完成后如图1所示。S104 , the same lines in all the ways are divided into a Set (group, for example, line 0 in way 0 and way 1 forms Set_0, and there are Set_0 to Set_n in total). After completing the setting of the Set, the division of the four-way group connection mapping method Set and line is completed, as shown in Figure 1 after the division is completed.

S2、对所划分的每一个Set设置一个寄存器栈,其容量为高速Cache的Set数n,寄存器栈由栈顶到栈底依次记录最近被访问的Set_a和最久没有被访问的Set_b。S2. Set up a register stack for each divided Set, the capacity of which is the Set number n of the high-speed Cache, and the register stack sequentially records Set_a that has been accessed recently and Set_b that has not been accessed for the longest time from the top of the stack to the bottom of the stack.

S3、当某一个Set被访问时,那么位于该Set号之上的栈内元素依次向下移动一行,而被访问的Set号则压入栈顶,这样实现了栈内元素的重排,得到近期不常使用的Set号。S3. When a certain Set is accessed, the elements in the stack above the Set number move down one line in turn, and the accessed Set number is pushed to the top of the stack, thus realizing the rearrangement of the elements in the stack, and obtaining Set number that is not frequently used recently.

S4、在近期不常使用的Set号中采用一种基于树状结构的方法找出是哪一路中的line需要进行替换。S4. Use a tree-like structure-based method in the recently used Set number to find out which line in the route needs to be replaced.

该步骤S4具体如下:The step S4 is specifically as follows:

S401、在Set中设计一个三位的寄存器,记做status[2:0],更新方式为:status[2:0]=00×时替换Way0;status[2:0]=01×时替换Way1;status[2:0]=1×0时替换Way2;status[2:0]=1×1时替换Way3。(“×”表示保持原值),真值表如表1所示,以实现对于近期访问的情况进一步的记录;S401. Design a three-bit register in Set, denoted as status[2:0], and the update method is: replace Way0 when status[2:0]=00×; replace Way1 when status[2:0]=01× ; Replace Way2 when status[2:0]=1×0; Replace Way3 when status[2:0]=1×1. (“×” means keep the original value), the truth table is shown in Table 1, in order to realize further records for the recent visit;

表1树状结构的LRU算法更新方法Table 1. LRU algorithm update method of tree structure

Figure BDA0001410335480000051
Figure BDA0001410335480000051

S402、当发生访问缺失时,首先判断寄存器status[2:0]中status[2]位的数值。当status[2]=0时,则判断status[1]的数值。若status[1]=0时,则替换Way0中的Line;若status[1]=1时,则替换Way1中的Line。当status[2]=1时,则判断status[0]的数值。若status[0]=0时,则替换Way2中的Line,若status[0]=1时则替换Way3中的Line。S402. When an access loss occurs, first determine the value of the status[2] bit in the register status[2:0]. When status[2]=0, the value of status[1] is judged. If status[1]=0, replace Line in Way0; if status[1]=1, replace Line in Way1. When status[2]=1, the value of status[0] is judged. If status[0]=0, replace Line in Way2, and if status[0]=1, replace Line in Way3.

S5、从主存中读出一个line的数据存储到高速Cache中,完成数据替换。S5. Read out the data of a line from the main memory and store it in the high-speed Cache to complete the data replacement.

在实际电路设计中,高速缓存的每一个line的替换状态(replace statues)是由一个SRAM或者一组寄存器构成的,结构如图4所示。在状态模块电路中,由编码电路路和解码电路组成。In the actual circuit design, the replacement status (replace statues) of each line of the cache is composed of an SRAM or a set of registers, and the structure is shown in Figure 4. In the state module circuit, it consists of an encoding circuit circuit and a decoding circuit.

1、解码电路1. Decoding circuit

解码电路的主要功能是根据有效位来判断是否每一个line中都已经被全部填满了数据,并且对替换状态进行译码。当高速缓存需要更新时,解码电路从以下两种情况判断出用于替换的line:The main function of the decoding circuit is to judge whether each line has been completely filled with data according to the valid bits, and to decode the replacement state. When the cache needs to be updated, the decoding circuit determines the line for replacement from the following two situations:

(1)有效位不全为1。这说明该Set中还有空闲的line。此时解码电路将有效位不为1的那个line,用于数据替换,图5中的左半部分是当部分line处于空闲时的流程图,其具体流程为:(1) The valid bits are not all 1. This shows that there are still free lines in the Set. At this time, the decoding circuit will use the line whose valid bit is not 1 for data replacement. The left half of Figure 5 is the flow chart when part of the line is idle. The specific flow is as follows:

T1、首先判断有效位valid[0],如果valid[0]为0则替换way0;否则进入T2;T1, first judge the valid bit valid[0], if valid[0] is 0, replace way0; otherwise, enter T2;

T2、判断有效位valid[1],如果valid[1]为0则替换way1;否则进入T3;T2, judge the valid bit valid[1], if valid[1] is 0, replace way1; otherwise, enter T3;

T3、判断有效位valid[2],如果valid[2]为0则替换way2;否则替换way3;T3, judge the valid bit valid[2], if valid[2] is 0, replace way2; otherwise, replace way3;

此处在硬件上是属于一种优先译码电路,真值表如下:This is a kind of priority decoding circuit in hardware, and the truth table is as follows:

表2部分line处于空闲状态时的替换电路真值表Table 2 Partial truth table for alternate circuits when line is idle

Figure BDA0001410335480000061
Figure BDA0001410335480000061

故根据真值表得到最小项,而设计出最优化的门级电路,如图6所示,门级电路逻辑表达式为:Therefore, the minimum term is obtained according to the truth table, and the optimized gate-level circuit is designed. As shown in Figure 6, the logic expression of the gate-level circuit is:

rep[0]=~valid[0];rep[0] = ~valid[0];

rep[1]=valid[0]&(~valid[1]);rep[1]=valid[0]&(~valid[1]);

rep[2]=valid[0]&valid[1]&(~valid[2]);rep[2]=valid[0]&valid[1]&(~valid[2]);

rep[3]=valid[0]&valid[1]&valid[2];rep[3]=valid[0]&valid[1]&valid[2];

(2)所有的有效位均为1。这种情况下,所有的line都已经被使用。解码电路将依据图3中的树状结构的思想,将替换状态存储器的值进行译码,决定出被替换的line。(2) All valid bits are 1. In this case, all lines have been used. The decoding circuit will decode the value of the replacement state memory according to the idea of the tree structure in FIG. 3 to determine the replaced line.

当所有line都已经被使用时,解码电路会判断替换状态存储器的每一位。但如果对每一位进行逐一判断必然会增加路径的延时,如果采用并行的判断方式可以加快判断的速度,从而降低路径的延时,所以本发明在电路设计上采用如图7所示的并行判断电路来完成解码电路的设计。When all lines have been used, the decoding circuit determines to replace each bit of the state memory. However, if each bit is judged one by one, the delay of the path will inevitably increase. If the parallel judgment method is used, the speed of judgment can be accelerated, thereby reducing the delay of the path. Therefore, the present invention adopts the circuit design as shown in Figure 7. Parallel judgment circuit to complete the design of the decoding circuit.

2、编码电路2. Encoding circuit

编码电路将各个way的命中和替换情况进行编码,并改写替换状态存储器中的内容。当高速缓存访问某个way时(不管是命中后读写还是缺失后替换),编码电路根据树状结构的LRU算法,将最近访问高速缓存的信息进行编码,并记录在寄存器中,图8是编码电路的结构。The encoding circuit encodes the hits and replacements of each way, and rewrites the contents of the replacement state memory. When the cache accesses a certain way (whether it is read-write after hit or replacement after miss), the encoding circuit encodes the information that has recently accessed the cache according to the LRU algorithm of the tree structure, and records it in the register, as shown in Figure 8. The structure of the encoding circuit.

上述实施例为本发明较佳的实施方式,但本发明的实施方式并不受上述实施例的限制,其他的任何未背离本发明的精神实质与原理下所作的改变、修饰、替代、组合、简化,均应为等效的置换方式,都包含在本发明的保护范围之内。The above-mentioned embodiments are preferred embodiments of the present invention, but the embodiments of the present invention are not limited by the above-mentioned embodiments, and any other changes, modifications, substitutions, combinations, The simplification should be equivalent replacement manners, which are all included in the protection scope of the present invention.

Claims (2)

1. A replacement strategy of a tree-structured modified LRU algorithm in a high-speed Cache is characterized by comprising the following steps:
s1, completing the division of the Set and line of the four-way group connection mapping mode, wherein the step S1 is as follows:
s101, dividing the Cache into 4 equal parts according to the space size requirement of the Cache to obtain 4 ways, namely 4 ways which are respectively way1, way2, way3 and way 4;
s102, equally dividing the main memory according to the size of each path to obtain pages 0-Page n;
s103, equally dividing each way in the cache and each Page in the main memory again to obtain each line which is line 0-line n respectively;
s104, dividing the same lines in all the ways into a Set, and finishing the Set setting to finish the Set of the four-way group connection mapping mode and the line division;
s2, setting a register stack for each divided Set, wherein the capacity of the register stack is the Set number n of the high-speed Cache, and the register stack sequentially records the most recently accessed Set _ a and the least recently accessed Set _ b from the stack top to the stack bottom;
s3, when a Set is accessed, the elements in the stack above the Set number move downwards one row in sequence, the accessed Set number is pressed into the top of the stack, and the elements in the stack are rearranged through the operation to obtain the Set number which is not frequently used in the near term;
s4, finding out the line in a specific path to be replaced by adopting a method based on a tree structure in a recently infrequently used Set number;
and S5, reading out the data of one line from the main memory and storing the data in the high-speed Cache to finish data replacement.
2. A replacement policy of a tree-structured LRU algorithm in a high-speed Cache according to claim 1, wherein said step S4 is as follows:
s401, designing a three-bit register in Set, recording the register as status [2:0], and updating the register in such a Way that WAy0 is replaced when status [2:0] is 00 x, WAy1 is replaced when status [2:0] is 01 x, WAy2 is replaced when status [2:0] is 1 x 0, and Way3 is replaced when status [2:0] is 1 x 1, wherein x represents that the original value is kept;
s402, when an access miss occurs, first, the value of status [2] bit in the register status [2:0] is determined, when status [2] is equal to 0, the value of status [1] is determined, when status [1] is equal to 0, Line in Way0 is replaced, and when status [1] is equal to 1, Line in Way1 is replaced;
when status [2] is equal to 1, the numerical value of status [0] is determined, and when status [0] is equal to 0, the Line in Way2 is replaced, and when status [0] is equal to 1, the Line in Way3 is replaced.
CN201710839187.8A 2017-09-18 2017-09-18 Replacement strategy of tree-structured improved LRU algorithm in high-speed Cache Expired - Fee Related CN107729263B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710839187.8A CN107729263B (en) 2017-09-18 2017-09-18 Replacement strategy of tree-structured improved LRU algorithm in high-speed Cache

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710839187.8A CN107729263B (en) 2017-09-18 2017-09-18 Replacement strategy of tree-structured improved LRU algorithm in high-speed Cache

Publications (2)

Publication Number Publication Date
CN107729263A CN107729263A (en) 2018-02-23
CN107729263B true CN107729263B (en) 2020-02-07

Family

ID=61206600

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710839187.8A Expired - Fee Related CN107729263B (en) 2017-09-18 2017-09-18 Replacement strategy of tree-structured improved LRU algorithm in high-speed Cache

Country Status (1)

Country Link
CN (1) CN107729263B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11294829B2 (en) 2020-04-21 2022-04-05 International Business Machines Corporation Cache replacement with no additional memory space

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1996268A (en) * 2006-12-28 2007-07-11 北京时代民芯科技有限公司 Method for implementing on-chip command cache

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7055004B2 (en) * 2003-09-04 2006-05-30 International Business Machines Corporation Pseudo-LRU for a locking cache
US7512739B2 (en) * 2006-07-05 2009-03-31 International Business Machines Corporation Updating a node-based cache LRU tree

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1996268A (en) * 2006-12-28 2007-07-11 北京时代民芯科技有限公司 Method for implementing on-chip command cache

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
一种改进的Pseudo-LRU替换算法;韩立敏,高德远;《微电子学与计算机》;20090630;第26卷(第6期);P54-57 *
采用基树的磁盘阵列Cache技术研究;杨巍;《中国优秀硕士学位论文全文数据库》;20111215(第S2期);I137-69 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11294829B2 (en) 2020-04-21 2022-04-05 International Business Machines Corporation Cache replacement with no additional memory space

Also Published As

Publication number Publication date
CN107729263A (en) 2018-02-23

Similar Documents

Publication Publication Date Title
CN105095116B (en) Cache method, cache controller and the processor replaced
CN106909515B (en) Multi-core shared last-level cache management method and device for mixed main memory
CN110018971B (en) cache replacement technique
US7783836B2 (en) System and method for cache management
CN103425600B (en) Address mapping method in a kind of solid-state disk flash translation layer (FTL)
US8966181B2 (en) Memory hierarchy with non-volatile filter and victim caches
CN110532200B (en) A memory system based on hybrid memory architecture
US8583874B2 (en) Method and apparatus for caching prefetched data
JP6088951B2 (en) Cache memory system and processor system
CN106569960B (en) A kind of last level cache management method mixing main memory
CN106547703A (en) A kind of FTL optimization methods based on block group structure
CN110795363B (en) Hot page prediction method and paging method for storage medium
CN104991743B (en) Loss equalizing method applied to solid state hard disc resistance-variable storing device caching
CN108762671A (en) Hybrid memory system based on PCM and DRAM and management method thereof
CN108572799B (en) Data page migration method of heterogeneous memory system of bidirectional hash chain table
US20190095331A1 (en) Multi-level system memory with near memory capable of storing compressed cache lines
CN102253901B (en) Read/write distinguished data storage replacing method based on phase change memory
Quan et al. Prediction table based management policy for STT-RAM and SRAM hybrid cache
CN105005510B (en) Error correction protection architecture and method applied to solid state disk resistance-variable storing device caching
CN110347338A (en) Mix internal storage data exchange and processing method, system and readable storage medium storing program for executing
CN111580754A (en) A Write-Friendly Flash SSD Cache Management Method
JP2019159791A (en) Memory system
Mittal Using cache-coloring to mitigate inter-set write variation in non-volatile caches
US20140108731A1 (en) Energy Optimized Cache Memory Architecture Exploiting Spatial Locality
CN107729263B (en) Replacement strategy of tree-structured improved LRU algorithm in high-speed Cache

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20201216

Address after: 510632 No. 601, Whampoa Avenue, Tianhe District, Guangdong, Guangzhou

Patentee after: Guangzhou Jinan University Science Park Management Co.,Ltd.

Address before: 510632 No. 601, Whampoa Avenue, Guangzhou, Guangdong

Patentee before: Jinan University

TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20210108

Address after: 703, 7th floor, No.37, Huajing Road, Huajing new town, 105 Zhongshan Avenue, Tianhe District, Guangzhou, Guangdong 510000

Patentee after: Blockchain new technology (Guangzhou) Co.,Ltd.

Patentee after: Guangzhou Jinan University Science Park Management Co.,Ltd.

Address before: 510632 No. 601, Whampoa Avenue, Tianhe District, Guangdong, Guangzhou

Patentee before: Guangzhou Jinan University Science Park Management Co.,Ltd.

CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20200207