WO2014068694A1 - 半導体装置及びキャッシュメモリへのデータ先読み方法 - Google Patents

半導体装置及びキャッシュメモリへのデータ先読み方法 Download PDF

Info

Publication number
WO2014068694A1
WO2014068694A1 PCT/JP2012/078139 JP2012078139W WO2014068694A1 WO 2014068694 A1 WO2014068694 A1 WO 2014068694A1 JP 2012078139 W JP2012078139 W JP 2012078139W WO 2014068694 A1 WO2014068694 A1 WO 2014068694A1
Authority
WO
WIPO (PCT)
Prior art keywords
way
data
access
address
cache
Prior art date
Application number
PCT/JP2012/078139
Other languages
English (en)
French (fr)
Inventor
進藤 誠
Original Assignee
ルネサスエレクトロニクス株式会社
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 ルネサスエレクトロニクス株式会社 filed Critical ルネサスエレクトロニクス株式会社
Priority to PCT/JP2012/078139 priority Critical patent/WO2014068694A1/ja
Priority to JP2014544114A priority patent/JP5901787B2/ja
Priority to US14/439,355 priority patent/US9892049B2/en
Publication of WO2014068694A1 publication Critical patent/WO2014068694A1/ja
Priority to US15/864,479 priority patent/US20180150399A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0862Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches with prefetch
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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/0802Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
    • G06F12/0864Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches using pseudo-associative means, e.g. set-associative or hashing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/28Using a specific disk cache architecture
    • G06F2212/281Single cache
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/60Details of cache memory
    • G06F2212/602Details relating to cache prefetching
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/60Details of cache memory
    • G06F2212/6028Prefetching based on hints or prefetch instructions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2212/00Indexing scheme relating to accessing, addressing or allocation within memory systems or architectures
    • G06F2212/60Details of cache memory
    • G06F2212/6032Way prediction in set-associative cache

