TWI738272B - Data arrangement method of flash memory, flash memory storage device and flash memory control circuit unit - Google Patents

Data arrangement method of flash memory, flash memory storage device and flash memory control circuit unit Download PDF

Info

Publication number
TWI738272B
TWI738272B TW109110830A TW109110830A TWI738272B TW I738272 B TWI738272 B TW I738272B TW 109110830 A TW109110830 A TW 109110830A TW 109110830 A TW109110830 A TW 109110830A TW I738272 B TWI738272 B TW I738272B
Authority
TW
Taiwan
Prior art keywords
garbage collection
flash memory
unit
collection operation
control circuit
Prior art date
Application number
TW109110830A
Other languages
Chinese (zh)
Other versions
TW202137220A (en
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 TW109110830A priority Critical patent/TWI738272B/en
Application granted granted Critical
Publication of TWI738272B publication Critical patent/TWI738272B/en
Publication of TW202137220A publication Critical patent/TW202137220A/en

Links

Images

Landscapes

  • Memory System (AREA)
  • Techniques For Improving Reliability Of Storages (AREA)
  • Read Only Memory (AREA)

Abstract

A data arrangement method of a flash memory, a flash memory storage device and a flash memory control circuit unit are provided. The method can be applied to a flash memory, an embedded memory device or a solid-state disk with a three-dimensional (3D) structure. The method includes: executing a background garbage collection operation in a background mode; receiving at least one write command from a host when the background garbage collection operation is not completed, suspending the background garbage collection operation and exiting the background mode; executing the at least one write command; and entering the background mode and continued executing the background garbage collection operation after completing the at least one write command. Therefore, execution efficiency of the write command in the foreground mode can be optimized.

Description

快閃記憶體之資料整理方法、快閃記憶體儲存裝置及快閃記憶體控制電路單元Flash memory data sorting method, flash memory storage device and flash memory control circuit unit

本發明是有關於一種記憶體管理技術,且特別是有關於一種快閃記憶體之資料整理方法、快閃記憶體儲存裝置及快閃記憶體控制電路單元。The present invention relates to a memory management technology, and more particularly to a flash memory data sorting method, a flash memory storage device and a flash memory control circuit unit.

數位相機、手機與MP3播放器在這幾年來的成長十分迅速,使得消費者對儲存媒體的需求也急速增加。由於可複寫式非揮發性記憶體模組(rewritable non-volatile memory module)(例如,快閃記憶體)具有資料非揮發性、省電、體積小、讀寫速度快以及無機械結構等特性,因此適合內建於上述所舉例的各種可攜式多媒體裝置中。因此,近年快閃記憶體產業成為電子產業中相當熱門的一環。Digital cameras, mobile phones and MP3 players have grown rapidly in the past few years, which has led to a rapid increase in consumer demand for storage media. Because rewritable non-volatile memory modules (for example, flash memory) have the characteristics of non-volatile data, power saving, small size, fast reading and writing speed, and no mechanical structure, Therefore, it is suitable for being built in various portable multimedia devices as exemplified above. Therefore, the flash memory industry has become a very popular part of the electronics industry in recent years.

以快閃記憶體為基礎的記憶體儲存裝置無法覆寫已經存在的儲存資料,而需要對儲存資料透過垃圾收集(garbage collection)操作來釋放實體抹除單元。一般來說,在執行垃圾收集過程中會先選擇多個實體抹除單元當作來源實體抹除單元,並選擇一個實體抹除單元當作目標實體抹除單元。接著將來源實體抹除單元中的有效資料搬移(或複製)至目標實體抹除單元,並且抹除來源實體抹除單元以釋放出來源實體抹除單元的無效資料所佔用的空間。然而,在目標實體抹除單元被關閉(即,被設定不能再被寫入任何資料)之前,主機系統的每一個寫入指令都要進行垃圾收集。如此一來,執行垃圾收集的期間會影響快閃記憶體儲存裝置在已更新(dirty)狀態下,主機系統的寫入指令的運作效率,進而導致快閃記憶體儲存裝置的延遲。因此,如何降低因為執行垃圾收集操作所導致的延遲,進而提升快閃記憶體儲存裝置的運作效率,為本領域技術人員所關心的議題。The memory storage device based on flash memory cannot overwrite the existing storage data, and needs to release the physical erasure unit through garbage collection operation on the storage data. Generally speaking, in the process of performing garbage collection, multiple physical erasing units are selected as the source physical erasing unit, and one physical erasing unit is selected as the target physical erasing unit. Then, the valid data in the source physical erasing unit is moved (or copied) to the target physical erasing unit, and the source physical erasing unit is erased to release the space occupied by the invalid data of the source physical erasing unit. However, before the target entity erase unit is turned off (that is, it is set to no longer be able to write any data), every write command of the host system must be garbage collected. As a result, the period during which garbage collection is performed will affect the operating efficiency of the write command of the host system in the dirty state of the flash memory storage device, which in turn causes the delay of the flash memory storage device. Therefore, how to reduce the delay caused by the garbage collection operation, thereby improving the operating efficiency of the flash memory storage device, is a topic of concern to those skilled in the art.

本發明提供一種快閃記憶體之資料整理方法、快閃記憶體儲存裝置及快閃記憶體控制電路單元,可藉由動態選擇垃圾收集操作的來源實體抹除單元和動態管理執行垃圾收集操作的時間來提高寫入指令的執行效率。The present invention provides a flash memory data sorting method, a flash memory storage device and a flash memory control circuit unit, which can dynamically select the source entity erasing unit of the garbage collection operation and dynamic management to perform the garbage collection operation Time to improve the execution efficiency of write instructions.

本發明的範例實施例提供一種快閃記憶體之資料整理方法,用於包括可複寫式非揮發性記憶體模組的記憶體儲存裝置,且所述快閃記憶體之資料整理方法包括:在背景模式執行背景垃圾收集操作;在所述背景垃圾收集操作未完成時接收主機系統的至少一個寫入指令,暫停所述背景垃圾收集操作且退出所述背景模式;執行所述寫入指令;以及完成執行所述至少一寫入指令後進入所述背景模式並繼續執行所述背景垃圾收集操作。An exemplary embodiment of the present invention provides a flash memory data organization method, which is used in a memory storage device including a rewritable non-volatile memory module, and the flash memory data organization method includes: The background mode executes a background garbage collection operation; receives at least one write instruction from the host system when the background garbage collection operation is not completed, suspends the background garbage collection operation and exits the background mode; executes the write instruction; and After completing the execution of the at least one write instruction, enter the background mode and continue to perform the background garbage collection operation.

在本發明的一實施例中,所述方法更包括:在執行所述背景垃圾收集操作時,將一或多個來源實體抹除單元的有效資料複製至目標實體抹除單元;抹除所述一或多個來源實體抹除單元且釋放所述一或多個來源實體抹除單元為空閒實體抹除單元;以及在暫停所述背景垃圾收集操作時,暫停將所述一或多個來源實體抹除單元的有效資料複製至所述目標實體抹除單元,並保留所述目標實體抹除單元且自所述背景模式進入前景模式以執行所述至少一個寫入指令。In an embodiment of the present invention, the method further includes: when performing the background garbage collection operation, copying valid data of one or more source entity erasing units to the target entity erasing unit; erasing the One or more source entity erasing units and releasing the one or more source entity erasing units as idle entity erasing units; and when the background garbage collection operation is suspended, the one or more source entities are suspended The effective data of the erasing unit is copied to the target entity erasing unit, and the target entity erasing unit is retained and enters the foreground mode from the background mode to execute the at least one write command.

在本發明的一實施例中,在所述背景模式執行所述背景垃圾收集操作的步驟包括:依據多個實體抹除單元對應的有效計數選擇所述實體抹除單元中的一或多個作為所述一或多個來源實體抹除單元,並將所述一或多個來源實體抹除單元的有效資料複製至所述目標實體抹除單元。In an embodiment of the present invention, the step of performing the background garbage collection operation in the background mode includes: selecting one or more of the physical erasing units as valid counts corresponding to a plurality of physical erasing units The one or more source physical erasing units and the effective data of the one or more source physical erasing units are copied to the target physical erasing unit.

在本發明的一實施例中,執行所述至少一個寫入指令的步驟包括:若在執行所述至少一個寫入指令的過程中有執行前景垃圾收集操作,則依據所述實體抹除單元對應的最新所述有效計數選擇所述實體抹除單元中的一或多個作為所述一或多個來源實體抹除單元,並將所述一或多個來源實體抹除單元的有效資料複製至所述目標實體抹除單元。In an embodiment of the present invention, the step of executing the at least one write instruction includes: if a foreground garbage collection operation is performed during the execution of the at least one write instruction, corresponding to the physical erasing unit The latest effective count of selects one or more of the physical erasure units as the one or more source physical erasure units, and copies the effective data of the one or more source physical erasure units to The target entity erasing unit.

在本發明的一實施例中,所述背景垃圾收集操作與所述前景垃圾收集操作共用相同的所述目標實體抹除單元。In an embodiment of the present invention, the background garbage collection operation and the foreground garbage collection operation share the same target entity erasing unit.

在本發明的一實施例中,用於判斷執行所述背景垃圾收集操作的第一啟動閥值大於判斷執行所述前景垃圾收集操作的第二啟動閥值。In an embodiment of the present invention, the first activation threshold for determining to perform the background garbage collection operation is greater than the second activation threshold for determining to perform the foreground garbage collection operation.

在本發明的一實施例中,完成執行所述至少一個寫入指令後進入所述背景模式並繼續執行所述背景垃圾收集操作的步驟更包括:在完成執行所述至少一個寫入指令後經過預定時間後進入所述背景模式;依據所述實體抹除單元對應的最新所述有效計數執行所述背景垃圾收集操作,選擇所述實體抹除單元中的一或多個作為所述一或多個來源實體抹除單元,並將所述一或多個來源實體抹除單元的有效資料複製至所述目標實體抹除單元。In an embodiment of the present invention, the step of entering the background mode and continuing to perform the background garbage collection operation after completing the execution of the at least one write instruction further includes: after completing the execution of the at least one write instruction, Enter the background mode after a predetermined time; execute the background garbage collection operation according to the latest effective count corresponding to the physical erasing unit, and select one or more of the physical erasing units as the one or more A source physical erasing unit, and copy valid data of the one or more source physical erasing units to the target physical erasing unit.

本發明的範例實施例提供一種快閃記憶體儲存裝置,包括連接介面單元、可複寫式非揮發性記憶體模組以及快閃記憶體控制電路單元。所述連接介面單元用以耦接至主機系統。所述快閃記憶體控制電路單元耦接至所述連接介面單元與所述可複寫式非揮發性記憶體模組,其中所述快閃記憶體控制電路單元用以在背景模式執行背景垃圾收集操作。所述快閃記憶體控制電路單元更用以在所述背景垃圾收集操作未完成時接收主機系統的至少一個寫入指令,暫停所述背景垃圾收集操作且退出所述背景模式。所述快閃記憶體控制電路單元更用以執行所述至少一個寫入指令。並且,所述快閃記憶體控制電路單元更用以完成執行所述至少一個寫入指令後進入所述背景模式並繼續執行所述背景垃圾收集操作。An exemplary embodiment of the present invention provides a flash memory storage device, including a connection interface unit, a rewritable non-volatile memory module, and a flash memory control circuit unit. The connection interface unit is used for coupling to the host system. The flash memory control circuit unit is coupled to the connection interface unit and the rewritable non-volatile memory module, wherein the flash memory control circuit unit is used to perform background garbage collection in a background mode operate. The flash memory control circuit unit is further configured to receive at least one write instruction from the host system when the background garbage collection operation is not completed, suspend the background garbage collection operation and exit the background mode. The flash memory control circuit unit is further used to execute the at least one write command. Moreover, the flash memory control circuit unit is further configured to enter the background mode after completing the execution of the at least one write instruction and continue to perform the background garbage collection operation.

在本發明的一實施例中,所述快閃記憶體控制電路單元更用以在執行所述背景垃圾收集操作時,將一或多個來源實體抹除單元的有效資料複製至目標實體抹除單元。所述快閃記憶體控制電路單元更用以抹除所述一或多個來源實體抹除單元且釋放所述一或多個來源實體抹除單元為空閒實體抹除單元。並且,所述快閃記憶體控制電路單元更用以在暫停所述背景垃圾收集操作時,暫停將所述一或多個來源實體抹除單元的有效資料複製至所述目標實體抹除單元,並保留所述目標實體抹除單元且自所述背景模式進入前景模式以執行所述至少一個寫入指令。In an embodiment of the present invention, the flash memory control circuit unit is further used for copying the effective data of one or more source entity erasing units to the target entity erasing when performing the background garbage collection operation unit. The flash memory control circuit unit is further used for erasing the one or more source physical erasing units and releasing the one or more source physical erasing units as idle physical erasing units. Moreover, the flash memory control circuit unit is further configured to suspend the copying of valid data of the one or more source physical erasing units to the target physical erasing unit when the background garbage collection operation is suspended, And reserve the target entity erasing unit and enter the foreground mode from the background mode to execute the at least one write command.

在本發明的一實施例中,在所述背景模式執行所述背景垃圾收集操作的運作中,所述快閃記憶體控制電路單元更用以依據多個實體抹除單元對應的有效計數選擇所述實體抹除單元中的一或多個作為所述一或多個來源實體抹除單元,並將所述一或多個來源實體抹除單元的有效資料複製至所述目標實體抹除單元。In an embodiment of the present invention, in the operation of performing the background garbage collection operation in the background mode, the flash memory control circuit unit is further configured to select the effective count corresponding to a plurality of physical erasing units. One or more of the physical erasing units are used as the one or more source physical erasing units, and valid data of the one or more source physical erasing units are copied to the target physical erasing unit.

在本發明的一實施例中,執行所述至少一個寫入指令的運作中,若在執行所述至少一個寫入指令的過程中有執行前景垃圾收集操作,則所述快閃記憶體控制電路單元更用以依據所述實體抹除單元對應的最新所述有效計數選擇所述實體抹除單元中的一或多個作為所述一或多個來源實體抹除單元,並將所述一或多個來源實體抹除單元的有效資料複製至所述目標實體抹除單元。In an embodiment of the present invention, in the operation of executing the at least one write instruction, if a foreground garbage collection operation is performed during the execution of the at least one write instruction, the flash memory control circuit The unit is further used for selecting one or more of the physical erasing units as the one or more source physical erasing units according to the latest effective count corresponding to the physical erasing unit, and combining the one or more The valid data of a plurality of source physical erasing units are copied to the target physical erasing unit.

在本發明的一實施例中,所述背景垃圾收集操作與所述前景垃圾收集操作共用相同的所述目標實體抹除單元。In an embodiment of the present invention, the background garbage collection operation and the foreground garbage collection operation share the same target entity erasing unit.

在本發明的一實施例中,用於判斷執行所述背景垃圾收集操作的第一啟動閥值大於判斷執行所述前景垃圾收集操作的第二啟動閥值。In an embodiment of the present invention, the first activation threshold for determining to perform the background garbage collection operation is greater than the second activation threshold for determining to perform the foreground garbage collection operation.

在本發明的一實施例中,完成執行所述至少一個寫入指令後進入所述背景模式並繼續執行所述背景垃圾收集操作的運作中,所述快閃記憶體控制電路單元更用以在完成執行所述至少一個寫入指令後經過預定時間後進入所述背景模式。並且,所述快閃記憶體控制電路單元更用以依據所述實體抹除單元對應的最新所述有效計數執行所述背景垃圾收集操作,選擇所述實體抹除單元中的一或多個作為所述一或多個來源實體抹除單元,並將所述一或多個來源實體抹除單元的有效資料複製至所述目標實體抹除單元。In an embodiment of the present invention, after the execution of the at least one write command is completed, the background mode is entered and the background garbage collection operation is continued. The flash memory control circuit unit is further used for The background mode is entered after a predetermined time has elapsed after the completion of the execution of the at least one write instruction. Moreover, the flash memory control circuit unit is further configured to perform the background garbage collection operation according to the latest effective count corresponding to the physical erasing unit, and select one or more of the physical erasing units as The one or more source physical erasing units and the effective data of the one or more source physical erasing units are copied to the target physical erasing unit.

本發明的範例實施例提供一種快閃記憶體控制電路單元,用於控制包括可複寫式非揮發性記憶體模組的快閃記憶體儲存裝置,且所述快閃記憶體控制電路單元包括主機介面、記憶體介面以及記憶體管理電路。所述主機介面用以耦接至主機系統。所述記憶體介面用以耦接至所述可複寫式非揮發性記憶體模組。所述記憶體管理電路耦接至所述主機介面與所述記憶體介面。所述快閃記憶體控制電路單元用以在背景模式執行背景垃圾收集操作。所述快閃記憶體控制電路單元更用以在所述背景垃圾收集操作未完成時接收主機系統的至少一個寫入指令,暫停所述背景垃圾收集操作且退出所述背景模式。所述快閃記憶體控制電路單元更用以執行所述至少一個寫入指令。並且,所述快閃記憶體控制電路單元更用以完成執行所述至少一個寫入指令後進入所述背景模式並繼續執行所述背景垃圾收集操作。Example embodiments of the present invention provide a flash memory control circuit unit for controlling a flash memory storage device including a rewritable non-volatile memory module, and the flash memory control circuit unit includes a host Interface, memory interface and memory management circuit. The host interface is used for coupling to a host system. The memory interface is used for coupling to the rewritable non-volatile memory module. The memory management circuit is coupled to the host interface and the memory interface. The flash memory control circuit unit is used to perform a background garbage collection operation in a background mode. The flash memory control circuit unit is further configured to receive at least one write instruction from the host system when the background garbage collection operation is not completed, suspend the background garbage collection operation and exit the background mode. The flash memory control circuit unit is further used to execute the at least one write command. Moreover, the flash memory control circuit unit is further configured to enter the background mode after completing the execution of the at least one write instruction and continue to perform the background garbage collection operation.

在本發明的一實施例中,所述快閃記憶體控制電路單元更用以在執行所述背景垃圾收集操作時,將一或多個來源實體抹除單元的有效資料複製至目標實體抹除單元。所述快閃記憶體控制電路單元更用以抹除所述一或多個來源實體抹除單元且釋放所述一或多個來源實體抹除單元為空閒實體抹除單元。並且,所述快閃記憶體控制電路單元更用以在暫停所述背景垃圾收集操作時,暫停將所述一或多個來源實體抹除單元的有效資料複製至所述目標實體抹除單元,並保留所述目標實體抹除單元且自所述背景模式進入前景模式以執行所述至少一個寫入指令。In an embodiment of the present invention, the flash memory control circuit unit is further used for copying the effective data of one or more source entity erasing units to the target entity erasing when performing the background garbage collection operation unit. The flash memory control circuit unit is further used for erasing the one or more source physical erasing units and releasing the one or more source physical erasing units as idle physical erasing units. Moreover, the flash memory control circuit unit is further configured to suspend the copying of valid data of the one or more source physical erasing units to the target physical erasing unit when the background garbage collection operation is suspended, And reserve the target entity erasing unit and enter the foreground mode from the background mode to execute the at least one write command.

在本發明的一實施例中,在所述背景模式執行所述背景垃圾收集操作的運作中,所述快閃記憶體控制電路單元更用以依據多個實體抹除單元對應的有效計數選擇所述實體抹除單元中的一或多個作為所述一或多個來源實體抹除單元,並將所述一或多個來源實體抹除單元的有效資料複製至所述目標實體抹除單元。In an embodiment of the present invention, in the operation of performing the background garbage collection operation in the background mode, the flash memory control circuit unit is further configured to select the effective count corresponding to a plurality of physical erasing units. One or more of the physical erasing units are used as the one or more source physical erasing units, and valid data of the one or more source physical erasing units are copied to the target physical erasing unit.

在本發明的一實施例中,執行所述至少一個寫入指令的運作中,若在執行所述至少一個寫入指令的過程中有執行前景垃圾收集操作,則所述快閃記憶體控制電路單元更用以依據所述實體抹除單元對應的最新所述有效計數選擇所述實體抹除單元中的一或多個作為所述一或多個來源實體抹除單元,並將所述一或多個來源實體抹除單元的有效資料複製至所述目標實體抹除單元。In an embodiment of the present invention, in the operation of executing the at least one write instruction, if a foreground garbage collection operation is performed during the execution of the at least one write instruction, the flash memory control circuit The unit is further used for selecting one or more of the physical erasing units as the one or more source physical erasing units according to the latest effective count corresponding to the physical erasing unit, and combining the one or more The valid data of a plurality of source physical erasing units are copied to the target physical erasing unit.

在本發明的一實施例中,所述背景垃圾收集操作與所述前景垃圾收集操作共用相同的所述目標實體抹除單元。In an embodiment of the present invention, the background garbage collection operation and the foreground garbage collection operation share the same target entity erasing unit.

在本發明的一實施例中,用於判斷執行所述背景垃圾收集操作的第一啟動閥值大於判斷執行所述前景垃圾收集操作的第二啟動閥值。In an embodiment of the present invention, the first activation threshold for determining to perform the background garbage collection operation is greater than the second activation threshold for determining to perform the foreground garbage collection operation.

在本發明的一實施例中,完成執行所述至少一個寫入指令後進入所述背景模式並繼續執行所述背景垃圾收集操作的運作中,所述快閃記憶體控制電路單元更用以在完成執行所述至少一個寫入指令後經過預定時間後進入所述背景模式。並且,所述快閃記憶體控制電路單元更用以依據所述實體抹除單元對應的最新所述有效計數執行所述背景垃圾收集操作,選擇所述實體抹除單元中的一或多個作為所述一或多個來源實體抹除單元,並將所述一或多個來源實體抹除單元的有效資料複製至所述目標實體抹除單元。In an embodiment of the present invention, after the execution of the at least one write command is completed, the background mode is entered and the background garbage collection operation is continued. The flash memory control circuit unit is further used for The background mode is entered after a predetermined time has elapsed after the completion of the execution of the at least one write instruction. Moreover, the flash memory control circuit unit is further configured to perform the background garbage collection operation according to the latest effective count corresponding to the physical erasing unit, and select one or more of the physical erasing units as The one or more source physical erasing units and the effective data of the one or more source physical erasing units are copied to the target physical erasing unit.

基於上述,在前景垃圾收集操作及背景垃圾收集操作可將來源實體抹除單元的有效資料搬移(或複製)至相同的目標實體抹除單元。並且在前景模式下,當可複寫式非揮發性記憶體模組的空閒實體抹除單元數量不大於啟動閥值,則依據多個實體抹除單元對應的有效計數選擇多個來源實體抹除單元以執行垃圾收集操作。並且當可複寫式非揮發性記憶體模組的空閒實體抹除單元數量大於啟動閥值,則執行寫入指令。換言之,藉由動態選擇垃圾收集操作的來源實體抹除單元和動態管理執行垃圾收集操作的時間,可有效提高寫入指令的執行效率。Based on the above, in the foreground garbage collection operation and the background garbage collection operation, the effective data of the source entity erasing unit can be moved (or copied) to the same target entity erasing unit. And in the foreground mode, when the number of free physical erasing units of the rewritable non-volatile memory module is not greater than the activation threshold, multiple source physical erasing units are selected based on the effective counts corresponding to multiple physical erasing units To perform garbage collection. And when the number of free physical erase units of the rewritable non-volatile memory module is greater than the activation threshold, the write command is executed. In other words, by dynamically selecting the source entity erasing unit of the garbage collection operation and dynamically managing the time for executing the garbage collection operation, the execution efficiency of the write instruction can be effectively improved.

一般而言,記憶體儲存裝置(亦稱,記憶體儲存系統)包括可複寫式非揮發性記憶體模組與控制器(亦稱,控制電路單元)。通常記憶體儲存裝置是與主機系統一起使用,以使主機系統可將資料寫入至記憶體儲存裝置或從記憶體儲存裝置中讀取資料。Generally speaking, a memory storage device (also known as a memory storage system) includes a rewritable non-volatile memory module and a controller (also known as a control circuit unit). Generally, the memory storage device is used together with the host system, so that the host system can write data to the memory storage device or read data from the memory storage device.

圖1是根據一範例實施例所繪示的主機系統、記憶體儲存裝置及輸入/輸出(I/O)裝置的示意圖。且圖2是根據另一範例實施例所繪示的主機系統、記憶體儲存裝置及輸入/輸出(I/O)裝置的示意圖。FIG. 1 is a schematic diagram of a host system, a memory storage device, and an input/output (I/O) device according to an exemplary embodiment. And FIG. 2 is a schematic diagram of a host system, a memory storage device, and an input/output (I/O) device according to another exemplary embodiment.

請參照圖1與圖2,主機系統11一般包括處理器111、隨機存取記憶體(random access memory, RAM)112、唯讀記憶體(read only memory, ROM)113及資料傳輸介面114。處理器111、隨機存取記憶體112、唯讀記憶體113及資料傳輸介面114皆耦接至系統匯流排(system bus)110。1 and 2, the host system 11 generally includes a processor 111, a random access memory (RAM) 112, a read only memory (ROM) 113, and a data transmission interface 114. The processor 111, the random access memory 112, the read-only memory 113, and the data transmission interface 114 are all coupled to a system bus 110.

在本範例實施例中,主機系統11是透過資料傳輸介面114與記憶體儲存裝置10耦接。例如,主機系統11可經由資料傳輸介面114將資料寫入至記憶體儲存裝置10或從記憶體儲存裝置10中讀取資料。此外,主機系統11是透過系統匯流排110與I/O裝置12耦接。例如,主機系統11可經由系統匯流排110將輸出訊號傳送至I/O裝置12或從I/O裝置12接收輸入訊號。In this exemplary embodiment, the host system 11 is coupled to the memory storage device 10 through the data transmission interface 114. For example, the host system 11 can write data to the memory storage device 10 or read data from the memory storage device 10 via the data transmission interface 114. In addition, the host system 11 is coupled to the I/O device 12 through the system bus 110. For example, the host system 11 can transmit output signals to the I/O device 12 or receive input signals from the I/O device 12 via the system bus 110.

在本範例實施例中,處理器111、隨機存取記憶體112、唯讀記憶體113及資料傳輸介面114是可設置在主機系統11的主機板20上。資料傳輸介面114的數目可以是一或多個。透過資料傳輸介面114,主機板20可以經由有線或無線方式耦接至記憶體儲存裝置10。記憶體儲存裝置10可例如是隨身碟201、記憶卡202、固態硬碟(Solid State Drive, SSD)203或無線記憶體儲存裝置204。無線記憶體儲存裝置204可例如是近距離無線通訊(Near Field Communication Storage, NFC)記憶體儲存裝置、無線傳真(WiFi)記憶體儲存裝置、藍牙(Bluetooth)記憶體儲存裝置或低功耗藍牙記憶體儲存裝置(例如,iBeacon)等以各式無線通訊技術為基礎的記憶體儲存裝置。此外,主機板20也可以透過系統匯流排110耦接至全球定位系統(Global Positioning System, GPS)模組205、網路介面卡206、無線傳輸裝置207、鍵盤208、螢幕209、喇叭210等各式I/O裝置。例如,在一範例實施例中,主機板20可透過無線傳輸裝置207存取無線記憶體儲存裝置204。In this exemplary embodiment, the processor 111, the random access memory 112, the read-only memory 113, and the data transmission interface 114 can be disposed on the motherboard 20 of the host system 11. The number of data transmission interfaces 114 may be one or more. Through the data transmission interface 114, the motherboard 20 can be coupled to the memory storage device 10 in a wired or wireless manner. The memory storage device 10 may be, for example, a flash drive 201, a memory card 202, a solid state drive (SSD) 203, or a wireless memory storage device 204. The wireless memory storage device 204 may be, for example, a Near Field Communication Storage (NFC) memory storage device, a wireless fax (WiFi) memory storage device, a Bluetooth (Bluetooth) memory storage device, or a Bluetooth low energy memory. A memory storage device based on various wireless communication technologies such as a bulk storage device (for example, iBeacon). In addition, the motherboard 20 can also be coupled to a Global Positioning System (GPS) module 205, a network interface card 206, a wireless transmission device 207, a keyboard 208, a screen 209, and a speaker 210 through the system bus 110. Type I/O device. For example, in an exemplary embodiment, the motherboard 20 can access the wireless memory storage device 204 through the wireless transmission device 207.

在一範例實施例中,所提及的主機系統為可實質地與記憶體儲存裝置配合以儲存資料的任意系統。雖然在上述範例實施例中,主機系統是以電腦系統來作說明,然而,圖3是根據另一範例實施例所繪示的主機系統與記憶體儲存裝置的示意圖。請參照圖3,在另一範例實施例中,主機系統31也可以是數位相機、攝影機、通訊裝置、音訊播放器、視訊播放器或平板電腦等系統,而記憶體儲存裝置30可為其所使用的SD卡32、CF卡33或嵌入式儲存裝置34等各式非揮發性記憶體儲存裝置。嵌入式儲存裝置34包括嵌入式多媒體卡(embedded MMC, eMMC)341及/或嵌入式多晶片封裝(embedded Multi Chip Package, eMCP)儲存裝置342等各類型將記憶體模組直接耦接於主機系統的基板上的嵌入式儲存裝置。In an exemplary embodiment, the host system mentioned is any system that can substantially cooperate with a memory storage device to store data. Although in the above exemplary embodiment, the host system is described as a computer system, FIG. 3 is a schematic diagram of the host system and the memory storage device according to another exemplary embodiment. 3, in another exemplary embodiment, the host system 31 can also be a system such as a digital camera, a video camera, a communication device, an audio player, a video player, or a tablet computer, and the memory storage device 30 can be used for it. Various non-volatile memory storage devices such as SD card 32, CF card 33 or embedded storage device 34 are used. The embedded storage device 34 includes embedded MMC (eMMC) 341 and/or embedded Multi Chip Package (embedded Multi Chip Package, eMCP) storage device 342. The memory module is directly coupled to the host system. Embedded storage device on the substrate.

圖4是根據本發明的一範例實施例所繪示的記憶體儲存裝置的概要方塊圖。請參照圖4,記憶體儲存裝置10(在本實施例中即,快閃記憶體儲存裝置)包括連接介面單元402、記憶體控制電路單元404(在本實施例中即,快閃記憶體控制電路單元)與可複寫式非揮發性記憶體模組406。FIG. 4 is a schematic block diagram of a memory storage device according to an exemplary embodiment of the present invention. 4, the memory storage device 10 (in this embodiment, flash memory storage device) includes a connection interface unit 402, a memory control circuit unit 404 (in this embodiment, flash memory control Circuit unit) and a rewritable non-volatile memory module 406.

連接介面單元402用以將記憶體儲存裝置10耦接至主機系統11。記憶體儲存裝置10可透過連接介面單元402與主機系統11通訊。在本範例實施例中,連接介面單元402是相容於序列先進附件(Serial Advanced Technology Attachment, SATA)標準。然而,必須瞭解的是,本發明不限於此,連接介面單元402亦可以是符合並列先進附件(Parallel Advanced Technology Attachment, PATA)標準、電氣和電子工程師協會(Institute of Electrical and Electronic Engineers, IEEE)1394標準、高速周邊零件連接介面(Peripheral Component Interconnect Express, PCI Express)標準、通用序列匯流排(Universal Serial Bus, USB)標準、SD介面標準、超高速一代(Ultra High Speed-I, UHS-I)介面標準、超高速二代(Ultra High Speed-II, UHS-II)介面標準、記憶棒(Memory Stick, MS)介面標準、MCP介面標準、MMC介面標準、eMMC介面標準、通用快閃記憶體(Universal Flash Storage, UFS)介面標準、eMCP介面標準、CF介面標準、整合式驅動電子介面(Integrated Device Electronics, IDE)標準或其他適合的標準。連接介面單元402可與記憶體控制電路單元404封裝在一個晶片中,或者連接介面單元402是佈設於一包含記憶體控制電路單元404之晶片外。The connection interface unit 402 is used to couple the memory storage device 10 to the host system 11. The memory storage device 10 can communicate with the host system 11 through the connection interface unit 402. In this exemplary embodiment, the connection interface unit 402 is compatible with the Serial Advanced Technology Attachment (SATA) standard. However, it must be understood that the present invention is not limited to this, and the connection interface unit 402 may also conform to the Parallel Advanced Technology Attachment (PATA) standard, the Institute of Electrical and Electronic Engineers (IEEE) 1394 Standard, high-speed peripheral component connection interface (Peripheral Component Interconnect Express, PCI Express) standard, universal serial bus (Universal Serial Bus, USB) standard, SD interface standard, Ultra High Speed-I (UHS-I) interface Standard, Ultra High Speed-II (UHS-II) interface standard, Memory Stick (MS) interface standard, MCP interface standard, MMC interface standard, eMMC interface standard, universal flash memory (Universal Flash Storage, UFS) interface standard, eMCP interface standard, CF interface standard, Integrated Device Electronics (IDE) standard or other suitable standards. The connection interface unit 402 and the memory control circuit unit 404 can be packaged in one chip, or the connection interface unit 402 can be arranged outside a chip including the memory control circuit unit 404.

記憶體控制電路單元404用以執行以硬體型式或韌體型式實作的多個邏輯閘或控制指令並且根據主機系統11的指令在可複寫式非揮發性記憶體模組406中進行資料的寫入、讀取與抹除等運作。The memory control circuit unit 404 is used to execute a plurality of logic gates or control commands implemented in a hardware type or a firmware type, and perform data processing in the rewritable non-volatile memory module 406 according to the instructions of the host system 11 Operations such as writing, reading, and erasing.

可複寫式非揮發性記憶體模組406是耦接至記憶體控制電路單元404並且用以儲存主機系統11所寫入之資料。可複寫式非揮發性記憶體模組406可以是單階記憶胞(Single Level Cell, SLC)NAND型快閃記憶體模組(即,一個記憶胞中可儲存1個位元的快閃記憶體模組)、多階記憶胞(Multi Level Cell, MLC)NAND型快閃記憶體模組(即,一個記憶胞中可儲存2個位元的快閃記憶體模組)、三階記憶胞(Triple Level Cell, TLC)NAND型快閃記憶體模組(即,一個記憶胞中可儲存3個位元的快閃記憶體模組)、四階記憶胞(Quad Level Cell, QLC)NAND型快閃記憶體模組(即,一個記憶胞中可儲存4個位元的快閃記憶體模組)、其他快閃記憶體模組或其他具有相同特性的記憶體模組。The rewritable non-volatile memory module 406 is coupled to the memory control circuit unit 404 and used to store data written by the host system 11. The rewritable non-volatile memory module 406 may be a single level cell (SLC) NAND flash memory module (that is, a flash memory that can store 1 bit in a memory cell). Module), Multi Level Cell (MLC) NAND-type flash memory module (that is, a flash memory module that can store 2 bits in a memory cell), and a third-level memory cell ( Triple Level Cell, TLC) NAND type flash memory module (that is, a flash memory module that can store 3 bits in a memory cell), Quad Level Cell (QLC) NAND type flash memory module Flash memory module (that is, a flash memory module that can store 4 bits in a memory cell), other flash memory modules, or other memory modules with the same characteristics.

