Flash memory controller, memory device, and method for accessing flash memory module

By establishing and updating the binary tree structure in the flash memory controller, the problem of inefficiency caused by data updates in a short period of time is solved, fast logical address search is realized, and the reading speed of the flash memory controller is improved.

CN112015671BActive Publication Date: 2024-09-06SILICON MOTION INC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010175866.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2019-05-28
Filing Date
2020-03-13
Publication Date
2024-09-06
Estimated Expiration
2040-03-13

AI Technical Summary

Technical Problem

When the flash memory controller processes data that is updated multiple times in a short period of time, multiple pieces of data corresponding to logical addresses are stored in the cache memory, making the traditional binary search method inapplicable and inefficient, and all data needs to be searched to ensure that valid data is transmitted.

Method used

Establish a binary tree in the flash memory controller, update the tree structure according to the received data, move the data to the flash memory module when the data volume reaches a certain value, and optimize the tree structure to reduce the number of layers when idle, and use the binary tree to accelerate Logical address search.

Benefits of technology

Quickly locate the required data through the binary tree structure, reduce search steps, improve the operating efficiency of the flash memory controller, and reduce the reading time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112015671B_ABST
    Figure CN112015671B_ABST
Patent Text Reader

Abstract

The present invention discloses a flash memory controller, comprising a read-only memory, a processor and a cache memory. The read-only memory is used to store a program code. The processor is used to execute the program code to access a flash memory module. When the processor receives first data from a host, the processor stores the first data in an area of ​​the cache memory, and the processor establishes or updates a binary tree according to the first data. The binary tree is used when the processor receives a read instruction from the host, and when a data amount of the data stored in the cache memory reaches a predetermined value, the processor moves the data from the cache memory to the flash memory module. The advantage of the present invention is that when the flash memory controller receives data from the host and stores the data in the cache memory, a binary tree is established or updated according to the received data, so that subsequent search operations are accelerated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to flash memory, and in particular to a search method of a flash memory controller. Background Art

[0002] When a host needs to write data to a flash memory module through a flash memory controller, the host will send the data to the flash memory controller, and the data will be temporarily stored in a cache memory or register in the flash memory controller. When the amount of data temporarily stored in the cache memory reaches a predetermined value, the data will be written to the flash memory module. For example, the flash memory controller continuously receives data from the host and stores the received data in the cache memory. When the amount of data received is sufficient to write to multiple word lines of the flash memory module, the flash memory controller starts to move the data in the cache memory to the flash memory module.

[0003] Since the data temporarily stored in the cache memory in the flash memory controller has not been written into the flash memory module, when the host wants to read the data, the flash memory controller can directly transmit the data stored in the cache memory to the host to shorten the access time. In detail, each data stored in the cache memory of the flash memory controller includes a corresponding logical address. When the host transmits a read instruction including a specific logical address, the flash memory controller will search the logical address of the data stored in the cache memory to determine whether there is a logical address that matches the specific logical address. If the cache memory contains data corresponding to the specific logical address, the flash memory controller can directly transmit the data to the host. However, if the data corresponding to the specific logical address is updated in a short time, that is, the host transmits two or more data corresponding to the specific logical address in a short time, then the cache memory of the flash memory controller will store two or more data corresponding to the specific logical address, of which the latest data will be valid data, and the remaining existing data received corresponding to the specific logical address will be regarded as invalid data. Therefore, in order to ensure that the flash memory controller can transmit valid data to the host, when the host transmits a read instruction including the specific logical address, the flash memory controller needs to search the logical addresses of all data temporarily stored in the cache memory, resulting in inefficiency in the operation of the flash memory controller. In addition, since one logical address can correspond to two or more data in the cache memory, the traditional binary search method is not suitable for the search operation of the flash memory controller. Summary of the invention

[0004] Therefore, an object of the present invention is to provide a flash memory controller. When a cache memory of the flash memory controller stores data from a host, the flash memory controller can establish a binary tree with specific information to solve the above problem.