Definitions

  • the present invention relates to a data prefetching technique for a cache memory, and more particularly to a technique effective when applied to a semiconductor device having a cache memory.
  • cache memory For example, a technique for dividing an instruction cache and a data cache, a technique for configuring a cache memory with a plurality of ways, a technique for prefetching data including an instruction code, and the like. Adopting such a technology is also effective for secure microcomputers, but on the other hand, it is also necessary to satisfy severe restrictions on circuit scale and power consumption.
  • Patent Documents 1 and 2 disclose data read-ahead technology in a cache memory.
  • Patent Document 1 discloses a technique for reading a data block including data to be accessed when a cache miss occurs and prefetching a set data block in the adjacent direction. Since the set adjacent direction is updated following the access history, the prefetching direction can also be followed.
  • Patent Document 2 in a multiple-way set associative cache memory, data that is expected to be read next is predicted in advance from which of a plurality of ways to be read, A technique for preventing an unnecessary way from being accessed is disclosed.
  • Patent Document 3 discloses a technique in which data for one page is read into a pre-read cache at a time by a row address system selection operation in a non-volatile memory, and then a part thereof is selected and read out by a column address system operation. Yes.
  • a multi-way cache When a multi-way cache is used, only one way may be used for continuous access of a series of data such as decryption operations of encryption, and other ways may not be used. If each way can be provided with a memory array having a large capacity, it is not a big problem. However, if only one block of nonvolatile memory memory capacity (one line) can be mounted on one way, data prefetching is possible. Even if is done, there is no area to store the data to be read ahead. A cache miss always occurs for each line, and overhead occurs due to the cache fill. If a memory array with a capacity of 2 ways is used as 1 way, prefetching can be executed within that 1 way, and no cache miss occurs for each line, but in the case of continuous access from 2 data series, A cache miss occurs for each access.
  • the semiconductor device includes a processor, a memory, a plurality of tags, a plurality of ways, and a cache control unit that correspond to each other, and is configured to be capable of the following operations.
  • the cache control unit performs the following operation when the first access and the second access are accesses to consecutive addresses that are successively executed, and the second access is an access through the first way.
  • the second access is an access in a direction in which the address increases with respect to the first access
  • data prefetching is performed for a way having a tag value that is one smaller than the tag value corresponding to the first way.
  • data prefetching is performed for a way that is one greater than the tag value corresponding to the first way.
  • FIG. 1 is a flowchart illustrating an operation example of the semiconductor device according to the embodiment.
  • FIG. 2 is a block diagram illustrating a configuration example of a semiconductor device according to an embodiment.
  • FIG. 3 is a flowchart (1/4) illustrating a detailed operation example of the semiconductor device according to the embodiment.
  • FIG. 4 is a flowchart (2/4) illustrating a detailed operation example of the semiconductor device according to the embodiment.
  • FIG. 5 is a flowchart (3/4) illustrating a detailed operation example of the semiconductor device according to the embodiment.
  • FIG. 6 is a flowchart (4/4) illustrating a detailed operation example of the semiconductor device according to the embodiment.
  • FIG. 7 is an explanatory diagram illustrating an operation example when the 2-way cache according to the embodiment operates independently.
  • FIG. 7 is an explanatory diagram illustrating an operation example when the 2-way cache according to the embodiment operates independently.
  • FIG. 10 is a timing chart (1/4) showing an operation example of the semiconductor device according to the comparative example.
  • FIG. 11 is a timing chart (2/4) illustrating an operation example of the semiconductor device according to the comparative example.
  • FIG. 12 is a timing chart (3/4) illustrating an operation example of the semiconductor device according to the comparative example.
  • FIG. 13 is a timing chart (4/4) showing an operation example of the semiconductor device according to the comparative example.
  • FIG. 14 is a timing chart (1/3) showing an operation example when a 2-way cache is prefetched as another way as another prefetch target.
  • FIG. 15 is a timing chart (2/3) showing an operation example when a 2-way cache is prefetched as another way as another prefetch target.
  • FIG. 16 is a timing chart (3/3) showing an operation example when a 2-way cache is prefetched as another way as another prefetch target.
  • FIG. 17 is a timing chart (1/2) showing an operation example when the 2-way cache operates independently.
  • FIG. 18 is a timing chart (2/2) illustrating an operation example when the 2-way cache operates independently.
  • a processor 53
  • a memory 55
  • a plurality of tags 65
  • a plurality of ways capable of storing a plurality of data at successive addresses of the memory using a tag value stored in the tag as a reference address (64)
  • a semiconductor device 50
  • a cache control unit 63
  • Each of the plurality of ways is provided with an address change direction flag (66) indicating the direction in which the two most recent accesses to the way are address increase or decrease.
  • the cache control unit is an access to an address in which a first access and a second access are sequentially performed from the processor to the memory (1), and the second access is an access through a first way.
  • a predetermined prefetching operation is configured for the second way that satisfies the following conditions.
  • the condition has an address change direction flag that matches the address change direction flag corresponding to the first way, and is opposite to the direction indicated by the address change direction flag with respect to the tag value corresponding to the first way. (4) having consecutive tag values.
  • the predetermined prefetching operation is prefetching (5) of data indicated by a tag value continuous in the direction indicated by the address change direction flag with respect to the tag value corresponding to the first way.
  • the address change direction flag (66) can be configured to be set autonomously by the cache control unit based on the access history to the cache memory.
  • the cache control unit when the cache miss occurs, the cache control unit is configured to be able to execute a cache fill in a unit of data length that is 1 / integer of the total data length of data stored in the way.
  • the cache control unit includes a valid flag (67) for each unit of the data length of the cache fill in each of the plurality of ways, and when a cache miss occurs, the cache fill target way All the valid flags corresponding to are cleared (23), and the valid flag corresponding to the cache-filled data can be set (25).
  • the cache control unit is configured to enable the following operations.
  • the address change direction flag corresponding to the second way matches the address change direction flag corresponding to the first way, and the tag value corresponding to the second way corresponds to the tag value corresponding to the first way.
  • the address change direction flag continues in the direction opposite to the direction, the data prefetching is performed for the second way after the data prefetching to the area in the first way.
  • the address change direction flag corresponding to the second way does not match the address change direction flag corresponding to the first way, or the tag value corresponding to the second way is the tag value corresponding to the first way
  • the following prefetching operation is performed. After the prefetching of data to the area in the first way, after the second access in the first way, the first direction opposite to the direction indicated by the address change direction flag corresponding to the first way Prefetch data to the area in 1 way.
  • the processor is configured to be able to execute a subsequent access of the second access after the second access is completed and before the cache memory completes the prefetching.
  • each of the plurality of ways is configured to be able to cache data at an arbitrary address in the memory.
  • the semiconductor device further includes an instruction cache, and the plurality of ways are data caches for the processor.
  • ⁇ Data prefetching method> A plurality of tags provided between the processor (53) and the memory (55) and capable of storing a plurality of tags (65) and a plurality of data at successive addresses of the memory using a tag value stored in the tag as a reference address
  • the data prefetching method in the cache memory (60) comprising the following way (64), comprising the following steps.
  • First step (1) for determining whether or not the first access to the memory from the processor and the second access continuous to the memory are accesses to consecutive addresses.
  • the determination result of the first step is an access to a continuous address
  • the first access and the second access are accesses by the same tag value for the same way among the plurality of ways, the latest to the way
  • a cache hit can be made to either way at all times by an operation in which the other way is prefetched in an empty cycle during a period in which one way is hit.
  • the address change direction attribute can be set autonomously by the cache control unit based on the access history to the cache memory.
  • each of the plurality of ways includes a valid flag (67) for each unit of the data length of the cache fill, and when a cache miss occurs in the third step, All the corresponding valid flags are cleared (23), and the valid flag corresponding to the cache-filled data is set (25).
  • the fourth step is executed after the sixth step, and based on the determination result of the fourth step that is not, the direction opposite to the direction indicated by the address change direction attribute corresponding to the first way
  • a data prefetching method further comprising a loop that repeats the sixth step (13) in order to prefetch data in an area in the first way in which the corresponding valid flag is not set.
  • a semiconductor device (50) including a processor (53), a memory (55), a plurality of tags (65), a plurality of ways (64), and a cache control unit (63) that correspond to each other 1: 1. It is configured as follows.
  • the cache control unit when the second access is an access in a direction in which the address increases relative to the first access, data for a way having a tag value that is 1 smaller than a tag value corresponding to the first way Is read ahead (4, 40).
  • data prefetching is performed for a way larger than the tag value corresponding to the first way (4, 45).
  • FIG. 2 is a block diagram illustrating a configuration example of a semiconductor device according to an embodiment.
  • a cache memory 60 is provided between the processor 53 and the memory 55.
  • the memory 55 may be a nonvolatile memory such as a flash memory, and may be any memory allocated to the memory space of the processor 53.
  • the cache memory 60 includes an instruction cache 62 and a data cache 61.
  • the data cache 61 includes a plurality of tags 65_0 to 65_3 and a plurality of ways 64_0 to 64_3 capable of storing a plurality of data at consecutive addresses in the memory 55 using the tag value stored in the tag as a reference address.
  • the tags 65_0 to 65_3 and the ways 64_0 to 64_3 are associated with 1: 1, and data D0 to D7 for 16 addresses, for example, are stored in the way 64_0, starting from the tag value stored in the tag 65_0.
  • the number of ways and tags is arbitrary, and at least two sets are sufficient.
  • the number of data stored in one way and the data length (bit length) per data are also arbitrary. This can be determined appropriately in consideration of the access unit from the processor 53 and the interface with the nonvolatile memory 55 to be cached.
  • FIG. 2 also illustrates other components, which will be described later.
  • FIG. 1 is a flowchart showing an operation example of a semiconductor device according to an embodiment.
  • step 1 When there is a data read request for accessing the nonvolatile memory 55 from the processor 53, it is determined whether or not the data read request and the immediately preceding data read request are data read requests to consecutive addresses (step 1). . As a result, when it is determined that it is a data read request to a continuous address, when two consecutive data read requests are accesses to the same way with the same tag value, the two most recent accesses to the way are addresses. An address change direction attribute indicating whether the direction of increase or decrease is added (step 2). The way (access target way) is accessed by the current data read request (step 3).
  • the presence / absence of another way (a prefetch target way) having a value is determined (step 4).
  • the prefetching of data indicated by the tag value continuous in the direction indicated by the address change direction attribute of the access target way is performed on the prefetching target way (step 5).
  • Way 0 corresponds to tag 0 (65 — 0)
  • way 1 corresponds to tag 1 (65 — 1).
  • the address change direction attribute is first given to the way 0 (64_0) (step 2). If the previous access to the way 0 (64_0) is an access to the address A-1, the address is increasing. Conversely, if the previous access is to the address A + 1, the address is It is a decreasing direction. The address change direction attribute is given to each way.
  • the tag 0 (65_0) corresponding to the way 0 (64_0) stores the upper address of the address A. If the access to way 0 (64_0) is a cache miss, the upper address of address A is stored in tag 0 (65_0) due to cache fill.
  • way 1 64_1
  • the determination condition is whether or not the tag value of the access target way has the same address change direction attribute and has a tag value continuous in the direction opposite to the direction indicated by the address change direction attribute (step 4). ).
  • the way 1 (64_1) has the same address change direction attribute as the way 0 (64_0) reflects the access history that both ways have been continuously accessed in the same address change direction.
  • tag 1 (65_1) corresponding to way 1 (64_1) has a tag value stored in tag 0 (65_0) corresponding to way 0 (64_0) in a direction opposite to the direction indicated by the address change direction attribute. Having continuous tag values indicates that way 1 (64_1) is already accessed. Therefore, if this condition is satisfied, the way 1 (64_1) has been continuously accessed with the same series of data, and there is a high possibility that the way has already been accessed. Therefore, the probability that the way 1 (64_1) is accessed again is low, and it can be determined that the way 1 (64_1) is suitable as a prefetch target following the access to the way 0 (64_0).
  • prefetching of data is executed in the direction indicated by the address change direction attribute with way 1 (64_1) as a prefetch target (step 5).
  • way 1 (64_1) has already been accessed by a series of accesses of the same data series.
  • A′-1 should be stored in the corresponding tag 1 (65_1).
  • the way 1 (64_1) is likely to be used to cache another series of data stored in another address area. Therefore, it is not appropriate as a prefetch target, and prefetch is not executed.
  • the way is appropriate as a prefetch target based on whether the address change direction attribute and the tag value are continuous. If there is a way suitable for the prefetch target, the access target way and the prefetch target way are combined to function as one way having a prefetch function. On the other hand, if there is no way suitable for the prefetch target, each way is made to function as an independent plurality of ways as an independent way.
  • the determination of whether or not to prefetch data is made based on the access history.
  • the cache control unit is autonomous without any special control from the outside simply by giving an address change direction attribute indicating the direction. Judgment is made and the way look-ahead function is switched. Since the cache circuit collects and holds the access history as information indicating whether or not the address change direction attribute and the tag value are continuous, the cache circuit can make an autonomous determination.
  • the way and the tag are associated with 1: 1 instead of providing a plurality of tags in one way.
  • one way is composed of only one line and one tag corresponding thereto.
  • a cache for at least two lines it can function as either a 1-way cache or a 2-way cache having a look-ahead function while autonomously switching.
  • This embodiment is not a large-scale cache circuit, but a small and low-power cache circuit that has extremely strict requirements for circuit scale and power consumption, such as a secure microcomputer that can be mounted on an IC card or the like. When applied, it is particularly effective.
  • FIG. 2 is a block diagram illustrating a configuration example of a semiconductor device according to an embodiment. A more detailed configuration example than that described in the outline of the embodiment will be described.
  • the semiconductor device 50 according to the present embodiment is, for example, a microcomputer 50 used for an IC card, which is formed on a single semiconductor substrate using a known semiconductor manufacturing technique, or a nonvolatile memory 55 or the like is formed in a separate chip. It is formed as a multichip module.
  • the present embodiment is not limited by the semiconductor device mounting method.
  • the microcomputer 50 includes a CPU 53, a DMAC 54, a ROM 56, a RAM 57, and a peripheral module 58 that are connected to each other via an address bus 51 and a data bus 52.
  • a DMAC (Direct Memory Access Controller) 54 can access the memory independently of the CPU and execute data transfer based on the transfer parameters set by the CPU 53.
  • a ROM (Read Only Memory) 56 and a RAM (Random Access Memory) 57 are memories.
  • the ROM 57 stores an instruction code of a program executed by the CPU 53 and initial values of data, and the RAM 57 stores values of variables used in the program. Store.
  • the peripheral module 58 is, for example, a timer module or a communication interface module.
  • a bus arbitration circuit, an interrupt control circuit, and the like can be provided.
  • the nonvolatile memory 55 is connected to the address bus 51 and the data bus 52 via the cache memory 60, and can be accessed from a bus master such as the CPU 53 or the DMAC 54.
  • the nonvolatile memory 55 and the cache memory 60 are connected to each other via a dedicated address bus 51_1 and a data bus 52_1.
  • the non-volatile memory 55 is a non-volatile memory such as a flash memory, a phase change memory, and a ferroelectric memory, for example.
  • the nonvolatile memory 55 can be replaced with any storage element allocated to the memory space of the CPU 53. It may be a volatile memory such as DRAM or SDRAM, or a memory other than a semiconductor.
  • the nonvolatile memory 55 includes, for example, a read buffer 78 and a selector 79. The data at the address specified by the upper bits of the address bus 51_1 is read from the memory unit 77 and temporarily stored in the read buffer 78. A part of the data is selected by the selector 79 and output to the data bus 52_1.
  • the size of the read buffer 78 coincide with the number of bits of the memory cells connected to one word line in the memory unit 77, the power consumption for accessing the nonvolatile memory 55 can be kept low. Furthermore, the provision of a pre-read cache described in Patent Document 3 is preferable because it can achieve more effective power consumption reduction.
  • the read buffer 78 is assumed to be 16 bytes and the data bus 52_1 is assumed to be 4 bytes, although not particularly limited.
  • the cache memory 60 includes a data cache 61, an instruction cache 62, and a cache control unit 63.
  • the data cache 61 includes four ways 64_0 to 64_3. Each way is associated with a tag 65_0 to 65_3, a decrement flag 66_0 to 66_3, and a valid flag 67_0 to 67_3.
  • LRU Least Recently ⁇ Used
  • a cache fill is performed on the least recently used (Least Recently Used) way.
  • the cache control unit 63 is provided with an address control unit 68 and a data control unit 69, and controls an interface of an access command with the CPU 53 and the like via the address bus 51 and the data bus 52 and an interface with the nonvolatile memory 55. To do.
  • the cache control unit 63 further includes an LRU flag 70, an LRU control unit 71, a tag control unit 72, a decrement flag control unit 73, and a valid flag control unit 74, and includes data cache tags 65_0 to 65_3 and decrement flags 66_0 to 66_3. And valid flags 67_0 to 67_3 are controlled.
  • the LRU control unit 71, tag control unit 72, decrement flag control unit 73, and valid flag control unit 74 are connected to the internal address bus 75_1 and the internal data bus 76_1.
  • Each of the ways 64_0 to 64_3 can hold a plurality of data.
  • Data in each way is composed of data with continuous addresses.
  • An upper address common to the address of the data stored in the way is stored in the corresponding tag.
  • data per address is 1 byte (8 bits)
  • the bit length of data constituting a way is 2 bytes (16 bits).
  • Each way can store 8 pieces of 2-byte data, and the upper bits excluding the lower 4 bits of the address correspond to the tag value.
  • the data bus 52 has a width of 2 bytes.
  • the cache can be fully associative.
  • the data stored in each way may be any address in the memory space of the CPU 53.
  • the decrement flag 66_0 to 66_3 is a flag indicating whether the access to each way 64_0 to 64_3 is an access in an address increasing direction or an access in a decreasing direction with respect to the previous access to the same way.
  • the valid flags 67_0 to 67_3 are flags that indicate whether or not the data of the respective ways 64_0 to 64_3 is valid.
  • a 1-bit flag is provided for each cache fill data size. For example, assuming that the data D0 to D7 constituting the ways 64_0 to 64_3 are 2 bytes (16 bits), respectively, and when a cache fill is performed every 4 bytes (32 bits), a 1 bit flag is set every 4 bytes.
  • Each flag is composed of a total of 4 bits V0 to V4.
  • addresses are allocated for each byte, if a 2-byte data read request is used, an even number of consecutive addresses is called a continuous address and if it is a 4-byte data read request, A continuous address in multiples of 4 is called a continuous address.
  • the bit length of the cache fill can be 4 bytes, for example. Accordingly, the internal data bus 76_1 and the interface circuits of the LRU control unit 71, the tag control unit 72, the decrement flag control unit 73, and the valid flag control unit 74 connected thereto may be provided with 4 bytes each. Thereby, a circuit scale can be suppressed and power consumption can be reduced. Further, it is possible to determine cache hit / miss and output data or perform cache fill in units of 4 bytes stored in the way. On the other hand, the number of data provided for each way can be matched with the number of data connected to one word line of the nonvolatile memory.
  • the read buffer 78 and the selector 79 provided in the nonvolatile memory 55 are not necessary, and data read from one word line can be filled into the way in a lump, thereby speeding up the cache fill. it can.
  • the valid flag at this time can be 1 bit for each way. In addition, a configuration without a valid flag may be possible.
  • the bit length of the cache fill can be appropriately designed in consideration of the circuit size, power consumption, and cache fill speed as described above.
  • FIG. 2 A detailed operation example of the semiconductor device illustrated in FIG. 2 will be described. 3, 4, 5, and 6 are flowcharts showing detailed operation examples of the semiconductor device according to the embodiment.
  • the cache control unit 63 of the cache memory 60 determines whether the bus command is an instruction fetch or not by data access. It is determined whether or not there is a data read request to the nonvolatile memory 55 (step 11). If it is not a data read request to the nonvolatile memory 55, it is determined whether or not all the data areas of all the ways 64_0 to 64_3 of the cache are valid (step 12). It is determined whether or not there is a flag for which 1 is not set among V0 to V4 constituting each of the valid flags 67_0 to 67_3.
  • the data is read from the nonvolatile memory 55 and the data area (Step 13).
  • a valid flag corresponding to the data area of the written way is set to 1 (step 14). This makes it possible to preliminarily pre-read data in the direction opposite to the pre-reading direction of the way indicated by the same tag (backward data) by using the period when no bus command is issued. The probability of a cache miss can be reduced.
  • the cache control unit 63 of the cache memory 60 takes in the address of the bus command (step 15) and reads this time. It is determined whether the address of the request is continuous with the address of the previous read request (step 16). If it is continuous, the process proceeds to step 2 for assigning the address change direction attribute to the way. If it is not continuous, the process proceeds to step 3 for accessing the way. In FIG. 3 and FIG. 4, it is displayed as a connector C2.
  • step 2 for assigning the address change direction attribute to the way the decrement flags 66_0 to 66_3 are set and updated. It is determined whether or not the address of the current read request matches the tag of any one way in the cache (step 17). If not, the process proceeds to step 3 for accessing the way. In FIG. 3 and FIG. 4, it is displayed as a connector C2. If there is a way with a matching tag value, it is determined whether the address of the continuous access is the increment direction or the decrement direction (step 18). As a result, if the direction is the increment direction, 0 is set to the decrement flag of the target way (step 19), and if the direction is the decrement direction, 1 is set to the decrement flag of the target way (step 20). Thereafter, the process proceeds to step 3 for accessing the way. In FIG. 3 and FIG. 4, it is displayed as a connector C3.
  • step 16 If it is not continuous access (step 16), or even if it is continuous access, and there is no way having a tag value that matches the address of the current read request (step 17), it is transferred to the way via the connector C2. Go to step 3 to access (FIG. 4).
  • step 22 it is determined whether or not there is a cache hit (step 22). In the case of a cache hit, the LRU flag 70 is updated so that the hit way is the latest (step 33), and read data is output from the hit way (step 34). If there is a cache miss, the cache fill is performed on the way storing the oldest data indicated by the LRU flag 70.
  • step 23 all bits (V0 to V3) of the valid flag of the way storing the oldest data are cleared to 0 (step 23), the data is read from the nonvolatile memory 55, and the data area of the target way (Step 24), and a valid flag corresponding to the data area of the written way is set to 1 (step 25).
  • step 26 an access target address is set in the tag of the written way (step 26), and the LRU flag 70 is updated so that the way to which the data has been written is the latest (step 27).
  • Read data is output from the way in which the data was written (step 28).
  • step 21 Even when the process proceeds to step 3 for accessing the way via the connector 3 through the step 2 for assigning the address change direction attribute to the way shown in FIG. 3, it is first determined whether or not it is a cache hit (see FIG. 3). Step 21). In the case of a cache hit, the LRU flag 70 is updated so that the hit way is the latest (step 33), and read data is output from the hit way (step 34). Even in the case of a cache miss, since it is known in step 17 that there is a way having the same tag value as the address of the current read request, the data area of the target way is read from the nonvolatile memory 55. Data is written (step 29).
  • step 35 it is determined whether the data area in the direction indicated by the decrement flag is filled starting from the data area of the accessed way (step 35).
  • the decrement flag of the accessed way is 0, it is checked whether any valid flag in the address increasing direction from the accessed data area is cleared to 0.
  • the decrement flag of the accessed way is 1, it is checked whether any valid flag in the address decreasing direction from the accessed data area is cleared to 0. If there is a data area in which the valid flag is not set to 1, data is read from the nonvolatile memory 55, written in that data area of the target way (step 36), and the valid flag 70 corresponding to the data area of the written way is stored. 1 is set (step 37). This operation is repeated until valid data is written (filled) in all data areas starting from the accessed data area and extending to the end of the way in the direction indicated by the decrement flag.
  • step 4 the way having the tag value continuous in the opposite direction to the direction indicated by the decrement flag is searched for in which the latest way and the decrement flag value match (step 4). If not, the process returns to step 11 for determining the presence or absence of data read to the nonvolatile memory 55 (shown as a flow connected by the connector C1 in the figure). On the other hand, if there is a way 64 that satisfies such conditions, the process proceeds to the data prefetching step shown in FIG. 6 via the connector C5.
  • step 38 the value of the decrement flag of the latest way and the way that satisfies the above condition is checked (step 38). If both the value of the decrement flag of the latest way and the way that satisfies the above condition are 0, the process proceeds to step 39.
  • a way that satisfies the above condition is a way that is determined as a way suitable for writing prefetched data.
  • the tag value of the way that matches the condition is updated to the tag value of the latest way + 1 line (step 39).
  • step 43 If the data area of the pre-read target way is not filled in the direction indicated by the decrement flag, that is, the address increasing direction, the address of the data read from the nonvolatile memory is incremented (step 43), and the next data is stored in the nonvolatile memory 55. (Step 40), and 1 is set to the valid flag of the corresponding data area (step 41). The operations from step 40 to step 43 are repeated until the data area of the prefetch target way is completely filled in the direction indicated by the decrement flag (step 42).
  • step 38 The value of the decrement flag of the latest way and the way that matches the above condition is checked (step 38). If both the value of the decrement flag of the latest way and the way that satisfies the above condition are 1, proceed to step 44.
  • a way that satisfies the above conditions is also a way that is determined as a way suitable for writing prefetched data.
  • the tag value of the way that matches the above condition is updated to the value of the latest way tag value minus one line (step 44). If the data area of the pre-read target way is not filled in the direction indicated by the decrement flag, that is, the address decreasing direction, the address of the data read from the nonvolatile memory is decremented (step 48), and the next data is stored in the nonvolatile memory 55. (Step 45), and 1 is set in the valid flag 67 of the corresponding data area (step 46). The operations from step 45 to step 48 are repeated until the data area of the prefetch target way is completely filled in the direction indicated by the decrement flag
  • step 42 and 47 When data is filled in all data areas of the way to be prefetched (steps 42 and 47), the process returns to step 11 for determining whether or not data is read from the nonvolatile memory 55 (in the figure, as a flow connected by the connector C1). Show).
  • a continuous cache hit occurs in continuous access of a series of data.
  • the other two ways can also function as one way for continuing the prefetching, or can function as two independent ways. Switching between functioning as one way to continue prefetching or functioning as two independent ways is performed only by comparing the decrement flag and the tag value.
  • the determination of whether or not to prefetch data is made based on the access history.
  • the cache control unit makes an autonomous decision without newly receiving control from the outside simply by providing a new decrement flag indicating the direction. Can be switched.
  • FIG. 7 is an explanatory diagram illustrating an operation example when the 2-way cache operates independently.
  • the case where the number of ways is 2 is illustrated. Even if the number of ways is 3 or more, the same effect is obtained.
  • Each of the two ways 64_0 and 64_1 holds eight 2-byte data D0 to D7, and includes corresponding tags 65_0 and 65_1 and decrement flags 66_0 and 66_1.
  • 1-bit valid flags V0 to V3 are provided for two pieces of data (4 bytes).
  • the LRU flag 70 indicates the way that was most recently accessed, either WAY 0 or WAY 1.
  • One address is assigned to one byte of data, and eight pieces of 2-byte data D0 to D7 correspond to data for 16 addresses.
  • the tag stores an address value higher than the lower 4 bits as a tag value.
  • D0 stores data corresponding to an address obtained by adding 0x0 to the lower 4 bits below the tag value on the basis of the tag value.
  • D7 store data corresponding to addresses obtained by adding 0x2, 0x4, 0x8,. 7, 8, and 9, the case where a data read at address 0x002008 is requested is taken as an example, the state before access is shown on the upper side of each figure, and the state after access is shown on the lower side of each figure Are schematically shown.
  • the tag value corresponding to the address 0x002008 is 0x00200, and the data of the address 0x002008 is stored at the position D4.
  • “0x” is a symbol indicating that the subsequent numerical value is in hexadecimal notation.
  • the tag value corresponding to the address 0x002008 is 0x00200, which is different from the tag values stored in the tags 65_0 and 65_1, and is thus determined as a cache miss (steps 17 and 22). Since the LRU flag 70 indicates the way 0, the cache fill is performed on the way 0 (steps 23 to 28).
  • the valid flags V0 to V3 of way 0 (64_0) are all cleared to 0 (step 23). Data is read from nonvolatile memory address 0x002008 and written to D4 and D5 of way 0 (64_0) (step 24).
  • the corresponding valid flag V2 is set to 1 (step 25).
  • 0x00200 is set to the tag 65_0 (step 26).
  • the LRU flag is changed to WAY 1 (step 27).
  • Data is output from D4 of way 0 (64_0) that has been cache-filled (step 28).
  • prefetching of data proceeds to D6 and D7.
  • 1 is set to V3 of the valid flag 67_0.
  • the condition determination in step 4 is performed.
  • the decrement flags 66_0 and 66_1 coincide with each other in the increasing direction.
  • the tag 65_1 of the way 1 is 0x00324, and is decrementing in the opposite direction to the decrement flags 66_0 and 66_1.
  • the tag value 0x00200 of the way 0 is different from the continuous tag value 0x001FF. Therefore, it is determined that the way 1 is not appropriate as a prefetch target (step 4).
  • the data of way 1 (64_1) is retained, and a cache hit occurs when there is an access to valid data D0 to D3 that matches the tag 65_1.
  • Way 1 (64_1) functions as a way independent of way 0 (64_0).
  • the way 0 is hit.
  • the tag value corresponding to the address 0x002008 is 0x00200 and matches the tag value stored in the tag 65_0, so the decrement flag is updated (steps 17 to 20). If the continuous access address is in the increment direction, the value of the decrement flag 66_0 is set to 0 (step 19), and if it is in the decrement direction, it is set to 1 (step 20). In FIG. 8, the increment direction is used.
  • a cache hit / miss is determined (step 21). Since the tag 65_0 matches but the data corresponding to the address 0x002008 should be stored, V2 of the valid flag 67_0 of D4 is 0, so the data corresponding to the address 0x002008 is not stored in the way 0 (64_0). . Therefore, it is determined as a cache miss. Data of 4 bytes is read from the non-volatile memory 55 from address 0x002008, written to D4 and D5 (step 29), and 1 is set to V2 of the corresponding valid flag 67_0 (step 30). The LRU flag 70 is updated to WAY 1 so that the accessed way 0 is the latest (step 31). Data is output from D4 of way 0 (64_0) that has been cache-filled (step 32).
  • prefetching of data proceeds to D6 and D7.
  • 1 is set to V3 of the valid flag 67_0.
  • the condition determination in step 4 is performed.
  • the tag 65_1 of the way 1 is 0x001FF, which is in the opposite direction to the increase direction of the address indicated by the decrement flags 66_0 and 66_1 and matches the tag value 0x00200 of the way 0 and the continuous tag value 0x001FF. It is determined that the target is appropriate (step 4).
  • the decrement flags 66_0 and 66_1 of the way 0 that is the latest way and the way 1 that satisfies the condition as the prefetch target are both 0 (step 38).
  • the value of the tag 65_1 of the way 1 that satisfies the condition to be prefetched is updated to 0x00201, which is the tag value 0x00200 + 1 of the tag 65_0 of the latest way 0 (step 39).
  • step 43 the data is sequentially read from the nonvolatile memory 55 while incrementing the address (step 43) until all the data D0 to D7 of way 1 are filled (step 42), and the address 0x002010 is stored in the data D0 to D7 of way 1 Data of .about.0x00201F is written (step 40), and V0 to V3 of the corresponding valid flag 67_1 are sequentially updated to 1 (step 41).
  • way 1 functions as a prefetch target of way 0.
  • way 0 and way 1 function alternately as an access target and a prefetch target, and no cache miss occurs.
  • Fig. 9 shows an example of the operation when the continuous access direction is the address decreasing direction.
  • D2 and D3 of way 0 64_0
  • 1 is set in the valid flag V1, and the other valid flags V0, V2, and V3 are cleared to 0.
  • the tag 65_0 stores 0x00200.
  • the valid flags V0 and V1 are set to 1, and the other valid flags V2 and V3 are cleared to 0.
  • the tag 65_1 stores 0x00201.
  • the decrement flags 66_0 and 66_1 are both set to 1.
  • prefetching of data proceeds to D0 and D1.
  • 1 is set to V0 of the valid flag 67_0.
  • the condition determination in step 4 is performed.
  • the tag 65_1 of the way 1 is 0x00201, which is the reverse direction of the address indicated by the decrement flags 66_0 and 66_1 and matches the tag value 0x00200 of the way 0 and the continuous tag value 0x00201, so the way 1 is prefetched. It is determined that the target is appropriate (step 4).
  • the decrement flags 66_0 and 66_1 of the way 0 that is the latest way and the way 1 that satisfies the condition for the prefetch target are both 1 (step 38).
  • the value of the tag 65_1 of the way 1 that satisfies the condition as a prefetch target is updated to 0x001FF, which is the tag value 0x00200-1 of the tag 65_0 of the latest way 0 (step 44).
  • the data is sequentially read from the nonvolatile memory 55 while incrementing the address (step 48) until all the data D0 to D7 of the way 1 are filled (step 47), and the address 0x001FFF is read into the data D0 to D7 of the way 1 Data of .about.0x001FF0 is written (step 45), and V0 to V3 of the corresponding valid flag 67_1 are sequentially updated to 1 (step 46).
  • the way 1 functions as a prefetch target of the way 0 as in the case of the continuous access in which the address described with reference to FIG.
  • way 0 and way 1 function alternately as an access target and a prefetch target, and no cache miss occurs.
  • FIGS. 10 to 13 are timing charts showing an operation example of the semiconductor device according to the comparative example.
  • FIGS. 14 to 16 are timing charts showing an operation example in the case where the 2-way caches are mutually prefetched and perform prefetching as one way.
  • FIGS. 17 to 18 are timing charts showing an operation example when the 2-way cache operates independently.
  • the horizontal axis is a time axis and is expressed in order from T1 in units of clock cycles.
  • a clock, a CPU access request, an address issued by the CPU, and read data to the CPU are shown in order from the top. Next, the operation of the cache memory 60 is shown.
  • An access request of the cache control circuit 63, an address issued from the cache memory 60 to the nonvolatile memory 55, and read data output from the nonvolatile memory 55 to the cache memory 60 are shown.
  • the internal states of way 0 and way 1 are shown.
  • the decrement flags 66_0 and 66_1 the value of the tag [23: 4] (65_0 and 65_1), and the values of the data D0 to D7 are shown in order from the top.
  • the value of the LRU flag 70 is shown.
  • the CPU 53 requests a 2-byte data read from the address 0x00200C in the cycle T1.
  • the value of the tag 65_0 of the way 0 is 0x01219
  • the value of the tag 65_1 of the way 1 is 0x001FF
  • the LRU flag 70 points to the way 0. Since there is no tag that matches the tag value 0x00200 corresponding to the address 0x00200C for which data read is requested, a cache miss occurs. Assume that two cycles are required to determine a cache miss, and the cache memory 60 outputs the address 0x00200C to the nonvolatile memory 55 in cycle T3.
  • the target of the cache fill is way 0 indicated by the LRU flag 70.
  • the LRU flag 70 is updated to way 1, and in cycle T4, the tag 65_0 of way 0 is updated to 0x00200.
  • Data reading is executed in the nonvolatile memory 55, but assuming that three cycles are required, the value @ 00200C of the address 0x00200C is read at cycle T6, and written to D6 / D7 of way 0 (64_0) at cycle T7. In addition, it is also output to the CPU 53. Since the cache fill is performed in units of 4 bytes, 4-byte data from addresses 0x00200C to 0x00200F is written to D6 and D7 of way 0 (64_0). Since the data read request from the CPU 53 is 2 bytes, 2 bytes stored in D6 are returned to the CPU 53.
  • the CPU 53 requests a 2-byte data read from the address 0x00200E in cycle T8.
  • the data at address 0x00200E is written to D7 of way 0 (64_0) by the previous cache fill. Since the data read request in cycle T1 is a request for 2-byte data read from address 0x00200C, the data read request in cycle T1 is a request for continuous reading in the address increasing direction.
  • the decrement flag 66_0 of way 0 is maintained as 0 indicating the address increasing direction. Since the data at address 0x00200E is stored in D7 of way 0 (64_0), it is a cache hit and is output as read data of the CPU as @ 00200E in cycle T9.
  • cycle T12 the CPU 53 requests a 2-byte data read from 0x002010 which is the next continuous address. Since the data at address 0x002010 is not cached, a cache miss occurs. The cache control circuit does not issue an access request until then (cycles T9 to T13).
  • the cache memory 60 outputs the address 0x002010 to the nonvolatile memory 55 at cycle T14.
  • the target of the cache fill is way 1 indicated by the LRU flag 70.
  • the LRU flag 70 is updated to way 0, and in cycle T15, the tag 65_1 of way 1 is updated to 0x00201.
  • data reading is executed in 3 cycles.
  • the value @ 002010 at address 0x002010 is read out and written to D0 / D1 of way 1 (64_1) at cycle T18. Also output to the CPU 53.
  • FIGS. 14 to 16 are timing charts showing an operation example in a case where the 2-way caches are prefetched as other prefetch targets and prefetched as one way.
  • the CPU 53 requests a 2-byte data read from the address 0x00200C in the cycle T1.
  • the value of the tag 65_0 of the way 0 is 0x01219
  • the value of the tag 65_1 of the way 1 is 0x001FF
  • the LRU flag 70 points to the way 0. Since there is no tag that matches the tag value 0x00200 corresponding to the address 0x00200c for which data read is requested, a cache miss occurs. Assume that two cycles are required to determine a cache miss, and the cache memory 60 outputs the address 0x00200C to the nonvolatile memory 55 in cycle T3.
  • the target of the cache fill is way 0 indicated by the LRU flag 70.
  • the LRU flag 70 is updated to way 1
  • the tag 65_0 of way 0 is updated to 0x00200.
  • Data reading is executed in the nonvolatile memory 55, but assuming that three cycles are required, the value @ 00200C of the address 0x00200C is read at cycle T6, and D6 / D7 of way 0 (64_0) is displayed at cycle T7 shown in FIG. And output to the CPU 53 together. Since the cache fill is performed in units of 4 bytes, 4-byte data from addresses 0x00200C to 0x00200F is written to D6 and D7 of way 0 (64_0). Since the data read request from the CPU 53 is 2 bytes, 2 bytes stored in D6 are returned to the CPU 53.
  • the CPU 53 requests a 2-byte data read from the address 0x00200E in cycle T8. Since the data read request in cycle T1 is a request for 2-byte data read from address 0x00200C, the data read request in cycle T1 is a request for continuous reading in the address increasing direction.
  • the decrement flag 66_0 of way 0 is maintained as 0 indicating the address increasing direction.
  • the data at address 0x00200E is written to D7 of way 0 (64_0) by the previous cache fill. Since the data at address 0x00200E is stored in D7 of way 0 (64_0), it is a cache hit and is output as read data of the CPU as @ 00200E in cycle T9.
  • the data prefetching operation shown in the flowcharts of FIGS. 3 to 6 is started.
  • the cache fill generated by the 2-byte data read request from address 0x00200C of cycle T1 the data area in the direction indicated by decrement flag 66_0 starting from D6 / D7 of way 0 is filled (step 35).
  • the process proceeds to a determination step as to whether there is a way suitable for prefetching.
  • a way is searched for which has the same decrement flag value as that of the latest way 0 and a tag value continuous in the direction opposite to the direction indicated by the decrement flag (step 4).
  • the decrement flags 66_0 and 66_1 both coincide with each other indicating the address increasing direction, the tag value of the way 1 is 0x001FF, the address decreasing direction is opposite to the direction indicated by the decrement flags 66_0 and 66_1, and the tag value of the way 0 is 0x00200. Since they are continuous, it is determined that the way 1 is suitable as a prefetch target. In cycle T8, the tag 65_1 is updated to 0x00201 obtained by adding 1 to 0x00200 (step 39).
  • cycle T12 the CPU 53 requests a 2-byte data read from 0x002010 which is the next continuous address.
  • 0x002010 since the data at the address 0x002010 has been read ahead in way 1, a cache hit occurs and is read out in cycle T13 shown in FIG.
  • a cache miss occurs and the data at the address 0x002010 is read at cycle T18.
  • the occurrence of a cache miss is suppressed and the execution cycle is shortened by 5 cycles.
  • a 2-byte data read is executed in 2 cycles when a cache hit occurs, and 7 cycles are required when a cache miss occurs.
  • the instruction fetch and the data read cycle can be executed even during the data prefetching period.
  • the cycle for performing the look-ahead can be hidden.
  • FIGS. 17 to 18 are timing charts showing an operation example when the 2-way cache operates independently.
  • the CPU 53 requests a 2-byte data read from the address 0x002008 in the cycle T1.
  • the value of the tag 65_0 of the way 0 is 0x01219
  • the value of the tag 65_1 of the way 1 is 0x0121A
  • the LRU flag 70 points to the way 0. Since there is no tag that matches the tag value 0x00200 corresponding to the address 0x002008 for which data read is requested, a cache miss occurs. Assume that two cycles are required to determine a cache miss, and the cache memory 60 outputs the address 0x002008 to the nonvolatile memory 55 in cycle T3.
  • the target of the cache fill is way 0 indicated by the LRU flag 70.
  • cycle T3 the LRU flag 70 is updated to way 1, and in cycle T4, the tag 65_0 of way 0 is updated to 0x00200.
  • Data reading is executed in the nonvolatile memory 55, but assuming that three cycles are required, the value @ 002008 at address 0x002008 is read at cycle T6, and D4 / D5 of way 0 (64_0) at cycle T7 shown in FIG. And output to the CPU 53 together.
  • the CPU 53 requests a 2-byte data read from address 0x00200A in cycle T8. Since the data read request in cycle T1 is a request for 2-byte data read from address 0x002008, the data read request in cycle T1 is a request for continuous reading in the address increasing direction.
  • the decrement flag 66_0 of way 0 is maintained as 0 indicating the address increasing direction. Since the data at address 0x00200A has been written to D5 of way 0 (64_0) by the previous cache fill, it is a cache hit, and is output as read data of the CPU as @ 00200A at cycle T9.
  • step 35 address 0x00200C is issued to nonvolatile memory 55 at cycle T6, and data @ 0x00200c read at cycle T7 shown in FIG. 18 is written to data area D6 / D7 at cycle T8 (step 36). Thereafter, the process proceeds to step 4.
  • the cache control circuit of the present embodiment simply refers to the tag value and the decrement flag to determine whether to function as a 2-way cache or whether the two ways collectively function as a prefetch target. It is possible to switch autonomously.
  • the present invention is not limited to the data cache embodiment, and can be applied to an instruction cache and a unified cache.
  • the number of ways is not limited to two, and can be arbitrarily determined.
  • the number of cycles used for determination of cache hit / miss can be appropriately designed as appropriate, and the number of cycles for reading data from the nonvolatile memory. May be any value.
  • the present invention relates to a technique for prefetching data into a cache memory, and can be widely applied to a semiconductor device equipped with a cache memory.
  • Step of determining whether or not consecutive access addresses are continuous 2 Step of assigning an address change direction attribute (decrement flag) to the way 3 Step of accessing the way 4 Step of determining whether or not the read-ahead operation is suitable 5 Steps for prefetching 50 Semiconductor device (secure microcomputer) 51 Address bus 52 Data bus 53 Processor (CPU) 54 DMA (Direct Memory Access) controller 55 Non-volatile memory 56 ROM (Read Only Memory) 57 RAM (Random Access Memory) 58 Peripheral Module 60 Cache Memory 61 Data Cache 62 Instruction Cache 63 Cache Control Unit 64 Way 65 Tag 66 Decrement Flag 67 Valid Flag 68 Address Control Unit 69 Data Control Unit 70 LRU (Least Recently Used) Flag 71 LRU Control Unit 72 Tag Control Unit 73 Decrement Flag Control Unit 74 Valid Flag Control Unit 75 Cache Control Unit Internal Address Bus 76 Cache Control Unit Internal Data Bus 77 Memory Unit 78 Read Buffer 79 Selector

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

 複数のウェイがそれぞれタグを1個のみ備えるマイコンであって、第1アクセスと第2アクセスが互いに連続して実行され、連続するアドレスへのアクセスであり、第2アクセスが第1ウェイを介するアクセスであるとき、キャッシュ制御部は次の動作を行う。第2アクセスが第1アクセスに対してアドレスが増加する方向でのアクセスのときには、第1ウェイに対応するタグ値よりも1小さいタグ値を持つウェイに対してデータの先読みを行ない、アドレスが減少する方向でのアクセスのときには、第1ウェイに対応するタグ値よりも1大きいウェイに対してデータの先読みを行う。これにより、複数ウェイで構成されるキャッシュメモリにおいて、そのまま複数ウェイとして機能するか、2ウェイが互いのウェイの先読みデータの格納先として、1つのウェイとして機能するかを、アクセス履歴に応じて自律的に切り替えることができる。

