Method for expanding cache memory

文档序号:781739 发布日期:2021-04-09 浏览:26次 中文

阅读说明:本技术 高速缓冲存储器的扩展方法 (Method for expanding cache memory ) 是由 周鸣 朱琳琳 于 2021-03-05 设计创作,主要内容包括:本发明涉及一种高速缓冲存储器的扩展方法,包括:在数据静态随机存储器和与外部存储器连接的总线之间设置第一开关;在数据静态随机存储器和标签静态随机存储器之间设置第二开关;在标签静态随机存储器和与处理器连接的总线之间设置第三开关;基于预设开关规则设置寄存器配置模块,以控制第一开关、第二开关和第三开关的通断将数据静态随机存储器和标签静态随机存储器切换至极高速缓存模式或高速缓存模式;设置分别和数据静态随机存储器以及标签静态随机存储器连接的极高速缓存控制器,用于在极高速缓存模式下数据静态随机存储器的数据读写控制以及标签静态随机存储器的信息维护。可以在不增加整个芯片静态容量的条件下,增加高速缓存的容量。(The invention relates to a method for expanding a cache memory, which comprises the following steps: setting a first switch between the data static random access memory and a bus connected with an external memory; a second switch is arranged between the data static random access memory and the tag static random access memory; a third switch is arranged between the tag static random access memory and a bus connected with the processor; setting a register configuration module based on a preset switch rule to control the on-off of a first switch, a second switch and a third switch so as to switch a data static random access memory and a tag static random access memory to a very high-speed cache mode or a high-speed cache mode; and a super cache controller respectively connected with the data static random access memory and the tag static random access memory is arranged and used for controlling data reading and writing of the data static random access memory and information maintenance of the tag static random access memory in a super cache mode. The capacity of the cache can be increased without increasing the static capacity of the entire chip.)

1. A method of cache expansion, comprising:

setting a first switch between the data static random access memory and a bus connected with an external memory;

a second switch is arranged between the data static random access memory and the tag static random access memory;

a third switch is arranged between the tag static random access memory and a bus connected with the processor;

setting a register configuration module based on a preset switch rule to control the on-off of the first switch, the second switch and the third switch to switch the data static random access memory and the tag static random access memory to a pole cache mode or a cache mode;

and the extremely high-speed cache controller is respectively connected with the data static random access memory and the tag static random access memory and is used for controlling data read-write control of the data static random access memory and information maintenance of the tag static random access memory in the extremely high-speed cache mode so as to realize memory expansion of the high-speed cache memory.

2. The method of claim 1, wherein the setting the register configuration module based on the preset switch rule to control the on/off of the first switch, the second switch, and the third switch to switch the data sram and the tag sram to the super cache mode or the cache mode comprises:

the first switch and the second switch are closed and the third switch is open, switching to the cache mode.

3. The method of claim 1, wherein the setting the register configuration module to switch the data sram and the tag sram to the super cache mode or the cache mode based on the preset switch rule to control the on/off of the first switch, the second switch, and the third switch further comprises:

the first switch and the second switch are open and the third switch is closed, switching to the pole cache mode.

4. The method according to claim 2, further comprising a direct memory access provided between a bus to which the external memory is connected and the external memory, for managing data stored in the data sram and the tag sram in the cache mode.

5. The method according to claim 3, wherein the data sram is configured to store a copy of a portion of the stored contents in the external memory in the polar cache mode, and the tag sram is configured to store information about the copy in the data sram.

6. The method of claim 4, wherein the data SRAM and the tag SRAM are both used for storing data in an external memory in the cache mode.

7. The method as claimed in claim 5, wherein the very high speed cache controller is connected to the data static random access memory and the tag static random access memory respectively, and the data read/write control of the data static random access memory and the information maintenance of the tag static random access memory in the very high speed cache mode comprise:

the method comprises the following steps that the extremely high-speed cache controller divides an address from a bus into a tag address, a memory address and an offset address, wherein the bit width of the offset address is the address bit width of one block in the data static random access memory; the bit width of the memory address is the address bit width of the data static random access memory; the tag address is the remaining bus address bit width.