[0005] At least one embodiment of the present invention provides a flash memory controller, including a read-only memory, a processor, and a cache memory. The read-only memory is used to store a program code. The processor is used to execute the program code to access a flash memory module. When the processor receives first data from a host, the processor stores the first data in an area of ​​the cache memory, and the processor establishes or updates a binary tree based on the first data, the binary tree is used when the processor receives a read instruction from the host, and when a data amount of the data stored in the cache memory reaches a predetermined value, the processor moves the data from the cache memory to the flash memory module.

[0006] Another embodiment of the present invention provides a memory device, including a flash memory module and a flash memory controller. The flash memory controller is used to access the flash memory module. When the flash memory controller receives first data from a host, the flash memory controller stores the first data in an area of ​​a cache memory in the flash memory controller, and the flash memory controller creates or updates a binary tree based on the first data, the binary tree is used when the flash memory controller receives a read instruction from the host, and when a data amount of the data stored in the cache memory reaches a predetermined value, the flash memory controller moves the data from the cache memory to the flash memory module.

[0007] Yet another embodiment of the present invention provides a method for accessing a flash memory module, comprising: receiving first data from a host and storing the first data in an area of ​​a cache memory; establishing or updating a binary tree based on the first data; searching the binary tree to obtain required data when a read instruction is received from the host; and moving the data from the cache memory to the flash memory module when a data amount of the data stored in the cache memory reaches a predetermined value. BRIEF DESCRIPTION OF THE DRAWINGS

[0008] Figure 1 FIG. 2 shows a memory device according to an embodiment of the present invention.

[0009] Figures 2 to 5 FIG. 4 is a schematic diagram showing an example of establishing a binary tree when a flash memory controller receives data from a host according to an embodiment of the present invention.

[0010] Figure 6 FIG. 4 is a schematic diagram showing an example of a processor rearranging a binary tree to reduce the number of layers according to an embodiment of the present invention.

[0011] Figure 7 is a flow chart showing a method for accessing a flash memory module according to an embodiment of the present invention.

[0012] The reference numerals are described as follows:

[0013] 100 Memory device

[0014] 110 Flash Memory Controller

[0015] 111 Interface Circuit

[0016] 112 Processor

[0017] 113 Cache memory

[0018] 114 Dynamic Random Access Memory Controller

[0019] 115 Read-only memory

[0020] 116 Control Logic Circuit

[0021] 120 Flash Memory Module

[0022] 130 Host

[0023] 140 Dynamic Random Access Memory

[0024] 181, 182 Core

[0025] 210 Form

[0026] 220 Binary Tree

[0027] CNT count value

[0028] LBA0, LBA4, LBA8 logical addresses DETAILED DESCRIPTION

[0029] The terms used in the following description and claims are used to refer to specific system components. As will be appreciated by those skilled in the art, a manufacturer may refer to a component by different names. This application does not intend to distinguish between components that have different names but the same function. In the following description and claims, the terms "including" and "including" are used in an open-ended manner and should be interpreted to mean "including but not limited to...". The terms "coupled" and "coupled" are intended to mean an indirect or direct electrical connection. Thus, if a first device is coupled to a second device, the connection may be a direct electrical connection or an indirect electrical connection through other devices and connections.

[0030] Figure 1 FIG. 1 is a diagram showing a memory device 100 according to an embodiment of the present invention. Figure 1As shown, the memory device 100 includes a flash memory controller 110 and a flash memory module 120. The flash memory controller 110 is used to access the flash memory module 120. In this embodiment, the flash memory controller 110 includes an interface circuit 111, a processor 112, a cache memory 113, a dynamic random access memory (DRAM) controller 114, a read-only memory (ROM) 115, and a control logic circuit 116, wherein the processor 112 can be a microprocessor or a central processing unit, and can include two cores 181 and 182. The read-only memory 115 can be used to store program codes. The processor 112 can execute the program code to control the access of the flash memory module 120. Figure 1 In the illustrated embodiment, the core 181 of the processor 112 may be mainly configured to control the operation between the flash controller 110 and the host 130, and the core 182 of the processor 112 may be mainly configured to control the operation between the flash controller 110 and the flash module 120. In addition, the DRAM controller 114 may be used to access a DRAM device 140 configured outside the flash controller 110.