Description

半導体装置及びキャッシュメモリへのデータ先読み方法
 本発明は、キャッシュメモリへのデータ先読み技術に関し、特にキャッシュメモリを備えた半導体装置に適用して有効な技術に関する。
 ICカード(Integrated Circuit Card)などに用いられるセキュアマイコンにおいて、近年、CPU(Central Processing Unit)の動作周波数が高まり、合せて大容量の不揮発メモリが搭載される傾向にある。CPUと大容量不揮発メモリの動作周波数の差が顕著となってきており、それを吸収するためにキャッシュメモリを搭載するものが増えてきている。しかし、ICカードなどでの利用を許容するために、回路規模や消費電力が極めて小さく制限されている。
 キャッシュメモリには、種々の方式が提案されている。例えば、命令キャッシュとデータキャッシュに分ける技術、キャッシュメモリを複数のウェイで構成する技術、命令コードを含むデータの先読みをする技術、などである。セキュアマイコンにおいても、このような技術の採用は有効であるが、一方、回路規模や消費電力に対する厳しい制約を満たす必要もある。
 特許文献1及び2には、キャッシュメモリにおけるデータの先読み技術が開示されている。特許文献1には、キャッシュミスが発生したとき、アクセス対象のデータを含むデータブロックを読込み、さらに、設定された隣接方向のデータブロックを先読みする技術が開示されている。設定される隣接方向は、アクセス履歴に追随して更新されるので、先読みの方向も追随させることができる。特許文献2には、複数ウェイのセットアソシャティブ方式のキャッシュメモリにおいて、次に読み出されると予想されるデータを予め複数のウェイのいずれから読み出されるかを予想して先読みしておき、実際のアクセスにおいて不要なウェイにアクセスすることを防止する技術が開示されている。
 特許文献3には、不揮発メモリにおいて、ロウアドレス系選択動作により1ページ分のデータを一括してプリリードキャッシュに読み出し、その後カラムアドレス系動作でその一部を選択して読み出す技術が開示されている。
特開平06-75853号公報 特開2005-84999号公報 特開2012-38385号公報
 特許文献1、2、及び3について本発明者が検討した結果、以下のような新たな課題があることがわかった。
 ICカードなどに用いられるセキュアマイコンにおいても、命令キャッシュとデータキャッシュに分ける技術、複数のウェイで構成する技術、及び、データの先読みをする技術は、有効であると考えられる。暗号技術では、長大なビット長の暗号鍵を使った暗号の復号演算などがあり、一連のデータの連続アクセスが予想されるので、先読み技術が有効である。認証のための照合処理では、2つのデータ系列からの連続アクセスが予想されるので、複数ウェイの採用が有効である。
 複数ウェイのキャッシュを採用した場合、暗号の復号演算などの一連のデータの連続アクセスでは、1つのウェイのみが使われ、他のウェイが使われない恐れがある。それぞれのウェイに容量の大きなメモリアレイを備えることができれば、大きな問題ではないが、1ウェイに不揮発メモリの1ブロック分(1ライン分)の容量のメモリアレイしか搭載できない場合には、データの先読みをしても次に先読みをするデータを格納すべき領域は残らない。1ライン毎に必ずキャッシュミスが発生し、キャッシュフィルのためオーバーヘッドが発生する。2ウェイ分の容量のメモリアレイを1ウェイとして用いれば、その1ウェイ内で先読みが実行でき、1ライン毎のキャッシュミスは発生しないが、2つのデータ系列からの連続アクセスの場合には、データアクセスごとにキャッシュミスが発生する。
 このような課題を解決するための手段を以下に説明するが、その他の課題と新規な特徴は、本明細書の記述及び添付図面から明らかになるであろう。
 本願において開示される発明のうち代表的なものについて簡単に説明すれば下記のとおりである。
 すなわち、プロセッサと、メモリと、互いに対応する複数のタグと複数のウェイとキャッシュ制御部を備える半導体装置であって、以下のような動作が可能に構成される。
 キャッシュ制御部は、第1アクセスと第2アクセスが互いに連続して実行される、連続するアドレスへのアクセスであり、第2アクセスが第1ウェイを介するアクセスであるとき、次の動作を行う。第2アクセスが第1アクセスに対してアドレスが増加する方向でのアクセスであるとき、第1ウェイに対応するタグ値よりも1小さいタグ値を持つウェイに対するデータの先読みを行う。第2アクセスが第1アクセスに対してアドレスが減少する方向でのアクセスであるとき、第1ウェイに対応するタグ値よりも1大きいウェイに対するデータの先読みを行う。
 本願において開示される発明のうち代表的なものによって得られる効果を簡単に説明すれば下記の通りである。
 すなわち、複数ウェイで構成されるキャッシュメモリにおいて、そのまま複数ウェイとして機能するか、2ウェイが互いのウェイの先読みデータの格納先として、1つのウェイとして機能するかを、アクセス履歴に応じて自律的に切り替えることができる。