可複寫式非揮發性記憶體模組406中的每一個記憶胞是以電壓(以下亦稱為臨界電壓)的改變來儲存一或多個位元。具體來說,每一個記憶胞的控制閘極(control gate)與通道之間有一個電荷捕捉層。透過施予一寫入電壓至控制閘極,可以改變電荷補捉層的電子量,進而改變記憶胞的臨界電壓。此改變記憶胞之臨界電壓的操作亦稱為「把資料寫入至記憶胞」或「程式化(programming)記憶胞」。隨著臨界電壓的改變,可複寫式非揮發性記憶體模組406中的每一個記憶胞具有多個儲存狀態。透過施予讀取電壓可以判斷一個記憶胞是屬於哪一個儲存狀態,藉此取得此記憶胞所儲存的一或多個位元。Each memory cell in the rewritable non-volatile memory module 406 stores one or more bits with a change in voltage (hereinafter also referred to as a threshold voltage). Specifically, there is a charge trapping layer between the control gate of each memory cell and the channel. By applying a write voltage to the control gate, the amount of electrons in the charge trapping layer can be changed, thereby changing the threshold voltage of the memory cell. This operation of changing the threshold voltage of the memory cell is also called "writing data to the memory cell" or "programming the memory cell". As the threshold voltage changes, each memory cell in the rewritable non-volatile memory module 406 has multiple storage states. By applying the read voltage, it is possible to determine which storage state a memory cell belongs to, thereby obtaining one or more bits stored in the memory cell.