8. The method of cache memory expansion according to claim 7, further comprising: taking the memory address as the address of a tag static random access memory and a data static random access memory, wherein the data read by the tag static random access memory comprises two parts, namely 1-bit effective bit and 1-bit tag bit; if the valid bit is 1 and the tag bit read by the tag sram is equal to the tag bit of the bus address, the data of the bus address is located in the data sram, and a corresponding portion of the data read by the data sram is selected by offsetting the address and the corresponding data is placed on the bus.

9. The method of cache memory expansion according to claim 8, further comprising: and if the valid bit is 0 or the tag bit of the tag static random access memory is not equal to the tag bit of the bus address, the data accessed by the bus is not in the data static random access memory, and the read operation is initiated to the external memory.

Technical Field

The invention belongs to the technical field of cache control, and particularly relates to an expansion method of a cache memory.

Background

The cache is used as a layer in a storage system, and mainly has the functions of improving the efficiency of the storage system and reducing the access delay of the storage system. The efficiency of reducing time delay and improving efficiency is based on the locality of data, namely that a host can repeatedly access a small block of storage at a large rate within a certain time. The cache only copies the contents of the small block of memory into the memory of the cache itself, and during this time, the host accesses the memory very close to the memory of the cache itself, which is much faster than the conventional low-cost memory such as a disk, a double-rate synchronous dynamic random access memory, a flash memory, etc.

Referring to FIG. 1, a conventional memory hierarchy is shown, which has two levels, a cache and an external memory. The speed of the external storage is low, and it takes thousands of nanoseconds to access the external storage, but the running speed of the processor is very fast, and the speed of the processor accessing the storage must be increased to exert the performance of the whole system. Scientists and experts in the industry have found through research that there is locality in the access of processors to storage. Locality is divided into temporal locality, which means that if a piece of storage is now accessed, it may be accessed again in the near future. Spatial locality refers to the large probability that a store that may need to be accessed in the near future is adjacent to the currently accessed store.

The cache memory utilizes locality to move currently accessed stored data and data in its vicinity to a high-speed storage (the storage is generally static random access memory, which is expensive and cannot be too large in storage capacity). Therefore, most of the data accessed by the processor can be directly accessed in the static random access memory, and the storage delay of thousands of nanoseconds is reduced to a few nanoseconds from the system viewpoint. The performance of the system is greatly improved.

The internal storage of the cache typically uses static random access memory. The static random access memory is composed of two parts, one part is used for storing external storage copies, namely the data static random access memory, and the other part is used for storing extra information such as tag bits, effective bits and the like, namely the tag static random access memory. In existing computer systems, the cache memory may be used as a tightly coupled Static Random Access Memory (SRAM) or memory controller for a processor or other host without requiring the cache to be opened. Existing caches typically use only static random access memory as the memory controller. This would result in significant waste because the tag sram would not be used for any purpose when the cache is not turned on.

Disclosure of Invention

In order to solve the problem of memory space waste caused by not opening a cache in the prior art, the invention provides an expansion method of a cache memory, which has the characteristics of increasing the capacity of a memory controller and the like under the condition of not increasing the capacity of a whole chip static random access memory.

A method for expanding a cache memory according to an embodiment of the present invention includes: setting a first switch between the data static random access memory and a bus connected with an external memory;

a second switch is arranged between the data static random access memory and the tag static random access memory;

a third switch is arranged between the tag static random access memory and a bus connected with the processor;

setting a register configuration module based on a preset switch rule to control the on-off of the first switch, the second switch and the third switch to switch the data static random access memory and the tag static random access memory to a pole cache mode or a cache mode;

and a cache controller respectively connected with the data static random access memory and the tag static random access memory is arranged and used for controlling data read-write control of the data static random access memory and information maintenance of the tag static random access memory in the extreme cache mode so as to realize memory expansion of the cache memory.