[0031] The flash memory module 120 may include one or more flash memory chips. Each flash memory chip includes a plurality of blocks, wherein a block may be a minimum erase unit of the flash memory. In addition, each block includes a plurality of data pages, wherein a data page is a minimum write unit of the flash memory. In this embodiment, the flash memory module 120 is a 3D NAND-type flash.

[0032] In this embodiment, the memory device 100 may be a portable memory device (e.g., a memory card that complies with Secure Digital (SD) / Multimedia Card (MMC), Compact Flash (CF), Memory Stick (MS), or Extreme Digital (XD) standards), and the host 130 is an electronic device that can be connected to the portable memory device, such as a mobile phone, a notebook computer, a desktop computer, etc. In another embodiment, the memory device 100 may be a solid state drive (SSD) or an embedded storage device that complies with Universal Flash Storage (UFS) or Embedded Multi Media Card (EMMC) specifications, so as to be disposed in an electronic device (e.g., disposed inside a mobile phone, a notebook computer, or a desktop computer), and the host 130 may be a processor in the electronic device.

[0033] When the host 130 wants to write data into the flash memory module 120, the data will be temporarily stored in the cache memory 113 or the DRAM 140. When the amount of data temporarily stored in the cache memory 113 or the DRAM 140 reaches a predetermined value (for example, the amount of data corresponds to one or more word lines of the flash memory module 120), the data will be written into the flash memory module 120. In this example, the cache memory 113 or the DRAM 140 can be regarded as a cache memory, that is, when the data required by the host 130 in a read instruction is data whose logical address is recorded in the cache memory, the flash memory controller 110 can directly transmit the data to the host 130. As described in the prior art section, the cache memory 113 or the DRAM 140 may store two or more different data corresponding to the same logical address. Therefore, the conventional controller needs to search the logical addresses of all the data temporarily stored in the cache memory to ensure that the flash memory controller 110 can obtain valid data. In this embodiment, in order to speed up the search operation, when the processor 112 receives data from the host 130, a binary tree can be established. Furthermore, when the host 130 sends a read command to the flash memory controller 110 , the processor 112 may use the binary tree to search for the required logical address to quickly obtain the required data, thereby improving the operating efficiency of the flash memory controller 110 .

[0034] Figures 2 to 5 FIG. 1 is an example showing how to create a binary tree when the flash controller 110 receives data from the host 130 according to an embodiment of the present invention. Figure 1, assuming that the host 130 transmits a first write instruction and first data with a logical address LBA0 to the flash memory controller 110, the core 181 of the processor 112 may store the first data with a logical address LBA0 in the cache memory 113 or the DRAM 140 (for the sake of simplicity, the cache memory 113 will be used as an example below). In this embodiment, the first data is stored in an area of ​​the cache memory 113 corresponding to a cache index value 0, and the cache memory 113 includes a table 210 for recording the cache index value and the corresponding logical address. At the same time, the core 181 transmits this cache information to the core 182 to indicate that the first data is stored in the cache memory 113. Then, when the core 182 is idle (for example, when the flash memory module 120 is busy), the core 182 begins to establish a binary tree 220 based on the cache information provided by the core 181. Figure 2 For example, the logical address LBA0 is the first node (highest node) of the binary tree, and the information that can be recorded in the binary tree 220 includes the logical address (for example, the logical address LBA0), the count value CNT of the logical address LBA0 (since the cache memory 113 currently only stores data of the logical address LBA0, the count value CNT=1), the cache index value 0, the left node of this logical address (left child node), and the right node of this logical address (right child node), where there is no data after the current logical address LBA0, and therefore, the values ​​of the left node and the right node will be set to FFFF.