在本範例實施例中,可複寫式非揮發性記憶體模組406的記憶胞可構成多個實體程式化單元,並且此些實體程式化單元可構成多個實體抹除單元。具體來說,同一條字元線上的記憶胞可組成一或多個實體程式化單元。若每一個記憶胞可儲存2個以上的位元,則同一條字元線上的實體程式化單元可至少可被分類為下實體程式化單元與上實體程式化單元。例如,一記憶胞的最低有效位元(Least Significant Bit, LSB)是屬於下實體程式化單元,並且一記憶胞的最高有效位元(Most Significant Bit, MSB)是屬於上實體程式化單元。一般來說,在MLC NAND型快閃記憶體中,下實體程式化單元的寫入速度會大於上實體程式化單元的寫入速度,及/或下實體程式化單元的可靠度是高於上實體程式化單元的可靠度。In this exemplary embodiment, the memory cells of the rewritable non-volatile memory module 406 can constitute a plurality of physical programming units, and these physical programming units can constitute a plurality of physical erasing units. Specifically, the memory cells on the same character line can form one or more physical programming units. If each memory cell can store more than two bits, the physical programming unit on the same character line can be at least classified into a lower physical programming unit and an upper physical programming unit. For example, the Least Significant Bit (LSB) of a memory cell belongs to the lower physical programming unit, and the Most Significant Bit (MSB) of a memory cell belongs to the upper physical programming unit. Generally speaking, in MLC NAND flash memory, the writing speed of the lower physical programming unit is higher than that of the upper physical programming unit, and/or the reliability of the lower physical programming unit is higher than that of the upper physical programming unit. The reliability of the physical programming unit.

在本範例實施例中,實體程式化單元為程式化的最小單元。即,實體程式化單元為寫入資料的最小單元。例如,實體程式化單元可為實體頁面(page)或是實體扇(sector)。若實體程式化單元為實體頁面,則此些實體程式化單元可包括資料位元區與冗餘(redundancy)位元區。資料位元區包含多個實體扇,用以儲存使用者資料,而冗餘位元區用以儲存系統資料(例如,錯誤更正碼等管理資料)。在本範例實施例中,資料位元區包含32個實體扇,且一個實體扇的大小為512位元組(byte, B)。然而,在其他範例實施例中,資料位元區中也可包含8個、16個或數目更多或更少的實體扇,並且每一個實體扇的大小也可以是更大或更小。另一方面,實體抹除單元為抹除之最小單位。亦即,每一實體抹除單元含有最小數目之一併被抹除之記憶胞。例如,實體抹除單元為實體區塊(block)。In this exemplary embodiment, the physical programming unit is the smallest programming unit. That is, the physical programming unit is the smallest unit for writing data. For example, the physical programming unit can be a physical page (page) or a physical sector (sector). If the physical programming unit is a physical page, these physical programming units may include a data bit area and a redundancy bit area. The data bit area contains multiple physical sectors to store user data, and the redundant bit area is used to store system data (for example, management data such as error correction codes). In this exemplary embodiment, the data bit area includes 32 physical sectors, and the size of one physical sector is 512 bytes (byte, B). However, in other exemplary embodiments, the data bit area can also include 8, 16, or more or less physical sectors, and the size of each physical sector can also be larger or smaller. On the other hand, the physical erasure unit is the smallest unit of erasure. That is, each physical erasing unit contains one of the smallest number of memory cells to be erased. For example, the physical erasing unit is a physical block.

圖5是根據本發明的一範例實施例所繪示的記憶體控制電路單元的概要方塊圖。請參照圖5,記憶體控制電路單元404包括記憶體管理電路502、主機介面504及記憶體介面506。FIG. 5 is a schematic block diagram of a memory control circuit unit according to an exemplary embodiment of the present invention. 5, the memory control circuit unit 404 includes a memory management circuit 502, a host interface 504, and a memory interface 506.

記憶體管理電路502用以控制記憶體控制電路單元404的整體運作。具體來說,記憶體管理電路502具有多個控制指令,並且在記憶體儲存裝置10運作時,此些控制指令會被執行以進行資料的寫入、讀取與抹除等運作。以下說明記憶體管理電路502的操作時,等同於說明記憶體控制電路單元404的操作。The memory management circuit 502 is used to control the overall operation of the memory control circuit unit 404. Specifically, the memory management circuit 502 has a plurality of control commands, and when the memory storage device 10 is operating, these control commands are executed to perform operations such as writing, reading, and erasing data. The following description of the operation of the memory management circuit 502 is equivalent to the description of the operation of the memory control circuit unit 404.

在本範例實施例中,記憶體管理電路502的控制指令是以韌體型式來實作。例如,記憶體管理電路502具有微處理器單元(未繪示)與唯讀記憶體(未繪示),並且此些控制指令是被燒錄至此唯讀記憶體中。當記憶體儲存裝置10運作時,此些控制指令會由微處理器單元來執行以進行資料的寫入、讀取與抹除等運作。In this exemplary embodiment, the control commands of the memory management circuit 502 are implemented in firmware. For example, the memory management circuit 502 has a microprocessor unit (not shown) and a read-only memory (not shown), and these control commands are burned into the read-only memory. When the memory storage device 10 is operating, these control commands are executed by the microprocessor unit to perform operations such as writing, reading, and erasing data.

在另一範例實施例中,記憶體管理電路502的控制指令亦可以程式碼型式儲存於可複寫式非揮發性記憶體模組406的特定區域(例如,記憶體模組中專用於存放系統資料的系統區)中。此外,記憶體管理電路502具有微處理器單元(未繪示)、唯讀記憶體(未繪示)及隨機存取記憶體(未繪示)。特別是,此唯讀記憶體具有開機碼(boot code),並且當記憶體控制電路單元404被致能時,微處理器單元會先執行此開機碼來將儲存於可複寫式非揮發性記憶體模組406中之控制指令載入至記憶體管理電路502的隨機存取記憶體中。之後,微處理器單元會運轉此些控制指令以進行資料的寫入、讀取與抹除等運作。In another exemplary embodiment, the control commands of the memory management circuit 502 can also be stored in a specific area of the rewritable non-volatile memory module 406 in the form of code (for example, the memory module is dedicated to storing system data). System area). In addition, the memory management circuit 502 has a microprocessor unit (not shown), a read-only memory (not shown), and a random access memory (not shown). In particular, the read-only memory has a boot code, and when the memory control circuit unit 404 is enabled, the microprocessor unit will first execute the boot code to store it in the rewritable non-volatile memory The control commands in the volume module 406 are loaded into the random access memory of the memory management circuit 502. After that, the microprocessor unit runs these control commands to perform data writing, reading, and erasing operations.

此外,在另一範例實施例中,記憶體管理電路502的控制指令亦可以一硬體型式來實作。例如,記憶體管理電路502包括微控制器、記憶胞管理電路、記憶體寫入電路、記憶體讀取電路、記憶體抹除電路與資料處理電路。記憶胞管理電路、記憶體寫入電路、記憶體讀取電路、記憶體抹除電路與資料處理電路是耦接至微控制器。記憶胞管理電路用以管理可複寫式非揮發性記憶體模組406的記憶胞或記憶胞群組。記憶體寫入電路用以對可複寫式非揮發性記憶體模組406下達寫入指令序列以將資料寫入至可複寫式非揮發性記憶體模組406中。記憶體讀取電路用以對可複寫式非揮發性記憶體模組406下達讀取指令序列以從可複寫式非揮發性記憶體模組406中讀取資料。記憶體抹除電路用以對可複寫式非揮發性記憶體模組406下達抹除指令序列以將資料從可複寫式非揮發性記憶體模組406中抹除。資料處理電路用以處理欲寫入至可複寫式非揮發性記憶體模組406的資料以及從可複寫式非揮發性記憶體模組406中讀取的資料。寫入指令序列、讀取指令序列及抹除指令序列可各別包括一或多個程式碼或指令碼並且用以指示可複寫式非揮發性記憶體模組406執行相對應的寫入、讀取及抹除等操作。在一範例實施例中,記憶體管理電路502還可以下達其他類型的指令序列給可複寫式非揮發性記憶體模組406以指示執行相對應的操作。In addition, in another exemplary embodiment, the control commands of the memory management circuit 502 can also be implemented in a hardware type. For example, the memory management circuit 502 includes a microcontroller, a memory cell management circuit, a memory writing circuit, a memory reading circuit, a memory erasing circuit, and a data processing circuit. The memory cell management circuit, the memory writing circuit, the memory reading circuit, the memory erasing circuit and the data processing circuit are coupled to the microcontroller. The memory cell management circuit is used to manage the memory cell or the memory cell group of the rewritable non-volatile memory module 406. The memory write circuit is used to issue a write command sequence to the rewritable non-volatile memory module 406 to write data into the rewritable non-volatile memory module 406. The memory read circuit is used to issue a read command sequence to the rewritable non-volatile memory module 406 to read data from the rewritable non-volatile memory module 406. The memory erasing circuit is used to issue an erasing command sequence to the rewritable non-volatile memory module 406 to erase data from the rewritable non-volatile memory module 406. The data processing circuit is used for processing data to be written to the rewritable non-volatile memory module 406 and data read from the rewritable non-volatile memory module 406. The write command sequence, the read command sequence, and the erase command sequence may each include one or more program codes or command codes and are used to instruct the rewritable non-volatile memory module 406 to perform corresponding writing and reading. Take and erase operations. In an exemplary embodiment, the memory management circuit 502 can also send other types of command sequences to the rewritable non-volatile memory module 406 to instruct to perform corresponding operations.