Further, the setting the register configuration module based on the preset switch rule to control the on/off of the first switch, the second switch and the third switch to switch the data sram and the tag sram to the extreme cache mode or the cache mode includes:

the first switch and the second switch are closed and the third switch is open, switching to the cache mode.

Further, the setting the register configuration module based on the preset switch rule to control the on/off of the first switch, the second switch and the third switch to switch the data sram and the tag sram to the extreme cache mode or the cache mode further includes:

the first switch and the second switch are open and the third switch is closed, switching to the pole cache mode.

The system further comprises a direct memory access arranged between a bus connected with the external memory and the external memory, and is used for managing the data stored in the data static random access memory and the tag static random access memory in the cache mode and managing the data stored in the data static random access memory and the tag static random access memory in the cache mode.

Further, the data static random access memory is used for storing a copy of the partially stored content in the external memory in the extreme cache mode, and the tag static random access memory is used for storing the related information of the copy in the data static random access memory.

Further, in the cache mode, both the data SRAM and the tag SRAM are used for storing data in the external memory.

Further, the cache controller is respectively connected to the data sram and the tag sram, and is configured to perform data read/write control of the data sram and information maintenance of the tag sram in the extreme cache mode, including:

the cache controller divides an address from a bus into a memory address, a memory address and an offset address, wherein the bit width of the offset address is the address bit width of one block in the data static random access memory; the bit width of the memory address is the address bit width of the data static random access memory; the tag address is the remaining bus address bit width.

Further, still include: taking the memory address as the address of a tag static random access memory and a data static random access memory, wherein the data read by the tag static random access memory comprises two parts, namely 1-bit effective bit and 1-bit tag bit; if the valid bit is 1 and the tag bit read by the tag sram is equal to the tag bit of the bus address, the data of the bus address is located in the data sram, and a corresponding portion of the data read by the data sram is selected by offsetting the address and the corresponding data is placed on the bus.

Further, still include: and if the valid bit is 0 or the tag bit of the tag static random access memory is not equal to the tag bit of the bus address, the data accessed by the bus is not in the data static random access memory, and the read operation is initiated to the external memory.

The invention has the beneficial effects that: by adopting a cache controller, a register configuration module, a first switch, a second switch and a third switch which are respectively connected with the register configuration module, and connecting the first switch between a data static random access memory and a bus connected with an external memory; the second switch is connected between the data static random access memory and the tag static random access memory; the third switch is connected between the tag static random access memory and a bus connected with the processor; the register configuration module is used for controlling the on-off of the first switch, the second switch and the third switch to switch the data static random access memory and the tag static random access memory to a super cache mode or a cache mode based on a preset switch rule, so that the capacity of the cache is increased under the condition that the capacity of the whole chip static random access memory is not increased when the different modes of the cache are switched, higher flexibility and better performance are provided for the use of a chip, and the application range of the cache is increased.

Drawings

In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.

FIG. 1 is a block diagram of a cache provided in accordance with an exemplary embodiment;

FIG. 2 is a schematic diagram of an extended architecture for a cache provided in accordance with an exemplary embodiment;

FIG. 3 is a schematic diagram of a pole cache mode provided in accordance with an illustrative embodiment;

FIG. 4 is a schematic diagram of a cache scheme provided in accordance with an exemplary embodiment.

Detailed Description

In order to make the objects, technical solutions and advantages of the present invention more apparent, the technical solutions of the present invention will be described in detail below. It is to be understood that the described embodiments are merely exemplary of the invention, and not restrictive of the full scope of the invention. All other embodiments, which can be derived by a person skilled in the art from the examples given herein without any inventive step, are within the scope of the present invention.

Referring to fig. 2, an embodiment of the present invention provides a method for expanding a cache memory, including:

a first switch is provided between a Data sram (Data static random access memory) and a bus connected to an external memory;

a second switch is arranged between the Data sram (Data static random access memory) and the Tag sram (Tag static random access memory);

a third switch is arranged between the Tag sram (Tag static random access memory) and a bus connected with the processor;

