Summary of the invention
The invention provides a kind of management method and device of nonvolatile memory, in order to realize, improve the efficiency of writing data, the life-span of improving NVM.
The invention provides a kind of management method of nonvolatile memory, described nonvolatile memory comprises an above block, each block comprises a plurality of pages, every page comprises data field and control information district, described control information district preserves page address, for identifying page sign and the check code of order that page object address is the write operation of described page address, described method comprises;
When carrying out write operation according to page object address, query aim block obtains two pages corresponding to page and described page object address that page address is identical, according to the check code of described two pages, choosing a page with page sign from described two pages skips as wheel, according to the page data of page corresponding to described page object address, obtain new page data, described new page data is write to described wheel and skip;
When carrying out read operation according to page object address, query aim block obtains page corresponding to described page object address, when corresponding two pages in described page object address, according to the check code of described two pages and page sign, from described two pages, choose a page as active page, read the data in described active page.
The present invention also provides a kind of management devices of nonvolatile memory, described nonvolatile memory comprises an above block, each block comprises a plurality of pages, every page comprises data field and control information district, described control information district preserves page address, for identifying page sign and the check code of order that page object address is the write operation of described page address, described device comprises:
The first enquiry module, for when carrying out write operation according to page object address, query aim block obtains two pages corresponding to page and described page object address that page address is identical;
Take turns the acquisition module that skips, be connected with described the first query block, for choosing one page with page sign from described two pages according to the check code of described two pages, as wheel, skip;
New data acquisition module, is connected with described the first enquiry module, for obtaining new page data according to the page data of page corresponding to described page object address;
Data writing module, skips for described new page data is write to described wheel;
The second enquiry module, for when carrying out read operation according to page object address, query aim block obtains page corresponding to described page object address;
Active page acquisition module, is connected with described the second enquiry module, for when corresponding two pages in described page object address, according to the check code of described two pages and page sign, from described two pages, chooses one page as active page;
Data read through model, is connected with described active page acquisition module, for reading the data of described active page.
In embodiments of the present invention, every renewal one secondary data only need to be write NVM one time, only need to spend in prior art for 1/4 time, has greatly improved the efficiency of writing data.In addition, every renewal one secondary data need to be write once wheel and skips, and wheel to skip be unfixed, so increased to a certain extent the life-span of NVM.
Embodiment
Below in conjunction with specification drawings and specific embodiments, the invention will be further described.
The management method embodiment of NVM
As shown in Figure 1, structural representation for NVM in the management method embodiment of NVM of the present invention, this NVM comprises an above block: block 1, block 2... block n, n is more than or equal to 1 natural number, each block comprises a plurality of pages: page 1, page 2... page m and 1 wheel skip, and m is more than or equal to 2 natural number, and every page comprises data field and control information district, data field save data, control information district preserves page address, page sign and check code.Wherein, this page address is logical page address, and page sign is for identifying page object address for the order of the write operation of this page address, and check code calculates according to the data of this page.
Alternatively, page sign can adopt the mode of sequential counting to identify the order of write operation, like this, carries out write operation one time, and page sign adds 1.Or page sign also can adopt the mode of cycle count to identify the order of write operation, for example: the length of page sign is 2 bits, the value of page sign can have 4 kinds of selections: 00,01,10,11, and cycle count mode is: 00 → 01 → 10 → 11 → 00.When adopting the mode of cycle count, should not occur cannot decision operation order situation, when cannot decision operation order, illustrate that the length that page identifies is inadequate.
As shown in Figure 2, be the schematic flow sheet of read operation in the management method embodiment of nonvolatile memory of the present invention, can comprise the steps;
Step 21, when carrying out read operation according to page object address, query aim block obtains page corresponding to this page object address, performs step 22;
Wherein, target block is the block at place, page object address.
Step 22, judge this page object address corresponding page quantity whether be two, if so, performstep 23, otherwise performstep 24.
Step 23, when corresponding two pages in this page object address, according to the check code of these two pages and page sign, from these two pages, choose one page as active page, performstep 25;
Alternatively, first judge that whether the check code of these two pages is correct; When the check code of one page is wherein correct and during the check code mistake of other one page, choose the correct page of check code as active page, there is the error in data that power-off or other unpredictable situations cause this page in check code explanation of error, check code correctly illustrates that the data in this page are correct while writing this page; When the check code of these two pages is all correct, the page of choosing nearest operation according to the page sign of these two pages is as active page, the data of storing in active page are latest data, the data of storing in another one page are legacy data, in other words, when the data of two pages are all correct, select the page that stores latest data as active page.
Step 24, when the corresponding page in this page object address, using this page as active page, performstep 25;
Step 25, read the data in this active page.
As shown in Figure 3, the schematic flow sheet for write operation in the management method embodiment of nonvolatile memory of the present invention, can comprise the steps:
Step 31, when carrying out write operation according to page object address, query aim block obtains two pages and page corresponding to this page object address that page address is identical.
Step 32, according to the check code of these two pages and page sign, from these two pages, choose one page and skip as wheel;
Alternatively, judge that whether the check code of these two pages is correct; When the check code of one page is wherein correct and during the check code mistake of other one page, the page of choosing check code mistake skips as wheel, there is the error in data that power-off or other unpredictable situations cause this page in check code explanation of error, check code correctly illustrates that the data of this page are correct while writing this page; When the check code of these two pages is all correct, the page of choosing operation the earliest according to the page sign of these two pages skips as wheel, and in the page of operation the earliest, the data of storage are legacy data, in other words, when the data of two pages are all correct, select the page that stores legacy data to skip as wheel.
Step 33, according to this page object address corresponding page page data obtain new page data;
Particularly, read the page data of page corresponding to this page object address, revise page sign in the page data of page corresponding to this page object address and the data of data field, obtain new page data.
Step 34, this new page data is write during this takes turns and skip;
What skip middle storage due to wheel is legacy data or wrong data, so new data can be write to wheel, covers original legacy data in skipping.
In schematic flow sheet shown in Fig. 3, there will be a kind of special circumstances: after query aim block, find that the quantity of the page that page object address is corresponding is two, and the page address of two pages identical with page address is identical.In order to process this situation, using in these two pages except this takes turns the page that another page skipping is corresponding as this page object address.
Adopt said method to operate NVM, in skipping, wheel writes new data, the content of preserving the page of legacy data remains unchanged, even if there is like this power-off or other unpredictable mistakes in writing the process of data, after re-powering, according to page sign and check code, judge, guarantee data or right with regard to all writing, or just do not write, there will not be other situations, thereby guaranteed the safety of data.
In the present embodiment, every renewal one secondary data only need to be write NVM one time, only need to spend in prior art for 1/4 time, has greatly improved the efficiency of writing data.In addition, every renewal one secondary data need to be write once wheel and skips, and wheel to skip be unfixed, so increased to a certain extent the life-span of NVM.
The management devices embodiment of NVM
In the present embodiment, the structure of this NVM is identical with structural representation shown in Fig. 1, does not repeat them here.
As shown in Figure 4, in management devices embodiment for NVM of the present invention, carry out the structural representation of the device of write operation, this device that carries out write operation can comprise thefirst enquiry module 41, take turns skipacquisition module 42, newdata acquisition module 43,data writing module 44, taking turns theacquisition module 42 that skips is connected with thefirst enquiry module 41, newdata acquisition module 43 is connected with thefirst enquiry module 41, anddata writing module 44 and newdata acquisition module 43 and thewheel acquisition module 42 that skips is connected.
Thefirst enquiry module 41 is for when carrying out write operation according to page object address, and query aim block obtains two pages and page corresponding to this page object address that page address is identical; Wherein, target block is the block at place, page object address.Taking turns theacquisition module 42 that skips skips as wheel for choosing one page with page sign from these two pages according to the check code of these two pages.Newdata acquisition module 43 is for obtaining new page data according to the page data of page corresponding to this page object address.Data writing module 44 is taken turns and is skipped for this new page data being write to this.
This course of work of device of carrying out write operation is as follows: when carrying out write operation according to page object address, thefirst enquiry module 41 query aim blocks obtain two pages and page corresponding to this page object address that page address is identical, thewheel acquisition module 42 that skips is chosen one page according to the check code of these two pages and page sign and is skipped as wheel from these two pages, newdata acquisition module 43 obtains new page data according to the page data of page corresponding to this page object address, anddata writing module 44 writes this new page data during this takes turns and skip.
As shown in Figure 5, carry out the structural representation of the device of read operation in the management devices embodiment for NVM of the present invention, this device that carries out read operation can comprise thesecond enquiry module 45, activepage acquisition module 46 and data read through model 47.Activepage acquisition module 46 is connected with thissecond enquiry module 45, and data read throughmodel 47 is connected with this activepage acquisition module 46.
Wherein, thesecond enquiry module 45 is for when carrying out read operation according to page object address, and query aim block obtains page corresponding to this page object address.Activepage acquisition module 46, for when corresponding two pages in this page object address, is chosen one page as active page according to the check code of these two pages and page sign from these two pages.Data read throughmodel 47 is for reading the data of this active page.
This course of work of device of carrying out read operation is as follows: when carrying out read operation according to page object address, thesecond enquiry module 45 query aim blocks obtain page corresponding to this page object address, when corresponding two pages in this page object address, activepage acquisition module 46 is chosen one page as active page according to the check code of these two pages and page sign from these two pages, and data read throughmodel 47 reads the data in this active page.When the corresponding page in page object address, data read throughmodel 47 directly reads the data in this page.
In the present embodiment, every renewal one secondary data only needsdata writing module 44 to write NVM one time, only need to spend in prior art for 1/4 time, has greatly improved the efficiency of writing data.In addition, every renewal one secondary data need to be write once wheel and skips, and wheel to skip be unfixed, so increased to a certain extent the life-span of NVM.
Alternatively, in order to find wheel to skip, thewheel acquisition module 42 that skips can comprise that thefirst judging unit 421, the firstround acquiring unit 422 and second that skips takes turns the acquiringunit 423 that skips.Thefirst judging unit 421 is connected with thefirst enquiry module 41, the firstround acquiring unit 422 and second that skips is taken turns the acquiringunit 423 that skips and is connected with thefirst judging unit 421, anddata writing module 44 and the firstround acquiring unit 422 and second that skips is taken turns the acquiringunit 423 that skips and is connected.
Wherein, whether thefirst judging unit 421 is correct for judging the check code of these two pages.The first round is skipped acquiringunit 422 for according to the judged result of thefirst judging unit 421, when the check code of one page is wherein correct and during the check code mistake of other one page, the page of choosing check code mistake skips as wheel, test the error in data that power-off or other unpredictable situations cause this page occurs when yard explanation of error is write this page, check code correctly illustrates that the data in this page are correct.Second takes turns the acquiringunit 423 that skips for according to the judged result of thefirst judging unit 421, when the check code of these two pages is all correct, the page of choosing operation the earliest according to the page sign of these two pages skips as wheel, in the page of operation the earliest, the data of storage are legacy data, in other words, when the data of two pages are all correct, select the page that stores legacy data to skip as wheel.
Alternatively, in order to find active page, activepage acquisition module 46 can comprise thesecond judging unit 461, the first activepage acquiring unit 462 and the second active page acquiring unit 463.Thesecond judging unit 461 is connected with thesecond enquiry module 45, the firstround acquiring unit 422 and second that skips is taken turns the acquiringunit 423 that skips and is connected with thesecond judging unit 461, and data read throughmodel 47 is connected with the second activepage acquiring unit 463 with the first activepage acquiring unit 462.
Whether thesecond judging unit 461 is correct for judging the check code of these two pages.The first activepage acquiring unit 462 is for according to the judged result of thissecond judging unit 461, when the check code of one page is wherein correct and during the check code mistake of other one page, choose the correct page of check code as active page, there is the error in data that power-off or other unpredictable situations cause this page in check code explanation of error, check code correctly illustrates that the data in this page are correct while writing this page.The second activepage acquiring unit 463 is for according to the judged result of thissecond judging unit 461, when the check code of these two pages is all correct, the page of choosing nearest operation according to the page sign of these two pages is as active page, the data of storing in active page are latest data, the data of storing in another one page are legacy data, in other words, when the data of two pages are all correct, select the page that stores latest data as active page.
Alternatively, in order to obtain new page data, newdata acquisition module 43 can comprise that readingunit 431 is connected with thefirst enquiry module 41 withmodification 432,Du unit,unit 431, revise 432Yu Du unit,unit 431 and connect,data writing module 44 is connected withmodification unit 43.
Readunit 431 for reading the page data of page corresponding to this page object address.Reviseunit 432 for revising the page sign of page data of page corresponding to this page object address and the data of data field, obtain new page data.Alternatively, the page sign in the page data of page corresponding to page object address is added to 1, in Update Table district, need the data revised, thereby obtain new page data.
Alternatively, in the process of write operation, also may there are a kind of special circumstances: after query aim block, the quantity of the page that page object address is corresponding is that the page address of two and two pages identical with page address is identical.In order to process this special circumstances, the present embodiment can also compriseabnormality processing module 48, is connected with thefirst enquiry module 41 and thewheel acquisition module 42 that skips, and newdata acquisition module 43 is also connected with abnormality processing module 48.Abnormality processing module 48 is for when carrying out write operation according to page object address, when the page address of this page object address and these two pages is identical, using in these two pages except this takes turns another page page corresponding as this page object address skipping.
Finally it should be noted that: above embodiment is only unrestricted in order to technical scheme of the present invention to be described, although the present invention is had been described in detail with reference to preferred embodiment, those of ordinary skill in the art is to be understood that, can modify or be equal to replacement technical scheme of the present invention, and not depart from the spirit and scope of technical solution of the present invention.