図1は、一実施形態に係る半導体装置の動作例を表すフローチャートである。 図2は、一実施形態に係る半導体装置の構成例を表すブロック図である。 図3は、一実施形態に係る半導体装置の詳細な動作例を表すフローチャート(1/4)である。 図4は、一実施形態に係る半導体装置の詳細な動作例を表すフローチャート(2/4)である。 図5は、一実施形態に係る半導体装置の詳細な動作例を表すフローチャート(3/4)である。 図6は、一実施形態に係る半導体装置の詳細な動作例を表すフローチャート(4/4)である。 図7は、一実施形態に係る2ウェイのキャッシュが独立に動作する場合の動作例を表す説明図である。 図8は、一実施形態に係る2ウェイのキャッシュが互いに他の先読み対象となって1ウェイとして、アドレスがインクリメント方向(デクリメントフラグ=0)の先読み動作する場合の動作例を表す説明図である。 図9は、一実施形態に係る2ウェイのキャッシュが互いに他の先読み対象となって1ウェイとして、アドレスがデクリメント方向(デクリメントフラグ=1)の先読み動作する場合の動作例を表す説明図である。 図10は、比較例に係る半導体装置の動作例を表すタイミングチャート(1/4)である。 図11は、比較例に係る半導体装置の動作例を表すタイミングチャート(2/4)である。 図12は、比較例に係る半導体装置の動作例を表すタイミングチャート(3/4)である。 図13は、比較例に係る半導体装置の動作例を表すタイミングチャート(4/4)である。 図14は、2ウェイのキャッシュが互いに他の先読み対象となって1ウェイとして先読み動作する場合の動作例を表すタイミングチャート(1/3)である。 図15は、2ウェイのキャッシュが互いに他の先読み対象となって1ウェイとして先読み動作する場合の動作例を表すタイミングチャート(2/3)である。 図16は、2ウェイのキャッシュが互いに他の先読み対象となって1ウェイとして先読み動作する場合の動作例を表すタイミングチャート(3/3)である。 図17は、2ウェイのキャッシュがそれぞれ独立して動作する場合の動作例を表すタイミングチャート(1/2)である。 図18は、2ウェイのキャッシュがそれぞれ独立して動作する場合の動作例を表すタイミングチャート(2/2)である。
1.実施の形態の概要
 先ず、本願において開示される発明の代表的な実施の形態について概要を説明する。代表的な実施の形態についての概要説明で括弧を付して参照する図面中の参照符号はそれが付された構成要素の概念に含まれるものを例示するに過ぎない。
 〔1〕<逆方向に連続するタグ値を持つウェイへの先読み>
 プロセッサ(53)と、メモリ(55)と、複数のタグ(65)と、前記タグに格納されるタグ値を基準アドレスとして前記メモリの連続するアドレスの複数のデータをそれぞれ格納可能な複数のウェイ(64)と、キャッシュ制御部(63)を備える半導体装置(50)であって、以下の通り構成される。
 前記複数のウェイのそれぞれに、前記ウェイに対する直近の2回のアクセスがアドレスの増加または減少のどちらかの方向を示すアドレス変化方向フラグ(66)を設ける。
 前記キャッシュ制御部は、前記プロセッサから前記メモリに対して連続して行う第1アクセスと第2アクセスが互いに連続するアドレスへのアクセスであり(1)、前記第2アクセスが第1ウェイを介するアクセスであるとき、以下の条件を満たす第2ウェイに対して、所定の先読み動作を可能に構成される。前記条件とは、前記第1ウェイに対応するアドレス変化方向フラグと一致するアドレス変化方向フラグを持ち、前記第1ウェイに対応するタグ値に対して、前記アドレス変化方向フラグが示す方向と逆方向で連続するタグ値を持つこと(4)である。前記所定の先読み動作とは、前記第1ウェイに対応するタグ値に対して、前記アドレス変化方向フラグが示す方向で連続するタグ値で示されるデータの先読み(5)である。
 これにより、複数ウェイで構成されるキャッシュメモリにおいて、そのまま複数ウェイとして機能するか、2ウェイが互いのウェイの先読みデータの格納先として、1つのウェイとして機能するかを、アクセス履歴に応じて自律的に切り替えることができる。
 〔2〕<デクリメントフラグの更新>
 項1において、前記キャッシュ制御部は、前記第2アクセスが前記第1アクセスと同一のウェイで且つ同一のタグ値へのアクセスであるときに、前記第2アクセスの対象アドレスが前記第1アクセスの対象アドレスより小さいとき、前記アドレス変化方向フラグをセット(2)可能に構成される。
 これにより、アドレス変化方向フラグ(66)が、キャッシュメモリへのアクセス履歴に基づいて、キャッシュ制御部によって自律的にセット可能に構成することができる。
 〔3〕<ワード単位のキャッシュフィル>
 項1において、前記キャッシュ制御部は、キャッシュミスのとき、前記ウェイに格納されるデータの合計のデータ長の整数分の1のデータ長の単位で、キャッシュフィルを実行可能に構成される。
 これにより、キャッシュフィルのための消費電力を低く抑えることができる。
 〔4〕<バリッドフラグ>
 項3において、前記キャッシュ制御部は、前記複数のウェイのそれぞれに、前記キャッシュフィルのデータ長の単位ごとに、有効フラグ(67)を備え、キャッシュミスが発生したとき、キャッシュフィルの対象のウェイに対応する前記有効フラグを全てクリアし(23)、キャッシュフィルしたデータに対応する前記有効フラグをセット(25)可能に構成される。
 これにより、ウェイに格納される所定のデータ長のデータ単位で、キャッシュヒット/ミスを判定し、データの出力またはキャッシュフィルを行うことができる。
 〔5〕<バリッドフラグを使った同一ウェイ後方へのデータの先読み>
 項4において、前記キャッシュ制御部は、前記第2アクセスの後、前記第1ウェイに対応するアドレス変化方向フラグによって示される方向で、対応する前記有効フラグがセットされていない前記第1ウェイ内の領域へのデータの先読み(12、13、14)を可能に構成される。
 これにより、連続アクセスの状態が崩れ、連続方向とは逆のアドレス方向へのアクセスが実行されたときにも、同一ウェイ内のデータであればヒットするように、同一ウェイ後方(連続方向とは逆のアドレス方向)への先読みを実施することができる。
 〔6〕<同一ウェイのアドレス変化方向へのデータの先読み後、逆方向へのデータの先読み>
 項5において、前記キャッシュ制御部は、以下の動作を可能に構成される。
 前記第2ウェイに対応するアドレス変化方向フラグと前記第1ウェイに対応するアドレス変化方向フラグとが一致し、前記第2ウェイに対応するタグ値が前記第1ウェイに対応するタグ値に対して、前記アドレス変化方向フラグが示す方向と逆方向で連続するときに、前記第1ウェイ内の領域へのデータの先読みの後に、前記第2ウェイに対するデータの先読みを行う。
 前記第2ウェイに対応するアドレス変化方向フラグと前記第1ウェイに対応するアドレス変化方向フラグとが一致せず、または、前記第2ウェイに対応するタグ値が前記第1ウェイに対応するタグ値に対して、前記アドレス変化方向フラグが示す方向と逆方向で連続しないときに、以下の先読み動作を行う。前記第1ウェイ内の領域へのデータの先読みの後に、前記第1ウェイ内の前記第2アクセスの後、前記第1ウェイに対応するアドレス変化方向フラグによって示される方向と逆方向の、前記第1ウェイ内の領域へのデータの先読みを行う。
 これにより、2ウェイに跨って先読み動作を行う場合であっても、連続アクセスの状態が崩れ、連続方向とは逆のアドレス方向へのアクセスが実行されたときに、キャッシュミスの確率を減らすように、同一ウェイ後方(連続方向とは逆のアドレス方向)への先読みを実施することができる。
 〔7〕<先読み実行サイクルの隠蔽>
 項1において、前記プロセッサは、前記第2アクセスの終了後、前記キャッシュメモリが前記先読みを完了する前に、前記第2アクセスの後続のアクセスを実行可能に構成される。
 これにより、先読みを実行するためのサイクルを隠蔽することができ、単位時間あたりに実行される有効な命令サイクル数を増やすことができる。
 〔8〕<フルアソシアティブ>
 項1において、前記複数のウェイのそれぞれは、前記メモリの任意のアドレスのデータをキャッシュすることが可能に構成される。
 これにより、各ウェイは格納するデータのメモリでのアドレスに制約されることなく、任意のアドレスのデータもキャッシュすることができる。
 〔9〕<データキャッシュ>
 項1において、前記半導体装置は命令キャッシュをさらに備え、前記複数のウェイは、前記プロセッサに対するデータキャッシュである。
 これにより、データに特化したキャッシュを構成することができる。一般にデータは、命令と比較して連続アクセスの場合のアドレスの規則性が単純である。一連のデータの連続アクセスと、それぞれで連続する2系列のデータを交互にアクセスする場合が極めて多い。この特徴を踏まえて、キャッシュ回路、特にキャッシュ制御部を単純化することができる。
 〔10〕<データ先読み方法>
 プロセッサ(53)とメモリ(55)の間に設けられ、複数のタグ(65)と前記タグに格納されるタグ値を基準アドレスとして前記メモリの連続するアドレスの複数のデータをそれぞれ格納可能な複数のウェイ(64)とを備える、キャッシュメモリ(60)におけるデータ先読み方法であって、以下の各ステップを含んで構成される。
 前記プロセッサから前記メモリに対する第1アクセスと連続する第2アクセスが互いに連続するアドレスへのアクセスであるか否かを判定する第1ステップ(1)。
 前記第1ステップの判定結果が連続アドレスへのアクセスであるとき、前記第1アクセスと前記第2アクセスが前記複数のウェイのうちの同一ウェイに対する同一タグ値によるアクセスであるとき、前記ウェイに対する直近の2回のアクセスがアドレスの増加または減少のどちらの方向かを示すアドレス変化方向属性を付与する第2ステップ(2)。
 前記第2アクセスによって第1ウェイをアクセスする第3ステップ(3)。
 前記第1ウェイと同一のアドレス変化方向属性を持ち、前記第1ウェイのタグ値に対して、前記同一のアドレス変化方向属性が示す方向と逆方向に連続するタグ値を持つ第2ウェイの有無を判定する第4ステップ(4)。
 前記第4ステップの有の判定結果に基づいて、前記第2ウェイを対象として、前記アドレス変化方向属性が示す方向で連続するタグ値で示されるデータの先読みを行う、第5ステップ(5)。
 これにより、複数ウェイで構成されるキャッシュメモリにおいて、そのまま複数ウェイとして機能するか、2ウェイが互いのウェイの先読みデータの格納先として、1つのウェイとして機能するかを、アクセス履歴に応じて自律的に切り替えることができる。
 〔11〕<キャッシュヒット/ミスに関わらずにデータ先読み>
 項10において、前記第3ステップがキャッシュヒットかキャッシュミスかに関わらず、前記第4ステップは前記第3ステップの後に実行される(21、22…C2…4)。前記第3ステップがキャッシュミスであるときは、前記第3ステップは前記第1ウェイのタグ値を更新し(26)、前記第5ステップは更新された前記第1ウェイのタグ値に基づいて前記先読みを行うか否かの判定を行う。
 これにより、キャッシュミスによるオーバーヘッドの発生を防止することができる。キャッシュミスしてキャッシュフィルする場合に限らず、キャッシュヒットしている期間にもデータの先読みをするので、連続アクセスの間、継続的にキャッシュヒットさせることができる。例えば、一方のウェイにヒットしている期間の空きサイクルに、他方のウェイの先読みを行うような動作により、常時どちらかのウェイにキャッシュヒットさせることができる。
 〔12〕<デクリメントフラグの更新>
 項10において、前記第1ステップは、前記第2アクセスが前記第1アクセスと同一のウェイで且つ同一のタグ値へのアクセスであるときに(17)、前記第2アクセスの対象アドレスが前記第1アクセスの対象アドレスより小さいとき(18)、前記アドレス変化方向属性としてアドレス減少方向をセットする(20)。
 これにより、アドレス変化方向属性が、キャッシュメモリへのアクセス履歴に基づいて、キャッシュ制御部によって自律的にセット可能に構成することができる。
 〔13〕<ワード単位のキャッシュフィル>
 項10において、前記第3ステップは、キャッシュミスのとき、前記ウェイに格納されるデータの合計のデータ長の整数分の1のデータ長の単位で、キャッシュフィルを行う。
 これにより、キャッシュフィルのための消費電力を低く抑えることができる。
 〔14〕<バリッドフラグ>
 項13において、前記複数のウェイのそれぞれは、前記キャッシュフィルのデータ長の単位ごとに、有効フラグ(67)を備え、前記第3ステップでキャッシュミスが発生したとき、キャッシュフィルの対象のウェイに対応する前記有効フラグを全てクリアし(23)、キャッシュフィルしたデータに対応する前記有効フラグをセットする(25)。
 これにより、ウェイに格納される所定のデータ長のデータ単位で、キャッシュヒット/ミスを判定し、データの出力またはキャッシュフィルを行うことができる。
 〔15〕<バリッドフラグを使った同一ウェイ後方へのデータの先読み>
 項14において、前記第3ステップの後、前記第1ウェイに対応するアドレス変化方向属性によって示される方向で、対応する前記有効フラグがセットされていない前記第1ウェイ内の領域へのデータの先読みを行う、第6ステップ(13)をさらに含む。
 これにより、連続アクセスの状態が崩れ、連続方向とは逆のアドレス方向へのアクセスが実行されたときにも、同一ウェイ内のデータであればヒットするように、同一ウェイ後方(連続方向とは逆のアドレス方向)への先読みを実施することができる。
 〔16〕<同一ウェイのアドレス変化方向へのデータの先読み後、逆方向へのデータの先読み>
 項15において、前記第6ステップの後で前記第4ステップを実行し、前記第4ステップの無の判定結果に基づいて、前記第1ウェイに対応するアドレス変化方向属性によって示される方向と逆の方向で、対応する前記有効フラグがセットされていない前記第1ウェイ内の領域へのデータの先読みを行うために、第6ステップ(13)を繰り返すループをさらに含む、データ先読み方法。
 これにより、2ウェイに跨って先読み動作を行う場合であっても、連続アクセスの状態が崩れ、連続方向とは逆のアドレス方向へのアクセスが実行されたときに、キャッシュミスの確率を減らすように、同一ウェイ後方(連続方向とは逆のアドレス方向)への先読みを実施することができる。
 〔17〕<逆方向に連続するタグ値を持つウェイへの先読み>
 プロセッサ(53)と、メモリ(55)と、互いに1:1対応する複数のタグ(65)と複数のウェイ(64)とキャッシュ制御部(63)を備える半導体装置(50)であって、以下のように構成される。
 前記プロセッサから前記メモリに対する第1アクセスと第2アクセスが互いに連続して実行され、連続するアドレスへのアクセスであり、前記第2アクセスが第1ウェイを介するアクセスであるとき(1)、以下の動作を可能に構成される。
 前記キャッシュ制御部は、前記第2アクセスが前記第1アクセスに対してアドレスが増加する方向でのアクセスであるときには、前記第1ウェイに対応するタグ値よりも1小さいタグ値を持つウェイに対するデータの先読み行う(4、40)。前記第2アクセスが前記第1アクセスに対してアドレスが減少する方向でのアクセスであるときには、前記第1ウェイに対応するタグ値よりも1大きいウェイに対するデータの先読みを行う(4、45)。
 これにより、複数ウェイで構成されるキャッシュメモリにおいて、そのまま複数ウェイとして機能するか、2ウェイが互いのウェイの先読みデータの格納先として、1つのウェイとして機能するかを、アクセス履歴に応じて自律的に切り替えることができる。
 2.実施の形態の詳細
 実施の形態について更に詳述する。なお、発明を実施するための形態を説明するための全図において、同一の機能を有する要素には同一の符号を付して、その繰り返しの説明を省略する。
 〔実施形態の概要〕
 図2は、一実施形態に係る半導体装置の構成例を表すブロック図である。
 一実施形態に係る半導体装置には、プロセッサ53とメモリ55の間にキャッシュメモリ60が設けられている。メモリ55は例えばフラッシュメモリなどの不揮発メモリであって良く、プロセッサ53のメモリ空間に割り付けられる如何なるメモリであっても良い。キャッシュメモリ60は、命令キャッシュ62とデータキャッシュ61を含む。データキャッシュ61は、複数のタグ65_0~65_3とそのタグに格納されるタグ値を基準アドレスとしてメモリ55の連続するアドレスの複数のデータをそれぞれ格納可能な複数のウェイ64_0~64_3とを備える。タグ65_0~65_3とウェイ64_0~64_3とは1:1に対応付けられ、タグ65_0に格納されるタグ値を起点として、例えば16アドレス分のデータD0~D7がウェイ64_0に格納される。ウェイとタグの数は任意で、少なくとも2組あれば良い。1個のウェイに格納されるデータの数、1データ当たりのデータ長(ビット長)も任意である。プロセッサ53からのアクセス単位や、キャッシュ対象の不揮発メモリ55とのインターフェースを考慮して適切に決めることができる。図2には、他の構成要素も描かれているが、それらについては後述する。
 図1は、一実施形態に係る半導体装置の動作例を表すフローチャートである。
 プロセッサ53から不揮発メモリ55に対するアクセスである、データリード要求があると、そのデータリード要求と直前のデータリード要求が互いに連続するアドレスへのデータリード要求であるか否かを判定する(ステップ1)。その結果、連続アドレスへのデータリード要求であると判定されたとき、連続する2回のデータリード要求が同一ウェイに対する同一タグ値によるアクセスであるとき、そのウェイに対する直近の2回のアクセスがアドレスの増加または減少のどちらの方向かを示すアドレス変化方向属性を付与する(ステップ2)。今回のデータリード要求によってそのウェイ(アクセス対象ウェイ)をアクセスする(ステップ3)。
 次に、ステップ3でアクセスされたウェイ(アクセス対象ウェイ)と同一のアドレス変化方向属性を持ち、アクセス対象ウェイのタグ値に対して、そのアドレス変化方向属性が示す方向と逆方向に連続するタグ値を持つ別のウェイ(先読み対象ウェイ)の有無を判定する(ステップ4)。前記第4ステップの有の判定結果に基づいて、先読み対象ウェイに対して、アクセス対象ウェイのアドレス変化方向属性が示す方向で連続するタグ値で示されるデータの先読みを行う(ステップ5)。
 これにより、複数ウェイで構成されるキャッシュメモリにおいて、そのまま複数ウェイとして機能するか、2ウェイが互いのウェイの先読みデータの格納先として、1つのウェイとして機能するかを、アクセス履歴に応じて自律的に切り替えることができる。
 動作原理の理解を助けるために、ウェイが2個の場合を考える。ウェイ0(64_0)とタグ0(65_0)が対応し、ウェイ1(64_1)とタグ1(65_1)が対応する。今、ウェイ0(64_0)へのアクセスがアドレスAからのリードであるとき、まず、ウェイ0(64_0)にアドレス変化方向属性を付与する(ステップ2)。ウェイ0(64_0)への直前のアクセスがアドレスA-1へのアクセスであった場合は、アドレスは増加方向であり、逆に直前のアクセスがアドレスA+1へのアクセスであった場合は、アドレスは減少方向である。アドレス変化方向属性は各ウェイに付与される。ウェイ0(64_0)に対応するタグ0(65_0)には、アドレスAの上位アドレスが格納される。ウェイ0(64_0)に対するアクセスが、キャッシュミスであったときは、キャッシュフィルにより、タグ0(65_0)には、アドレスAの上位アドレスが格納される。
 次に、先読みに適するウェイを探索する。今、ウェイが2個のみの場合を仮定しているので、アクセス対象のウェイ0(64_0)に対し、ウェイ1(64_1)が先読み対象として適するか否かの判定をする場合について考える。判定の条件は、同一のアドレス変化方向属性を持ち、アクセス対象ウェイのタグ値に対して、そのアドレス変化方向属性が示す方向と逆方向に連続するタグ値を持つか否かである(ステップ4)。ウェイ1(64_1)がウェイ0(64_0)と同一のアドレス変化方向属性を持つとは、どちらのウェイも同じアドレスの変化方向で連続アクセスされてきたという、アクセス履歴を反映したものである。さらに、ウェイ1(64_1)に対応するタグ1(65_1)が、そのアドレス変化方向属性が示す方向と逆方向に、ウェイ0(64_0)に対応するタグ0(65_0)に格納されるタグ値と連続するタグ値を持つとは、ウェイ1(64_1)が既にアクセスされたウェイであることを示すものである。したがって、この条件を満たせば、ウェイ1(64_1)は同じ系列のデータで連続してアクセスされてきており、既にアクセスされたウェイである可能性が高い。したがって、ウェイ1(64_1)は再度アクセスされる確率は低く、ウェイ0(64_0)へのアクセスに続く先読み対象として適するものであると判断できる。そこで、ウェイ1(64_1)を先読みの対象として、そのアドレス変化方向属性が示す方向にデータの先読みを実行する(ステップ5)。例えば、アドレス変化方向が増加方向で、タグ0(65_0)にアドレスAの上位アドレスであるA’がタグ値として格納されているとき、ウェイ1(64_1)が同じデータ系列の一連のアクセスで既にアクセスされたウェイである場合には、対応するタグ1(65_1)には、A’-1が格納されているはずである。逆に、この条件が満たされない場合には、ウェイ1(64_1)は別のアドレス領域に格納されている別の系列のデータをキャッシュするために使われている可能性が高い。そのため、先読み対象としては適切でなく、先読みは実行されない。
 このように、本実施形態では、アドレス変化方向属性とタグ値が連続しているか否かに基づいて、先読み対象として適切なウェイか否かを判定している。先読み対象に適するウェイがあれば、アクセス対象のウェイと先読み対象のウェイを組合せて、あたかも先読み機能を備えた1つのウェイとして機能させる。一方、先読み対象に適するウェイがなければ、各ウェイは独立のウェイとして、本来の複数ウェイのとして機能させる。一般にデータの先読みをすべきか否かの判断は、アクセス履歴に基づいて行われる。本実施形態では、タグ値がアクセス履歴を反映している点に着目し、その方向を示すアドレス変化方向属性を付与するだけで、外部からの特別な制御を受けずに、キャッシュ制御部が自律的に判断して、ウェイの先読み機能を切り替えている。キャッシュ回路はアクセス履歴を、アドレス変化方向属性とタグ値が連続しているか否かという情報に集約して保持しているので、自律的に判断することができる。
 ここで注意すべきは、1つのウェイに複数のタグを備えるのではなく、ウェイとタグが1:1に対応付けられる点である。換言すれば、1つのウェイが1ラインとそれに対応する1個のタグのみで構成される。最小限2ライン分のキャッシュを備えれば、それを、先読み機能を持つ1ウェイキャッシュまたは2ウェイのキャッシュのいずれかとして自律的に切り替えながら機能させることができる。本実施形態は、大規模なキャッシュ回路ではなく、ICカードなどに搭載可能なセキュアマイコンなどの、回路規模と消費電力に対して極めて厳しい要求があるような、小型かつ低消費電力のキャッシュ回路に適用すると、特に有効である。
 〔実施形態(構成例)〕
 図2は、一実施形態に係る半導体装置の構成例を表すブロック図である。実施形態の概要で説明したよりも、より詳細な構成例について説明する。本実施形態に係る半導体装置50は、例えば、ICカードに用いられるマイコン50であって、単一の半導体基板上に公知の半導体製造技術を用いて形成され、或いは、不揮発メモリ55などを別チップとしたマルチチップモジュールとして形成される。本実施形態は、半導体装置の実装方法によって制限されるものではない。
 マイコン50は、アドレスバス51とデータバス52を介して互いに接続される、CPU53、DMAC54、ROM56、RAM57、周辺モジュール58を備える。DMAC(Direct Memory Access Controller)54は、CPU53によって設定される転送パラメータに基づいて、CPUとは独立にメモリにアクセスしてデータ転送を実行することができる。ROM(Read Only Memory)56とRAM(Random Access Memory)57はメモリであり、ROM57はCPU53で実行されるプログラムの命令コードやデータの初期値を格納し、RAM57はプログラムで使われる変数の値を格納する。周辺モジュール58は、例えば、タイマモジュールや通信インターフェースモジュールである。この他、図示されないバス調停回路、割り込み制御回路などを備えることができる。
 不揮発メモリ55は、キャッシュメモリ60を介して、アドレスバス51とデータバス52に接続されており、CPU53、DMAC54などのバスマスタからアクセスされることができる。不揮発メモリ55とキャッシュメモリ60は、専用のアドレスバス51_1とデータバス52_1を介して、相互に接続されている。
 不揮発メモリ55は、例えば、フラッシュメモリ、相変化メモリ、強誘電体メモリ、などの不揮発メモリである。不揮発メモリ55は、CPU53のメモリ空間に割り付けられている如何なる記憶素子にも置き換えることができる。DRAM、SDRAMなどの揮発メモリであってもよく、半導体以外のメモリであっても良い。不揮発メモリ55は、例えば、リードバッファ78とセレクタ79を備えて構成される。アドレスバス51_1の上位ビットで指定されるアドレスのデータをメモリ部77から読み出してリードバッファ78に一時格納し、そのうちの一部をセレクタ79で選択してデータバス52_1に出力する。リードバッファ78の大きさは、メモリ部77において1本のワード線に接続されるメモリセルのビット数と一致させることにより、不揮発メモリ55のアクセスのための消費電力を低く抑えることができる。さらに、特許文献3に記載される、プリリードキャッシュを備えると、消費電力低減をより効果的に実現することができ好適である。本実施形態では、特に制限されないが、リードバッファ78は16バイトとし、データバス52_1は4バイトとして説明する。
 キャッシュメモリ60は、データキャッシュ61と命令キャッシュ62とキャッシュ制御部63とを含む。データキャッシュ61には、4個のウェイ64_0~64_3を備える。各ウェイには、それぞれ、タグ65_0~65_3、デクリメントフラグ66_0~66_3、バリッドフラグ67_0~67_3が対応付けられる。キャッシュの制御には、例えば、LRU(Least Recently Used)方式を採用することができる。キャッシュミスが発生したときに、最も過去に使われた(Least Recently Used)ウェイにキャッシュフィルを行う方式である。キャッシュ制御部63には、アドレス制御部68とデータ制御部69とが設けられ、アドレスバス51とデータバス52を介したCPU53などとのアクセスコマンドのインターフェース、及び、不揮発メモリ55とのインターフェースを制御する。キャッシュ制御部63はさらに、LRUフラグ70とLRU制御部71、タグ制御部72、デクリメントフラグ制御部73、及び、バリッドフラグ制御部74を備え、データキャッシュのタグ65_0~65_3、デクリメントフラグ66_0~66_3、及び、バリッドフラグ67_0~67_3を制御する。LRU制御部71、タグ制御部72、デクリメントフラグ制御部73、及び、バリッドフラグ制御部74は、内部アドレスバス75_1と内部データバス76_1に接続されている。
 ウェイ64_0~64_3は、それぞれ、複数のデータを保持することができる。各ウェイ内のデータは、アドレスの連続するデータで構成される。ウェイに格納されるデータのアドレスに共通する上位アドレスが対応するタグに格納される。本実施形態では、1アドレス当たりのデータを1バイト(8ビット)とし、ウェイを構成するデータのビット長は2バイト(16ビット)として説明する。各ウェイには2バイトのデータを8個格納することができ、アドレスの下位4ビットを除く上位ビットが、タグ値に対応する。データバス52は2バイトの幅を持つとする。キャッシュはフルアソシアティブ方式とすることができる。各ウェイに格納されるデータは、CPU53のメモリ空間のどこのアドレスでも良い。
 デクリメントフラグ66_0~66_3は、各ウェイ64_0~64_3へのアクセスが同じウェイへの直前のアクセスに対して、アドレスの増加方向のアクセスか、減少方向のアクセスかを示すフラグである。ウェイごとに設けられる。バリッドフラグ67_0~67_3は、各ウェイ64_0~64_3のデータが有効か否かを表すフラグである。ウェイ64_0~64_3を構成するデータに対して、1回のキャッシュフィルのデータサイズごとに1ビットのフラグを備える。例えば、ウェイ64_0~64_3を構成するデータD0~D7がそれぞれ2バイト(16ビット)のデータであるとし、4バイト(32ビット)ごとにキャッシュフィルされるとき、4バイトごとに1ビットのフラグを備え、各フラグを合計4ビットV0~V4で構成する。本実施形態では、アドレスが1バイト毎に割り付けられているので、2バイトのデータリード要求であれば、アドレスが偶数で連続することを、連続アドレスと呼び、4バイトのデータリード要求であれば、アドレスが4の倍数で連続することを、連続アドレスと呼ぶ。
 データと命令のそれぞれにキャッシュを設けることにより、それぞれに特化したキャッシュ方式を採用することができる。一般にデータは、命令と比較して連続アクセスの場合のアドレスの規則性が単純である。一連のデータの連続アクセスと、それぞれで連続する2系列のデータを交互にアクセスする場合が極めて多い。この特徴を踏まえて、キャッシュ回路、特にキャッシュ制御部を単純化することができる。この実施形態では4ウェイの例を示したが、2ウェイとすることができる。最小限2ウェイを備えれば、一連のデータの連続アクセスと、それぞれで連続する2系列のデータを交互にアクセスする場合とに対応することができる。一方、データと命令を区別せず、1つのキャッシュメモリにキャッシュする構成とすることもできる。その場合は、ウェイ数を多くすることにより、動作状態においてデータをキャッシュするウェイと命令をキャッシュするウェイに分かれることが期待される。制御が一元化される点でメリットがある。データキャッシュについて採用した実施形態について説明しているが、同様の構成を命令キャッシュに採用することもできる。各ウェイは、フルアソシアティブとすることができる。これにより、各ウェイは格納するデータのメモリでのアドレスに制約されることなく、任意のアドレスのデータもキャッシュすることができる。
 キャッシュフィルのビット長は、例えば4バイトとすることができる。これにより、内部データバス76_1及びそれに接続される、LRU制御部71、タグ制御部72、デクリメントフラグ制御部73、及び、バリッドフラグ制御部74のインターフェース回路は、それぞれ4バイトずつ備えればよい。これにより、回路規模を抑え、消費電力を低減することができる。また、ウェイに格納される4バイト単位で、キャッシュヒット/ミスを判定し、データの出力またはキャッシュフィルを行うことができる。一方、ウェイごとに備えるデータ数を、不揮発メモリの1ワード線に接続されるデータ数と一致させることもできる。この場合には、不揮発メモリ55に備えるリードバッファ78とセレクタ79を不要とし、1本のワード線から読み出されるデータを一括してウェイにフィルすることができ、キャッシュフィルの高速化を図ることができる。この時のバリッドフラグは、ウェイごとに1ビットとすることができる。また、バリッドフラグを備えない構成も可能とすることができる。キャッシュフィルのビット長は、以上のような回路規模、消費電力、及びキャッシュフィルの速度を勘案して、適切に設計することができる。
 〔動作フロー〕
 図2に示した半導体装置の詳細な動作例について説明する。図3、図4、図5及び図6は、一実施形態に係る半導体装置の詳細な動作例を表すフローチャートである。
 CPU53またはDMAC54などのバスマスタから、アドレスバス51とデータバスに52を介してバスコマンドが発行されると、キャッシュメモリ60のキャッシュ制御部63は、そのバスコマンドが命令フェッチであるのか、データアクセスであるのか、特に不揮発メモリ55へのデータリード要求であるか否かを判定する(ステップ11)。不揮発メモリ55へのデータリード要求でない場合には、キャッシュの全ウェイ64_0~64_3の全データ領域が全て有効か否かを判定する(ステップ12)。バリッドフラグ67_0~67_3のそれぞれを構成するV0~V4のうち、1がセットされていないフラグの有無を判定する。有効ではないデータが存在するとき、即ち、バリッドフラグ67_0~67_3のそれぞれを構成するV0~V4のうち、1がセットされていないフラグがあるとき、不揮発メモリ55からデータをリードし、そのデータ領域にライトする(ステップ13)。ライトしたウェイのデータ領域に対応するバリッドフラグを1にセットする(ステップ14)。これにより、バスコマンドが発行されていない期間を有向に利用して、データの先読み、もしくは同じタグで示されるウェイの先読み方向とは逆方向のデータ(後方のデータ)を、事前に予備的に読み込んでおくことができ、キャッシュミスの確率を減らすことができる。
 発行されたバスコマンドが、不揮発メモリ55へのデータリード要求である場合には(ステップ11)、キャッシュメモリ60のキャッシュ制御部63は、そのバスコマンドのアドレスを取り込み(ステップ15)、今回のリード要求のアドレスが、直前のリード要求のアドレスと連続しているか否かを判定する(ステップ16)。連続している場合には、ウェイにアドレス変化方向属性を付与するステップ2に進み、連続していない場合は、ウェイにアクセスするステップ3に進む。図3と図4にはコネクタC2として表示する。
 ウェイにアドレス変化方向属性を付与するステップ2では、デクリメントフラグ66_0~66_3の設定と更新を行う。今回のリード要求のアドレスがキャッシュのいずれか1つのウェイのタグと一致するか否かの判定を行う(ステップ17)。一致しない場合は、ウェイにアクセスするステップ3に進む。図3と図4にはコネクタC2として表示する。タグ値が一致したウェイがあれば、連続アクセスのアドレスがインクリメント方向かデクリメント方向かを判定する(ステップ18)。その結果、インクリメント方向であれば対象ウェイのデクリメントフラグに0を設定し(ステップ19)、デクリメント方向であれば対象ウェイのデクリメントフラグに1を設定する(ステップ20)。その後、ウェイにアクセスするステップ3に進む。図3と図4にはコネクタC3として表示する。
 連続アクセスでない場合(ステップ16)、または、連続アクセスであっても、今回のリード要求のアドレスと一致するタグ値を持つウェイがない場合(ステップ17)は、コネクタC2を経由して、ウェイにアクセスするステップ3に進む(図4)。まずキャッシュヒットか否かを判定する(ステップ22)。キャッシュヒットの場合は、ヒットしたウェイが最新になるようにLRUフラグ70を更新し(ステップ33)、ヒットしたウェイからリードデータを出力する(ステップ34)。キャッシュミスした場合は、LRUフラグ70によって指示される、最も古いデータを格納しているウェイにキャッシュフィルを行う。具体的には、最も古いデータを格納しているウェイのバリッドフラグの全ビット(V0~V3)を0にクリアし(ステップ23)、不揮発メモリ55からデータを読みこんで対象のウェイのデータ領域に書き込み(ステップ24)、書き込んだウェイのデータ領域に対応するバリッドフラグを1にセットする(ステップ25)。次に、書き込んだウェイのタグにアクセス対象のアドレスを設定し(ステップ26)、データを書き込んだウェイが最新になるようにLRUフラグ70を更新する(ステップ27)。データを書き込んだウェイからリードデータを出力する(ステップ28)。
 図3に示した、ウェイにアドレス変化方向属性を付与するステップ2を経て、ウェイにアクセスするステップ3にコネクタ3を経由して進んだ場合も、まず、キャッシュヒットか否かの判定を行う(ステップ21)。キャッシュヒットの場合は、ヒットしたウェイが最新になるようにLRUフラグ70を更新し(ステップ33)、ヒットしたウェイからリードデータを出力する(ステップ34)。キャッシュミスの場合であっても、ステップ17において、今回のリード要求のアドレスと同一のタグ値を持つウェイがあることがわかっているので、その対象のウェイのデータ領域に、不揮発メモリ55からのデータを書き込む(ステップ29)。これは、リード要求のアドレスと同一のタグ値を持つウェイはあるが、アクセス対象アドレスのデータは有効でない(バリッドフラグがセットされていない)場合のフローである。不揮発メモリ55からデータを読みこんで対象のウェイのデータ領域に書き込んだ後(ステップ29)、書き込んだウェイのデータ領域に対応するバリッドフラグを1にセットする(ステップ30)。次に、書き込んだウェイのタグにアクセス対象のアドレスを設定し(ステップ26)、データを書き込んだウェイが最新になるようにLRUフラグ70を更新する(ステップ27)。データを書き込んだウェイからリードデータを出力する(ステップ28)。以上示したように、今回のリード要求がキャッシュヒットかキャッシュミスかに関わらず、コネクタC4を経て図5に示す、先読みに適するウェイがあるか否かについての判定ステップに進む。
 まず、アクセスしたウェイのデータ領域を起点に、デクリメントフラグが示す方向のデータ領域はフィルされているかを判定する(ステップ35)。アクセスされたウェイのデクリメントフラグが0の場合、アクセスされたデータ領域からアドレスの増加方向のバリッドフラグのうち、0クリアされたものがないかを調べる。アクセスされたウェイのデクリメントフラグが1の場合、アクセスされたデータ領域からアドレスの減少方向のバリッドフラグのうち、0クリアされたものがないかを調べる。バリッドフラグが1に設定されていないデータ領域があれば、不揮発メモリ55からデータを読込み、対象のウェイのそのデータ領域に書き込み(ステップ36)、書き込んだウェイのデータ領域に対応するバリッドフラグ70に1をセットする(ステップ37)。この操作は、アクセスされたデータ領域を起点に、デクリメントフラグが示す方向のウェイの末端までの全てのデータ領域に、有効なデータが書き込まれる(フィルされる)まで、繰り返される。
 次に、最新のウェイとデクリメントフラグの値が一致し、且つ、デクリメントフラグが示す方向と逆方向に連続したタグ値を持つウェイを探索する(ステップ4)。もしなければ、不揮発メモリ55へのデータリード有無を判定するステップ11に戻る(図ではコネクタC1によって接続されるフローとして示す)。一方、そのような条件を満たすウェイ64があれば、コネクタC5を経由して、図6に示すデータの先読みステップに進む。
 まず、最新のウェイと上記条件が一致したウェイのデクリメントフラグの値を調べ(ステップ38)、最新のウェイと上記条件を満たしたウェイのデクリメントフラグの値が共に0の場合、ステップ39に進む。上記条件を満たしたウェイは、先読みデータを書き込むのに適したウェイと判定されたウェイである。条件が一致したウェイのタグ値を、最新のウェイのタグ値+1ライン分の値に更新する(ステップ39)。先読み対象のウェイのデータ領域が、デクリメントフラグが示す方向、即ちアドレスの増加方向に全てフィルされていなければ、不揮発メモリから読み込むデータのアドレスをインクリメントし(ステップ43)、次のデータを不揮発メモリ55から転送し(ステップ40)、対応するデータ領域のバリッドフラグに1をセットする(ステップ41)。先読み対象のウェイのデータ領域が、デクリメントフラグが示す方向に全てフィルされるまで(ステップ42)、ステップ40からステップ43の操作を繰り返す。
 最新のウェイと上記条件が一致したウェイのデクリメントフラグの値を調べ(ステップ38)、最新のウェイと上記条件を満たしたウェイのデクリメントフラグの値が共に1の場合、ステップ44に進む。上記条件を満たしたウェイもまた、先読みデータを書き込むのに適したウェイと判定されたウェイである。上記条件が一致したウェイのタグ値を、最新のウェイのタグ値-1ライン分の値に更新する(ステップ44)。先読み対象のウェイのデータ領域が、デクリメントフラグが示す方向、即ちアドレスの減少方向に全てフィルされていなければ、不揮発メモリから読み込むデータのアドレスをデクリメントし(ステップ48)、次のデータを不揮発メモリ55から転送し(ステップ45)、対応するデータ領域のバリッドフラグ67に1をセットする(ステップ46)。先読み対象のウェイのデータ領域が、デクリメントフラグが示す方向に全てフィルされるまで(ステップ47)、ステップ45からステップ48の操作を繰り返す。
 先読み対象のウェイの全てのデータ領域にデータがフィルされたときは(ステップ42、47)、不揮発メモリ55へのデータリード有無を判定するステップ11に戻る(図ではコネクタC1によって接続されるフローとして示す)。
 以上述べたように、先読みデータを書き込むのに適したウェイがあれば、そのウェイは、アクセス対象のウェイに対して先読みデータを書き込むために使われる。その後、そのままデクリメントフラグ66が示す方向で連続アクセスが続き、先読み対象のウェイがアクセス対象になった時点では、アクセス対象だったウェイが、先読みデータを書き込むのに適したウェイとしての条件を満たすこととなる。2つのウェイの間で、互いにアクセス対象と先読み対象の関係を入れ替えながら、継続的に先読みを続けることができる。これは、ステップ3においてキャッシュヒットであってもキャッシュミスであっても、次の先読みデータを書き込むのに適したウェイの判定ステップに進むように構成されているため、キャッシュヒットが続いても先読みが実行されるためである。
 本実施形態に示したように、4個のウェイで構成した場合であっても、2個のウェイがあれば、上記のように一連のデータの連続アクセスに当たって、継続的にキャッシュヒットし続けるように動作させることができる。即ち、2個のウェイを組合せて、キャッシュミスによるオーバーヘッドが発生しないように、先読みを継続する1個のウェイとして機能させることができる。このとき、この2個のウェイは、条件を満たさなくなると自律的に2個の独立したウェイに戻る。全体を4ウェイで構成した場合、他の2個のウェイもまた、先読みを継続する1個のウェイとして機能させることもできるし、2個の独立したウェイとして機能させることもできる。先読みを継続する1個のウェイとして機能させるか、2個の独立したウェイとして機能させるかの切り替えは、デクリメントフラグとタグ値の比較のみによって行われる。一般にデータの先読みをすべきか否かの判断は、アクセス履歴に基づいて行われる。本実施形態では、タグ値がアクセス履歴を反映している点に着目し、その方向を示すデクリメントフラグを新たに設けるだけで、外部からの制御を受けずに、キャッシュ制御部が自律的に判断して切り替えることができる。
 〔動作例〕
 本実施形態の動作例について説明する。図7は、2ウェイのキャッシュが独立に動作する場合の動作例を表す説明図である。図8は、2ウェイのキャッシュが互いに他の先読み対象となって1ウェイとして、アドレスがインクリメント方向(デクリメントフラグ=0)に先読み動作する場合の動作例を表す説明図である。図9は、2ウェイのキャッシュが互いに他の先読み対象となって1ウェイとして、アドレスがデクリメント方向(デクリメントフラグ=1)に先読み動作する場合の動作例を表す説明図である。それぞれウェイ数が2の場合を例示する。ウェイ数が3以上であっても、同様に作用する。2個のウェイ64_0、64_1はそれぞれ、8個の2バイトデータD0~D7を保持し、対応するタグ65_0、65_1、及び、デクリメントフラグ66_0、66_1を備える。データ2個(4バイト)に対して1ビットのバリッドフラグV0~V3が設けられている。LRUフラグ70は、WAY0またはWAY1のいずれか最も過去にアクセスされたウェイを示す。アドレスは1バイトのデータに対して1アドレスが割り付けられており、8個の2バイトデータD0~D7は16アドレス分のデータに相当する。タグには下位4ビットよりも上位のアドレス値がタグ値として格納される。D0はタグ値を基準にタグ値の下の下位4ビットに0x0を付加したアドレスに対応するデータが格納される。D2,D3,D4・・・D7は、それぞれ、タグ値に0x2、0x4、0x8、・・・0xEを付加したアドレスに対応するデータが格納される。図7、図8、図9のそれぞれにおいて、アドレス0x002008のデータリードが要求された場合を例に採り、各図の上側にはアクセス前の状態を、各図の下側にはアクセス後の状態を、それぞれ模式的に示す。アドレス0x002008に対応するタグ値は、0x00200であり、アドレス0x002008のデータは、D4の位置に格納されることになる。ここで、「0x」は後続の数値が16進表記であることを示す記号である。
 図7において、アクセス前は、ウェイ0(64_0)のD2とD3のみが有効で、バリッドフラグV1に1がセットされ他のバリッドフラグV0,V2,V3は0にクリアされている。タグ65_0には0x0011Cが格納されている。ウェイ1(64_1)はD0,D1,D2,D3が有効で、バリッドフラグV0,V1に1がセットされ、他のバリッドフラグV2,V3は0にクリアされている。タグ65_1には0x00324が格納されている。
 アドレス0x002008のデータリードが要求されると、いずれのウェイにもヒットしない。アドレス0x002008に対応するタグ値は0x00200であり、タグ65_0、65_1に格納されているタグ値とも異なるため、キャッシュミスと判定される(ステップ17、ステップ22)。LRUフラグ70はウェイ0を指しているので、ウェイ0に対してキャッシュフィルを行う(ステップ23~28)。ウェイ0(64_0)のバリッドフラグV0~V3を全て0にクリアする(ステップ23)。不揮発メモリのアドレス0x002008からデータを読込み、ウェイ0(64_0)のD4とD5に書き込む(ステップ24)。対応するバリッドフラグV2に1をセットする(ステップ25)。タグ65_0に0x00200をセットする(ステップ26)。LRUフラグをWAY1に変更する(ステップ27)。キャッシュフィルした、ウェイ0(64_0)のD4からデータを出力する(ステップ28)。その後、データの先読みは、D6,D7に進む。データの先読みが行われると、バリッドフラグ67_0のV3に1がセットされる。デクリメントフラグ66_0が示すアドレスの増加方向での先読みが終了したとき、ステップ4の条件判定を行う。デクリメントフラグ66_0と66_1は増加方向で一致している。ウェイ1のタグ65_1は0x00324であって、デクリメントフラグ66_0と66_1とは逆方向の減少方向で、ウェイ0のタグ値0x00200と連続したタグ値0x001FFとは異なる。よって、ウェイ1は先読みの対象としては適切でないと判定されることとなる(ステップ4)。ウェイ1(64_1)のデータは保持され、タグ65_1と一致しデータの有効なD0~D3に対するアクセスがあった場合に、キャッシュヒットする。ウェイ1(64_1)はウェイ0(64_0)とは独立のウェイとして機能する。
 ウェイ0(64_0)のD4とD5がキャッシュフィルされ、D6とD7に先読みデータが書き込まれた時点では、ウェイ0(64_0)のD0~D3のバリッドフラグV0とV1は0にクリアされたままである。これ以降、空きサイクルを使って、ステップ12、13、14によって、ウェイ0(64_0)のD0~D3のデータが読み込まれる。D0~D3のデータはキャッシュフィルされたアドレス0x002008のデータから見て、デクリメントフラグ66_0が示すアドレスの増加方向とは逆方向のデータである。先読み方向とは逆方向のデータを、空きサイクルを利用してキャッシュに読み込んでおくことにより、連続アクセスの状態が崩れ、連続方向とは逆のアドレス方向へのアクセスが実行されたときにも、同一ウェイ内のデータであればキャッシュヒットさせることができ、キャッシュミスの確率を低減することができる。
 図8において、アクセス前は、ウェイ0(64_0)のD2とD3のみが有効で、バリッドフラグV1に1がセットされ、他のバリッドフラグV0,V2,V3は0にクリアされている。タグ65_0には0x00200が格納されている。ウェイ1(64_1)はD0,D1,D2,D3が有効で、バリッドフラグV0,V1に1がセットされ他のバリッドフラグV2,V3は0にクリアされている。タグ65_1には0x001FFが格納されている。
 アドレス0x002008のデータリードが要求されると、ウェイ0にヒットする。アドレス0x002008に対応するタグ値は0x00200であり、タグ65_0に格納されているタグ値と一致するため、デクリメントフラグの更新が実行される(ステップ17~20)。連続アクセスのアドレスがインクリメント方向であればデクリメントフラグ66_0の値を0とし(ステップ19)、デクリメント方向であれば1とする(ステップ20)。図8では、インクリメント方向とする。
 次にキャッシュヒット/ミスを判定する(ステップ21)。タグ65_0は一致するがアドレス0x002008に対応するデータが格納されているべき、D4のバリッドフラグ67_0のV2は0であるので、ウェイ0(64_0)にはアドレス0x002008に対応するデータは格納されていない。よって、キャッシュミスと判定される。不揮発メモリ55からアドレス0x002008から4バイト分のデータを読み込んで、D4とD5に書き込み(ステップ29)、対応するバリッドフラグ67_0のV2に1をセットする(ステップ30)。アクセスしたウェイ0が最新になるように、LRUフラグ70をWAY1に更新する(ステップ31)。キャッシュフィルした、ウェイ0(64_0)のD4からデータを出力する(ステップ32)。
 その後、データの先読みは、D6,D7に進む。データの先読みが行われると、バリッドフラグ67_0のV3に1がセットされる。デクリメントフラグ66_0が示すアドレスの増加方向での先読みが終了したとき、ステップ4の条件判定を行う。ウェイ1のタグ65_1は0x001FFであって、デクリメントフラグ66_0と66_1が示すアドレスの増加方向とは逆方向で、ウェイ0のタグ値0x00200と連続したタグ値0x001FFと一致するので、ウェイ1は先読みの対象として適切であると判定される(ステップ4)。最新のウェイであるウェイ0と先読み対象としての条件を満たしたウェイ1のデクリメントフラグ66_0と66_1は共に0で一致している(ステップ38)。先読み対象としての条件を満たしたウェイ1のタグ65_1の値を、最新のウェイ0のタグ65_0のタグ値0x00200+1である、0x00201に更新する(ステップ39)。その後、ウェイ1のデータD0~D7が全てフィルされるまで(ステップ42)、アドレスをインクリメントしながら(ステップ43)、不揮発メモリ55からデータを順次読み込み、ウェイ1のデータD0~D7に、アドレス0x002010~0x00201Fのデータを書き込み(ステップ40)、対応するバリッドフラグ67_1のV0~V3を順次1に更新する(ステップ41)。これにより、ウェイ1はウェイ0の先読み対象として機能する。以降、連続アクセスが続く限り、ウェイ0とウェイ1が交互にアクセス対象と先読み対象として機能し、キャッシュミスは発生しない。
 ウェイ1(64_1)のD0~D7への先読みを完了した後、CPU53からのアクセスが未だウェイ0に対してであって、アクセスサイクルに空きがある場合には、図7を用いて説明したのと同様に、ステップ12、13、14によって、ウェイ0(64_0)に先読み方向とは逆方向のデータを読み込んでおくこともできる。これにより、2ウェイに跨って先読み動作を行う場合であっても、連続アクセスの状態が崩れ、連続方向とは逆のアドレス方向へのアクセスが実行されたときに、キャッシュミスの確率を減らすように、同一ウェイ後方(連続方向とは逆のアドレス方向)への先読みを実施することができる。
 図9を使って、連続アクセスの方向がアドレスの減少方向である場合の動作例を示す。アクセス前は、ウェイ0(64_0)のD2とD3のみが有効で、バリッドフラグV1に1がセットされ他のバリッドフラグV0,V2,V3は0にクリアされている。タグ65_0には0x00200が格納されている。ウェイ1(64_1)はD0,D1,D2,D3が有効で、バリッドフラグV0,V1に1がセットされ他のバリッドフラグV2,V3は0にクリアされている。タグ65_1には0x00201が格納されている。デクリメントフラグ66_0と66_1には共に1がセットされている。
 アドレス0x002006のデータリードが要求された例について説明する。アドレス0x002006のデータリードが要求されると、ウェイ0にヒットする。アドレス0x002006に対応するタグ値は0x00200であり、タグ65_0に格納されているタグ値と一致するため、デクリメントフラグの更新が実行される(ステップ17~20)。連続アクセスのアドレスがデクリメント方向であるので、デクリメントフラグ66_0の値を1とする(ステップ20)。タグ65_0が一致し、アドレス0x002006に対応するデータが格納されているべき、D2のバリッドフラグ67_0のV1は1であるので、ウェイ0(64_0)にはアドレス0x002006に対応するデータが格納されている。よって、キャッシュヒットと判定される(ステップ21)。LRUフラグ70を更新し(ステップ33)、ヒットしたウェイ0(64_0)のD2からデータを出力する(ステップ34)。
 その後、データの先読みは、D0,D1に進む。データの先読みが行われると、バリッドフラグ67_0のV0に1がセットされる。デクリメントフラグ66_0が示すアドレスの減少方向での先読みが終了したとき、ステップ4の条件判定を行う。ウェイ1のタグ65_1は0x00201であって、デクリメントフラグ66_0と66_1が示すアドレスの減少方向とは逆方向で、ウェイ0のタグ値0x00200と連続したタグ値0x00201と一致するので、ウェイ1は先読みの対象として適切であると判定される(ステップ4)。最新のウェイであるウェイ0と先読み対象としての条件を満たしたウェイ1のデクリメントフラグ66_0と66_1は共に1で一致している(ステップ38)。先読み対象としての条件を満たしたウェイ1のタグ65_1の値を、最新のウェイ0のタグ65_0のタグ値0x00200-1である、0x001FFに更新する(ステップ44)。その後、ウェイ1のデータD0~D7が全てフィルされるまで(ステップ47)、アドレスをインクリメントしながら(ステップ48)、不揮発メモリ55からデータを順次読み込み、ウェイ1のデータD0~D7に、アドレス0x001FFF~0x001FF0のデータを書き込み(ステップ45)、対応するバリッドフラグ67_1のV0~V3を順次1に更新する(ステップ46)。これにより、図8を使って説明したアドレスが増加方向の連続アクセスの場合と同様に、ウェイ1はウェイ0の先読み対象として機能する。以降、連続アクセスが続く限り、ウェイ0とウェイ1が交互にアクセス対象と先読み対象として機能し、キャッシュミスは発生しない。
 ウェイ1(64_1)のD0~D7への先読みを完了した後、先読みしたウェイ1へのCPU53からのアクセスを始める前であって、アクセスサイクルに空きがある場合には、図7を用いて説明したのと同様に、ステップ12、13、14によって、ウェイ0(64_0)に先読み方向とは逆方向のデータD4~D7を読み込んでおくこともできる。これにより、アドレスが増加方向の連続アクセスの場合と同様に、2ウェイに跨って先読み動作を行う場合であっても、連続アクセスの状態が崩れ、連続方向とは逆のアドレス方向へのアクセスが実行されたときに、キャッシュミスの確率を減らすように、同一ウェイ後方(連続方向とは逆のアドレス方向)への先読みを実施することができる。
 〔動作タイミング〕
 本実施形態の動作例についてタイミングチャートを使ってさらに詳しく説明する。
 図10~13は、比較例に係る半導体装置の動作例を表すタイミングチャートである。図14~16は、2ウェイのキャッシュが互いに他の先読み対象となって1ウェイとして先読み動作する場合の動作例を表すタイミングチャートである。図17~18は、2ウェイのキャッシュがそれぞれ独立して動作する場合の動作例を表すタイミングチャートである。各図において、横軸は時間軸であり、クロックサイクル単位でT1から順に表記する。縦軸方向には、上から順に、クロック、CPUのアクセス要求、CPUが発行するアドレス、CPUへのリードデータが示される。次にキャッシュメモリ60の動作が示される。キャッシュ制御回路63のアクセス要求、キャッシュメモリ60から不揮発メモリ55に対して発行されるアドレスと、不揮発メモリ55からキャッシュメモリ60に対して出力されるリードデータが示される。さらに次にはウェイ0とウェイ1の内部状態が示される。ウェイ0とウェイ1のそれぞれについて、上から順にデクリメントフラグ66_0と66_1、タグ[23:4](65_0と65_1)の値、データD0~D7の値が示される。最下段には、LRUフラグ70の値が示される。
 図10において、CPU53はサイクルT1にアドレス0x00200Cからの2バイトのデータリードを要求している。このとき、ウェイ0のタグ65_0の値は0x01219、ウェイ1のタグ65_1の値は0x001FFであり、LRUフラグ70はウェイ0を指している。データリードを要求されているアドレス0x00200Cに対応するタグ値0x00200に一致するタグはないので、キャッシュミスが発生する。キャッシュミスの判断に2サイクル要するとし、サイクルT3においてキャッシュメモリ60が不揮発メモリ55に対してアドレス0x00200Cを出力する。キャッシュフィルの対象は、LRUフラグ70が示すウェイ0である。サイクルT3でLRUフラグ70はウェイ1に更新され、サイクルT4でウェイ0のタグ65_0が、0x00200に更新される。不揮発メモリ55内ではデータの読み出しが実行されるが、3サイクルを要するとして、サイクルT6でアドレス0x00200Cの値@00200Cが読み出され、サイクルT7でウェイ0(64_0)のD6/D7に書き込まれ、合わせてCPU53にも出力される。キャッシュフィルは4バイト単位で行われるので、アドレス0x00200Cから0x00200Fまでの4バイトのデータがウェイ0(64_0)のD6とD7に書き込まれる。CPU53からのデータリード要求は2バイトであるから、D6に格納される2バイトが、CPU53に返送される。
 図11において、CPU53はサイクルT8にアドレス0x00200Eからの2バイトのデータリードを要求している。アドレス0x00200Eのデータは、先のキャッシュフィルにより、ウェイ0(64_0)のD7に書き込まれている。サイクルT1でのデータリード要求が、アドレス0x00200Cからの2バイトのデータリードを要求であったので、サイクルT1でのデータリード要求は、アドレス増加方向での連続リードの要求である。ウェイ0のデクリメントフラグ66_0は、アドレス増加方向を示す0のまま維持される。アドレス0x00200Eのデータは、ウェイ0(64_0)のD7に格納されているので、キャッシュヒットであり、サイクルT9に@00200EとしてCPUのリードデータとして出力される。サイクルT12に、CPU53がさらに次の連続アドレスである0x002010からの2バイトのデータリードを要求している。アドレス0x002010のデータはキャッシュされていないのでキャッシュミスを発生する。キャッシュ制御回路は、それまでの間(サイクルT9~T13)は、アクセス要求を発行しない。
 図12において、サイクルT14においてキャッシュメモリ60が不揮発メモリ55に対してアドレス0x002010を出力する。キャッシュフィルの対象は、LRUフラグ70が示すウェイ1である。サイクルT14でLRUフラグ70はウェイ0に更新され、サイクルT15でウェイ1のタグ65_1が、0x00201に更新される。不揮発メモリ55内ではデータの読み出しが3サイクルを要して実行され、サイクルT17でアドレス0x002010の値@002010が読み出され、サイクルT18でウェイ1(64_1)のD0/D1に書き込まれ、合わせてCPU53にも出力される。
 以上のように、連続アクセスに対する先読み機能がない場合には、キャッシュラインの境界ごとに、キャッシュミスが発生し、キャッシュミス処理期間がオーバーヘッドとなる。
 図14~16は、2ウェイのキャッシュが互いに他の先読み対象となって1ウェイとして先読み動作する場合の動作例を表すタイミングチャートである。
 図14において、CPU53はサイクルT1にアドレス0x00200Cからの2バイトのデータリードを要求している。このとき、ウェイ0のタグ65_0の値は0x01219、ウェイ1のタグ65_1の値は0x001FFであり、LRUフラグ70はウェイ0を指している。データリードを要求されているアドレス0x00200cに対応するタグ値0x00200に一致するタグはないので、キャッシュミスが発生する。キャッシュミスの判断に2サイクル要するとし、サイクルT3においてキャッシュメモリ60が不揮発メモリ55に対してアドレス0x00200Cを出力する。キャッシュフィルの対象は、LRUフラグ70が示すウェイ0である。サイクルT3でLRUフラグ70はウェイ1に更新され、サイクルT4でウェイ0のタグ65_0が、0x00200に更新される。不揮発メモリ55内ではデータの読み出しが実行されるが、3サイクルを要するとして、サイクルT6でアドレス0x00200Cの値@00200Cが読み出され、図15に示すサイクルT7でウェイ0(64_0)のD6/D7に書き込まれ、合わせてCPU53にも出力される。キャッシュフィルは4バイト単位で行われるので、アドレス0x00200Cから0x00200Fまでの4バイトのデータがウェイ0(64_0)のD6とD7に書き込まれる。CPU53からのデータリード要求は2バイトであるから、D6に格納される2バイトが、CPU53に返送される。
 図15において、CPU53はサイクルT8にアドレス0x00200Eからの2バイトのデータリードを要求している。サイクルT1でのデータリード要求が、アドレス0x00200Cからの2バイトのデータリードを要求であったので、サイクルT1でのデータリード要求は、アドレス増加方向での連続リードの要求である。ウェイ0のデクリメントフラグ66_0は、アドレス増加方向を示す0のまま維持される。アドレス0x00200Eのデータは、先のキャッシュフィルにより、ウェイ0(64_0)のD7に書き込まれている。アドレス0x00200Eのデータは、ウェイ0(64_0)のD7に格納されているので、キャッシュヒットであり、サイクルT9に@00200EとしてCPUのリードデータとして出力される。
 これと並行して、図3~図6のフローチャートに示したデータ先読み動作が開始される。サイクルT1のアドレス0x00200Cからの2バイトのデータリード要求によって発生したキャッシュフィルの後、ウェイ0のD6/D7を起点にデクリメントフラグ66_0が示す方向のデータ領域は、フィルされているので(ステップ35)、先読みに適するウェイがあるか否かについての判定ステップに進む。最新のウェイであるウェイ0とデクリメントフラグの値が一致し、且つ、デクリメントフラグが示す方向と逆方向に連続したタグ値を持つウェイを探索する(ステップ4)。デクリメントフラグ66_0と66_1はともにアドレス増加方向を示して一致しており、ウェイ1のタグ値は0x001FFでデクリメントフラグ66_0と66_1が示す方向とは逆のアドレス減少方向で、ウェイ0のタグ値0x00200と連続しているので、ウェイ1は先読みの対象として適すると判定される。サイクルT8でタグ65_1に0x00200に1を加えた0x00201に更新される(ステップ39)。サイクルT9以降、不揮発メモリ55からアドレス0x002010以降のデータ@002010、@002014、@002018、@00201Cが順次読み出され、それぞれウェイ1のD0/D1,D2/D3,D4/D5,D6/D7に書き込まれる。
 サイクルT12に、CPU53がさらに次の連続アドレスである0x002010からの2バイトのデータリードを要求している。この時点で、アドレス0x002010のデータはウェイ1に先読みされているので、キャッシュヒットし、図16に示すサイクルT13で読み出される。比較例では、アドレス0x002010のデータはキャッシュされていなかったのでキャッシュミスが発生し、アドレス0x002010のデータが読み出されたのは、サイクルT18である。本実施形態の先読みを行うことにより、キャッシュミスの発生が抑えられ、実行サイクルが5サイクル短縮される。2バイトのデータリードは、キャッシュヒットしたとき2サイクルで実行され、キャッシュミスしたとき、7サイクルを要する。1ウェイ=1ラインを16バイトで構成し、2バイトずつの連続アクセスを行うとき、ウェイ内のみの先読みを行う比較例では、8回の連続アクセスに対して7回のキャッシュヒットと1回のキャッシュミスが発生するので、21サイクルを要することとなる。一方、本実施形態に示すように、2個のウェイを交互にアクセス対象と先読み対象として機能させることにより、キャッシュミスは発生せず16サイクルで済む。
 また、図14~16に示すように、データ先読みの期間中も命令フェッチとデータリードサイクルは、実行可能である。先読みを実行するためのサイクルは隠蔽することができる。
 また、ウェイ1へのデータの先読み終了後、図16に示すサイクル15、16、17、18において、既にアクセスされたウェイ0のデータD6/D7から、デクリメントフラグ66_0が示すのとは逆方向のD0/D1,D2/D3,D4/D5に、対応するデータが読み込まれる。これは、図3~図6に示したフローチャートのステップ12~ステップ14が実行された結果である。連続アクセスが乱れた場合に、キャッシュミスの確率を減らすことができる。一方、ステップ12~ステップ14を実行しないように設計することもできる。その場合は、連続アクセスが継続された場合に無駄になる、デクリメントフラグ66_0が示すのとは逆方向の読み込みを中止することができ、その分の消費電力を低減することができる。
 図17~18は、2ウェイのキャッシュがそれぞれ独立して動作する場合の動作例を表すタイミングチャートである。
 図17において、CPU53はサイクルT1にアドレス0x002008からの2バイトのデータリードを要求している。このとき、ウェイ0のタグ65_0の値は0x01219、ウェイ1のタグ65_1の値は0x0121Aであり、LRUフラグ70はウェイ0を指している。データリードを要求されているアドレス0x002008に対応するタグ値0x00200に一致するタグはないので、キャッシュミスが発生する。キャッシュミスの判断に2サイクル要するとし、サイクルT3においてキャッシュメモリ60が不揮発メモリ55に対してアドレス0x002008を出力する。キャッシュフィルの対象は、LRUフラグ70が示すウェイ0である。サイクルT3でLRUフラグ70はウェイ1に更新され、サイクルT4でウェイ0のタグ65_0が、0x00200に更新される。不揮発メモリ55内ではデータの読み出しが実行されるが、3サイクルを要するとして、サイクルT6でアドレス0x002008の値@002008が読み出され、図18に示すサイクルT7でウェイ0(64_0)のD4/D5に書き込まれ、合わせてCPU53にも出力される。
 図18において、CPU53はサイクルT8にアドレス0x00200Aからの2バイトのデータリードを要求している。サイクルT1でのデータリード要求が、アドレス0x002008からの2バイトのデータリードを要求であったので、サイクルT1でのデータリード要求は、アドレス増加方向での連続リードの要求である。ウェイ0のデクリメントフラグ66_0は、アドレス増加方向を示す0のまま維持される。アドレス0x00200Aのデータは、先のキャッシュフィルにより、ウェイ0(64_0)のD5に書き込まれているので、キャッシュヒットであり、サイクルT9に@00200AとしてCPUのリードデータとして出力される。
 一方、図3~図6のフローチャートに示したデータ先読み動作が開始される。サイクルT1のアドレス0x002008からの2バイトのデータリード要求によって発生したキャッシュフィルの後、ウェイ0のD4/D5を起点にデクリメントフラグ66_0が示す方向のデータ領域D6/D7は、まだフィルされていない(ステップ35)。そこで、サイクルT6で不揮発メモリ55に対してアドレス0x00200Cを発行し、図18に示すサイクルT7で読み込まれるデータ@0x00200cをサイクルT8でデータ領域D6/D7に書き込む(ステップ36)。その後、ステップ4に進むが、ウェイ0とウェイ1のタグ値は連続しないので、ステップ38~48に示すデータの先読みは実行されない。代わりに、ステップ12~14により、図18に示すサイクルT8,T9,T10に、ウェイ0のD0/D1,D2/D3に、それぞれアドレス0x002000と0x002004のデータが読み込まれる。一方、ウェイ1のデータは維持される。2ウェイのキャッシュメモリとして機能する。
 これにより、本実施形態のキャッシュ制御回路は、2ウェイのキャッシュとして機能するか、2個のウェイをまとめて交互に先読み対象として機能させるかを、タグの値とデクリメントフラグを参照するだけで、自律的に切替えることが可能となっている。
 以上本発明者によってなされた発明を実施形態に基づいて具体的に説明したが、本発明はそれに限定されるものではなく、その要旨を逸脱しない範囲において種々変更可能であることは言うまでもない。
 例えば、データキャッシュについての実施形態に限らず、命令キャッシュやユニファイドキャッシュにも適用することができる。また、ウェイ数は2に限定されず任意に決めることができ、キャッシュヒット/ミスの判定に費やすサイクル数は、適宜最適に設計することができ、また、不揮発メモリのデータリードのためのサイクル数は、任意の値であってよい。
 本発明はキャッシュメモリへのデータ先読み技術に関し、特にキャッシュメモリを備えた半導体装置に広く適用することができる。
 1 連続するアクセスのアドレスが連続するか否かを判定するステップ
 2 ウェイにアドレス変化方向属性(デクリメントフラグ)を付与するステップ
 3 ウェイにアクセスするステップ
 4 先読み動作に適合するか否かを判定するステップ
 5 先読みを実行するステップ
 50 半導体装置(セキュアマイコン)
 51 アドレスバス
 52 データバス
 53 プロセッサ(CPU)
 54 DMA(Direct Memory Access)コントローラ
 55 不揮発メモリ
 56 ROM(Read Only Memory)
 57 RAM(Random Access Memory)
 58 周辺モジュール
 60 キャッシュメモリ
 61 データキャッシュ
 62 命令キャッシュ
 63 キャッシュ制御部
 64 ウェイ
 65 タグ
 66 デクリメントフラグ
 67 バリッドフラグ
 68 アドレス制御部
 69 データ制御部
 70 LRU(Least Recently Used)フラグ
 71 LRU制御部
 72 タグ制御部
 73 デクリメントフラグ制御部
 74 バリッドフラグ制御部
 75 キャッシュ制御部内部アドレスバス
 76 キャッシュ制御部内部データバス
 77 メモリ部
 78 リードバッファ
 79 セレクタ