主機介面504是耦接至記憶體管理電路502。記憶體管理電路502可透過主機介面504與主機系統11通訊。主機介面504可用以接收與識別主機系統11所傳送的指令與資料。例如,主機系統11所傳送的指令與資料可透過主機介面504來傳送至記憶體管理電路502。此外,記憶體管理電路502可透過主機介面504將資料傳送至主機系統11。在本範例實施例中,主機介面504是相容於SATA標準。然而,必須瞭解的是本發明不限於此,主機介面504亦可以是相容於PATA標準、IEEE 1394標準、PCI Express標準、USB標準、SD標準、UHS-I標準、UHS-II標準、MS標準、MMC標準、eMMC標準、UFS標準、CF標準、IDE標準或其他適合的資料傳輸標準。The host interface 504 is coupled to the memory management circuit 502. The memory management circuit 502 can communicate with the host system 11 through the host interface 504. The host interface 504 can be used to receive and identify commands and data sent by the host system 11. For example, the commands and data sent by the host system 11 can be sent to the memory management circuit 502 through the host interface 504. In addition, the memory management circuit 502 can transmit data to the host system 11 through the host interface 504. In this exemplary embodiment, the host interface 504 is compatible with the SATA standard. However, it must be understood that the present invention is not limited to this. The host interface 504 can also be compatible with PATA standards, IEEE 1394 standards, PCI Express standards, USB standards, SD standards, UHS-I standards, UHS-II standards, and MS standards. , MMC standard, eMMC standard, UFS standard, CF standard, IDE standard or other suitable data transmission standards.

記憶體介面506是耦接至記憶體管理電路502並且用以存取可複寫式非揮發性記憶體模組406。也就是說,欲寫入至可複寫式非揮發性記憶體模組406的資料會經由記憶體介面506轉換為可複寫式非揮發性記憶體模組406所能接受的格式。具體來說,若記憶體管理電路502要存取可複寫式非揮發性記憶體模組406,記憶體介面506會傳送對應的指令序列。例如,這些指令序列可包括指示寫入資料的寫入指令序列、指示讀取資料的讀取指令序列、指示抹除資料的抹除指令序列、以及用以指示各種記憶體操作(例如,改變讀取電壓準位或執行垃圾收集操作等等)的相對應的指令序列。這些指令序列例如是由記憶體管理電路502產生並且透過記憶體介面506傳送至可複寫式非揮發性記憶體模組406。這些指令序列可包括一或多個訊號,或是在匯流排上的資料。這些訊號或資料可包括指令碼或程式碼。例如,在讀取指令序列中,會包括讀取的辨識碼、記憶體位址等資訊。The memory interface 506 is coupled to the memory management circuit 502 and used to access the rewritable non-volatile memory module 406. In other words, the data to be written into the rewritable non-volatile memory module 406 is converted into a format acceptable by the rewritable non-volatile memory module 406 through the memory interface 506. Specifically, if the memory management circuit 502 needs to access the rewritable non-volatile memory module 406, the memory interface 506 will send the corresponding command sequence. For example, these command sequences may include a write command sequence instructing to write data, a read command sequence instructing to read data, an erase command sequence instructing to erase data, and various memory operations (for example, changing read Take the voltage level or perform garbage collection operations, etc.) corresponding to the sequence of instructions. These command sequences are generated by the memory management circuit 502 and transmitted to the rewritable non-volatile memory module 406 through the memory interface 506, for example. These command sequences can include one or more signals, or data on the bus. These signals or data may include script codes or program codes. For example, in the read command sequence, the read identification code, memory address and other information will be included.

在一範例實施例中,記憶體控制電路單元404還包括錯誤檢查與校正電路508、緩衝記憶體510與電源管理電路512。In an exemplary embodiment, the memory control circuit unit 404 further includes an error checking and correction circuit 508, a buffer memory 510, and a power management circuit 512.

錯誤檢查與校正電路508是耦接至記憶體管理電路502並且用以執行錯誤檢查與校正操作以確保資料的正確性。具體來說,當記憶體管理電路502從主機系統11中接收到寫入指令時,錯誤檢查與校正電路508會為對應此寫入指令的資料產生對應的錯誤更正碼(error correcting code, ECC)及/或錯誤檢查碼(error detecting code, EDC),並且記憶體管理電路502會將對應此寫入指令的資料與對應的錯誤更正碼及/或錯誤檢查碼寫入至可複寫式非揮發性記憶體模組406中。之後,當記憶體管理電路502從可複寫式非揮發性記憶體模組406中讀取資料時會同時讀取此資料對應的錯誤更正碼及/或錯誤檢查碼,並且錯誤檢查與校正電路508會依據此錯誤更正碼及/或錯誤檢查碼對所讀取的資料執行錯誤檢查與校正操作。The error checking and correcting circuit 508 is coupled to the memory management circuit 502 and used to perform error checking and correcting operations to ensure the correctness of the data. Specifically, when the memory management circuit 502 receives a write command from the host system 11, the error checking and correction circuit 508 will generate a corresponding error correcting code (ECC) for the data corresponding to the write command. And/or error detecting code (EDC), and the memory management circuit 502 will write the data corresponding to the write command and the corresponding error correction code and/or error check code to the rewritable non-volatile In the memory module 406. After that, when the memory management circuit 502 reads data from the rewritable non-volatile memory module 406, it will read the error correction code and/or error check code corresponding to the data at the same time, and the error check and correction circuit 508 Based on this error correction code and/or error check code, error checking and correction operations will be performed on the read data.

緩衝記憶體510是耦接至記憶體管理電路502並且用以暫存來自於主機系統11的資料與指令或來自於可複寫式非揮發性記憶體模組406的資料。電源管理電路512是耦接至記憶體管理電路502並且用以控制記憶體儲存裝置10的電源。The buffer memory 510 is coupled to the memory management circuit 502 and used to temporarily store data and commands from the host system 11 or data from the rewritable non-volatile memory module 406. The power management circuit 512 is coupled to the memory management circuit 502 and used to control the power of the memory storage device 10.

在一範例實施例中,圖4的可複寫式非揮發性記憶體模組406亦稱為快閃(flash)記憶體模組,且記憶體控制電路單元404亦稱為用於控制快閃記憶體模組的快閃記憶體控制器。在一範例實施例中,圖5的記憶體管理電路502亦稱為快閃記憶體管理電路。In an exemplary embodiment, the rewritable non-volatile memory module 406 of FIG. 4 is also called a flash memory module, and the memory control circuit unit 404 is also called for controlling the flash memory The flash memory controller of the physical module. In an exemplary embodiment, the memory management circuit 502 of FIG. 5 is also referred to as a flash memory management circuit.

圖6是根據本發明的一範例實施例所繪示的管理可複寫式非揮發性記憶體模組的示意圖。請參照圖6,記憶體管理電路502可將可複寫式非揮發性記憶體模組406的實體單元610(0)~610(B)邏輯地分組至儲存區601與替換區602。儲存區601中的實體單元610(0)~610(A)是用以儲存資料,而替換區602中的實體單元610(A+1)~610(B)則是用以替換儲存區601中損壞的實體單元。例如,若從某一個實體單元中讀取的資料所包含的錯誤過多而無法被更正時,此實體單元會被視為是損壞的實體單元。須注意的是,若替換區602中沒有可用的實體抹除單元,則記憶體管理電路502可能會將整個記憶體儲存裝置10宣告為寫入保護(write protect)狀態,而無法再寫入資料。FIG. 6 is a schematic diagram of managing a rewritable non-volatile memory module according to an exemplary embodiment of the present invention. 6, the memory management circuit 502 can logically group the physical units 610(0) to 610(B) of the rewritable non-volatile memory module 406 into the storage area 601 and the replacement area 602. The physical units 610(0)~610(A) in the storage area 601 are used to store data, and the physical units 610(A+1)~610(B) in the replacement area 602 are used to replace the storage area 601 Damaged physical unit. For example, if the data read from a certain physical unit contains too many errors to be corrected, the physical unit will be regarded as a damaged physical unit. It should be noted that if there is no available physical erasing unit in the replacement area 602, the memory management circuit 502 may declare the entire memory storage device 10 as a write protect state, and no more data can be written. .

在本範例實施例中,每一個實體單元是指一個實體抹除單元。然而,在另一範例實施例中,一個實體單元亦可以是指一個實體位址、一個實體程式化單元或由多個連續或不連續的實體位址組成。記憶體管理電路502會配置邏輯單元612(0)~612(C)以映射儲存區601中的實體單元610(0)~610(A)。在本範例實施例中,每一個邏輯單元是指一個邏輯位址。然而,在另一範例實施例中,一個邏輯單元也可以是指一個邏輯程式化單元、一個邏輯抹除單元或者由多個連續或不連續的邏輯位址組成。此外,邏輯單元612(0)~612(C)中的每一者可被映射至一或多個實體單元。In this exemplary embodiment, each physical unit refers to a physical erasing unit. However, in another exemplary embodiment, a physical unit may also refer to a physical address, a physical programming unit, or consist of multiple continuous or discontinuous physical addresses. The memory management circuit 502 will configure the logical units 612(0)-612(C) to map the physical units 610(0)-610(A) in the storage area 601. In this exemplary embodiment, each logical unit refers to a logical address. However, in another exemplary embodiment, a logic unit may also refer to a logic programming unit, a logic erasing unit, or consist of multiple consecutive or discontinuous logic addresses. In addition, each of the logical units 612(0)-612(C) may be mapped to one or more physical units.

記憶體管理電路502可將邏輯單元與實體單元之間的映射關係(亦稱為邏輯-實體位址映射關係)記錄於至少一邏輯-實體位址映射表。當主機系統11欲從記憶體儲存裝置10讀取資料或寫入資料至記憶體儲存裝置10時,記憶體管理電路502可根據此邏輯-實體位址映射表來執行對於記憶體儲存裝置10的資料存取操作。The memory management circuit 502 can record the mapping relationship between the logical unit and the physical unit (also referred to as the logical-physical address mapping relationship) in at least one logical-physical address mapping table. When the host system 11 wants to read data from the memory storage device 10 or write data to the memory storage device 10, the memory management circuit 502 can perform the processing of the memory storage device 10 according to the logical-physical address mapping table. Data access operations.

需先說明的是,以下說明記憶體控制電路單元404的操作時,等同於說明記憶體管理電路502的操作。It should be noted that the following description of the operation of the memory control circuit unit 404 is equivalent to the description of the operation of the memory management circuit 502.

在本實施例提供的快閃記憶體之資料整理方法可應用於立體(3D)結構之快閃記憶體、嵌入式記憶體裝置或固態硬碟,但本發明不限於此。The flash memory data sorting method provided in this embodiment can be applied to a three-dimensional (3D) structure flash memory, an embedded memory device or a solid state drive, but the invention is not limited to this.

在本實施例中,記憶體儲存裝置10在背景模式執行背景垃圾收集操作。若記憶體儲存裝置10在執行背景垃圾收集操作時接收到主機系統11的寫入指令,則記憶體儲存裝置10暫停背景垃圾收集操作且退出背景模式進入前景模式。接著,記憶體儲存裝置10自主機系統11接收多個寫入指令,在完成執行寫入指令後進入背景模式並繼續執行背景垃圾收集操作。具體來說,當記憶體儲存裝置10接收到來自主機系統11的寫入指令時,記憶體控制電路單元404需立即執行並且回應主機系統11,以避免逾時。於此,為回應主機系統11所執行之程序的模式稱為前景模式。相對地,記憶體控制電路單元404亦可在閒置下(即,未收到主機系統11所傳送之指令)運作。例如可在閒置時執行垃圾收集操作等。於此,不是為了回應主機系統11所執行之程序的模式稱為背景模式。在本實施例中,記憶體儲存裝置10在空閒時間(idle time)自前景模式進入背景模式,並在符合背景模式的垃圾收集條件時執行垃圾收集操作。In this embodiment, the memory storage device 10 performs the background garbage collection operation in the background mode. If the memory storage device 10 receives a write command from the host system 11 while performing the background garbage collection operation, the memory storage device 10 suspends the background garbage collection operation and exits the background mode and enters the foreground mode. Then, the memory storage device 10 receives a plurality of write commands from the host system 11, enters the background mode after completing the execution of the write commands, and continues to perform the background garbage collection operation. Specifically, when the memory storage device 10 receives a write command from the host system 11, the memory control circuit unit 404 needs to immediately execute and respond to the host system 11 to avoid timeout. Herein, the mode in response to the program executed by the host system 11 is called the foreground mode. In contrast, the memory control circuit unit 404 can also operate in an idle state (that is, without receiving a command from the host system 11). For example, garbage collection can be performed when idle. Here, the mode not in response to the program executed by the host system 11 is called the background mode. In this embodiment, the memory storage device 10 enters the background mode from the foreground mode during idle time, and performs the garbage collection operation when the garbage collection conditions of the background mode are met.

背景模式的垃圾收集條件可例如,記憶體控制電路單元404判斷可複寫式非揮發性記憶體模組406的空閒實體抹除單元(free physical erasing unit)數量是否大於背景垃圾收集操作的啟動閥值。並且,當可複寫式非揮發性記憶體模組406的空閒實體抹除單元數量不大於啟動閥值時,記憶體控制電路單元404執行背景垃圾收集操作。在執行背景垃圾收集操作時,記憶體控制電路單元404將多個來源實體抹除單元的有效資料搬移(或複製)至目標實體抹除單元,並抹除來源實體抹除單元且釋放來源實體抹除單元為空閒實體抹除單元。此外,在暫停背景垃圾收集操作時,記憶體控制電路單元404暫停將來源實體抹除單元的有效資料搬移(或複製)至目標實體抹除單元,並保留目標實體抹除單元且自背景模式進入前景模式以執行寫入指令。The garbage collection condition in the background mode can be, for example, the memory control circuit unit 404 determines whether the number of free physical erasing units of the rewritable non-volatile memory module 406 is greater than the start threshold of the background garbage collection operation . Moreover, when the number of idle physical erasing units of the rewritable non-volatile memory module 406 is not greater than the activation threshold, the memory control circuit unit 404 performs the background garbage collection operation. When performing the background garbage collection operation, the memory control circuit unit 404 transfers (or copies) the valid data of multiple source physical erasing units to the target physical erasing unit, erasing the source physical erasing unit and releasing the source physical erasing unit The erasing unit is an idle physical erasing unit. In addition, when the background garbage collection operation is suspended, the memory control circuit unit 404 suspends the transfer (or copy) of the effective data of the source entity erasing unit to the target entity erasing unit, and reserves the target entity erasing unit and enters from the background mode Foreground mode to execute write instructions.

一般而言,若在前景模式執行寫入指令時發生空閒實體抹除單元的數量不夠時,記憶體控制電路單元404會在完成執行一寫入指令後執行垃圾收集操作。然而執行垃圾收集操作時必須停止執行其他寫入指令,因而會造成延遲。Generally speaking, if the number of free physical erase units is insufficient when the write command is executed in the foreground mode, the memory control circuit unit 404 will perform a garbage collection operation after completing the execution of a write command. However, other write instructions must be stopped when garbage collection is performed, which will cause delays.

