This application claims the priority from the TW Patent Application No. 112128245, filed on Jul. 27, 2023, and all contents of such TW Patent Application are included in the present invention.
The present invention is related to flash memory technology, in particular to, a method for emulating electrically-erasable programmable read-only memory by using a flash memory and a flash memory system using the same.
Electrically-erasable programmable read-only memory (EEPROM) was first introduced by Intel in 1978 as a replacement for traditional read-only memory (ROM). The unit of electrically-erasable programmable read-only memory is a byte. Besides, read and write operations of electrically-erasable programmable read-only memory are performed individually and required to be performed on each byte. Since the read and write operations of electrically-erasable programmable read-only memory require frequent erase and write operations, electrically-erasable programmable read-only memory generally can support one hundred thousand times to one million times of read and write cycles.
Flash Memory was introduced by the Japanese company Toshiba in 1988. It was mainly developed to address the long write time of electrically-erasable programmable read-only memory. The write speed of electrically-erasable programmable read-only memory is slower than that of flash Memory, generally requiring approximately 4 milliseconds. However, some applications of micro control units (MCUs) require simulating/emulating the operations of electrically-erasable programmable read-only memory. In addition to the characteristic of reading and writing in units of 1 byte or 2 bytes, electrically-erasable programmable read-only memory may also write directly. In contrast, conventional flash memory requires erasing the entire page of data before writing, and thus does not have the random access characteristics of electrically-erasable programmable read-only memory.
The present disclosure provides a method for emulating electrically-erasable programmable read-only memory by using a flash memory and a flash memory system using the same. According to the address characteristics of flash memory and electrically-erasable programmable read-only memory, the provided method and flash memory system installed with a control method enable the flash memory to achieve a random access manner similar to that of electrically-erasable programmable read-only memory.
Embodiments of the present disclosure provide a method for emulating electrically-erasable programmable read-only memory by using a flash memory, adapted for emulating rewritable electrically-erasable programmable read-only memory in the flash memory, the method comprising: dividing each of units of the flash memory into a data field and an address field; allocating a part of the units as a first page in a sector; wherein in response to an instruction to write data into a specific storage address of the sector, the method comprises: determining, starting from an initial unit of an initial page of the sector, whether one of the address fields of the units has been written; when the one of the address fields is in a written state, finding a next unit based on the one of the address fields until a final unit is found, wherein an address field of the final unit has not been written; finding a writable unit, wherein both a data field and an address field of the writable unit have not been written; and writing the data into the data field of the writable unit and writing the address field of the final unit into the address of the writable unit.
Embodiments of the present disclosure provide a flash memory system, comprising: a control circuit; and a flash memory, each of units of the flash memory being divided into a data field and an address field, and a part of the units being allocated as a first page in a sector, wherein: when the control circuit receives an instruction to read a specific storage address of the sector, the control circuit determines, starting from an initial unit of an initial page of the sector, whether one of the address fields of the units has been written; when the control circuit determines that the one of the address fields is in a written state, the control circuit finds a next unit based on the one of the address fields until a final unit is found, wherein an address field of the final unit has not been written; and the control circuit reads the data field of the final unit.
According to preferred embodiments of the present disclosure, wherein in response to an instruction to read a specific storage address of the sector, the method comprises: determining, starting from an initial unit of an initial page of the sector, whether one of the address fields of the units has been written; when the one of the address fields is in a written state, finding a next unit based on the one of the address fields until a target unit is found, wherein an address field of the target unit has not been written; and reading a data field of the target unit.
According to preferred embodiments of the present disclosure, the method comprises: allocating at least one second page in the sector; wherein in response to the instruction to write the specific storage address of the sector, the method further comprises: when the first page is fully stored, finding a unit of the second page, wherein an address field of the unit of the second page has not been written; and writing a data field of the found unit of the second page.
Embodiments of the present disclosure provide a method for emulating electrically-erasable programmable read-only memory by using a flash memory, adapted for emulating rewritable electrically-erasable programmable read-only memory in the flash memory, the method comprising: dividing each of units of the flash memory into a data field and an address field; allocating a part of the units as a first page in a sector; wherein in response to an instruction to read a specific storage address of the sector, the method comprises: determining, starting from an initial unit of the first page of the sector, whether one of the address fields of the units has been written; when the one of the address fields is in a written state, finding a next address based on the one of the address fields until a target unit is found, wherein an address field of the target unit has not been written; and reading the data field of the target unit.
To sum up, the embodiments of the present disclosure adopt, in flash memory, that the partition scheme originally used for electrically-erasable programmable read-only memory is applied in the addressing scheme of flash memory and that one data field and one address pointer field are allocated in each writable unit. When the address pointer field is in a written state, it represents that the data in the data field is not the latest written data. In this situation, it only requires continuously searching for the address of the address pointer field until a unit is found. The situation that the address pointer field of this unit has not been written represents that the data in the data field of this unit is the latest data. This allows emulating the memory allocation of electrically-erasable programmable read-only memory while reducing the number of times to erase the entire page in the flash memory, thereby extending its lifespan.
To further understand the technology, means, and effects of the present disclosure, reference may be made by the detailed description and drawing as follows. Accordingly, the purposes, features and concepts of the present disclosure can be thoroughly and concretely understood. However, the following description and drawings are only used to reference and illustrate the implementation of the present disclosure, and they are not used to limit the present disclosure.
The drawings are provided to make the persons with ordinary knowledge in the field of the art further understand the present disclosure, and are incorporated into and constitute a part of the specification of the present invention. The drawings illustrate demonstrated embodiments of the present disclosure, and are used to explain the principle of the present disclosure together with the description of the present disclosure.
In order to make the features and advantages of the present disclosure more obvious and comprehensible, preferred embodiments accompanied with drawings are described in detail below. The following description contains specific information pertaining to exemplary implementations in the present disclosure. The drawings in the present disclosure and their accompanying detailed description are directed to merely exemplary implementations. However, the present disclosure is not limited to merely these exemplary implementations. Other variations and implementations of the present disclosure will occur to those skilled in the art. Unless noted otherwise, like or corresponding elements among the figures may be indicated by like or corresponding reference numerals. Moreover, the drawings and illustrations in the present disclosure are generally not to scale, and are not intended to correspond to actual relative dimensions.
However, certain special applications may require flexible read and write operations and a smaller capacity. In this case, read and write capabilities of electrically-erasable programmable read-only memory may still be applied to the product. Thus, in this embodiment, the characteristics of the flash memory 101 are used to avoid the number of times to erase the entire page for random access.
When the control circuit 100 receives the instruction to modify the data in unit 0x00 of the electrically-erasable programmable read-only memory to 99aah, and to modify the data in unit 0x02 of the electrically-erasable programmable read-only memory to bbcch (as illustrated by reference numeral 401), the control circuit 100 writes 99aah into the address of unit 0x10 of the flash memory and writes bbcch into the address of unit 0x14 of the flash memory. Afterwards, the control circuit 100 adds 0010h to the address field 204 of the address of unit 0x00 of the flash memory, which represents that the updated data in unit 0x00 of the electrically-erasable programmable read-only memory is stored in the address of 0x10 of the flash memory. Additionally, the control circuit 100 adds 0014h to the address field 204 of the address of unit 0x04 of the flash memory, which represents that the updated data in unit 0x02 of the electrically-erasable programmable read-only memory is stored in the address of 0x14 of the flash memory.
When the control circuit 100 receives the instruction to modify the data in unit 0x02 of the electrically-erasable programmable read-only memory to ddeeh (as illustrated by reference numeral 402), the control circuit 100 writes ddeeh into the address of unit 0x18 of the flash memory. Afterwards, the control circuit 100 finds that the address field 204 of the address of unit 0x04 of the flash memory has been written. Accordingly, based on the written data 0014h, the control circuit 100 finds the address of unit 0x14 and determines that the address field 204 of unit 0x14 of the flash memory has not been written. This represents that unit 0x14 is the final data at last time in unit 0x02 of the electrically-erasable programmable read-only memory. Thus, the control circuit 100 writes 0018h into the address field 204 of unit 0x14, which represents that the latest data in unit 0x02 of the electrically-erasable programmable read-only memory is stored in unit 0x18.
According to the above embodiments, assuming that the control circuit 100 needs to read the data in unit 0x02 of the electrically-erasable programmable read-only memory, the control circuit 100 first finds the address field of unit 0x04 of the flash memory and determines whether it has been written. If it has been written, this represents that the data in the data field of unit 0x04 of the flash memory is not the latest data. Accordingly, the control circuit 100 finds the address field of unit 0x14 of the flash memory according to 0014h in the address field. Since the address field of unit 0x14 of the flash memory has also been written, the control circuit 100 finds the address field of unit 0x18 of the flash memory according to 0018h in the address field. Since the address field of unit 0x18 of the flash memory has not been written, this represents that the data in the data field of unit 0x18 of the flash memory is the latest data. Thus, the control circuit 100 reads this data ddeeh as the data in unit 0x02 of electrically-erasable programmable read-only memory.
Next, when the control circuit 100 receives the instruction to modify the data in unit 0x00 of the electrically-erasable programmable read-only memory to 1234h (as illustrated by reference numeral 403), the control circuit 100 finds that this page has been fully written with data. Accordingly, the control circuit 100 writes 1234h into 0x00 in a new page of the same sector 200. The control circuit 100 sequentially reads the corresponding data in addresses of units 0x02, 0x04, and 0x06 of the electrically-erasable programmable read-only memory and writes them into the data fields of units 0x04, 0x80, and 0x0c of the new page using the above methods. Afterwards, the control circuit 100 performs the erase operation on the page storing the old data.
Furthermore, since the capacity of conventional electrically-erasable programmable read-only memory is extremely small, the capacity of flash memory 101 is generally much larger than that of electrically-erasable programmable read-only memory. Thus, in the above embodiments, flash memory 101 has multiple sectors 200, and these sectors 200 may respectively emulate multiple electrically-erasable programmable read-only memories. Moreover, the read and write operations may be performed in the manner of serving the above-described address field as the memory address pointer.
According to the above embodiments, this invention may be summarized as a method for emulating electrically erasable programmable read-only memory by using a flash memory.
According to the above embodiments, if the plurality of electrically-erasable programmable read-only memories are to be emulated, multiple sectors of the flash memory may be respectively used as the emulated electrically-erasable programmable read-only memories.
To sum up, the embodiments of the present disclosure adopt, in flash memory, that the partition scheme originally used for electrically-erasable programmable read-only memory is applied in the addressing scheme of flash memory and that one data field and one address pointer field are allocated in each writable unit. When the address pointer field is in a written state, it represents that the data in the data field is not the latest written data. In this situation, it only requires continuously searching for the address of the address pointer field until a unit is found. The address pointer field of this unit has not been written, which represents that the data in the data field of this unit is the latest data. This allows emulating the memory allocation of electrically-erasable programmable read-only memory while reducing the number of times to erase the entire page in the flash memory, thereby extending its lifespan.
It should be understood that the examples and the embodiments described herein are for illustrative purpose only, and various modifications or changes in view of them will be suggested to those skilled in the art, and will be included in the spirit and scope of the application and the appendix with the scope of the claims.
Number | Date | Country | Kind |
---|---|---|---|
112128245 | Jul 2023 | TW | national |