setting a register configuration module based on a preset switch rule to control the on-off of a first switch, a second switch and a third switch so as to switch a data static random access memory and a tag static random access memory to a very high-speed cache mode or a high-speed cache mode;

and a cache controller respectively connected with the data static random access memory and the tag static random access memory is arranged and used for controlling data reading and writing of the data static random access memory and information maintenance of the tag static random access memory in an extreme cache mode.

The cache Memory is located between the processor and the main Memory, dram (Dynamic Random Access Memory), and is a small-scale, but high-speed Memory, and is usually composed of sram (Static Random Access Memory).

Specifically, Reg in the figure is a register configuration module of Cache (Cache memory), and registers inside the module can be modified by a processor and used for controlling the switching of a Cache mode and a pole Cache mode. The cache in cache mode is a fixed size RAM, tightly coupled to the processor core, providing comparable performance to a cache, which has the advantage over a cache that program code can precisely control what functions or code are placed there (in RAM). Upon entering the cache mode, a segment of address space is allocated for the data SRAM and the tag SRAM. When switching to the extreme cache mode, the address space allocated to the data SRAM and the tag SRAM is cancelled, and normal cache interaction with the processor is performed. The capacity of the cache can be increased without increasing the capacity of the static random access memory of the whole chip, and higher flexibility and better performance are provided for the use of the chip.

As a possible implementation manner of the above embodiment, controlling the on/off of the first switch, the second switch, and the third switch to switch the data sram and the tag sram to the very cache mode or the cache mode based on the preset switch rule includes:

the first switch and the second switch are closed and the third switch is open to switch to the cache mode.

The first switch and the second switch are open and the third switch is closed to switch to the pole cache mode. I.e. when the register is configured in cache mode as shown in the figure, switches 1, 2 are closed and switch 3 is open. When configured in the pole cache mode, switches 1, 2 are open and switch 3 is closed. Meanwhile, when entering the cache mode, the system allocates a section of address space for the data SRAM and the tag SRAM. When switching to the extreme cache mode, the address space allocated by the system to the data SRAM and the tag SRAM is eliminated.

For example, a 32KB cache, which is associated in 4-way, i.e., 4 ways, has a block size of 16B, and can maximally cache 1M of space. It needs 4 tag srams, each having a depth of 512 and a width of at least 9 bits. In actual use, the width of the random static memory is n times of 2. So in practice the size of each tag sram is 512 x 16 bits. The sum of all tag static random access memory spaces is 4 KB. According to the improvement of the present invention, the space of the cache can be increased by 4KB compared to 12.5%.

It should be noted that, the specific structures of the first switch, the second switch and the third switch described above may be selected by those skilled in the art according to actual requirements, and the present invention is not limited herein.

Referring to fig. 3, in the high-level cache mode, the cache controller, the data sram, is used to store a copy of a portion of the stored contents in the next-level memory (the ddr sdram, the flash memory, the sdram, etc. in fig. 1). The tag static random access memory is used for storing information related to the copy in the data static random access memory, and the information comprises a tag bit and a valid bit. The cache controller is used for controlling the reading and writing of the data static random access memory and maintaining the information of the tag static random access memory. When the cache receives an address from the bus, the address is split into a tag address, a memory address, and an offset address. The bit width of the offset address is the address bit width (the lowest bit of the bus address) of one block, the bit width of the memory address is the address bit width of the data static random access memory, and the label address is the bit width (the highest bit of the bus address) of the rest bus address. The cache is configured before it is used, e.g. the current cache needs to cover an address space of 0x20000000 to 0x 30000000. The cache subtracts 0x20000000 from the address on the bus before performing address splitting. Thus, the bus address of 0x20000000 to 0x30000000 becomes 0x00000000 to 0x10000000, for example, if the block is 32 bytes, the offset address is 5 bits low, the tag address has an address bit width equal to (log 2 ((0 x30000000-0x 20000000)/32)) -the memory address has an address bit width equal to the tag sram bit width, i.e., the data sram bit width, and the memory address is used as the tag sram and the data sram address. The data read by the tag SRAM comprises two parts, wherein if the valid bit of 1bit and the tag bit of 1bit is 1, the tag bit read by the tag SRAM is equal to the tag bit of the bus address. Then the data representing the bus address is located in the data sram, and the corresponding portion of the data read by the data sram is selected by offsetting the address and placing the portion of the data on the bus. If the valid bit is 0 or the tag bit of the tag SRAM and the tag bit of the bus address are not equal, it indicates that the data accessed by the bus is not in the data SRAM. At this time, the cache initiates a read operation to the next-level memory through the Master bus, and data in the address space from TAG + ADDR +0 to TAG + ADDR + block needs to be read. After all the data are obtained, the data are stored in the data static random access memory, and at the same time, the data are written into the ADDR address in the tag static random access memory, the valid bit in the data is rewritten into 1, and the tag bit is rewritten into the tag bit on the bus. And then the data obtained from the next storage is placed on the Slave bus through the OFFSET selection.