因此在本實施例提供的快閃記憶體之資料整理方法中,記憶體控制電路單元404在進入前景模式後,可以判斷可複寫式非揮發性記憶體模組406的空閒實體抹除單元數量是否大於前景垃圾收集操作的啟動閥值。並且,當可複寫式非揮發性記憶體模組406的空閒實體抹除單元數量不大於啟動閥值時,記憶體控制電路單元404執行前景垃圾收集操作。在一實施例中,用於判斷執行背景垃圾收集操作的啟動閥值大於判斷執行前景垃圾收集操作的啟動閥值。Therefore, in the flash memory data sorting method provided in this embodiment, the memory control circuit unit 404 can determine whether the number of free physical erasing units of the rewritable non-volatile memory module 406 after entering the foreground mode Greater than the start threshold of the foreground garbage collection operation. Moreover, when the number of idle physical erasing units of the rewritable non-volatile memory module 406 is not greater than the activation threshold, the memory control circuit unit 404 performs the foreground garbage collection operation. In one embodiment, the start threshold for judging to perform the background garbage collection operation is greater than the start threshold for judging to perform the foreground garbage collection operation.

在一實施例中,記憶體控制電路單元404在背景模式執行背景垃圾收集操作時,依據多個實體抹除單元對應的有效計數(valid count)選擇多個來源實體抹除單元執行垃圾收集操作。具體而言,記憶體控制電路單元404在空閒實體抹除單元數量不大於啟動閥值時,會依據各實體抹除單元對應的有效計數決定各實體抹除單元的排列順序。接著在執行背景垃圾收集操作時,記憶體控制電路單元404依據排序順序選擇可複寫式非揮發性記憶體模組406包括的實體抹除單元中的一或多個作為來源實體抹除單元,並將來源實體抹除單元的有效資料搬移(或複製)至目標實體抹除單元。若某一個來源實體抹除單元所儲存的有效資料皆已被搬移(或複製),則記憶體控制電路單元404抹除此來源實體抹除單元且釋放已抹除的來源實體抹除單元為空閒實體抹除單元。記憶體控制電路單元404可依據釋放的空閒實體抹除單元的數量增加空閒實體抹除單元數量。In one embodiment, when the memory control circuit unit 404 performs the background garbage collection operation in the background mode, it selects a plurality of source physical erasing units to perform the garbage collection operation according to the valid counts corresponding to the plurality of physical erasing units. Specifically, when the number of idle physical erasing units is not greater than the activation threshold, the memory control circuit unit 404 determines the arrangement order of the physical erasing units according to the effective count corresponding to each of the physical erasing units. Then, when performing the background garbage collection operation, the memory control circuit unit 404 selects one or more of the physical erasing units included in the rewritable non-volatile memory module 406 as the source physical erasing unit according to the sort order, and Move (or copy) the valid data of the source entity erasing unit to the target entity erasing unit. If the valid data stored in a certain source physical erase unit has been moved (or copied), the memory control circuit unit 404 erases the source physical erase unit and releases the erased source physical erase unit to be idle Physical erasure unit. The memory control circuit unit 404 can increase the number of free physical erasing units according to the number of free physical erasing units.

在一範例實施例中,各實體抹除單元的排列順序關連於各實體抹除單元中有效資料的多寡(此處以有效計數表示之)。依據有效計數的數值大小,可決定在執行背景垃圾收集操作時作為來源實體抹除單元的實體抹除單元。在本範例實施例中,記憶體控制電路單元404會依據各實體抹除單元對應的有效計數的數值大小,從有效計數的數值小的實體抹除單元排序到有效計數的數值大的實體抹除單元。在本範例實施例中,記憶體控制電路單元404從有效計數的數值最小的實體抹除單元開始,依照排列順序選擇實體抹除單元作為來源實體抹除單元,並依據被選擇的來源實體抹除單元執行垃圾收集操作。In an exemplary embodiment, the arrangement order of each physical erasing unit is related to the amount of valid data in each physical erasing unit (represented by a valid count here). According to the value of the effective count, the physical erasing unit can be determined as the source physical erasing unit when the background garbage collection operation is performed. In this exemplary embodiment, the memory control circuit unit 404 sorts from the physical erasing unit with a small effective count to the physical erasing unit with a large effective count according to the value of the effective count corresponding to each physical erasing unit. unit. In this exemplary embodiment, the memory control circuit unit 404 starts from the physical erasing unit with the smallest effective count, selects the physical erasing unit as the source physical erasing unit according to the arrangement sequence, and erases according to the selected source physical The unit performs garbage collection operations.

在一實施例中,若記憶體控制電路單元404在執行寫入指令時判斷可複寫式非揮發性記憶體模組406的空閒實體抹除單元數量不大於前景垃圾收集操作的啟動閥值,而需執行前景垃圾收集操作時,則記憶體控制電路單元404依據實體抹除單元對應的有效計數的數值大小更新實體抹除單元的排列順序。並且,記憶體控制電路單元404依據更新的排列順序選擇可複寫式非揮發性記憶體模組406包括的實體抹除單元中的一或多個作為來源實體抹除單元,並將來源實體抹除單元的有效資料搬移(或複製)至目標實體抹除單元。In one embodiment, if the memory control circuit unit 404 determines that the number of free physical erasing units of the rewritable non-volatile memory module 406 is not greater than the start threshold of the foreground garbage collection operation when executing the write command, and When the foreground garbage collection operation needs to be performed, the memory control circuit unit 404 updates the arrangement sequence of the physical erasing units according to the numerical value of the effective count corresponding to the physical erasing unit. Moreover, the memory control circuit unit 404 selects one or more of the physical erasing units included in the rewritable non-volatile memory module 406 as the source physical erasing unit according to the updated arrangement order, and erases the source physical The effective data of the unit is moved (or copied) to the target entity to erase the unit.

在一實施例中,背景垃圾收集操作與前景垃圾收集操作共用相同的目標實體抹除單元。具體而言,在本實施例中,記憶體控制電路單元404在執行前景垃圾收集操作時,將來源實體抹除單元的有效資料搬移(或複製)至與執行背景垃圾收集操作時相同的目標實體抹除單元中。然而,本發明並不限於此,在另一實施例中,背景垃圾收集操作與前景垃圾收集操作也可使各自對應的目標實體抹除單元。In one embodiment, the background garbage collection operation and the foreground garbage collection operation share the same target entity erasure unit. Specifically, in this embodiment, when the memory control circuit unit 404 performs the foreground garbage collection operation, it moves (or copies) the valid data of the source entity erasing unit to the same target entity as the background garbage collection operation. Wipe the unit. However, the present invention is not limited to this. In another embodiment, the background garbage collection operation and the foreground garbage collection operation can also wipe out the corresponding target entity units.

換句話說,由於在執行前景垃圾收集操作之前,已執行了一些寫入操作,改變了實體抹除單元的有效計數,因此在本實施例提供的快閃記憶體之資料整理方法中,記憶體控制電路單元404在前景模式判斷是否執行垃圾收集操作時,可以根據當前實體抹除單元的有效計數來動態地選擇垃圾收集操作的來源實體抹除單元,而非以執行背景垃圾收集時的實體抹除單元的有效計數來選擇來源實體抹除單元,而可達到釋放最多實體抹除單元的目的。In other words, because some write operations have been performed before the foreground garbage collection operation is performed, which changes the effective count of the physical erase unit, therefore, in the flash memory data organization method provided in this embodiment, the memory When the control circuit unit 404 determines whether to perform the garbage collection operation in the foreground mode, it can dynamically select the source entity erasing unit of the garbage collection operation according to the effective count of the current entity erasing unit, instead of performing the physical erasing of the background garbage collection. The effective count of the erasing unit is used to select the source physical erasing unit, and the purpose of releasing the most physical erasing unit can be achieved.

在另一實施例中,在執行前景垃圾收集操作時,已抹除的來源實體抹除單元會被釋放為空閒實體抹除單元,並且記憶體控制電路單元404可依據釋放的空閒實體抹除單元的數量增加空閒實體抹除單元數量。此時,空閒實體抹除單元數量增加,記憶體控制電路單元404判斷空閒實體抹除單元數量是否大於啟動閥值。若記憶體控制電路單元404判斷空閒實體抹除單元數量不大於啟動閥值,表示可複寫式非揮發性記憶體模組406中空閒實體抹除單元的數量仍不足,因此記憶體控制電路單元404繼續執行前景垃圾收集操作。相對地,若記憶體控制電路單元404判斷空閒實體抹除單元數量大於啟動閥值則停止執行前景垃圾收集操作,並繼續執行寫入指令。In another embodiment, when the foreground garbage collection operation is performed, the erased source physical erase unit is released as an idle physical erase unit, and the memory control circuit unit 404 can erase the unit based on the released idle physical erase unit Increase the number of free physical erasure units. At this time, the number of free physical erasing units increases, and the memory control circuit unit 404 determines whether the number of free physical erasing units is greater than the activation threshold. If the memory control circuit unit 404 determines that the number of free physical erasing units is not greater than the activation threshold, it means that the number of free physical erasing units in the rewritable non-volatile memory module 406 is still insufficient, so the memory control circuit unit 404 Continue to perform foreground garbage collection operations. In contrast, if the memory control circuit unit 404 determines that the number of free physical erasing units is greater than the start threshold, it stops performing the foreground garbage collection operation and continues to execute the write command.

另一方面,當空閒實體抹除單元數量大於啟動閥值時,記憶體控制電路單元404執行寫入指令。此時,記憶體儲存裝置10自主機系統11持續接收多個寫入指令,執行寫入指令時記憶體控制電路單元404將寫入指令對應的資料寫入至可複寫式非揮發性記憶體模組406中,因此空閒實體抹除單元的數量會減少。在執行寫入指令時,記憶體控制電路單元404可以判斷空閒實體抹除單元數量是否大於啟動閥值。若記憶體控制電路單元404判斷空閒實體抹除單元數量不大於啟動閥值,則依據實體抹除單元對應的有效計數重新決定來源實體抹除單元的排列順序,以依據更新的排列順序執行垃圾收集操作。垃圾收集操作的具體方式如前所述,在此不再贅述。On the other hand, when the number of free physical erasing units is greater than the activation threshold, the memory control circuit unit 404 executes the write command. At this time, the memory storage device 10 continuously receives a plurality of write commands from the host system 11. When the write command is executed, the memory control circuit unit 404 writes the data corresponding to the write command to the rewritable non-volatile memory module. In the group 406, therefore, the number of free physical erasure units will be reduced. When the write command is executed, the memory control circuit unit 404 can determine whether the number of idle physical erasing units is greater than the activation threshold. If the memory control circuit unit 404 determines that the number of free physical erasing units is not greater than the activation threshold, it re-determines the arrangement order of the source physical erasing units according to the effective count corresponding to the physical erasing unit, and performs garbage collection according to the updated arrangement order operate. The specific method of garbage collection operation is as described above, and will not be repeated here.

在一實施例中,記憶體控制電路單元404在完成執行寫入指令後經過預定時間後進入背景模式。並且在進入背景模式後,記憶體控制電路單元404依據實體抹除單元對應的最新有效計數的數值大小更新實體抹除單元的排列順序,依據排列順序選擇可複寫式非揮發性記憶體模組406包括的實體抹除單元中的一或多個作為來源實體抹除單元,並將來源實體抹除單元的有效資料搬移(或複製)至目標實體抹除單元。於此,記憶體控制電路單元404將來源實體抹除單元的有效資料搬移(或複製)至與暫停執行背景垃圾收集操作時相同的目標實體抹除單元。In one embodiment, the memory control circuit unit 404 enters the background mode after a predetermined time has passed after completing the execution of the write command. And after entering the background mode, the memory control circuit unit 404 updates the arrangement order of the physical erasing units according to the value of the latest valid count corresponding to the physical erasing unit, and selects the rewritable non-volatile memory module 406 according to the arrangement order One or more of the included physical erasing units are used as the source physical erasing unit, and the effective data of the source physical erasing unit is moved (or copied) to the target physical erasing unit. Here, the memory control circuit unit 404 moves (or copies) the valid data of the source entity erasing unit to the same target entity erasing unit as when the background garbage collection operation is suspended.

圖7是根據本發明的一範例實施例所繪示的快閃記憶體之資料整理方法的範例。圖8是根據本發明的一範例實施例所繪示的目標實體抹除單元的示意圖。請參照圖7,在本範例實施例中,記憶體控制電路單元404的執行時間區分為空閒時間T IDLE及前景操作時間T FG。記憶體控制電路單元404在空閒時間T IDLE進入背景模式。在背景模式中記憶體控制電路單元404可以進行資料搬移(或複製)的操作,例如在本範例實施例中,記憶體控制電路單元404在符合背景模式的垃圾收集條件時執行垃圾收集操作。具體而言,在時間點A至時間點B之間的空閒時間T IDLE進入背景垃圾收集時間T BG並執行背景垃圾收集操作。記憶體控制電路單元404會依據可複寫式非揮發性記憶體模組406包括的各實體抹除單元對應的有效計數的數值大小,從有效計數的數值小的實體抹除單元排序到有效計數的數值大的實體抹除單元。記憶體控制電路單元404從有效計數的數值最小的實體抹除單元開始,依照排列順序選擇實體抹除單元作為來源實體抹除單元,並同時選擇一個實體抹除單元作為目標實體抹除單元(例如圖8中的實體抹除單元810)。在本實施例中,記憶體控制電路單元404例如從實體抹除單元中選擇5個實體抹除單元作為來源實體抹除單元。接著,記憶體控制電路單元404依據被選擇的來源實體抹除單元執行垃圾收集操作,將被選擇的5個來源實體抹除單元的有效資料搬移(或複製)至目標實體抹除單元810。記憶體控制電路單元404抹除來源實體抹除單元且釋放已抹除的來源實體抹除單元為空閒實體抹除單元,並依據釋放的空閒實體抹除單元的數量增加空閒實體抹除單元數量。然而,記憶體控制電路單元404可能會在背景垃圾收集操作未完成時接收主機系統11的寫入指令。例如圖7中的時間點B。 FIG. 7 is an example of a flash memory data sorting method according to an exemplary embodiment of the present invention. FIG. 8 is a schematic diagram of a target entity erasing unit according to an exemplary embodiment of the present invention. Referring to FIG. 7, in this exemplary embodiment, the execution time of the memory control circuit unit 404 is divided into an idle time T IDLE and a foreground operation time T FG . The memory control circuit unit 404 enters the background mode during the idle time T IDLE. In the background mode, the memory control circuit unit 404 can perform data transfer (or copy) operations. For example, in this exemplary embodiment, the memory control circuit unit 404 performs a garbage collection operation when the garbage collection conditions in the background mode are met. Specifically, in the idle time T IDLE between the time point A and the time point B, the background garbage collection time T BG is entered and the background garbage collection operation is performed. The memory control circuit unit 404 will sort the effective count corresponding to each physical erasing unit included in the rewritable non-volatile memory module 406 from the physical erasing unit with the smaller effective count to the one with the effective count. The physical erasure unit with a large value. The memory control circuit unit 404 starts from the physical erasing unit with the smallest effective count, selects the physical erasing unit as the source physical erasing unit according to the arrangement sequence, and selects a physical erasing unit as the target physical erasing unit (for example, The physical erasure unit 810 in FIG. 8). In this embodiment, the memory control circuit unit 404, for example, selects five physical erasing units from the physical erasing units as the source physical erasing units. Then, the memory control circuit unit 404 performs a garbage collection operation according to the selected source entity erasing unit, and moves (or copies) the valid data of the selected 5 source entity erasing units to the target entity erasing unit 810. The memory control circuit unit 404 erases the source physical erase unit and releases the erased source physical erase unit as an idle physical erase unit, and increases the number of idle physical erase units according to the number of released idle physical erase units. However, the memory control circuit unit 404 may receive a write command from the host system 11 when the background garbage collection operation is not completed. For example, time point B in Figure 7.