[0035] Then, if Figure 3 As shown, the host 130 transmits a second write instruction and second data with a logical address LBA4 to the flash controller 110, and the core 181 of the processor 112 can store the second data with a logical address LBA4 in the cache memory 113. In this embodiment, the second data is stored in the area corresponding to the cache index value 1 in the cache memory 113, and the table 210 records the cache index value 1 and the corresponding logical address LBA4. At the same time, the core 181 transmits this cache information to the core 182 to indicate that the second data is stored in the cache memory 113. Then, when the core 182 is idle, the core 182 starts to update the binary tree 220 according to the cache information provided by the core 181. Figure 3For example, the logical address LBA4 is the right node following the highest node of the binary tree (since the logical address LBA4 is greater than the logical address LBA0), and the binary tree 220 can record information including the logical address (e.g., the logical address LBA4), the count value CNT of the logical address LBA4 (since the cache memory 113 currently only stores data of the logical address LBA4, the count value CNT=1), the cache index value 1, the logical address of the left node of this logical address, and the logical address of the right node, wherein since there is no data after the current logical address LBA4, the logical addresses of the left node and the right node will be set to FFFF. In addition, since the logical address LBA4 is added to the right node of the logical address LBA0, the value of the right node of the logical address LBA0 is updated to have the cache index value 1.

[0036] Then, if Figure 4 As shown, the host 130 transmits a third write instruction and third data with a logical address LBA8 to the flash memory controller 110, and the core 181 of the processor 112 may store the third data with a logical address LBA8 in the cache memory 113. In this embodiment, the third data is stored in the area of ​​the cache memory 113 corresponding to the cache index value 2, and the table 210 records the cache index value 2 and the corresponding logical address LBA8. At the same time, the core 181 transmits this cache information to the core 182 to indicate that the third data is stored in the cache memory 113. Then, when the core 182 is idle, the core 182 begins to update the binary tree 220 according to the cache information provided by the core 181. Then, when the core 182 is idle, the core 182 begins to update the binary tree 220 according to the cache information provided by the core 181. Figure 4 For example, the logical address LBA8 is the right node following the logical address LBA4 of the binary tree (because the logical address LBA8 is greater than the logical address LBA4), and the binary tree 220 can record information including the logical address (for example, the logical address LBA8), the count value CNT of the logical address LBA8 (because the cache memory 113 currently only stores data of the logical address LBA8, the count value CNT=1), the cache index value 2, the logical address of the left node of this logical address, and the logical address of the right node, wherein there is no data after the current logical address LBA8, therefore, the logical addresses of the left node and the right node will be set to FFFF. In addition, because the logical address LBA8 is added to the right node of the logical address LBA4, the value of the right node of the logical address LBA4 is updated to have the cache index value 2.

[0037] Then, if Figure 5As shown, the host 130 transmits a fourth write instruction and fourth data with a logical address LBA4 to the flash controller 110, and the core 181 of the processor 112 can store the fourth data with a logical address LBA4 in the cache memory 113. In this embodiment, the fourth data is stored in the area corresponding to the cache index value 3 in the cache memory 113, and the table 210 records the cache index value 3 and the corresponding logical address LBA4. At the same time, the core 181 transmits this cache information to the core 182 to indicate that the fourth data is stored in the cache memory 113. Then, when the core 182 is idle, the core 182 starts to update the binary tree 220 according to the cache information provided by the core 181. Figure 5 For example, since the logical address LBA4 with the fourth data has been recorded in the table 210 and the binary tree 220, it means that the fourth data is used to update the second data currently stored (that is, the second data becomes invalid data). The relevant information of the logical address LBA4 in the binary tree 220 must be updated so that the count value CNT of the logical address LBA4 is updated to 2, and the cache index value must also be updated to 3 corresponding to the fourth data.

[0038] In one embodiment, if the flash memory controller 110 receives a read command including the logical address LBA4 from the host 130, Figure 5 The binary tree 220 shown is used as an example. The core 181 or the core 182 will compare the logical address LBA4 with the logical address LBA0 of the highest node of the binary tree 220. Since the logical address LBA4 is greater than the logical address LBA0, the core 181 or the core 182 will search for the right node of the highest node in the next step. Then, since the right node of the highest node of the binary tree 220 corresponds to the logical address LBA4, which matches the logical address LBA4 carried by the read instruction, the core 181 or the core 182 can refer to the cache index value 3 currently recorded in the binary tree 220 to obtain the cache address of the data to be read, and the core 181 or the core 182 does not need to access the flash memory module 120, but directly reads the fourth data stored in the area corresponding to the cache index value 3, and transmits the fourth data to the host 130. In view of the above, since the embodiment of the present invention uses only two steps to search for the required data, compared with the traditional technology that uses four steps to search for the required data (that is, four data are stored in the above-mentioned cache memory 113), the embodiment of the present invention does improve the search speed.