Claims (17)

  1.  プロセッサと、メモリと、複数のタグと、前記タグに格納されるタグ値を基準アドレスとして前記メモリの連続するアドレスの複数のデータをそれぞれ格納可能な複数のウェイと、キャッシュ制御部を備える半導体装置であって、
     前記複数のウェイのそれぞれに、前記ウェイに対する直近の2回のアクセスがアドレスの増加または減少のどちらかの方向を示すアドレス変化方向フラグを設け、
     前記キャッシュ制御部は、前記プロセッサから前記メモリに対して連続して行う第1アクセスと第2アクセスが互いに連続するアドレスへのアクセスであり、前記第2アクセスが第1ウェイを介するアクセスであり、前記第1ウェイに対応するアドレス変化方向フラグと一致するアドレス変化方向フラグを持ち、前記第1ウェイに対応するタグ値に対して、前記アドレス変化方向フラグが示す方向と逆方向で連続するタグ値を持つ、第2ウェイに対して、前記第1ウェイに対応するタグ値に対して、前記アドレス変化方向フラグが示す方向で連続するタグ値で示されるデータの先読みを可能に構成される、半導体装置。
  2.  請求項1において、前記キャッシュ制御部は、前記第2アクセスが前記第1アクセスと同一のウェイで且つ同一のタグ値へのアクセスであるときに、前記第2アクセスの対象アドレスが前記第1アクセスの対象アドレスより小さいとき、前記アドレス変化方向フラグをセット可能に構成される、半導体装置。
  3.  請求項1において、前記キャッシュ制御部は、キャッシュミスのとき、前記ウェイに格納されるデータの合計のデータ長の整数分の1のデータ長の単位で、キャッシュフィルを実行可能に構成される、半導体装置。
  4.  請求項3において、前記キャッシュ制御部は、前記複数のウェイのそれぞれに、前記キャッシュフィルのデータ長の単位ごとに、有効フラグを備え、キャッシュミスが発生したとき、キャッシュフィルの対象のウェイに対応する前記有効フラグを全てクリアし、キャッシュフィルしたデータに対応する前記有効フラグをセット可能に構成される、半導体装置。
  5.  請求項4において、前記キャッシュ制御部は、前記第2アクセスの後、前記第1ウェイに対応するアドレス変化方向フラグによって示される方向で、対応する前記有効フラグがセットされていない前記第1ウェイ内の領域へのデータの先読みを可能に構成される、半導体装置。
  6.  請求項5において、前記キャッシュ制御部は、前記第2ウェイに対応するアドレス変化方向フラグと前記第1ウェイに対応するアドレス変化方向フラグとが一致し、前記第2ウェイに対応するタグ値が前記第1ウェイに対応するタグ値に対して、前記アドレス変化方向フラグが示す方向と逆方向で連続するときに、前記第1ウェイ内の領域へのデータの先読みの後に、前記第2ウェイに対するデータの先読みを可能に構成され、
     前記第2ウェイに対応するアドレス変化方向フラグと前記第1ウェイに対応するアドレス変化方向フラグとが一致せず、または、前記第2ウェイに対応するタグ値が前記第1ウェイに対応するタグ値に対して、前記アドレス変化方向フラグが示す方向と逆方向で連続しないときに、前記第1ウェイ内の領域へのデータの先読みの後に、前記第1ウェイ内の前記第2アクセスの後、前記第1ウェイに対応するアドレス変化方向フラグによって示される方向と逆方向の、前記第1ウェイ内の領域へのデータの先読みを可能に構成される、半導体装置。
  7.  請求項1において、前記プロセッサは、前記第2アクセスの終了後、前記キャッシュメモリが前記先読みを完了する前に、前記第2アクセスの後続のアクセスを実行可能に構成される、半導体装置。
  8.  請求項1において、前記複数のウェイのそれぞれは、前記メモリの任意のアドレスのデータをキャッシュすることが可能に構成される、半導体装置。
  9.  請求項1において、命令キャッシュをさらに備え、前記複数のウェイは、前記プロセッサに対するデータキャッシュである、半導体装置。
  10.  プロセッサとメモリの間に設けられ、複数のタグと前記タグに格納されるタグ値を基準アドレスとして前記メモリの連続するアドレスの複数のデータをそれぞれ格納可能な複数のウェイとを備える、キャッシュメモリにおけるデータ先読み方法であって、
     前記プロセッサから前記メモリに対する第1アクセスと連続する第2アクセスが互いに連続するアドレスへのアクセスであるか否かを判定する第1ステップと、
     前記第1ステップの判定結果が連続アドレスへのアクセスであるとき、前記第1アクセスと前記第2アクセスが前記複数のウェイのうちの同一ウェイに対する同一タグ値によるアクセスであるとき、前記ウェイに対する直近の2回のアクセスがアドレスの増加または減少のどちらの方向かを示すアドレス変化方向属性を付与する第2ステップと、
     前記第2アクセスによって第1ウェイをアクセスする第3ステップと、
     前記第1ウェイと同一のアドレス変化方向属性を持ち、前記第1ウェイのタグ値に対して、前記同一のアドレス変化方向属性が示す方向と逆方向に連続するタグ値を持つ第2ウェイの有無を判定する第4ステップと、
     前記第4ステップの有の判定結果に基づいて、前記第2ウェイを対象として、前記アドレス変化方向属性が示す方向で連続するタグ値で示されるデータの先読みを行う、第5ステップとを含む、データ先読み方法。
  11.  請求項10において、前記第3ステップがキャッシュヒットかキャッシュミスかに関わらず、前記第4ステップは前記第3ステップの後に実行され、前記第3ステップがキャッシュミスであるときは、前記第3ステップは前記第1ウェイのタグ値を更新し、前記第5ステップは更新された前記第1ウェイのタグ値に基づいて前記先読みを行うか否かの判定を行う、データ先読み方法。
  12.  請求項10において、前記第1ステップは、前記第2アクセスが前記第1アクセスと同一のウェイで且つ同一のタグ値へのアクセスであるときに、前記第2アクセスの対象アドレスが前記第1アクセスの対象アドレスより小さいとき、前記アドレス変化方向属性としてアドレス減少方向をセットする、データ先読み方法。
  13.  請求項10において、前記第3ステップは、キャッシュミスのとき、前記ウェイに格納されるデータの合計のデータ長の整数分の1のデータ長の単位で、キャッシュフィルを行う、データ先読み方法。
  14.  請求項13において、前記複数のウェイのそれぞれは、前記キャッシュフィルのデータ長の単位ごとに、有効フラグを備え、前記第3ステップでキャッシュミスが発生したとき、キャッシュフィルの対象のウェイに対応する前記有効フラグを全てクリアし、キャッシュフィルしたデータに対応する前記有効フラグをセットする、データ先読み方法。
  15.  請求項14において、前記第3ステップの後、前記第1ウェイに対応するアドレス変化方向属性によって示される方向で、対応する前記有効フラグがセットされていない前記第1ウェイ内の領域へのデータの先読みを行う、第6ステップをさらに含む、データ先読み方法。
  16.  請求項15において、前記第6ステップの後で前記第4ステップを実行し、前記第4ステップの無の判定結果に基づいて、前記第1ウェイに対応するアドレス変化方向属性によって示される方向と逆の方向で、対応する前記有効フラグがセットされていない前記第1ウェイ内の領域へのデータの先読みを行う、第7ステップをさらに含む、データ先読み方法。
  17.  プロセッサと、メモリと、互いに1:1対応する複数のタグと複数のウェイとキャッシュ制御部を備える半導体装置であって、
     前記プロセッサから前記メモリに対する第1アクセスと第2アクセスが互いに連続して実行され、連続するアドレスへのアクセスであり、前記第2アクセスが第1ウェイを介するアクセスであるとき、
     前記キャッシュ制御部は、前記第2アクセスが前記第1アクセスに対してアドレスが増加する方向でのアクセスであるときには、前記第1ウェイに対応するタグ値よりも1小さいタグ値を持つウェイに対するデータの先読みを可能とし、前記第2アクセスが前記第1アクセスに対してアドレスが減少する方向でのアクセスであるときには、前記第1ウェイに対応するタグ値よりも1大きいウェイに対するデータの先読みを可能に構成される、半導体装置。