在時間點B,主機系統11發送多個寫入指令,記憶體儲存裝置10自主機系統11接收多個寫入指令,並從空閒時間T IDLE進入前景操作時間T FG,亦即,退出背景模式進入前景模式來處理寫入指令。此時,記憶體控制電路單元404暫停背景垃圾收集操作且自背景模式進入前景模式。在本實施例中,由於背景垃圾收集操作暫停,在背景垃圾收集時選擇5個來源實體抹除單元中的資料可能還沒全部被搬移(或複製)至目標實體抹除單元。請參照圖8,記憶體控制電路單元404僅完成搬移(或複製)其中3個來源實體抹除單元的資料至目標實體抹除單元的子實體抹除單元810(0)~810(2),記憶體控制電路單元404會保留目標實體抹除單元810並進入前景模式。在前景模式中,記憶體控制電路單元404判斷可複寫式非揮發性記憶體模組406的空閒實體抹除單元數量是否大於啟動閥值TH FG。換句話說,記憶體控制電路單元404判斷空閒實體抹除單元數量是否滿足在前景模式執行垃圾收集操作的條件。在本範例實施例中,時間點B時的空閒實體抹除單元數量不滿足在前景模式執行垃圾收集操作的條件(即,空閒實體抹除單元數量大於啟動閥值TH FG),記憶體控制電路單元404執行寫入指令,並且不執行垃圾收集操作。 At time point B, the host system 11 sends multiple write commands, the memory storage device 10 receives multiple write commands from the host system 11, and enters the foreground operation time T FG from the idle time T IDLE , that is, exits the background mode Enter foreground mode to process write instructions. At this time, the memory control circuit unit 404 suspends the background garbage collection operation and enters the foreground mode from the background mode. In this embodiment, because the background garbage collection operation is suspended, the data in the five source entity erasing units selected during the background garbage collection may not have all been moved (or copied) to the target entity erasing unit. Referring to FIG. 8, the memory control circuit unit 404 only completes the transfer (or copy) of the data of three source physical erasing units to the sub-physical erasing units 810(0)~810(2) of the target physical erasing unit. The memory control circuit unit 404 retains the target entity erasing unit 810 and enters the foreground mode. In the foreground mode, the memory control circuit unit 404 determines whether the number of idle physical erasing units of the rewritable non-volatile memory module 406 is greater than the activation threshold TH FG . In other words, the memory control circuit unit 404 determines whether the number of idle physical erasing units meets the conditions for performing the garbage collection operation in the foreground mode. In this exemplary embodiment, the number of free physical erasing units at time point B does not meet the conditions for performing the garbage collection operation in the foreground mode (that is, the number of free physical erasing units is greater than the activation threshold TH FG ), the memory control circuit Unit 404 executes write instructions and does not execute garbage collection operations.

接著,記憶體儲存裝置10在時間點B至時間點C(即,時間間隔T1)自主機系統11持續接收多個寫入指令,執行寫入指令時記憶體控制電路單元404將寫入指令對應的資料寫入至可複寫式非揮發性記憶體模組406中,因此空閒實體抹除單元數量會減少。在執行寫入指令時,記憶體控制電路單元404可以持續判斷空閒實體抹除單元數量是否大於啟動閥值TH FGNext, the memory storage device 10 continuously receives multiple write commands from the host system 11 from time B to time C (ie, time interval T1). When the write commands are executed, the memory control circuit unit 404 corresponds to the write commands The data of is written into the rewritable non-volatile memory module 406, so the number of free physical erasing units will be reduced. When the write command is executed, the memory control circuit unit 404 can continuously determine whether the number of idle physical erasing units is greater than the activation threshold TH FG .

在時間點C,記憶體控制電路單元404判斷空閒實體抹除單元數量滿足在前景模式執行垃圾收集操作的條件(即,空閒實體抹除單元數量不大於啟動閥值TH FG),則依據實體抹除單元對應的有效計數重新選擇實體抹除單元中的一或多個作為來源實體抹除單元以執行垃圾收集操作。於此,重新選擇的來源實體抹除單元可能會與先前(例如,背景模式)選擇的來源實體抹除單元不同。具體而言,在時間點C,記憶體控制電路單元404會依據各實體抹除單元對應的有效計數的數值大小,從有效計數的數值小的實體抹除單元排序到有效計數的數值大的實體抹除單元。記憶體控制電路單元404從有效計數的數值最小的實體抹除單元開始,依照排列順序選擇實體抹除單元作為來源實體抹除單元,並同時選擇一個實體抹除單元作為目標實體抹除單元。在本範例實施例中,記憶體控制電路單元404執行前景垃圾收集操作,並將來源實體抹除單元的有效資料搬移(或複製)至目標實體抹除單元801的子實體抹除單元810(3)~810(5)。記憶體控制電路單元404抹除來源實體抹除單元且釋放已抹除的來源實體抹除單元為空閒實體抹除單元,並依據釋放的空閒實體抹除單元的數量增加空閒實體抹除單元數量。在另一實施例中,記憶體控制電路單元404可以選擇其他的目標實體抹除單元,本發明不限於此。 At time point C, the memory control circuit unit 404 determines that the number of free physical erasing units meets the conditions for performing the garbage collection operation in the foreground mode (that is, the number of free physical erasing units is not greater than the activation threshold TH FG ), and then it is based on the physical erasing The effective count corresponding to the erasing unit reselects one or more of the physical erasing units as the source physical erasing unit to perform the garbage collection operation. Here, the re-selected source entity erasure unit may be different from the source entity erasure unit previously selected (for example, in the background mode). Specifically, at time point C, the memory control circuit unit 404 will sort from the physical erasing unit with a small effective count to the entity with a large effective count according to the value of the effective count corresponding to each physical erasing unit Wipe the unit. The memory control circuit unit 404 starts from the physical erasing unit with the smallest effective count, selects the physical erasing unit as the source physical erasing unit according to the arrangement sequence, and selects a physical erasing unit as the target physical erasing unit at the same time. In this exemplary embodiment, the memory control circuit unit 404 performs the foreground garbage collection operation, and transfers (or copies) the valid data of the source entity erasing unit to the sub-entity erasing unit 810 of the target entity erasing unit 801 (3 )~810(5). The memory control circuit unit 404 erases the source physical erase unit and releases the erased source physical erase unit as an idle physical erase unit, and increases the number of idle physical erase units according to the number of released idle physical erase units. In another embodiment, the memory control circuit unit 404 may select other target entity erasing units, and the present invention is not limited to this.

接著,記憶體控制電路單元404在時間點C至時間點D(即,時間間隔T2)執行前景垃圾收集操作,持續釋放空閒實體抹除單元,因此空閒實體抹除單元數量會增加。在執行垃圾收集操作時,記憶體控制電路單元404可以持續判斷空閒實體抹除單元數量是否大於啟動閥值TH FG。在時間點D,記憶體控制電路單元404判斷空閒實體抹除單元數量不滿足在前景模式執行垃圾收集操作的條件(即,空閒實體抹除單元數量大於啟動閥值TH FG),則記憶體控制電路單元404執行寫入指令。 Then, the memory control circuit unit 404 performs a foreground garbage collection operation from time C to time D (ie, time interval T2), and continuously releases idle physical erasing units, so the number of idle physical erasing units will increase. During the garbage collection operation, the memory control circuit unit 404 can continuously determine whether the number of idle physical erasing units is greater than the activation threshold TH FG . At time D, the memory control circuit unit 404 determines that the number of free physical erasing units does not meet the conditions for performing the garbage collection operation in the foreground mode (that is, the number of free physical erasing units is greater than the activation threshold TH FG ), then the memory control The circuit unit 404 executes the write instruction.

時間點D至時間點E(即,時間間隔T3)及時間點F至時間點G(即,時間間隔T5)的相關內容可參照前述時間點B至時間點C所述的實施內容,並且時間點E至時間點F(即,時間間隔T4)的相關內容可參照前述時間點C至時間點D所述的實施內容,在此不再贅述。在時間點E至時間點F,記憶體控制電路單元404重新選擇來源實體抹除單元以執行前景垃圾收集操作,並可將來源實體抹除單元的有效資料搬移(或複製)至目標實體抹除單元801的子實體抹除單元810(6)~810(9)。在另一實施例中,記憶體控制電路單元404可以選擇其他的目標實體抹除單元,本發明不限於此。The relevant content from time point D to time point E (ie, time interval T3) and time point F to time point G (ie, time interval T5) can refer to the implementation content described above from time point B to time point C, and time For the relevant content from point E to time point F (ie, time interval T4), please refer to the implementation content from time point C to time point D, which will not be repeated here. From time E to time F, the memory control circuit unit 404 reselects the source entity erasing unit to perform the foreground garbage collection operation, and can move (or copy) the effective data of the source entity erasing unit to the target entity erasing The fruit body of the unit 801 is erased from the units 810(6) to 810(9). In another embodiment, the memory control circuit unit 404 may select other target entity erasing units, and the present invention is not limited to this.

接著,在時間點G,記憶體儲存裝置10不再從主機系統11接收到寫入指令,因此記憶體控制電路單元404從前景操作時間T FG進入空閒時間T IDLE,亦即,退出前景模式進入背景模式。背景模式的相關內容可參照前述時間點A至時間點B所述的實施內容,在此不再贅述。在時間點G,記憶體控制電路單元404可等待預設時間T preset,並在經過預設時間T preset後進入背景垃圾收集時間T BG並執行背景垃圾收集操作,並可重新選擇來源實體抹除單元以將來源實體抹除單元的有效資料搬移(或複製)至目標實體抹除單元801的子實體抹除單元810(10)~810(14)。在另一實施例中,記憶體控制電路單元404可以選擇其他的目標實體抹除單元,本發明不限於此。最後,記憶體控制電路單元404關閉目標實體抹除單元以完成垃圾收集操作。 Then, at time G, the memory storage device 10 no longer receives a write command from the host system 11, so the memory control circuit unit 404 enters the idle time T IDLE from the foreground operation time T FG , that is, exits the foreground mode and enters Background pattern. For the related content of the background mode, please refer to the implementation content described from time point A to time point B, which will not be repeated here. At time point G, the memory control circuit unit 404 can wait for the preset time T preset , and enter the background garbage collection time T BG after the preset time T preset elapses and perform the background garbage collection operation, and can re-select the source entity to erase The unit transfers (or copies) the effective data of the source physical erasing unit to the sub-physical erasing units 810 (10) to 810 (14) of the target physical erasing unit 801. In another embodiment, the memory control circuit unit 404 may select other target entity erasing units, and the present invention is not limited to this. Finally, the memory control circuit unit 404 turns off the target entity erasing unit to complete the garbage collection operation.

圖9是根據本發明的一範例實施例所繪示的快閃記憶體之資料整理方法的流程圖。在步驟S902中,在背景模式執行背景垃圾收集操作。在步驟S904中,在背景垃圾收集操作未完成時接收主機系統的至少一個寫入指令,暫停背景垃圾收集操作且退出背景模式。在步驟S906中,執行寫入指令。在步驟S908中,完成執行寫入指令後進入背景模式並繼續執行背景垃圾收集操作。FIG. 9 is a flowchart of a flash memory data sorting method according to an exemplary embodiment of the present invention. In step S902, the background garbage collection operation is performed in the background mode. In step S904, when the background garbage collection operation is not completed, at least one write instruction from the host system is received, the background garbage collection operation is suspended, and the background mode is exited. In step S906, a write command is executed. In step S908, after completing the execution of the write instruction, the background mode is entered and the background garbage collection operation is continued.

圖10是根據本發明的一範例實施例所繪示的快閃記憶體之資料整理方法的流程圖。請參照圖10,在步驟S1002中,暫停背景垃圾收集操作且退出背景模式進入前景模式。在步驟S1004中,判斷可複寫式非揮發性記憶體模組的空閒實體抹除單元數量是否大於啟動閥值。在可複寫式非揮發性記憶體模組的空閒實體抹除單元數量不大於啟動閥值(步驟S1004,判斷為否)時,依據多個實體抹除單元對應的有效計數選擇多個來源實體抹除單元以執行前景垃圾收集操作(步驟S1006)。在可複寫式非揮發性記憶體模組的空閒實體抹除單元數量大於啟動閥值(步驟S1004,判斷為是)時,執行寫入指令(步驟S1008)。FIG. 10 is a flowchart of a flash memory data sorting method according to an exemplary embodiment of the present invention. Referring to FIG. 10, in step S1002, the background garbage collection operation is suspended and the background mode is exited to enter the foreground mode. In step S1004, it is determined whether the number of free physical erasing units of the rewritable non-volatile memory module is greater than the activation threshold. When the number of free physical erasing units of the rewritable non-volatile memory module is not greater than the activation threshold (step S1004, judged as No), select multiple source physical erasing units according to the valid counts corresponding to the multiple physical erasing units Divide the unit to perform the foreground garbage collection operation (step S1006). When the number of free physical erasing units of the rewritable non-volatile memory module is greater than the activation threshold (step S1004, the judgment is YES), the write command is executed (step S1008).

然而,圖9與圖10中各步驟已詳細說明如上,在此便不再贅述。值得注意的是,圖9與圖10中各步驟可以實作為多個程式碼或是電路,本發明不加以限制。此外,圖9與圖10的方法可以搭配以上範例實施例使用,也可以單獨使用,本發明不加以限制。However, each step in FIG. 9 and FIG. 10 has been described in detail as above, and will not be repeated here. It should be noted that each step in FIG. 9 and FIG. 10 can be implemented as multiple program codes or circuits, and the present invention is not limited. In addition, the methods in FIG. 9 and FIG. 10 can be used in conjunction with the above exemplary embodiments, or can be used alone, and the present invention is not limited.

綜上所述,本發明提供的快閃記憶體之資料整理方法、快閃記憶體儲存裝置及快閃記憶體控制電路單元,可在響應主機系統的寫入指令時,依據當前空閒實體抹除單元的狀態動態判斷垃圾收集操作是否可以等待。當發現當前空閒實體抹除單元數量超過啟動閥值時,快閃記憶體控制電路單元會將現在的垃圾收集操作先待決(pending)起來,並執行寫入指令。並且在下次滿足前景模式的垃圾收集條件時再執行垃圾收集操作。In summary, the flash memory data sorting method, flash memory storage device, and flash memory control circuit unit provided by the present invention can be erased according to the current idle entity in response to a write command from the host system The state of the unit dynamically determines whether the garbage collection operation can wait. When it is found that the current number of free physical erasing units exceeds the start threshold, the flash memory control circuit unit will first pending (pending) the current garbage collection operation and execute the write command. And the garbage collection operation will be executed when the garbage collection conditions of the foreground mode are met next time.

