Electronic apparatus with compressed data storage and control method thereof

An electronic apparatus includes a read-only memory (ROM), a random access memory (RAM), a processing module, a demand paging module and a decompression module. The ROM stores multiple sets of compressed data corresponding to a plurality of sets of uncompressed data. The plurality of sets of uncompressed data are divided from one same set of original data. According to a request associated with the set of original data and from the processing module, the demand paging module selects one or more sets from the multiple sets of compressed data. The decompression module decompresses and stores the selected one or more sets of compressed data to the RAM for use of the processing module.

This application claims the benefit of Taiwan application Serial No. 101131208, filed Aug. 28, 2012, the subject matter of which is incorporated herein by reference.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The invention relates in general to a memory technique, and more particularly to a technique for saving memory space.

2. Description of the Related Art

Code and data that are no longer to be modified after electronic products are shipped out of the factory are generally recorded in a read-only memory (ROM). In the recently years, one development trend for consumer electronic products has been to integrate various functions into a single product. For example, portable handsets are designed to support extra functions such as a camera and Internet browsing in addition to basic telephone functions. Diversified functions lead to large and complex coding. To store a greater amount of code and data, the capacity of a ROM built into an electronic product is inevitably and correspondingly enlarged, leading to increased hardware costs.

In response to the above issue, a current solution is to burn compressed code and data into a ROM. Taking an example of compressing a code of an application and burning the compressed code into a ROM, an electronic device first fetches the compressed code from the ROM, and then decompresses the code through a decompressor to a random access memory (RAM) for the use of a corresponding processor.

In the prior art, an application is utilized as a unit of compression/decompression. In other words, when a certain application is needed, an electronic device is required to decompress all code of the desired application to a RAM in order to utilize the application. However, the above approach suffers from a drawback that the RAM must have a large capacity for accommodating all kinds of decompressed code. Thus, hardware costs of an electronic product are again increased due to a costly RAM.

SUMMARY OF THE INVENTION

The invention is directed to an electronic device and control method thereof. By utilizing appropriately divided program code or data as a unit of compression/decompression and incorporating a demand paging technique, the electronic device and control method thereof disclosed by the present invention effectively reduce a required memory space of a random access memory (RAM) to lower hardware costs of the electronic device.

According to an aspect of the present invention, an electronic device is provided. The electronic device includes a read-only memory (ROM), a RAM, a processing module, and a demand paging module and a decompression module. The ROM stores a plurality of sets of compressed data corresponding to a plurality of sets of uncompressed data. The plurality of sets of uncompressed data are divided from a same set of original data. In response to a request associated with the set of original data and from the processing module, the demand paging module selects one or more sets from the multiple sets of compressed data. The decompression module decompresses and stores the selected compressed data to the RAM for the use of the processing module.

According to another aspect of the present invention, a control method for an electronic device is provided. The electronic device includes a ROM and a RAM. The ROM stores a plurality of sets of compressed data corresponding to a plurality of sets of uncompressed data. The plurality of sets of uncompressed data are divided from a same set of original data. In response to a request associated with the original data, one or more sets of compressed data are selected from the plurality of sets of compressed data. The selected one or more sets of compressed data are decompressed and stored to the RAM. An operation associated with the set of original data is performed according to a set of decompressed data generated from decompressing the one or more sets of compressed data.

According to yet another aspect of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium stores program code that is readable and executable by a controller. The program code is for controlling an electronic device. The electronic device includes a ROM and a RAM. The ROM stores a plurality of sets of compressed data corresponding to a plurality of sets of uncompressed data. The plurality of sets of uncompressed data are divided from a same set of original data. In response to a request associated with the set of original data, a first set of program code of the program code selects one or more sets of compressed data from the plurality of sets of compressed data. A second set of program code of the program code decompresses and stores the selected one or more sets of compressed data to the RAM. A third set of program code of the program code executes an operation associated with the set of original data according to decompressed data generated from decompressing the selected one or more sets of compressed data.

DETAILED DESCRIPTION OF THE INVENTION

Referring toFIG. 1, an electronic device100according to an embodiment of the present invention includes a read-only memory (ROM)11, a random-access memory (RAM)12, a processing module13, a demand paging module14and a decompression module15. In practice, the electronic device100may be a device that stores data and program code in a ROM, e.g., a smart handset, a personal digital assistant (PDA), a laptop computer, a game console or a portable pad.

The ROM11stores a plurality of sets of compressed data. In practice, the plurality of sets of compressed data may respectively correspond to various kinds of program code, software data or user data.FIG. 2Ashows an example of stored contents in the ROM11. Compressed data A1′ to An′ correspond to an application A, and respectively include a part of a compressed program code of the application A. Compressed data B1′ and B2′ correspond to software data B, and respectively include a part of the compressed software data B. In addition, the ROM11in the embodiment further stores a set of uncompressed user data C.