PCT/JP2012/078139 2012-10-31 2012-10-31 半導体装置及びキャッシュメモリへのデータ先読み方法 WO2014068694A1 (ja)

Priority Applications (4)

Application Number Priority Date Filing Date Title
PCT/JP2012/078139 WO2014068694A1 (ja) 2012-10-31 2012-10-31 半導体装置及びキャッシュメモリへのデータ先読み方法
JP2014544114A JP5901787B2 (ja) 2012-10-31 2012-10-31 半導体装置及びキャッシュメモリへのデータ先読み方法
US14/439,355 US9892049B2 (en) 2012-10-31 2012-10-31 Semiconductor device and method for prefetching to cache memory
US15/864,479 US20180150399A1 (en) 2012-10-31 2018-01-08 Semiconductor device and method for prefetching to cache memory

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/JP2012/078139 WO2014068694A1 (ja) 2012-10-31 2012-10-31 半導体装置及びキャッシュメモリへのデータ先読み方法

Related Child Applications (2)

Application Number Title Priority Date Filing Date
US14/439,355 A-371-Of-International US9892049B2 (en) 2012-10-31 2012-10-31 Semiconductor device and method for prefetching to cache memory
US15/864,479 Continuation US20180150399A1 (en) 2012-10-31 2018-01-08 Semiconductor device and method for prefetching to cache memory