綜上所述,本發明在前景垃圾收集操作及背景垃圾收集操作可將來源實體抹除單元的有效資料搬移(或複製)至相同的目標實體抹除單元。並且在前景模式下,當可複寫式非揮發性記憶體模組的空閒實體抹除單元數量不大於啟動閥值,則依據多個實體抹除單元對應的有效計數選擇多個來源實體抹除單元以執行垃圾收集操作。並且當可複寫式非揮發性記憶體模組的空閒實體抹除單元數量大於啟動閥值,則執行寫入指令。基此,本發明藉由動態選擇垃圾收集操作的來源實體抹除單元和動態管理執行垃圾收集操作的時間,可減少在前景模式執行垃圾收集操作的機率,並盡可能的在背景模式執行垃圾收集操作。並且,藉由動態選擇垃圾收集操作的來源實體抹除單元,可快速釋放空閒實體抹除單元。據以,可減少垃圾收集操作所造成的延遲,而有效提高寫入指令的執行效率。In summary, the present invention can move (or copy) the effective data of the source entity erasing unit to the same target entity erasing unit in the foreground garbage collection operation and the background garbage collection operation. And in the foreground mode, when the number of free physical erasing units of the rewritable non-volatile memory module is not greater than the activation threshold, multiple source physical erasing units are selected based on the effective counts corresponding to multiple physical erasing units To perform garbage collection. And when the number of free physical erase units of the rewritable non-volatile memory module is greater than the activation threshold, the write command is executed. Based on this, the present invention dynamically selects the source entity erasure unit of the garbage collection operation and dynamically manages the time to perform the garbage collection operation, which can reduce the probability of performing the garbage collection operation in the foreground mode, and perform the garbage collection in the background mode as much as possible. operate. In addition, by dynamically selecting the source physical erasing unit of the garbage collection operation, the idle physical erasing unit can be quickly released. Accordingly, the delay caused by the garbage collection operation can be reduced, and the execution efficiency of the write instruction can be effectively improved.

10,30:記憶體儲存裝置 11,31:主機系統 110:系統匯流排 111:處理器 112:隨機存取記憶體 113:唯讀記憶體 114:資料傳輸介面 12:輸入/輸出(I/O)裝置 20:主機板 201:隨身碟 202:記憶卡 203:固態硬碟 204:無線記憶體儲存裝置 205:全球定位系統模組 206:網路介面卡 207:無線傳輸裝置 208:鍵盤 209:螢幕 210:喇叭 32:SD卡 33:CF卡 34:嵌入式儲存裝置 341:嵌入式多媒體卡 342:嵌入式多晶片封裝儲存裝置 402:連接介面單元 404:記憶體控制電路單元 406:可複寫式非揮發性記憶體模組 502:記憶體管理電路 504:主機介面 506:記憶體介面 508:錯誤檢查與校正電路 510:緩衝記憶體 512:電源管理電路 601、801:儲存區 602:替換區 610(0)~610(B):實體單元 612(0)~612(C):邏輯單元 801:目標實體抹除單元 810(0)~810(14):子實體抹除單元 A~G:時間點 T1~T5:時間間隔 TH BG,TH FG:啟動閥值 T IDLE:空閒時間 T FG:前景操作時間 T BG:背景垃圾收集時間 T preset:預設時間 S902:步驟(在背景模式執行背景垃圾收集操作) S904:步驟(在背景垃圾收集操作未完成時接收主機系統的至少一個寫入指令,暫停背景垃圾收集操作且退出背景模式) S906:步驟(執行寫入指令) S908:步驟(完成執行寫入指令後進入背景模式並繼續執行背景垃圾收集操作) S1002:步驟(暫停背景垃圾收集操作且退出背景模式進入前景模式) S1004:步驟(判斷可複寫式非揮發性記憶體模組的空閒實體抹除單元數量是否大於啟動閥值) S1006:步驟(依據多個實體抹除單元對應的有效計數選擇多個來源實體抹除單元以執行前景垃圾收集操作) S1008:步驟(執行寫入指令) 10, 30: memory storage device 11, 31: host system 110: system bus 111: processor 112: random access memory 113: read-only memory 114: data transmission interface 12: input/output (I/O ) Device 20: Motherboard 201: Flash Drive 202: Memory Card 203: Solid State Drive 204: Wireless Memory Storage Device 205: Global Positioning System Module 206: Network Interface Card 207: Wireless Transmission Device 208: Keyboard 209: Screen 210: speaker 32: SD card 33: CF card 34: embedded storage device 341: embedded multimedia card 342: embedded multi-chip package storage device 402: connection interface unit 404: memory control circuit unit 406: rewritable non Volatile memory module 502: memory management circuit 504: host interface 506: memory interface 508: error checking and correction circuit 510: buffer memory 512: power management circuit 601, 801: storage area 602: replacement area 610 ( 0)~610(B): physical unit 612(0)~612(C): logical unit 801: target entity erasing unit 810(0)~810(14): sub-entity erasing unit A~G: point in time T1~T5: Time interval TH BG , TH FG : start threshold T IDLE : idle time T FG : foreground operation time T BG : background garbage collection time T preset : preset time S902: step (execute background garbage collection in background mode Operation) S904: Step (receive at least one write instruction from the host system when the background garbage collection operation is not completed, suspend the background garbage collection operation and exit the background mode) S906: Step (execute the write instruction) S908: Step (complete the execution of the write After entering the command, enter the background mode and continue to perform the background garbage collection operation) S1002: Step (pause the background garbage collection operation and exit the background mode to enter the foreground mode) S1004: Step (determine the idle physical erase of the rewritable non-volatile memory module) Whether the number of erasure units is greater than the start threshold) S1006: Step (Select multiple source entity erasure units based on the effective counts corresponding to multiple entity erasure units to perform foreground garbage collection operations) S1008: Step (execute write instructions)

圖1是根據一範例實施例所繪示的主機系統、記憶體儲存裝置及輸入/輸出(I/O)裝置的示意圖。 圖2是根據另一範例實施例所繪示的主機系統、記憶體儲存裝置及輸入/輸出(I/O)裝置的示意圖。 圖3是根據另一範例實施例所繪示的主機系統與記憶體儲存裝置的示意圖。 圖4是根據本發明的一範例實施例所繪示的記憶體儲存裝置的概要方塊圖。 圖5是根據本發明的一範例實施例所繪示的記憶體控制電路單元的概要方塊圖。 圖6是根據本發明的一範例實施例所繪示的管理可複寫式非揮發性記憶體模組的示意圖。 圖7是根據本發明的一範例實施例所繪示的快閃記憶體之資料整理方法的範例。 圖8是根據本發明的一範例實施例所繪示的目標實體抹除單元的示意圖。 圖9是根據本發明的一範例實施例所繪示的快閃記憶體之資料整理方法的流程圖。 圖10是根據本發明的一範例實施例所繪示的快閃記憶體之資料整理方法的流程圖。 FIG. 1 is a schematic diagram of a host system, a memory storage device, and an input/output (I/O) device according to an exemplary embodiment. FIG. 2 is a schematic diagram of a host system, a memory storage device, and an input/output (I/O) device according to another exemplary embodiment. FIG. 3 is a schematic diagram of a host system and a memory storage device according to another exemplary embodiment. FIG. 4 is a schematic block diagram of a memory storage device according to an exemplary embodiment of the present invention. FIG. 5 is a schematic block diagram of a memory control circuit unit according to an exemplary embodiment of the present invention. FIG. 6 is a schematic diagram of managing a rewritable non-volatile memory module according to an exemplary embodiment of the present invention. FIG. 7 is an example of a flash memory data sorting method according to an exemplary embodiment of the present invention. FIG. 8 is a schematic diagram of a target entity erasing unit according to an exemplary embodiment of the present invention. FIG. 9 is a flowchart of a flash memory data sorting method according to an exemplary embodiment of the present invention. FIG. 10 is a flowchart of a flash memory data sorting method according to an exemplary embodiment of the present invention.

S902:步驟(在背景模式執行背景垃圾收集操作) S902: Step (perform background garbage collection operation in background mode)

S904:步驟(在背景垃圾收集操作未完成時接收主機系統的至少一個寫入指令,暫停背景垃圾收集操作且退出背景模式) S904: Step (receive at least one write instruction from the host system when the background garbage collection operation is not completed, suspend the background garbage collection operation and exit the background mode)

S906:步驟(執行寫入指令) S906: Step (execute write instruction)

S908:步驟(完成執行寫入指令後進入背景模式並繼續執行背景垃圾收集操作) S908: Step (Enter the background mode after completing the write instruction and continue to perform the background garbage collection operation)

Claims (21)

