BACKGROUND

Technical Field

The disclosure generally relates to a data processing system, and more specifically, to data processing system that loads instruction data of an instruction from a memory and a method thereof.

Description of Related Art

In a data processing system, a microprocessor may access memory (e.g., read-only memory (ROM), random access memory (RAM) or any other non-volatile memory) to load instruction data by using an instruction address. However, in many cases, the memory may be affected by various factors such as temperature, supply voltage fluctuations (e.g., voltage drop, spikes, or up/down conditions), or any other conditions that influence the output of the memory. For example, under a low voltage operation, voltage fluctuations may cause errors in the instruction data read from the memory, and wrong instruction may be executed by the microprocessor. In some cases, critical data may be erased from the memory due to an execution of wrong instruction, which causes fatal failure of the memory.

SUMMARY

In the disclosure, a data processing system and a method thereof are provided to prevent reading wrong instruction data from the memory.

In one of the embodiments, a data processing system includes a memory, a read data check circuit, and a microprocessor. The memory includes a first region and a second region, where the first region stores a plurality of instruction data and the second region stores a dummy data. The read data check circuit is coupled to the second region of the memory to receive a dummy data, and comparing the dummy data to a hardwire data. The microprocessor is coupled to the memory and the read data check circuit and configured to access the memory using an instruction address to fetch instruction data, receive the instruction data from the first region and a comparison result from the read data check circuit in response to the instruction address, and determine that the instruction data corresponds to the instruction address according to the comparison result.

In one of the embodiments, a method of reading instruction data of an instruction from a memory is provided. The method comprises the following steps. A first instruction address corresponding to a first instruction is received. A first instruction data and a first dummy data is obtained from the memory based on the first instruction address. The first dummy data is compared to a hardwire data. Then, the first instruction data is provided to the microprocessor when determined that the dummy data matches the hardwire data.

In the present invention, a comparison stage is added into an instruction pipeline of the instruction. Accordingly, the disclosure reduces the chance of executing a wrong or unintended instruction by cross check the integrity of the instruction data using the dummy data which is read at the same time (or under the same condition) as the instruction data.