Publications (1)

Publication Number Publication Date
WO2014068694A1 true WO2014068694A1 (ja) 2014-05-08

Family

ID=50626664

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/JP2012/078139 WO2014068694A1 (ja) 2012-10-31 2012-10-31 半導体装置及びキャッシュメモリへのデータ先読み方法

Country Status (3)

Country Link
US (2) US9892049B2 (ja)
JP (1) JP5901787B2 (ja)
WO (1) WO2014068694A1 (ja)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10120808B2 (en) * 2016-04-22 2018-11-06 Arm Limited Apparatus having cache memory disposed in a memory transaction path between interconnect circuitry and a non-volatile memory, and corresponding method
JP2018106227A (ja) * 2016-12-22 2018-07-05 ルネサスエレクトロニクス株式会社 キャッシュメモリ装置及び半導体装置
US11151043B2 (en) * 2019-08-12 2021-10-19 Micron Technology, Inc. Demand delay and data value correlated memory pre-fetching systems and methods
US11741248B2 (en) * 2019-08-20 2023-08-29 Bank Of America Corporation Data access control using data block level encryption
KR20210066631A (ko) * 2019-11-28 2021-06-07 삼성전자주식회사 메모리에 데이터를 기입하기 위한 장치 및 방법
US11977738B2 (en) * 2022-09-06 2024-05-07 Arm Limited Allocation of store requests

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2001195304A (ja) * 2000-01-13 2001-07-19 Hitachi Ltd キャッシュ記憶装置
WO2005091146A1 (ja) * 2004-03-24 2005-09-29 Matsushita Electric Industrial Co., Ltd. キャッシュメモリ及びその制御方法
JP2008217825A (ja) * 2008-04-30 2008-09-18 Univ Waseda マルチプロセッサ
JP2010073029A (ja) * 2008-09-19 2010-04-02 Toshiba Corp 命令キャッシュシステム

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0675853A (ja) 1992-08-25 1994-03-18 Oki Electric Ind Co Ltd キャッシュメモリ装置
JP4374956B2 (ja) 2003-09-09 2009-12-02 セイコーエプソン株式会社 キャッシュメモリ制御装置およびキャッシュメモリ制御方法
JP2007206806A (ja) * 2006-01-31 2007-08-16 Matsushita Electric Ind Co Ltd キャッシュ観測装置、プロセッサの解析方法およびキャッシュメモリ
US7529889B2 (en) * 2006-08-14 2009-05-05 Arm Limited Data processing apparatus and method for performing a cache lookup in an energy efficient manner
US7958317B2 (en) * 2008-08-04 2011-06-07 International Business Machines Corporation Cache directed sequential prefetch
US8762649B2 (en) * 2010-03-29 2014-06-24 Via Technologies, Inc. Bounding box prefetcher
JP2012038385A (ja) 2010-08-06 2012-02-23 Renesas Electronics Corp データ処理装置
KR101788245B1 (ko) * 2011-02-25 2017-11-16 삼성전자주식회사 다중 포트 캐시 메모리 장치 및 그 구동 방법

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2001195304A (ja) * 2000-01-13 2001-07-19 Hitachi Ltd キャッシュ記憶装置
WO2005091146A1 (ja) * 2004-03-24 2005-09-29 Matsushita Electric Industrial Co., Ltd. キャッシュメモリ及びその制御方法
JP2008217825A (ja) * 2008-04-30 2008-09-18 Univ Waseda マルチプロセッサ
JP2010073029A (ja) * 2008-09-19 2010-04-02 Toshiba Corp 命令キャッシュシステム