[0039] In addition, if the flash memory controller 110 receives a read instruction including the logical address LBA7 from the host 130, Figure 5 As an example, the binary tree 220 shown in FIG. 1 is used. Since the core 181 or the core 182 can use only three steps (such as Figure 5As shown, the binary tree 220 has only three levels) determines that the logical address LBA7 is not stored in the cache memory 113, so the core 182 can read the data with the logical address LBA7 from the flash memory module 120 and transmit the data to the host 130. In view of the above, since the flash memory controller 110 can quickly determine whether the data with the logical address LBA7 is stored in the cache memory 113, the reading speed of the flash memory controller 110 can also be improved.

[0040] In an embodiment of the present invention, the core 182 of the processor 112 may rearrange the binary tree 220 to reduce the number of levels of the binary tree 220. For example, the core 182 may use a self-balancing binary search tree algorithm, such as an AVL (Adelson-Velsky and Landis) tree or a red-black tree to reduce the number of levels. Figure 6 For example, the binary tree 220 can be rotated so that the node of the logical address LBA4 becomes the highest node and the logical address LBA0 becomes the left node of the logical address LBA4. Therefore, the binary tree 220 can be updated from three levels to two levels, so that the search speed can be further improved.

[0041] When the amount of data to be written to the flash memory module 120 reaches a predetermined value (e.g., multiple data pages, one or more word lines, etc.), the flash memory controller 110 writes the first data having the logical address LBA0, the second data having the logical address LBA4, the third data having the logical address LBA8, the fourth data having the logical address LBA4, and subsequent data to the flash memory module 120. Then, after the first data, the second data, the third data, the fourth data, and subsequent data are removed from the cache memory 113, the core 181 may transmit this information to the core 182 to notify the core 182 that the binary tree 220 needs to be updated, and the core 182 updates the binary tree 220 when idle to remove the related information.

[0042] Figure 7 FIG. 1 is a flow chart showing a method for accessing a flash memory module according to an embodiment of the present invention. Figures 1 to 6 The method flow of accessing the flash memory module is as follows:

[0043] Step S700: The process starts.

[0044] Step S702: Receive data from the host.

[0045] Step S704: Store the data in a cache memory in the flash memory controller.

[0046] Step S706: Create or update a binary tree according to the information of the received data.

[0047] Step S708: Determine whether the amount of data stored in the cache memory has reached a predetermined value. If the amount of data stored in the cache memory has reached the predetermined value, proceed to step S710. If the amount of data stored in the cache memory has not reached the predetermined value, return to step S702 to continue receiving subsequent data from the host.

[0048] Step S710: Move data from the cache memory to the flash memory module.

[0049] Step S712: Update the binary tree to delete the information of the data removed from the cache memory.

[0050] To briefly summarize the present invention, in the flash memory controller of the present invention, when the flash memory controller receives data from the host and stores the data in the cache memory, the flash memory controller establishes or updates the binary tree according to the received data, so that the subsequent search operation (if any) can be accelerated. In addition, the binary tree is established or updated by the core circuit for managing the flash memory controller and the flash memory module. Therefore, since the core circuit must have idle time when the flash memory module is busy (for example, in the read or write operation of the flash memory module), the core circuit can use the idle time to manage the binary tree to avoid affecting the overall performance of the flash memory controller.

[0051] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A flash memory controller, comprising: A read-only memory for storing a program code; a processor, configured to execute the program code to access a flash memory module; as well as a cache memory; When the processor receives first data from a host, the processor stores the first data in an area of ​​the cache memory, and the processor creates or updates a binary tree according to the first data, the binary tree is used when the processor receives a read instruction from the host, and when a data amount of the data stored in the cache memory reaches a predetermined value, the processor moves the data from the cache memory to the flash memory module; wherein the binary tree comprises a logical address of the first data, a count value of the logical address of the first data, and a cache index value of the area of ​​the cache memory; When the processor receives second data from the host after establishing or updating the binary tree according to the first data, the processor stores the second data in another area of ​​the cache memory, and when a logical address of the second data is not recorded in the cache memory, the processor updates the binary tree so that the binary tree includes the logical address of the second data, a count value of the logical address of the second data, and a cache index value of the other area of ​​the cache memory; and when the logical address of the second data is the same as the logical address of the first data, the processor updates the binary tree to increase a count value of the logical address, and updates the cache index value corresponding to the logical address to the cache index value of the other area.

