The present invention relates to a method of leveling the amount of static wear in a nonvolatile memory device. The present invention also relates to a memory controller for operating the non-volatile memory device in accordance with the method.
Nonvolatile memory devices having an array of non-volatile memory cells are well known in the art. Non-volatile memories can be of NOR type or NAND type. In certain types of non-volatile memories, the memory is characterized by having a plurality of blocks, with each block having a plurality of bits, with all of the bits in a block being erasable at the same time. Hence, these are called flash memories, because all of the bits or cells in the same block are erased together. After the block is erased, the cells within the block can be programmed by certain size (such as byte) as in the case of NOR memory, or a page is programmed at once as in the case of NAND memories.
Referring to
As is well known, the address signals supplied by the host device 30 to the controller 10 is in the nature of logical address, and that the controller 10 must translate that logical address into a physical address. Further, the NAND memory device 20 is characterized by having a plurality of blocks, with each block comprising a plurality of bits or memory cells, which are erased together. Thus, in an erase operation the memory cells of an entire block are erased together. As discussed above, such feature is common to all flash memory devices, wherein all memory cells in a block are erased in a “flash”.
One of the problems of flash non-volatile memory devices is that there is a finite amount by which a block can be erased before problems, such as data retention, occur. Thus, it is desired to even out the “wear” or the number of cycles by which each block is erased. Hence, there is a desire to level the wear of blocks in a flash memory device.
Referring to
Referring to
The above described methods are called dynamic wear-leveling methods, in that wear level is considered only when data in a block is updated, i.e. the block would have had to be erased in any event. However, the dynamic wear-leveling method does not operate if there is no data update to a block. The problem with dynamic wear-leveling method is that for blocks that do not have data that is updated, such as those blocks storing operating system data or other types of data that is not updated or is updated infrequently, the wear level technique does not serve to cause the leveling of the wear for these blocks with all other blocks that have had more frequent changes in data. Thus, for example, if physical blocks 200 and 500 store operating system data, and are not updated at all or are updated infrequently, those physical blocks may have very little wear, in contrast to blocks such as physical block 501 (as well as all of the other blocks in the first plurality of blocks) that might have had greater wear. This large difference between physical blocks 501 and physical blocks 200 and 500, for example, may result in a lower over all usage of all the physical blocks of the NAND memory 20.
A memory controller controls the operation of a non-volatile memory device. The memory device has a data storage section and an erased storage section. The data storage section has a first plurality of blocks and the erased storage section has a second plurality of blocks. Each of the first and second plurality of blocks has a plurality of non-volatile memory bits that are erased together. Further, each block has an associated counter for storing a count of the number of times the block has been erased. The memory controller has program instructions which are to determine the count in the counters associated with the blocks of the first plurality of blocks to select a third block, and to determine the count in the counters associated with the blocks of the second plurality of blocks to select a fourth block. The program instructions are further configured to transfer data from the third block to the fourth block, and associating said fourth block with said first plurality of blocks. Finally the program instructions are configured to erase said third block and incrementing the counter associated with said third block, and associating said third block with said second plurality of blocks.
The present invention is also a method of operating a non-volatile memory device in accordance with the above described steps.
The present invention relates to a memory controller 10 of the type shown in
Referring to
Further, associated with each block is a physical address, which is mapped to a user logical address, by a table, called a Mapping Table, which is well known in the art. The memory device 20 has a first plurality of blocks that are used to store data (designated as user logical blocks, such as 8, 200, 700, 3, 3908 and 0, each with its associated physical blocks address designated as 200, 500, 501, 502, 508, 801 etc.). The memory device 20 also comprises a second plurality of blocks that comprise spare blocks, bad blocks and overhead blocks. The spare blocks are erased blocks and form the Erased Pool and other blocks that do not store data. Further, each of the physical blocks in the Erased Pool has a counter counting the number of times that block has been erased. Thus, as the physical block 200 is erased, its associated erase counter is incremented. The blocks in the Erased Pool are candidates for swapping. The erase operation can occur before a block is placed into the Erased Pool or immediately before it is used and moved out of the Erased Pool. In the latter event, the blocks in the Erased Pool may not all be erased blocks.
As previously described in the background of the invention, when a certain block, such as user block 8, having a physical address of 200 (hereinafter all blocks shall be referred to by their physical address) is updated, some of the data from that block along with new data may need to be written to a block from the Erased Pool. Thereafter, block 200 must be erased and is then “moved” to be associated with the Erased Pool (if the erased block can still retain data. Otherwise, the erased block is “moved” to the blocks that are deemed “Bad Blocks”).
The “movement” of the physical block 200 from the first plurality of blocks (the stored data blocks) to the second plurality of blocks (the Erased Pool or the Bad Blocks) occurs by simply updating the Mapping Table. Schematically, this is shown as the physical address block 200 is “moved” to the Erased Pool.
In the present invention, however, the wear-level method may be applied even if there is no update to any data in any of the blocks from the first plurality of blocks. This is called static wear leveling. Specifically, within the first plurality of blocks, a determination is first made as to the Least Frequently Used (LFU) blocks, i.e. those blocks having the lowest erase count stored in the erase counter. The LFU log may contain a limited number of blocks, such as 16 blocks, in the preferred embodiment. Thus, as shown in
Thereafter, the block with the lowest count in the erase counter within the LFU, such as physical block 200, is erased (even if there is no data to be updated to the physical block 200). The erased physical block 200 is then “moved” to the second plurality of blocks, i.e. either the Erased Pool or the Bad Blocks.
The plurality of erased blocks in the Erased Pool is also arranged in an order ranging from the “youngest”, i.e. the block with the count in the erase counter being the lowest, to the “oldest”, i.e. the block with the count in the erase counter being the highest. The block which is erased from the first plurality and whose erase counter is incremented has its count in the erase counter compared to the erase counter of all the other blocks in the Erased Pool and arranged accordingly. The arrangement need not be in a physical order. The arrangement, e.g. can be done by a link list or a table list or any other means.
The block with the highest erase count, or the “oldest” block (such as physical block 20) from the erased Pool is then used to store data retrieved from the “youngest” block (physical block 200) from the LFU in the first plurality of blocks. Physical block 20 is then returned to the first plurality of blocks.
Based upon the foregoing description, it can been that with the static wear level method of the present invention, blocks in the first plurality which are not updated or are infrequently updated, will be “recycled” into the Erased Pool and re-used, thereby causing the wear to be leveled among all of the blocks in the NAND memory 20. It should be noted that in the method of the present invention, when the “youngest” block among the LFU is returned to the Erased Pool, the “oldest” block from the Erased Pool is used to replace the “youngest” block from the LFU. This may seem contradictory in that the “youngest” from LFU may then reside in the Erased Pool without ever being subsequently re-used. However, this is only with regard to the static wear level method of the present invention. It is contemplated that as additional data is to be stored in the NAND memory 20 and a new erased block is requested, that the “youngest” erased block from the Erased Pool is then used to store the new or additional data. Further, the “youngest” block from the Erased Pool is also used in the dynamic wear level method of the prior art. Thus, the blocks from the Erased Pool will all be eventually used. Furthermore, because the static wear level method of the present invention operates when data to a block is not being replaced, there are additional considerations, such as frequency of operation (so as not to cause undue wear) as well as resource allocation. These issues are discussed hereinafter.
At the outset, the issue is when are the blocks within the first plurality of blocks scanned to create the LFU, which is used in the subsequent static wear level method of the present invention. There are a number of ways this can be done. What follows are various possible techniques, that are illustrative and not meant to be exhaustive. Further, some of these methods may be collectively used together.
First, the controller 10 can scan the first plurality of blocks when the NAND memory 20 is first powered up.
Second, the controller 10 can scan the first plurality of blocks when the host 30 issues a specific command to scan the first plurality of blocks in the NAND memory 20. As a corollary to this method, the controller 10 can scan the first plurality of blocks when the host 30 issues a READ or WRITE command to read or write certain blocks in the NAND memory 20. Thereafter, the controller 10 can continue to read all of the rest of the erase counters within the first plurality of blocks. In addition, the controller 10 may limit the amount of time to a pre-defined period by which scanning would occur after a READ or WRITE command is received from the host 30.
Third, the controller 10 can scan the first plurality of blocks in the background. This can be initiated, for example, when there has not been any pending host command for a certain period of time, such as 5 m sec, and can be stopped when the host initiates a command to which the controller 10 must respond.
Fourth, the controller 10 can initiate a scan after a predetermined event, such as after a number of ATA commands is received by the controller 10 from the host 30.
Once it is determined when the erase counters for each of the blocks in the first plurality of blocks is scanned to create the LFU, the next determining element is the methodology by which the erase counters of the first plurality of blocks are scanned. Again, there are a number of methods, and what is described hereinbelow is illustrative only and is by no means exhaustive.
First, the controller 10 can scan all of the blocks in the first plurality of blocks in a linear manner starting from the first entry in the Mapping Table, until the last entry.
Second, the controller 10 can scan the blocks in the first plurality of blocks based upon a command from the host 30. Fort example, if the host 30 knows where data, such as operating system programs, are stored and thus which blocks are more probable of containing the “youngest” blocks, then the host 30 can initiate the scan at certain logical address or to indicate the addresses where scanning should be limited.
Third, the controller 10 can also scan all the blocks of the first plurality of blocks in a random manner. The processor in the controller 10 can include a random number generator which generates random numbers that can be used to correlate to the physical addresses of the blocks.
Fourth, the controller 10 can also scan all the blocks of the first plurality of blocks in a pseudo random manner. The processor in the controller 10 can include a pseudo random number generator (such as a prime number generator) which generates pseudo random numbers that can be used to correlate to the physical addresses of the blocks.
Once the LFU is created, then the method of the present invention can be practiced. However, since the static wear level method of the present invention does not depend on the updating of data in a block, the issue becomes when does the exchange of data between the “youngest” block in the LFU and that of the “oldest” block in the Erased Pool occur. There are a number of ways this can be done. Again, what follows are various possible techniques, and is illustrative and not meant to be exhaustive.
First, the controller 10 can exchange a limited number of blocks, such as sixteen (16), when the NAND memory 20 is first powered up.
Second, the controller 10 can exchange a number of blocks in response to the host 30 issuing a specific command to exchange the number of blocks. As a corollary to this method, the controller 10 can also exchange a limited number of blocks, such as one (1), after the host 30 issues a READ or WRITE command to read or write certain blocks in the NAND memory 20. Thereafter, the controller 10 can exchange one block.
Third, the controller 10 can exchange a limited number of blocks, such as sixteen (16), in the background. This can be initiated, for example, when there has not been any pending host command for a certain period of time, such as 5 m sec, and can be stopped when the host initiates a command to which the controller 10 must respond.
Fourth, the controller 10 can exchange a limited number of blocks, such as one (1) after a predetermined event, such as after a number of ATA commands is received by the controller 10 from the host 30.
It should be clear that although the method of the present invention levels the wear among all of the blocks in the NAND memory 20, the continued exchange of data from one block in the LFU to another block in the Erased Pool can cause excessive wear. There are a number of methods to prevent unnecessary exchanges. Again, what follows are various possible techniques, and is illustrative and not meant to be exhaustive. Further, the methods described herein may be collectively implemented.
First, a determination can be made between the count in the erase counter of the “youngest” in the LFU and the “oldest” in the blocks of the Erased Pool. If the difference is within a certain range, the exchange between the “youngest” in the LFU and the “oldest” block in the Erased Pool would not occur. The difference between the count in the erase counter of the “youngest” in the LFU and the “oldest” block in the Erased Pool can also be stored in a separate counter.
Second, the controller 10 can maintain two counters: one for storing the number of host initiated erase counts, and another for storing the number of erase counts due to static wear level method of the present invention. In the event, the difference between the two values in the two counters is less than a pre-defined number, then the static wear level method of the present invention would not occur. The number of host initiated erase counts would include all of the erase counts cause by dynamic wear level, i.e. when data in any block is updated, and any other events, that causes an erase operation to occur.
Third, the controller 10 can set a flag associated with each block. As each block is exchanged from the Erased Pool, the flag is set. Once the flag is set, that block is no longer eligible for the wear level method of the present invention until the flags of all the blocks within the first plurality of blocks are set. Thereafter, all of the flags of the blocks are re-set and the blocks are then eligible again for the wear level method of the present invention.
Fourth, a counter is provided with each block in the first plurality of blocks for storing data representing the time when that block was last erased, pursuant to the method of the present invention. In addition, the controller 10 provides a counter for storing the global time for the first plurality of blocks. In the event, a block is selected to have its data to be exchanged with a block from the Erased Pool, the counter storing the time representing when the last erase operation occurred is compared to the global time. In the event the difference is less than a predetermined number, (indicating that the block of interest was recently erased pursuant to the static wear level method of the present invention), then the block is not erased and is not added to the LFU (or if already on the LFU, it is removed therefrom).
As is well known in the art, flash memory, and especially NAND memory 20 is prone to error. Thus, the controller 10 contains error detection and error correction software. Another benefit of the method of the present invention is that, as each block in the LFU is read and then the data is recorded to an erased block from the Erased Pool, the controller 10 can determine to what degree the data from the read block contains errors. If the data read from the read block is data which does not need correction, then the erased block is returned to the Erased Pool. However, if data read from the read block contains correctable error, (and depending upon the degree of correction), the read block may then be returned to the Bad Block pool. In this manner, marginally good blocks can be detected and retired before the data stored therein becomes unreadable.
It should be apparent that there are many benefits of the method and controller of the present invention. By evening the wear among all of the blocks, the overall life usage of the NAND memory 20 is increased, and the reliability improved.