一種快閃記憶體之資料整理方法,用於包括一可複寫式非揮發性記憶體模組的一快閃記憶體儲存裝置,且該快閃記憶體之資料整理方法包括:在一背景模式執行一背景垃圾收集操作以將一或多個來源實體抹除單元的有效資料複製至目標實體抹除單元;在該背景垃圾收集操作未完成時接收主機系統的至少一個寫入指令,暫停該背景垃圾收集操作及保留該目標實體抹除單元且退出該背景模式;執行該至少一個寫入指令;以及完成執行該至少一個寫入指令後進入該背景模式並繼續執行該背景垃圾收集操作,其中執行該至少一個寫入指令的步驟包括:若在執行該至少一個寫入指令的過程中執行一前景垃圾收集操作,則在執行該前景垃圾收集操作時將該一或多個來源實體抹除單元的有效資料複製至所保留的該目標實體抹除單元。 A flash memory data organization method is used in a flash memory storage device including a rewritable non-volatile memory module, and the flash memory data organization method includes: executing in a background mode A background garbage collection operation to copy valid data of one or more source entity erasing units to the target entity erasing unit; when the background garbage collection operation is not completed, at least one write command from the host system is received, and the background garbage is suspended Collect operation and retain the target entity erasing unit and exit the background mode; execute the at least one write instruction; and after the completion of the at least one write instruction, enter the background mode and continue to perform the background garbage collection operation, wherein the The step of at least one write instruction includes: if a foreground garbage collection operation is performed during the execution of the at least one write instruction, then when the foreground garbage collection operation is performed, the effective of the one or more source entities is erased. The data is copied to the reserved target entity erasing unit. 如請求項1所述的快閃記憶體之資料整理方法,更包括:在執行該背景垃圾收集操作時,在將該一或多個來源實體抹除單元的有效資料複製至該目標實體抹除單元的步驟之後,抹除該一或多個來源實體抹除單元且釋放該一或多個來源實體抹除單元為空閒實體抹除單元;以及 在暫停該背景垃圾收集操作時,暫停將該一或多個來源實體抹除單元的有效資料複製至該目標實體抹除單元,並保留該目標實體抹除單元且自該背景模式進入一前景模式以執行該至少一個寫入指令。 The flash memory data sorting method according to claim 1, further comprising: when the background garbage collection operation is performed, the effective data of the one or more source entity erasing units is copied to the target entity to erase After the cell step, erase the one or more source physical erase units and release the one or more source physical erase units as idle physical erase units; and When the background garbage collection operation is suspended, the effective data of the one or more source entity erasing units is suspended to the target entity erasing unit, and the target entity erasing unit is retained and entering a foreground mode from the background mode To execute the at least one write instruction. 如請求項1所述的快閃記憶體之資料整理方法,其中在該背景模式執行該背景垃圾收集操作以將該一或多個來源實體抹除單元的有效資料複製至該目標實體抹除單元的步驟包括:依據多個實體抹除單元對應的有效計數選擇該些實體抹除單元中的一或多個作為該一或多個來源實體抹除單元,並將該一或多個來源實體抹除單元的有效資料複製至該目標實體抹除單元。 The flash memory data organization method according to claim 1, wherein the background garbage collection operation is executed in the background mode to copy the effective data of the one or more source entity erasing units to the target entity erasing unit The steps include: selecting one or more of the physical erasing units as the one or more source physical erasing units according to the effective counts corresponding to the plurality of physical erasing units, and erasing the one or more source entities The effective data of the erasing unit is copied to the target entity erasing unit. 如請求項3所述的快閃記憶體之資料整理方法,其中執行該前景垃圾收集操作的步驟更包括:依據該些實體抹除單元對應的最新該有效計數選擇該些實體抹除單元中的一或多個作為該一或多個來源實體抹除單元。 The flash memory data sorting method according to claim 3, wherein the step of performing the foreground garbage collection operation further includes: selecting one of the physical erasing units according to the latest effective count corresponding to the physical erasing units One or more erase units are used as the one or more source entities. 如請求項4所述的快閃記憶體之資料整理方法,其中該背景垃圾收集操作與該前景垃圾收集操作共用相同的該目標實體抹除單元。 The flash memory data sorting method according to claim 4, wherein the background garbage collection operation and the foreground garbage collection operation share the same target entity erasing unit. 如請求項4所述的快閃記憶體之資料整理方法,其中用於判斷執行該背景垃圾收集操作的一第一啟動閥值大於判斷執行該前景垃圾收集操作的一第二啟動閥值。 The flash memory data sorting method according to claim 4, wherein a first activation threshold for determining to perform the background garbage collection operation is greater than a second activation threshold for determining to perform the foreground garbage collection operation. 如請求項3所述的快閃記憶體之資料整理方法,其中完成執行該至少一個寫入指令後進入該背景模式並繼續執行該背景垃圾收集操作的步驟更包括:在完成執行該至少一個寫入指令後經過一預定時間後進入該背景模式;依據該些實體抹除單元對應的最新該有效計數執行該背景垃圾收集操作,選擇該些實體抹除單元中的一或多個作為該一或多個來源實體抹除單元,並將該一或多個來源實體抹除單元的有效資料複製至該目標實體抹除單元。 According to claim 3, the flash memory data sorting method, wherein the step of entering the background mode after executing the at least one write command and continuing to perform the background garbage collection operation further includes: after the completion of the at least one write command The background mode is entered after a predetermined time after the instruction is entered; the background garbage collection operation is executed according to the latest effective count corresponding to the physical erasing units, and one or more of the physical erasing units are selected as the one or Multiple source physical erasing units, and copy valid data of the one or more source physical erasing units to the target physical erasing unit. 一種快閃記憶體儲存裝置,包括:一連接介面單元,用以耦接至一主機系統;一可複寫式非揮發性記憶體模組;以及一快閃記憶體控制電路單元,耦接至該連接介面單元與該可複寫式非揮發性記憶體模組,其中該快閃記憶體控制電路單元用以在一背景模式執行一背景垃圾收集操作以將一或多個來源實體抹除單元的有效資料複製至目標實體抹除單元,該快閃記憶體控制電路單元更用以在該背景垃圾收集操作未完成時接收主機系統的至少一個寫入指令,暫停該背景垃圾收集操作及保留該目標實體抹除單元且退出該背景模式,該快閃記憶體控制電路單元更用以執行該至少一個寫入指令,並且 該快閃記憶體控制電路單元更用以完成執行該至少一個寫入指令後進入該背景模式並繼續執行該背景垃圾收集操作,其中執行該至少一個寫入指令的運作中,若在執行該至少一個寫入指令的過程中執行一前景垃圾收集操作,則該快閃記憶體控制電路單元更用以在執行該前景垃圾收集操作時將該一或多個來源實體抹除單元的有效資料複製至所保留的該目標實體抹除單元。 A flash memory storage device includes: a connection interface unit for coupling to a host system; a rewritable non-volatile memory module; and a flash memory control circuit unit coupled to the Connecting the interface unit and the rewritable non-volatile memory module, wherein the flash memory control circuit unit is used to perform a background garbage collection operation in a background mode to erase the effectiveness of one or more source entities The data is copied to the target entity erasing unit, and the flash memory control circuit unit is further used to receive at least one write command from the host system when the background garbage collection operation is not completed, suspend the background garbage collection operation and retain the target entity Erase the unit and exit the background mode, the flash memory control circuit unit is further used to execute the at least one write command, and The flash memory control circuit unit is further configured to enter the background mode after completing the execution of the at least one write command and continue to perform the background garbage collection operation. In the operation of executing the at least one write command, if the at least one write command is executed, A foreground garbage collection operation is executed during a write command, and the flash memory control circuit unit is further used to copy the effective data of the one or more source entity erasing units to the foreground garbage collection operation. The retained erase unit of the target entity. 如請求項8所述的快閃記憶體儲存裝置,其中該快閃記憶體控制電路單元更用以在執行該背景垃圾收集操作時,在將一或多個來源實體抹除單元的有效資料複製至該目標實體抹除單元的運作之後,抹除該一或多個來源實體抹除單元且釋放該一或多個來源實體抹除單元為空閒實體抹除單元,並且該快閃記憶體控制電路單元更用以在暫停該背景垃圾收集操作時,暫停將該一或多個來源實體抹除單元的有效資料複製至該目標實體抹除單元,並保留該目標實體抹除單元且自該背景模式進入一前景模式以執行該至少一個寫入指令。 The flash memory storage device according to claim 8, wherein the flash memory control circuit unit is further used for copying valid data of one or more source entity erasing units when performing the background garbage collection operation After the operation of the target physical erase unit, erase the one or more source physical erase units and release the one or more source physical erase units as idle physical erase units, and the flash memory control circuit The unit is further used to suspend the copying of the effective data of the one or more source entity erasing units to the target entity erasing unit when the background garbage collection operation is suspended, and to retain the target entity erasing unit from the background mode Enter a foreground mode to execute the at least one write command. 如請求項8所述的快閃記憶體儲存裝置,其中在該背景模式執行該背景垃圾收集操作以將該一或多個來源實體抹除單元的有效資料複製至該目標實體抹除單元的運作中,該快閃記憶體控制電路單元更用以依據多個實體抹除單元對應的有效計數選擇該些實體抹除單元中的一或多個作為該一或多 個來源實體抹除單元,並將該一或多個來源實體抹除單元的有效資料複製至該目標實體抹除單元。 The flash memory storage device according to claim 8, wherein the background garbage collection operation is executed in the background mode to copy the effective data of the one or more source physical erasing units to the target physical erasing unit Wherein, the flash memory control circuit unit is further used for selecting one or more of the physical erasing units as the one or more according to the effective counts corresponding to the plurality of physical erasing units. A source physical erasing unit, and copy valid data of the one or more source physical erasing units to the target physical erasing unit. 如請求項10所述的快閃記憶體儲存裝置,其中執行該前景垃圾收集操作的運作中,該快閃記憶體控制電路單元更用以依據該些實體抹除單元對應的最新該有效計數選擇該些實體抹除單元中的一或多個作為該一或多個來源實體抹除單元。 The flash memory storage device according to claim 10, wherein in the operation of performing the foreground garbage collection operation, the flash memory control circuit unit is further configured to select the latest valid count corresponding to the physical erasing units One or more of the physical erasing units serve as the one or more source physical erasing units. 如請求項11所述的快閃記憶體儲存裝置,其中該背景垃圾收集操作與該前景垃圾收集操作共用相同的該目標實體抹除單元。 The flash memory storage device according to claim 11, wherein the background garbage collection operation and the foreground garbage collection operation share the same target entity erasing unit. 如請求項11所述的快閃記憶體儲存裝置,其中用於判斷執行該背景垃圾收集操作的一第一啟動閥值大於判斷執行該前景垃圾收集操作的一第二啟動閥值。 The flash memory storage device according to claim 11, wherein a first activation threshold for determining to perform the background garbage collection operation is greater than a second activation threshold for determining to perform the foreground garbage collection operation. 如請求項10所述的快閃記憶體儲存裝置,其中完成執行該至少一個寫入指令後進入該背景模式並繼續執行該背景垃圾收集操作的運作中,該快閃記憶體控制電路單元更用以在完成執行該至少一個寫入指令後經過一預定時間後進入該背景模式,並且該快閃記憶體控制電路單元更用以依據該些實體抹除單元對應的最新該有效計數執行該背景垃圾收集操作,選擇該些實體抹除單元中的一或多個作為該一或多個來源實體抹除單元,並將該一或多個來源實體抹除單元的有效資料複製至該目標實體抹除單 元。 The flash memory storage device according to claim 10, wherein after the execution of the at least one write command is completed, the background mode is entered and the background garbage collection operation is continued, the flash memory control circuit unit is further used In order to enter the background mode after a predetermined time has elapsed after the execution of the at least one write command, and the flash memory control circuit unit is further used to execute the background garbage according to the latest valid count corresponding to the physical erasing units Collect operation, select one or more of the physical erasing units as the one or more source physical erasing units, and copy the valid data of the one or more source physical erasing units to the target physical erasing unit one Yuan. 一種快閃記憶體控制電路單元,用於控制包括一可複寫式非揮發性記憶體模組的一快閃記憶體儲存裝置,且該快閃記憶體控制電路單元包括:一主機介面,用以耦接至一主機系統;一記憶體介面,用以耦接至該可複寫式非揮發性記憶體模組;以及一記憶體管理電路,耦接至該主機介面與該記憶體介面,其中該快閃記憶體控制電路單元用以在一背景模式執行一背景垃圾收集操作以將一或多個來源實體抹除單元的有效資料複製至目標實體抹除單元,該快閃記憶體控制電路單元更用以在該背景垃圾收集操作未完成時接收主機系統的至少一個寫入指令,暫停該背景垃圾收集操作及保留該目標實體抹除單元且退出該背景模式,該快閃記憶體控制電路單元更用以執行該至少一個寫入指令,並且該快閃記憶體控制電路單元更用以完成執行該至少一個寫入指令後進入該背景模式並繼續執行該背景垃圾收集操作,其中執行該至少一個寫入指令的運作中,若在執行該至少一個寫入指令的過程中執行一前景垃圾收集操作,則該快閃記憶體控制電路單元更用以在執行該前景垃圾收集操作時將該一或多個來源實體抹除單元的有效資料複製至所保留的該目標實體抹除單 元。 A flash memory control circuit unit for controlling a flash memory storage device including a rewritable non-volatile memory module, and the flash memory control circuit unit includes: a host interface for Coupled to a host system; a memory interface for coupling to the rewritable non-volatile memory module; and a memory management circuit coupled to the host interface and the memory interface, wherein the The flash memory control circuit unit is used for performing a background garbage collection operation in a background mode to copy valid data of one or more source physical erasing units to the target physical erasing unit, and the flash memory control circuit unit is more Used to receive at least one write instruction from the host system when the background garbage collection operation is not completed, suspend the background garbage collection operation, retain the target entity erasing unit and exit the background mode, the flash memory control circuit unit is more Is used to execute the at least one write instruction, and the flash memory control circuit unit is further used to complete the execution of the at least one write instruction and then enter the background mode and continue to perform the background garbage collection operation, wherein the at least one write is executed In the operation of the input command, if a foreground garbage collection operation is performed during the execution of the at least one write command, the flash memory control circuit unit is further used to perform the one or more foreground garbage collection operations during the execution of the foreground garbage collection operation. Copy the valid data of the source entity erasure unit to the reserved target entity erasure list Yuan. 如請求項15所述的快閃記憶體控制電路單元,其中該快閃記憶體控制電路單元更用以在執行該背景垃圾收集操作時,在將一或多個來源實體抹除單元的有效資料複製至目標實體抹除單元的運作之後,抹除該一或多個來源實體抹除單元且釋放該一或多個來源實體抹除單元為空閒實體抹除單元,並且該快閃記憶體控制電路單元更用以在暫停該背景垃圾收集操作時,暫停將該一或多個來源實體抹除單元的有效資料複製至該目標實體抹除單元,並保留該目標實體抹除單元且自該背景模式進入一前景模式以執行該至少一個寫入指令。 The flash memory control circuit unit according to claim 15, wherein the flash memory control circuit unit is further used to erase valid data of one or more source entities when performing the background garbage collection operation After the operation of copying to the target physical erase unit, erase the one or more source physical erase units and release the one or more source physical erase units as idle physical erase units, and the flash memory control circuit The unit is further used to suspend the copying of the effective data of the one or more source entity erasing units to the target entity erasing unit when the background garbage collection operation is suspended, and to retain the target entity erasing unit from the background mode Enter a foreground mode to execute the at least one write command. 如請求項15所述的快閃記憶體控制電路單元,其中在該背景模式執行該背景垃圾收集操作以將該一或多個來源實體抹除單元的有效資料複製至該目標實體抹除單元的運作中,該快閃記憶體控制電路單元更用以依據多個實體抹除單元對應的有效計數選擇該些實體抹除單元中的一或多個作為該一或多個來源實體抹除單元,並將該一或多個來源實體抹除單元的有效資料複製至該目標實體抹除單元。 The flash memory control circuit unit according to claim 15, wherein the background garbage collection operation is performed in the background mode to copy the effective data of the one or more source entity erasing units to the target entity erasing unit In operation, the flash memory control circuit unit is further used for selecting one or more of the physical erasing units as the one or more source physical erasing units according to the effective counts corresponding to the plurality of physical erasing units. And copy the effective data of the one or more source physical erasing units to the target physical erasing unit. 如請求項17所述的快閃記憶體控制電路單元,其中執行該前景垃圾收集操作的運作中,該快閃記憶體控制電路單元更用以依據該些實體抹除單元對應的最新該有效計數選擇該些實體抹除單元中的一或多個作為該 一或多個來源實體抹除單元。 The flash memory control circuit unit according to claim 17, wherein in the operation of performing the foreground garbage collection operation, the flash memory control circuit unit is further used for according to the latest valid count corresponding to the physical erasing units Select one or more of these physical erasure units as the One or more source entity erasure units. 如請求項18所述的快閃記憶體控制電路單元,其中該背景垃圾收集操作與該前景垃圾收集操作共用相同的該目標實體抹除單元。 The flash memory control circuit unit according to claim 18, wherein the background garbage collection operation and the foreground garbage collection operation share the same target entity erasing unit. 如請求項18所述的快閃記憶體控制電路單元,其中用於判斷執行該背景垃圾收集操作的一第一啟動閥值大於判斷執行該前景垃圾收集操作的一第二啟動閥值。 The flash memory control circuit unit according to claim 18, wherein a first activation threshold for determining to perform the background garbage collection operation is greater than a second activation threshold for determining to perform the foreground garbage collection operation. 如請求項17所述的快閃記憶體控制電路單元,其中完成執行該至少一個寫入指令後進入該背景模式並繼續執行該背景垃圾收集操作的運作中,該快閃記憶體控制電路單元更用以在完成執行該至少一個寫入指令後經過一預定時間後進入該背景模式,並且該快閃記憶體控制電路單元更用以依據該些實體抹除單元對應的最新該有效計數執行該背景垃圾收集操作,選擇該些實體抹除單元中的一或多個作為該一或多個來源實體抹除單元,並將該一或多個來源實體抹除單元的有效資料複製至該目標實體抹除單元。 The flash memory control circuit unit according to claim 17, wherein after completing the execution of the at least one write command, it enters the background mode and continues to perform the background garbage collection operation, the flash memory control circuit unit is more Used to enter the background mode after a predetermined time has elapsed after the execution of the at least one write command is completed, and the flash memory control circuit unit is further used to execute the background mode according to the latest valid count corresponding to the physical erasing units Garbage collection operation, selecting one or more of the physical erasing units as the one or more source physical erasing units, and copying the valid data of the one or more source physical erasing units to the target physical erasing unit In addition to the unit.
TW109110830A 2020-03-30 2020-03-30 Data arrangement method of flash memory, flash memory storage device and flash memory control circuit unit TWI738272B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
TW109110830A TWI738272B (en) 2020-03-30 2020-03-30 Data arrangement method of flash memory, flash memory storage device and flash memory control circuit unit

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
TW109110830A TWI738272B (en) 2020-03-30 2020-03-30 Data arrangement method of flash memory, flash memory storage device and flash memory control circuit unit

Publications (2)

Publication Number Publication Date
TWI738272B true TWI738272B (en) 2021-09-01
TW202137220A TW202137220A (en) 2021-10-01

Family

ID=78777862

Family Applications (1)

Application Number Title Priority Date Filing Date
TW109110830A TWI738272B (en) 2020-03-30 2020-03-30 Data arrangement method of flash memory, flash memory storage device and flash memory control circuit unit

Country Status (1)

Country Link
TW (1) TWI738272B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150261452A1 (en) * 2014-03-12 2015-09-17 Samsung Electronics Co., Ltd. Memory device and controlling method of the same
US20180024920A1 (en) * 2016-07-20 2018-01-25 Sandisk Technologies Llc System and method for tracking block level mapping overhead in a non-volatile memory
US20190278490A1 (en) * 2017-04-07 2019-09-12 Micron Technology, Inc. Memory management

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150261452A1 (en) * 2014-03-12 2015-09-17 Samsung Electronics Co., Ltd. Memory device and controlling method of the same
US20180024920A1 (en) * 2016-07-20 2018-01-25 Sandisk Technologies Llc System and method for tracking block level mapping overhead in a non-volatile memory
US20190278490A1 (en) * 2017-04-07 2019-09-12 Micron Technology, Inc. Memory management

Also Published As

Publication number Publication date
TW202137220A (en) 2021-10-01

Similar Documents

Publication Publication Date Title
CN111400201B (en) Data sorting method of flash memory, storage device and control circuit unit
TWI587135B (en) Data storage method, memory storage device and memory control circuit unit
US11755242B2 (en) Data merging method, memory storage device for updating copied L2P mapping table according to the physical address of physical unit
CN107239225B (en) Memory management method, memory storage device and memory control circuit unit
TW202038098A (en) Memory control method, memory storage device and memory control circuit unit
TW202318150A (en) Memory performance optimization method, memory control circuit unit and memory storage device
TWI717755B (en) Memory control method, memory storage device and memory control circuit unit
CN106775479B (en) Memory management method, memory storage device and memory control circuit unit
TWI702496B (en) Memory management method, memory storage device and memory control circuit unit
CN112051971B (en) Data merging method, memory storage device and memory control circuit unit
TWI688956B (en) Memory control method, memory storage device and memory control circuit unit
TW201734795A (en) Memory management method, memory storage device and memory control circuit unit
CN112835536B (en) Memory control method, memory storage device and memory control circuit unit
CN112394883B (en) Data merging method, memory storage device and memory control circuit unit
TWI712886B (en) Memory management method, memory storage device and memory control circuit unit
TWI738272B (en) Data arrangement method of flash memory, flash memory storage device and flash memory control circuit unit
TWI720400B (en) Memory control method, memory storage device and memory control circuit unit
TWI823792B (en) Mapping table updating method, memory storage device and memory control circuit unit
TWI793966B (en) Memory management method, memory storage device and memory control circuit unit
US11455243B2 (en) Data merge method performing data merge operations with identifying valid data of source nodes for next data merge operation, memory storage device, and memory control circuit unit
CN112114737B (en) Memory control method, memory storage device and memory control circuit unit
TWI831366B (en) Data writing method, memory storage device and memory control circuit unit
TWI845275B (en) Memory management method, memory storage device and memory control circuit unit
CN112445418B (en) Memory control method, memory storage device and memory control circuit unit
CN108121663B (en) Data storage method, memory storage device and memory control circuit unit