FIG. 2Bshows a corresponding relationship between the compressed data A1′ to An′ and the application A. The application A is divided into an n number of parts A1to An before being compressed. The n number of parts are later respectively compressed into the plurality of sets of compressed data A1′ to An′. In other words, the compressed data A1′ to An′ respectively correspond to uncompressed data A1to An divided from a same set of original data (i.e., the program code of the application A). In practice, a basis for dividing the application A may be a data size. For example, the program code corresponding to the application A is divided into an n number of same-sized parts. Alternatively, a basis for dividing the program code of the application A may be according to module type. For example, the data A1to An may be respectively associated with different function modules of the application A. It should be noted that, the number of data generated after dividing one set of the original data is not limited to a particular number.

When the processing module13initiates a utilization request for the application A, the demand paging module14determines in which page(s) the program code needed by the processing module13is included (e.g., according to a mapping table). Assume that the program code needed by the processing module13is included in the compressed data A1′ to A3′. In an embodiment, the processing module13prompts the demand paging module14to fetch the compressed data A1′ to A3′ from the ROM11, and provides the compressed data A1′ to A3′ to the decompression module15. The decompression module15then stores the decompressed data (the uncompressed data A1restored) to the RAM12for the use of the processing module15. In an alternative embodiment, the processing module13prompts the demand paging module14to process one set of compressed data at a time, e.g., the compressed A1′ is first processed. The compressed data A1′ is decompressed, and the data (e.g., the uncompressed data A1restored) generated from decompression is first stored to a block12ain the RAM12and then executed. The demand paging module14performs the same process on the compressed data A2′, and stores the data A2generated from decompression to another block12bof the RAM12and executes the data A2. Assuming that the decompressed data corresponding to the data A1′ is fully executed, the decompressed data A3corresponding to the third set of compressed data A3′ may be stored to the same block of the RAM12as the decompressed data corresponding to the data A′. That is, the fully executed data A1stored in the block12acan be overwritten.

In the above example, the RAM12is required to have a capacity sufficient for storing only the uncompressed data A1to A3or A1to A2. That is to say, the capacity of the RAM12is not necessarily designed to be sufficient for accommodating all program code (including the uncompressed data A1to An) of the application A. Similarly, if the utilization request initiated by the processing module13for software data B is included in the compressed data B2′, instead of simultaneously selecting the compressed data B1′ and B2′, the demand paging module14may select only the compressed data B2′ from the ROM11. In addition to the advantage of saving space of the ROM through the compression technique, such an approach evidently reduces a capacity requirement on the RAM12.

Further, if the processing module13initiates a utilization request for the user data C, the processing module13may directly fetch the user data C from the ROM11. It should be noted that, when insufficient space is left in the RAM12, the processing module13may command to delete or overwrite data in the RAM12currently not needed to release a space for accommodating a latest output of the decompression module15.

In an embodiment, the RAM12is divided into two sections—a first section for storing decompressed data generated by the decompression module15, and a second section for storing other data outputted by the decompression module15. The size of the first section may be fixed, or may be dynamically adjusted according to controls of the processing module13. For example, to enhance performance of the processing module13when executing the application A, the processing module13may expand the first section while reducing the second section, and prompt the demand paging module14and the decompression module15to decompress all of the compressed data A1′ to A3′ to the RAM12, so as to allow the processing module13to immediately utilize all of the program code of the application A. In contrast, if the application A is determined to be an application of a lesser priority, the processing module13may restrict the size of the first section to accommodate only one set of decompressed data.

FIG. 3shows a flowchart of a control method for an electronic device according to another embodiment of the present invention. The electronic device includes a ROM and a RAM. The ROM stores a plurality of sets of compressed data corresponding to a plurality of sets of uncompressed data. The uncompressed plurality of sets data are divided from a same set of original data. In step S32, in response to a request associated with the set of original data, one or more sets of compressed data are selected from the plurality of sets of compressed data. In step S34, the selected one or more sets of compressed data are decompressed and stored to the RAM. In step S36, an operation associated with the set of original data is performed according to a set of decompressed data generated from decompressing the selected one or more sets of compressed data.

Various modifications (e.g., details for dividing the uncompressed data) in the foregoing description associated with the electronic device100may be applied to the control method inFIG. 3, and shall be omitted herein.

A computer-readable storage medium is further provided according to yet another embodiment of the present invention. The computer-readable storage medium stores program code that is readable and executable by a controller. The program code is for controlling an electronic device. The electronic device includes a ROM and a RAM. The ROM stores a plurality of sets of compressed data corresponding to a plurality of sets of uncompressed data. The plurality of sets of uncompressed data are divided from a same set of original data. In response to a request associated with the set of original data, a first set of program code of the program code selects one or more sets of compressed data from the plurality of sets of compressed data. A second set of program code of the program code decompresses and stores the selected one or more sets of compressed data to the RAM. A third set of program code of the program code executes an operation associated with the set of original data according to a set of decompressed data generated from decompressing the selected one or more sets of compressed data.

As described in the foregoing embodiments, an electronic device and control method thereof is disclosed by the present invention. By utilizing appropriately divided program code or data as a unit of compression/decompression and incorporating a demand paging technique, the electronic device and control method thereof disclosed by the present invention effectively reduces a required memory space of ROM to further lower hardware costs of the electronic device.