Referring to fig. 4, in the cache mode, when the chip does not need to use the cache for acceleration, the data sram and the tag sram of the cache can be used as the cache. When the slave bus initiates an access, the address distinguishes whether the current access is data static random access memory, tag static random access memory or other storage. The two sram blocks can store temporary data of the processor, and transfer data of the next level Memory to the data sram and the tag sram through DMA (Direct Memory Access).

The biggest difference between the cache mode and the level cache mode is that the copy of the next level memory stored in the data static random access memory of the cache is dynamically refreshed. In cache mode, the sram always stores the address currently accessed by the processor and the data in the vicinity, and the data of the address that the processor has not accessed for a long time must make room for the data of the address that the processor has accessed recently. The copy stored in the data sram in the cache mode is transferred by DMA or SLVAE (master slave mode), and is static. In addition, the tag SRAM is used to store information for each block in the data SRAM in the polar cache mode. In cache mode, the tag sram is used to store copies or temporary data.

Based on the same design idea, the embodiment of the invention also provides a cache, which comprises the extended structure for the cache described in the above embodiment. The specific implementation manner of the extended structure for cache can refer to the specific implementation manner provided in the above embodiments, and the detailed description of the present invention is omitted here.

When the extended structure for the cache and the cache provided by the above embodiments of the present invention are used as a cache, the tag sram may also be used as a part of the cache, and the capacity of the cache may be increased without increasing the static storage capacity of the whole chip, so as to provide higher flexibility and better performance for the use of the chip, and have a wider application range.

It will be understood by those skilled in the art that all or part of the steps carried by the method for implementing the above embodiments may be implemented by hardware related to instructions of a program, which may be stored in a computer readable storage medium, and when the program is executed, the program includes one or a combination of the steps of the method embodiments.

In addition, functional units in the embodiments of the present invention may be integrated into one processing module, or each unit may exist alone physically, or two or more units are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode. The integrated module, if implemented in the form of a software functional module and sold or used as a stand-alone product, may also be stored in a computer readable storage medium.

The storage medium mentioned above may be a read-only memory, a magnetic or optical disk, etc.

In the description herein, references to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, the schematic representations of the terms used above do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.

What has been described above includes examples of one or more embodiments. It is, of course, not possible to describe every conceivable combination of components or methodologies for purposes of describing the aforementioned embodiments, but one of ordinary skill in the art may recognize that many further combinations and permutations of various embodiments are possible. Accordingly, the embodiments described herein are intended to embrace all such alterations, modifications and variations that fall within the scope of the appended claims. Furthermore, to the extent that the term "includes" is used in either the detailed description or the claims, such term is intended to be inclusive in a manner similar to the term "comprising" as "comprising" is interpreted when employed as a transitional word in a claim. Furthermore, any use of the term "or" in the specification of the claims is intended to mean a "non-exclusive or".

The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the appended claims.

13页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种内存管理单元、地址转译方法以及处理器

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类