Also Published As

Publication number Publication date
US20150293850A1 (en) 2015-10-15
US20180150399A1 (en) 2018-05-31
JPWO2014068694A1 (ja) 2016-09-08
US9892049B2 (en) 2018-02-13
JP5901787B2 (ja) 2016-04-13

Similar Documents

Publication Publication Date Title
JP5901787B2 (ja) 半導体装置及びキャッシュメモリへのデータ先読み方法
US10067872B2 (en) Memory speculation for multiple memories
US7139878B2 (en) Method and apparatus for dynamic prefetch buffer configuration and replacement
JP5417879B2 (ja) キャッシュ装置
US8725987B2 (en) Cache memory system including selectively accessible pre-fetch memory for pre-fetch of variable size data
US20100191918A1 (en) Cache Controller Device, Interfacing Method and Programming Method Using the Same
US11301250B2 (en) Data prefetching auxiliary circuit, data prefetching method, and microprocessor
US20090177842A1 (en) Data processing system and method for prefetching data and/or instructions
JP5428687B2 (ja) メモリ制御装置
JP2018534666A (ja) インメモリ処理及び狭幅データポートを備えたコンピュータデバイス
EP2524314B1 (en) System and method to access a portion of a level two memory and a level one memory
US7313658B2 (en) Microprocessor and method for utilizing disparity between bus clock and core clock frequencies to prioritize cache line fill bus access requests
WO2007046066A1 (en) Cache with high access store bandwidth
JP2007500402A (ja) 周辺装置アクセス保護付きデータ処理システム
US20170147498A1 (en) System and method for updating an instruction cache following a branch instruction in a semiconductor device
JP4024247B2 (ja) 半導体データプロセッサ
US9645825B2 (en) Instruction cache with access locking
JP2011154528A (ja) データ処理装置
JP2004240616A (ja) メモリコントローラ及びメモリアクセス制御方法
JP4765249B2 (ja) 情報処理装置およびキャッシュメモリ制御方法
US20090164732A1 (en) Cache memory system and cache memory control method
US11294821B1 (en) Write-back cache device
JP4583981B2 (ja) 画像処理装置
US20120151150A1 (en) Cache Line Fetching and Fetch Ahead Control Using Post Modification Information
JP2009252004A (ja) キャッシュシステム

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 12887400

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2014544114

Country of ref document: JP

Kind code of ref document: A

WWE Wipo information: entry into national phase

Ref document number: 14439355

Country of ref document: US

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 12887400

Country of ref document: EP

Kind code of ref document: A1