2. The flash memory controller according to claim 1, wherein: The logical address of the first data corresponds to a first node of the binary tree, and the binary tree also includes information of a left node and a right node of the first node.

3. The flash memory controller according to claim 1, wherein: The processor includes a first core and a second core, the first core is used to control the operation between the flash memory controller and the host, the second core is used to control the operation between the flash memory controller and the flash memory module, and the second core of the processor establishes or updates the binary tree according to the first data.

4. The flash memory controller according to claim 3, wherein: When the processor receives the first data from the host, the first core of the processor stores the first data in the area of ​​the cache memory, and the first core transmits information of the first data to notify the second core to establish or update the binary tree according to the first data.

5. A memory device, characterized in that: include: a flash memory module; as well as a flash memory controller for accessing the flash memory module; When the flash memory controller receives first data from a host, the flash memory controller stores the first data in an area of ​​a cache memory in the flash memory controller, and the flash memory controller creates or updates a binary tree according to the first data, the binary tree is used when the flash memory controller receives a read instruction from the host, and when a data amount of the data stored in the cache memory reaches a predetermined value, the flash memory controller moves the data from the cache memory to the flash memory module; wherein the binary tree comprises a logical address of the first data, a count value of the logical address of the first data, and a cache index value of the area of ​​the cache memory; When the flash memory controller receives second data from the host after establishing or updating the binary tree according to the first data, the flash memory controller stores the second data in another area of ​​the cache memory, and when a logical address of the second data is not recorded in the cache memory, the flash memory controller updates the binary tree so that the binary tree includes the logical address of the second data, a count value of the logical address of the second data, and a cache index value of the other area of ​​the cache memory; and when the logical address of the second data is the same as the logical address of the first data, the flash memory controller updates the binary tree to increase a count value of the logical address, and updates the cache index value corresponding to the logical address to the cache index value of the other area.

6. The memory device according to claim 5, wherein: The logical address of the first data corresponds to a first node of the binary tree, and the binary tree also includes information of a left node and a right node of the first node.

7. The memory device according to claim 5, wherein: The flash memory controller includes a processor, which includes a first core and a second core. The first core is used to control the operation between the flash memory controller and the host, and the second core is used to control the operation between the flash memory controller and the flash memory module. The second core of the processor establishes or updates the binary tree according to the first data.

8. The memory device according to claim 7, wherein: When the flash controller receives the first data from the host, the first core of the processor stores the first data in the area of ​​the cache memory, and the first core transmits information of the first data to notify the second core to establish or update the binary tree according to the first data.

9. A method for accessing a flash memory module, characterized in that: include: receiving first data from a host and storing the first data in an area of ​​a cache memory; Establishing or updating a binary tree according to the first data, wherein the binary tree includes a logical address of the first data, a count value of the logical address of the first data, and a cache index value of the area of ​​the cache memory; When receiving a read command from the host, searching the binary tree to obtain required data; When a data amount of the data stored in the cache memory reaches a predetermined value, the data is moved from the cache memory to the flash memory module; receiving second data from the host after establishing or updating the binary tree according to the first data; storing the second data in another area of ​​the cache memory; When a logical address of the second data is not recorded in the cache memory, updating the binary tree so that the binary tree includes the logical address of the second data, a count value of the logical address of the second data, and a cache index value of the other area of ​​the cache memory; as well as When the logical address of the second data is the same as the logical address of the first data, the binary tree is updated to increase a count value of the logical address, and the cache index value corresponding to the logical address is updated to the cache index value of the other area.

10. The method according to claim 9, characterized in that Also includes: Writing the first data into the flash memory module; deleting the first data from the cache memory; as well as The binary tree is updated to delete information of the first data.