201015565 九、發明說明: 【發明所屬之技術領域】 本發明是有關於-種應用於儲存媒體管理系統的耗損 ,平均方法及裝置’主要應用於大容量儲存設備的媒體管理 系統。 【先前技術】 ❹ 非揮發性記憶體,例如電子可抹除可程式唯讀記憶體 (Electrically Erasable Programmable Read-Only Memory ; eeprom),是_種有著單位資料寫人,區塊資料抹除的 物理,性的大容量儲存媒體,其由一個或多個儲存單元組 成,每個儲存單元儲存一個或多個資料位元。一 般用在即插即用(Plug &Play)介面卡中,絲存放硬體 設置資料’也常用在防止軟體非法拷㈣“硬體鎖,,上面。 卿RQM-般制錢存單元劃分材抹除區塊的形 攀式來進行抹除操作,然而由於其本身物理特性的限制,使 ,在使用過程中存在著可抹除區塊的使用壽命較短的問 題。一塊可抹除區塊抹除次數一般為1〇萬次至1〇〇萬次。 j其使用過程中,如果頻繁地抹除某個區塊,則會導致該 區塊的壽命很快被耗盡,進而影響整個儲存媒體的使用= 命。 。 為了均衡地使用不同的可抹除區塊,需要 均技術來對抹除操作進行處理。最直接的一 抹除區塊中記錄下該區塊的抹除次數(erase c〇unt),並在抹 VTU08-0〇〇8I〇〇.TW/0608A-A41792-TW/Fmal 5 201015565 抹除次數的區塊進行抹二兔二員::擇有較小的 但這種使用抹除次數來實現耗損平均的 點。如果在抹除區塊時關掉電源’則顧塊的抹除有也 將隨之丢失’使得在接下來的耗損平均時對該區塊二 :生偏差,從而不能真實反映系統中可抹除區塊= ❿ 【發明内容】 為了解決現有技術中所存在的,關掉系統電 除區塊的抹除次數也將隨之丢失,使得在接下來 均時對該區塊的處理產生偏差的問題,本發 憶體系統、非揮發性記憶體的耗損平均方法及裝置。種記 本發明提供一種耗損平均方法,適用於一非揮發性記 憶體。非揮發性記憶體包括多個資料區塊。每—資料區塊 對應一時。鋪平均方法包括:根據該等資料區塊所 對應的時間值的先後順序,排列該等資料區塊的順序,以 形成-鏈表;以及判斷是否對該等資料區塊進行一抹除操 作。當對該等㈣區塊進行抹除操作時,根據該鏈表中的 該等資料區塊的日相值的先後,選擇相應的資料區塊進行 該抹除操作。 本發明還提供-種耗損平均裝置,義於—非揮發性 記憶體。該非揮發性記憶體包括多個資料區塊。每一資料 區塊對應,間值。該耗損平均裝置包括,—移位模組以 及一判斷抹除模組。移位·根據該等資料區塊所對應的 VTU08-0008I00-TW/0608A-A41792-TW/Final 6 201015565 時間值的先後顺序, 鏈表。判斷祙除 排列該等資料區塊的順序,以形成一 該等資料區魂==耦接到該移位模組,用於判斷是否對 除操作,根據誃^抹除操作。如對該等資料區塊進行抹 選擇相應的資^「中的該等資料區塊的時間值的先後, 本發明該抹除操作。 資料區塊、〜位、種5己憶體系統。記憶體系統包括多個 ❹201015565 IX. Description of the Invention: [Technical Field of the Invention] The present invention relates to a media management system for a large-capacity storage device in which a loss, averaging method and apparatus applied to a storage medium management system are used. [Prior Art] ❹ Non-volatile memory, such as Electrically Erasable Programmable Read-Only Memory ( eeprom), is a type of physics that has unit data writers and block data erased. A mass storage medium consisting of one or more storage units, each storage unit storing one or more data bits. Generally used in the Plug & Play (Plug & Play) interface card, silk storage hardware settings data is also commonly used to prevent software illegal copying (four) "hard body lock, above. Qing RQM-like money storage unit partition material wipe In addition to the shape of the block to erase, but due to its physical characteristics, there is a problem of short life of the erasable block during use. An erasable block wipe The number of divisions is usually from 10 million to 10,000. j. In the course of its use, if a certain block is erased frequently, the life of the block will be quickly exhausted, which will affect the entire storage medium. The use of = =. In order to use different erasable blocks in a balanced manner, the technique is required to process the erase operation. The most direct erase block records the number of erases of the block (erase c〇 Unt), and in the wipe VTU08-0〇〇8I〇〇.TW/0608A-A41792-TW/Fmal 5 201015565 erase the number of blocks to wipe the two rabbits:: choose a smaller but this use wipe In addition to the number of times to achieve the average of wear and tear. If you turn off the power when erasing the block' The erasure of the block will also be lost, so that the block 2 will be deviated in the next wear and tear, so that the erasable block in the system cannot be truly reflected. 发明 [Summary] In order to solve the prior art In the presence of the system, the number of erasures to turn off the system is also lost, so that the processing of the block is deviated in the next time, the memory system, non-volatile memory A method for averaging wear and loss. The invention provides a method for averaging loss, which is suitable for a non-volatile memory. The non-volatile memory includes a plurality of data blocks. Each data block corresponds to one time. : arranging the order of the data blocks according to the order of time values corresponding to the data blocks to form a linked list; and determining whether to perform an erase operation on the data blocks. When the block performs the erasing operation, the corresponding data block is selected to perform the erasing operation according to the sequence of the solar phase values of the data blocks in the linked list. The present invention also provides a type of wear leveling The device is defined as a non-volatile memory. The non-volatile memory includes a plurality of data blocks, and each data block corresponds to a value. The wear leveling device includes a shift module and a judgment erase die. Group. According to the order of the time values of the VTU08-0008I00-TW/0608A-A41792-TW/Final 6 201015565 corresponding to the data blocks, the list is judged to eliminate the order of the data blocks. To form a data area soul == coupled to the shift module, used to determine whether to eliminate the operation, according to the 抹 ^ erase operation. If the data block is wiped to select the corresponding resource ^ " The order of the time values of the data blocks, the erase operation of the present invention. Data block, ~ bit, species 5 recall system. The memory system includes multiple ❹
空間回收裝置。=裝置、一耗損平均裝置以及-儲存 儲存該箅資艇π寻資料區塊能夠被抹除。位址映射裝置 抹除後的理位址’並記錄該等#料區塊進行 置,用於根摅一$ 。耗損平均裝置連接到該位址映射裝 資料區塊進行―二;:損平均種子’判斷是否對該等 後的資料區塊進行管警:存空間回收裝置對祙除 “Bh、 ㈣用於資料的再寫人或讀取。 桿記來反㈣用可抹除區塊的抹除時間戳記作為抹除 來限ί耗損;=:::?數並且還使用耗損平均種子 平=二用壽命的情況下’做到對系統效率和耗損 為讓本發明之特徵和優點 較佳實施例,並配合所附圖式 【實施方式】 能更明顯易懂,下文特舉出 ’作詳細說明如下: 為解決現有技術中的問題,本發明提出一種耗損平均 方法’其可以透過使用可抹㈣塊的抹_間戳記(time stamp)作為抹除標記來反映塊的乾損資訊,並且為了 VTU〇8-〇〇〇8I〇〇-TW/0608A-A41792-TW/Final 7 201015565 防止過度使用耗損平均處理技術而造成系統性能降低,還 使用耗損平均種子(wear leveling seed)來限定耗損平均 發生的次數。 首先,需要說明的是時間戳記與耗損平均種子的概 念。時間戳記指的是在袜除操作時,記錄在EEpR〇Mflash 中每一個可抹除區塊上的系統時間,時間戳記可儲存於不 同的位置’例如可存於抹除區塊中、EEPR〇M 一個固定位 置或外部空間。耗損平均種子為一常數,其主要作用是用 W 來限定耗損平均發生的次數。 第1A圖為非揮發性記憶體的典型應用系統模組圖,從 上至下分為四層。第一層為應用層1〇,第二層為構系統層 12,第二層為媒體管理層軟體14,第四層為硬體訪問層 16。其中,媒體管理層軟體14包括了至少三個部分,即, 位址映射模組141、耗損平均模組142以及儲存空間回收 模組143。位址映射模組141用於儲存資料區塊的物理位 φ 址以及對資料區塊進行抹除後所記錄的一時間值,即時間 戳記。耗損平均模組丨42連接到位址映射模組141,用於 根據一亂數及一耗損平均種子進行抹除次數計算,以平均 所述多個資料區塊中每個資料區塊進行抹除的次數,其 中,關於亂數及耗損平均種子將在之後進行詳細說明。^ 存空間回收模組143用於將抹除後的資料區塊進行管理, 用於資料的再寫入或讀取。在另一個實施例中,第四層為 NOR flash,即NOR型快閃記憶體。媒體管理層軟體^ 還可包括壞區塊管理的功能,由於壞區塊管理非為本發明 VTXJ08-0008IOO-TW/0608A-A41792-TW/Final 201015565 的重點,在此不作贅述。 軟體㈣耗損平均模組142。h要應用於媒體官理層 模組tit平均模組142的㈣結構圖。耗損平均 棋組巴栝一移位模組1421 模組1421可進行—移位 抹除模組1422。移位 F坡八娜^ 作㈣,_與所述多個資料 ❹ ❿ 】ί:=!抹除時㈣記,按照時間的先後順序將多 最S' 、即’鏈表表頭的資料區塊抹除時間 1422辆接i1資料^塊抹除時間最晚。判斷抹除模組 1421 ’可進行-判斷抹除步驟,判斷 疋否對鏈表中的資料區塊進行抹除操作,並根據時間值的 先後選定減㈣龍塊進練除。值的 第2圖為本發明所述的耗損平均抹除方法流程圖。其 中S201為移位操作步驟,根據多個資料區塊對應的時間值 建立可抹除區塊的鏈表n實施例中,時間值可以為 最後-次訪問該資料區塊所記錄的系統時間。為根據 S201形成的鏈表中的資料區塊時間值的先後,選擇相應的 資料區塊進行抹除操作,S2G5中,判斷是否f要進行回 收操作,其觸條件可以衫财的空閒少於外部請求所 需要的空間’亦可以為磁片整理等操作。在S2Q7中,透過 -耗損平均種子判定是料資㈣塊進行回收抹除操作, 從而控制發生耗損平均的概率。以下將結合_對上述各 個步驟進行進一步的說明。 VTU08-0008I00-TW/0608A-A41792-TW/Fmal 9 201015565 第3A圖即為按照時間先後順序排列的 區塊0〜6為已使用(USED)的抹除區塊,區未、’ (腦)的抹除區塊。鏈表頭的區塊〇祙^ ^使用 表尾的區塊7抹_間最晚。 ^間最早,鏈 疼/二圖為如上所述的按抹除時間戮記的時間先後順 序建立可抹除區塊鏈表的流程圖,即帛2圖中的步^ S·-般情況下,該絲於初始_段^。以職^ 為例:如步驟S31G,按物理順序,開简嫩㈣的可 抹除區塊進行遍歷(erg〇dic)操作。之後,如步驟阳〇 位於起始位第G個可抹除區塊。接著,如步驟S33〇, 如遍歷結束’則流程結束。如遍歷未 戰_,判斷可抹除區塊鏈表是否為 二可絲11塊鏈料空,騎行歸驟S35G,將^ 塊設為鏈表表頭,如可抹除區塊鍵表不為空 驟S370,從可抹除區塊鍵表的表頭開始 與鏈表中遍制㈣能塊二者抹除時 至步驟S371’若待插入區塊的抹除時間戮記晚於二 歷到的當前區塊的抹除時間戳記,則進行至步驟幻表71 中遍 繼續取鏈表的下-區塊進行比較,並 續 判斷,若早於,則進行至_㈣370繼續 表中當前遍歷到的位置; 塊插入到鏈 取當前區塊的下—㈣,並返回至步称咖。=理 ==::::=除:=:= VTUOe-OOOglOO-TW/OeOSA^npS-TW/Fiuaj 201015565 或,1要= 可姑本領域技術人員可根據需要自行設定。 备要進订祙除操作時,則需要將抹除後的當前 間即抹除後的時間戳記記入抹除區 塊键入 到鍵表的最後端。請參看第4Affi 將紅塊鏈入 矣的姑其為抹除時間戰記鏈 7中^缝^圖’駭塊3進行抹除操作,按照區塊 塊Ϊ戳記的早晚,將區塊3 ·可抹除區 參 ❹ =ΓΠ::二區塊7之後’則抹除操作後現有鏈 中3〜6為原區塊4〜7,區塊7為原區塊3。 第4Β圖為將抹除時間戮記記入可抹 圖。步驟S410,確定需要抹除的_ Δ 现〒的机程 接荃_ _抹除操作。 接著切至㈣_,結束鎌操作,獲取 間。然後,進行至步驟剛,將獲取的當前系統時間j 抹除區塊隊列中所保存的最晚抹除時間戳記進行比較了 步驟卿獲取的㈣_是錢於可抹除區塊隊列 中所保存的最晚祙除時間戳記’如晚於則進行至 S450,將所獲取的系統時間記入到區塊A中,如不晚於 進行至步驟S470,將可抹除區塊隊列中保存的最晚抹除時 =加上增量,並記入到區塊A令。其中,增量通常為 1,S然本領域技術人員也可根據需要選擇不同的增量值 於步驟S450或S470結束後,均進行至步驟S46〇 f將區塊 A鏈入到按抹除時關記先後順序鏈結的可抹除區塊鍵表 的尾部,繼而流程結束。 當系統中的儲存空間少於外部所請求的儲存空間,或 是系統後臺本身需要進行例如磁片整理等操作時,將進行 VTUO8-OOO8I00-TW/O6O8 A-A41792-TW/Final 11 201015565 一回收處理。在系統需要對可抹除區塊進行回收處理時, 還可透過-耗損平㈣子來做到對线效率和耗損平均效 果的兼顧’該耗損平均種子可以將發生耗損平均的概率限 定為某個確定的值。 第5A圖為可祙除區塊的回收處理流程圖,即第2圖中 的步驟S207。如步驟剛’收到需要對系、统中的可抹除區 塊的儲存空間進行回收操作的請求。之後,如步驟S520,Space recovery unit. = device, a wear leveling device, and - storage storage of the submarine boat π search data block can be erased. The address mapping device erases the logical address ' and records the #material block for setting a root $. The wear leveling device is connected to the address mapping data block for "two;: loss average seed" to determine whether the data block for the subsequent data block is handled: the storage space recovery device removes "Bh, (4) for data Rewrite the person or read. The pole is reversed. (4) Use the erase time stamp of the erasable block as the erase limit to limit the loss; =:::? and also use the wear average seed level = dual life In the case of 'system efficiency and wear and tear, a better embodiment of the features and advantages of the present invention, and with the accompanying drawings [embodiment] can be more clearly understood, the following detailed description is as follows: To solve the problems in the prior art, the present invention proposes a wear leveling method which can reflect the dryness information of a block by using a time stamp of a wipeable (four) block as an erase mark, and for VTU〇8- 〇〇〇8I〇〇-TW/0608A-A41792-TW/Final 7 201015565 Prevents over-use of wear-and-loss processing techniques resulting in reduced system performance, and also uses wear leveling seeds to limit the average number of wear and tear occurrences. What needs to be explained is the concept of time stamp and wear average seed. The time stamp refers to the system time recorded in each erasable block in EEpR〇Mflash during the socks removal operation. The time stamp can be stored in different The position ' can be stored, for example, in the erase block, EEPR 〇M a fixed position or an external space. The wear average seed is a constant, and its main function is to use W to limit the average number of occurrences of wear. Figure 1A is non-volatile The typical application system module diagram of memory is divided into four layers from top to bottom. The first layer is the application layer 1〇, the second layer is the system layer 12, and the second layer is the media management layer software 14, the fourth layer. The hardware management layer 16 includes at least three parts, namely, an address mapping module 141, a wear leveling module 142, and a storage space recovery module 143. The address mapping module 141 is used. The physical bit address of the stored data block and a time value recorded after the data block is erased, that is, the time stamp. The wear leveling module 42 is connected to the address mapping module 141 for and The wear averaged seed is used to calculate the number of erasures, and the average number of erasures for each of the plurality of data blocks is averaged. The random seed and the average wearer will be described in detail later. The module 143 is configured to manage the erased data block for data rewriting or reading. In another embodiment, the fourth layer is a NOR flash, that is, a NOR type flash memory. The management software ^ can also include the function of bad block management. Since the bad block management is not the focus of the present invention VTXJ08-0008IOO-TW/0608A-A41792-TW/Final 201015565, it will not be described here. The software (4) wears the average module 142. h is applied to the media structure layer (t) structure diagram of the module tit average module 142. The wear leveling block player shifting module 1421 module 1421 can perform the shifting erase module 1422. Shift F Slope Ba Na ^ (4), _ and the above-mentioned multiple data ❹ 】 】 ί:=! When erasing (four), in the order of time will be more than S', that is, the data area of the 'chain table header Block erase time 1422 cars connected to i1 data ^ block erase time is the latest. It is judged that the erasing module 1421' can perform - judge the erasing step, judge whether or not the data block in the linked list is erased, and select the minus (four) block to be trained according to the time value. Figure 2 is a flow chart of the wear leveling erase method according to the present invention. S201 is a shift operation step, and the linked list of the erasable blocks is established according to the time value corresponding to the plurality of data blocks. In the embodiment, the time value may be the system time recorded in the last-time access to the data block. In order to select the data block according to the time value of the data block in the linked list formed by S201, the corresponding data block is selected for the erase operation, and in S2G5, it is judged whether or not f is to be subjected to the recovery operation, and the touch condition can be idle less than the external one. The space required for the request can also be an operation such as disk sorting. In S2Q7, the permeation-loss average seed is determined to be the material (four) block for the erase erase operation, thereby controlling the probability of occurrence of wear and tear. The above steps will be further explained in conjunction with _. VTU08-0008I00-TW/0608A-A41792-TW/Fmal 9 201015565 Figure 3A shows that blocks 0 to 6 in chronological order are used (USED) erase blocks, areas not, '(brain) Wipe the block. The block header block 〇祙 ^ ^ uses the block at the end of the block 7 wipe _ the latest. The earliest, the chain pain / the second picture is the flow chart of erasing the block list in the chronological order of the erase time as described above, that is, the step in the figure 2 S , the silk is in the initial _ segment ^. Taking the job ^ as an example: In step S31G, in the physical order, the eraseable block of the simple (4) is traversed (erg〇dic). After that, as in the step, the impotence is located at the Gth erasable block of the start bit. Next, as in step S33, if the traversal ends, the flow ends. For example, if the traversal is not warned, it is judged whether the block list can be erased as the second wire and the block is empty. The ride is returned to the S35G, and the block is set as the list header. For example, the block key can be erased. The empty step S370, starting from the header of the erasable block key table and the ubiquitous (four) energy block in the linked list, to the step S371', if the erasing time of the block to be inserted is later than two calendars After erasing the timestamp of the current block, proceed to step syllable 71 to continue to compare the lower-block of the linked list, and continue to judge, if it is earlier, proceed to _(four) 370 to continue the current traversal in the table. The position is inserted into the chain to take the current block - (d), and return to the step. =理 ==::::=Except:=:= VTUOe-OOOglOO-TW/OeOSA^npS-TW/Fiuaj 201015565 Or, 1 to = can be set by the technicians in the field. When you want to subscribe to the delete operation, you need to delete the current time stamped after erasing into the erase block and type it into the last end of the key table. Please refer to the 4Affi to insert the red block into the 矣 为 抹 抹 抹 时间 战 战 战 7 7 7 ^ ^ ^ ^ ^ ^ 3 3 3 3 3 3 3 3 3 抹 抹 抹 抹 抹 抹 抹 抹 抹 抹 抹 抹 抹 抹 抹 抹 抹 抹 抹 抹 抹In addition to the area ❹ = ΓΠ:: after the second block 7 'then the existing chain 3 ~ 6 in the existing chain is the original block 4 ~ 7, block 7 is the original block 3. The fourth picture is to record the erasing time into the rewritable picture. In step S410, it is determined that the _ Δ current machine _ _ erase operation needs to be erased. Then cut to (4) _, end the operation, and get between. Then, proceed to the step, and compare the obtained current system time j to erase the latest erasing timestamp saved in the block queue to compare the steps obtained by the step (4) _ is saved in the erasable block queue The latest erasure timestamp 'If it is later than then proceed to S450, the acquired system time is recorded in block A, and if it is not later than proceeding to step S470, the erasable block queue will be saved at the latest. When erasing = plus increment, and credited to block A. Wherein, the increment is usually 1, and the person skilled in the art can also select different increment values as needed after the end of step S450 or S470, and proceed to step S46〇f to link the block A to the erasing erasing. The trailing of the block key table can be erased in sequence, and the process ends. VTUO8-OOO8I00-TW/O6O8 A-A41792-TW/Final 11 201015565 A recycling when the storage space in the system is less than the external storage space requested, or the system background itself needs to perform operations such as disk finishing. deal with. When the system needs to recycle the erasable block, it can also achieve the balance between the line efficiency and the average wear-loss effect through the wear-down (four) sub-the average seed can limit the probability of occurrence of wear and loss to a certain The determined value. Fig. 5A is a flow chart showing the recycling process of the erasable block, i.e., step S207 in Fig. 2. If the step is just received, a request is received for the recovery operation of the storage space of the erasable block in the system. After that, as step S520,
系統根據最高效率原則,查找存有無效資料最多的可抹除 區塊,也就是最髒的區塊,設為區塊A。 ’、 關於步驟S520中所述的最髒的區塊,現具體說明。以 二OR flash為例,假設NOR flash的每個可抹除區塊為⑽乂, 每一個可抹除區塊中儲存空間可按磁區的大小來組織。這 襄假設每個磁區大小為128位元組,這樣,一個可抹陝區 塊中就包含有512 m28位元組大小的磁區。槽系統= NORflash的可抹除區塊中寫入資料時,需要對其做編程^ 作,而且以磁區為最小寫入單位,也就是每次至少寫入 位元組。 由於NOR flash的特性,物理上儲存的資料透過編 操作(program)只能從1變成0,而不能從〇變成丨。如果二 要將資料從0變成1,只能透過對整個可抹除區塊進彳_ = 除操作(erase),一次性將區塊中所有的資料重新置/丁^ 樣,當需要修改位於可抹除區塊中某個磁區中的資料這 並不能將當前需要寫入的有效資料直接覆蓋到該磁區’ 是需要在當前區塊或別的區塊中尋找某個空閒即沒^被g vTU〇8-〇〇〇8i〇〇.TW/0608A-A41792-TW/Final 201015565 入過資料的磁區,將有效資料寫入,而且需要將原來的睐 射到同一邏輯位址的磁區標記為無效資料磁區。 對於如何尋找最髒的區塊,一般的作法為在系統初始 化時,會遍歷所有可抹除區塊,統計區槐中所包含的有效 資料磁區數,無效資料磁區數和空閒資料磁區數,並粑遠 些資訊保存到系統記憶體中相應的資料結構中,並且在使 用的過程中’同步更新這些資料結構。在需要查找最辮的 區塊時,只需要訪問這些位於記憶體中的統計資訊,找出 哪一區塊中的無效資料磁區為最多就可以了。也就是説, 當一個可抹除區塊中的被標記為無效資料磁區的數量最多 時,將該可抹除區塊稱為最髒的區塊,如步驟S520中戶斤述 的區塊A。該部分屬於現有技術,在此不再詳細敍述。 請再參看第5A圖,接著進行至步驟S53〇,根據設定 的耗損平均種子值,判斷是否需要對區塊A進行回收操 作。具體判斷過程透過公式(1)進行說明: random% ( wear-leveling seed ) = = j ( 1 ) 其中’random為亂數’實際應用中為一偽亂數(近似於 理想亂數)’其可透過標準庫函數rand〇m()或其他途捏獲 得。wear-leveling seed為耗損平均種子,其屬於一經驗常 數值’假設將耗損平均種子設置為50,則透過公式(〇 的計算,如果random為理想的亂數,則發生耗損平均處理 的概率就為1/50,即將發生耗損平均處理的概率限定為近 似1/50。另外’需要說明的是’亂數除以耗損平均種^得 到的餘數可以為其他值,例如2、3等等,本領域技術人^ VTU08-0008I00-TW/0608A-A41792-TW/Final 13 201015565 可根據需要對餘數值進行設定。 關於耗損平均種子值可以根據儲存媒體的容量靈活選 疋,以經驗值為主。但是總的來說,由於儲存媒體容量增 大,本身的區塊數增多,用戶使用時所存在的隨機性會使 得對於耗損平均處理的需求會降低,所以該耗損平均種子 的值可以取得較大。 請再參看第5A圖,如公式 中 random%According to the principle of highest efficiency, the system searches for the erasable block with the most invalid data, that is, the dirtiest block, and sets it to block A. The most dirty block described in step S520 will now be specifically described. Taking the two OR flash as an example, it is assumed that each erasable block of the NOR flash is (10), and the storage space in each erasable block can be organized according to the size of the magnetic area. This assumes that each extent is 128 bytes, so that a smear block contains a 512 m28 byte size. Slot system = When writing data in the erasable block of NORflash, it needs to be programmed, and the magnetic area is the minimum writing unit, that is, at least the byte is written at a time. Due to the nature of the NOR flash, the physically stored data can only be changed from 1 to 0 through the program, and cannot be changed from 〇 to 丨. If you want to change the data from 0 to 1, you can only re-set all the data in the block by y = _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ Can erase the data in a certain magnetic area in the block. This does not directly cover the valid data that needs to be written directly to the magnetic area. It is necessary to find some idle space in the current block or other blocks. The magnetic area of the data has been written by g vTU〇8-〇〇〇8i〇〇.TW/0608A-A41792-TW/Final 201015565, and the original data is required to be shot to the same logical address. The area is marked as an invalid data area. For the most dirty block, the general practice is to traverse all erasable blocks during system initialization, the number of valid data blocks contained in the statistical area, the number of invalid data areas and the free data area. The number and the far-end information are saved to the corresponding data structure in the system memory, and these data structures are updated synchronously during use. When you need to find the most embarrassing block, you only need to access these statistics in the memory to find out which block has the most invalid data area. That is, when the number of marked data sectors that are marked as invalid in an erasable block is the largest, the erasable block is referred to as the dirtiest block, such as the block described in step S520. A. This part belongs to the prior art and will not be described in detail herein. Referring to Fig. 5A again, proceeding to step S53, it is judged whether or not the block A needs to be recovered according to the set wear average seed value. The specific judgment process is explained by the formula (1): random% ( wear-leveling seed ) = = j ( 1 ) where 'random is a random number' is a pseudo-random number (approximating the ideal random number) in the actual application. Obtained through the standard library function rand〇m() or other means. The wear-leveling seed is the wear averaged seed, which belongs to an empirical constant value. Assuming that the wear average seed is set to 50, the formula is calculated. If the random is the ideal random number, the probability of the wear average processing is 1/50, the probability of impending average processing is limited to approximately 1/50. In addition, it should be noted that the remainder obtained by dividing the random number by the wear average can be other values, such as 2, 3, etc., in the field. Technician ^ VTU08-0008I00-TW/0608A-A41792-TW/Final 13 201015565 The remaining values can be set as needed. The average seed value for wear and tear can be flexibly selected according to the capacity of the storage medium, mainly based on experience values. In addition, as the storage medium capacity increases, the number of blocks itself increases, and the randomness of the user's use makes the demand for the wear leveling process lower, so the average value of the worn average seed can be larger. See Figure 5A again, as in the formula random%
(wear-leveiing seed)的計算結果不為i,則進行至步觸 S550’對區塊a進行回收操作’將區塊A中的有效資料拷 貝到系統預留的空閒區塊B,並將區塊入抹除。如公式㈠, 中rand〇m%(wear_levelingseed)的計算結果為卜則不需 要對區塊A進行回收操作,進行至步驟S54〇,取位於 除時間戳記先後順序鍵結的可祙除區塊鏈表的 C ’區塊C是系統中抹除時間戳記最早的區塊,塊 至步驟S57G,對區塊C進行回收操作,將區境 二 資料拷貝到系統預留的空閒區塊B,並將區塊叭有效 步驟S550或S57〇結束後,均進行至步驟祝。,按:二於 B即系統中抹除時間戳記最晚的區塊中記 =、、、區塊 記的早晚,將區塊A或(:鏈入可抹除區塊陣列^時間戳 關於步驟S530、S540、μ70至S56〇,請參看=程結束。 判斷是否需要對區塊4進行回收操作〇,將區5β圓’ 效資料拷貝到系統預留的空閒區塊7中。透^八4中的有 算確定需要進行耗損平均處理,取位㈣抹2式(1)計 後順序鏈結的可抹除區塊鏈表的表頭的區=等間戳記先 進行回收操 VTUO8-OOO8IO0-TW/O6O8A-A41792-TW/Final 201015565 作’將區塊〇中的有效資料拷貝到系統預留的空閒區塊7, 並將區塊〇抹除,並按照區塊7中記錄的抹除時間戳記的 早晚,將區塊〇鏈入可抹除區塊隊列中,鏈入區塊7之後, 完成了回收處理。則回收處理後的現有鏈表中區塊〇〜6為 原區塊1〜7 ’現區塊7為原區塊0。關於步驟S530、S550 至S560,可參照第4Α圖,在此不再詳細敍述。 本發明透過使用可抹除區塊的抹除時間戳記作為抹除 標記來反映該區塊的耗損情況’即使掉電後當前抹除時間 資訊丟失,再開機時,可選擇抹除系統區塊中保存的系統 時間最早的可抹除區塊,則可避免現有技術中關掉電源則 丟失抹除次數資訊而使得在接下來的耗損平均時對該區塊 的處理產生偏差,從而不能真實反映系統中可抹除區塊的 使用壽命。並且,本發明還透過耗損平均種子來限定耗損 平均處理的發生次數,從而在真實反映系統中可抹除區塊 的使用壽命的情況下,做到對系統效率和耗損平均效果的 φ 兼顧》 雖然本發明已以較佳實施例揭露如上’然其並非用以 限定本發明,任何所屬技術頜域中具有通常知識者,在不 脫離本發明之精神和範圍内,當可作些許之更動與潤飾, 因此本發明之保護範圍當視後附之申請專利範圍所界定者 為準。 【圖式簡單說明】 第1Α圖為根據本發明的一個實施例所迷的非揮發性 記憶體的典型應用系統模組圖。 VTU08-00〇8I〇〇.tw/0608A-A41792-TW/Final 15 201015565 圖為根據本發明的一個實施例所述的 模組的細部結構圖。 知平均 除方根據本發明的-個實施例所述的乾損平均抹 圖為根據本發明的—個實施例所 先後順序排列_表示㈣。 A、、、時間 第3B圖為根據本發明的一個 參If the calculation result of (wear-leveiing seed) is not i, proceed to step S550' to perform recovery operation on block a'. Copy the valid data in block A to the free block B reserved by the system, and copy the area. Block into the erase. As in the formula (1), the calculation result of rand〇m%(wear_levelingseed) is not required to perform the recovery operation on the block A, and the process proceeds to step S54, and the deletable blockchain located in the sequence of the timestamps is deleted. The C' block C of the table is the block in the system that erases the earliest time stamp, and the block goes to step S57G to perform the recovery operation on the block C, and the area 2 data is copied to the free block B reserved by the system, and After the block effective step S550 or S57 is completed, the process proceeds to the step. , press: two in the B is the system to erase the timestamp in the latest block in the =,,, block, remember the morning and evening, block A or (: chain into the erasable block array ^ time stamp on the steps S530, S540, μ70 to S56〇, please refer to = end of the process. Determine whether it is necessary to perform the recovery operation on block 4, and copy the area 5β round effect data to the free block 7 reserved by the system. In the calculation of the need to determine the wear and tear average processing, take the position (4) wipe 2 (1) after the sequential link of the erasable block list of the head of the table = equal stamp first to carry out the recovery operation VTUO8-OOO8IO0- TW/O6O8A-A41792-TW/Final 201015565 "Copy the valid data in the block to the free block 7 reserved by the system, and erase the block and follow the erase time recorded in block 7. In the morning and evening of the stamp, the block is chained into the queue of the erasable block, and after the block 7 is completed, the recycling process is completed. Then, the block 〇~6 in the existing linked list after the recycling process is the original block 1~ 7 'The current block 7 is the original block 0. For the steps S530, S550 to S560, reference can be made to the fourth drawing, which will not be described in detail herein. By using the erase time stamp of the erasable block as the erase mark to reflect the loss of the block', even if the current erase time information is lost after power failure, you can choose to save the system block when you turn it on again. The earliest erasable block of the system time can avoid the loss of the erasure information in the prior art, so that the processing of the block is deviated in the subsequent wear averaging, and thus cannot be truly reflected in the system. The service life of the block can be erased. Moreover, the present invention also limits the number of occurrences of the wear average processing by consuming the average seed, thereby achieving system efficiency in the case where the life of the block can be erased in the true reflection system. And the averaging effect of the wear and tear averaging effect. Although the present invention has been disclosed in the preferred embodiments as described above, it is not intended to limit the invention, and any one of ordinary skill in the art can be found in the present invention without departing from the spirit and scope of the present invention. The scope of protection of the present invention is subject to the definition of the scope of the appended patent application. BRIEF DESCRIPTION OF THE DRAWINGS FIG. 1 is a block diagram of a typical application system of a non-volatile memory according to an embodiment of the present invention. VTU08-00〇8I〇〇.tw/0608A-A41792-TW/Final 15 201015565 A detailed structural diagram of a module according to an embodiment of the present invention. The average averaging eliminator according to an embodiment of the present invention is a sequence according to an embodiment of the present invention. Arrangement_represents (4). A, , and time 3B is a reference according to the present invention.
間戳:的時間先後順序建立可抹除區塊鍵表的流:除時 圖為根據本發明的一個實施例所述的袜除時 戳記鏈表的袜除操作示意圖。 第4B圖為根據本發明的—個實施例所述的將袜除時 間戳記記入可抹除區塊中的流程圖。 第5A圖為根據本發明的一個實施例所述的可抹除區 塊的回收處理流程圖。 第5B圖根據本發明的一個實施例所述的為抹除時間 戳記鏈表的回收操作示意圖。 【主要元件符號說明】 10 :應用層; 12 :檔系統層; 14 :媒體管理層軟體; 16 :硬體訪問層; 141 :位址映射模組; 142 :耗損平均模組; 143 :儲存空間回收模組; VTU08-0008I00-TW/0608A.A41792*TW/Final 16 201015565 1421 :移位模組; 1422 :判斷抹除模組; 0〜7 :區塊; S201〜S207 、 S310〜S3712 、 S410〜S470 、 S510〜S570 : 步驟。The time stamping sequence establishes a stream of erasable block key tables: the time division is a schematic view of the shoe removing operation of the stocking time stamping list according to an embodiment of the present invention. Figure 4B is a flow diagram of the time stamping of the sock in the erasable block in accordance with an embodiment of the present invention. Fig. 5A is a flow chart showing the recycling process of the erasable block according to an embodiment of the present invention. Figure 5B is a schematic illustration of the recycling operation for the erase time stamp list, in accordance with one embodiment of the present invention. [Main component symbol description] 10: application layer; 12: file system layer; 14: media management software; 16: hardware access layer; 141: address mapping module; 142: wear leveling module; 143: storage space Recycling module; VTU08-0008I00-TW/0608A.A41792*TW/Final 16 201015565 1421: Shift module; 1422: Judging erase module; 0~7: Block; S201~S207, S310~S3712, S410 ~S470, S510~S570: Steps.
VTU08-0008IOO-TW/0608A-A41792-TW/Final 17VTU08-0008IOO-TW/0608A-A41792-TW/Final 17