Control circuit and control method

By introducing a write protection logic circuit in the memory, using the mode setting value and the protection setting value to determine whether to change the enable setting value, the problem of error writing and tampering of memory data during writing is solved, and the data is realized Safety protection.

CN119068933APending Publication Date: 2024-12-03NUVOTON
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311757740.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2023-05-31
Filing Date
2023-12-20
Publication Date
2024-12-03

AI Technical Summary

Technical Problem

During the writing process, existing memory is prone to data errors or malicious tampering, resulting in data storage errors and lacks an effective protection mechanism.

Method used

A control circuit is designed, including a storage circuit, a temporary register and a write protection logic circuit. The mode setting value is used to determine whether to change the enable setting value, mode setting value and protection setting value to realize the writing of data. Input protection to ensure data integrity and security.

Benefits of technology

Improves the security of memory data, prevents miswrites and malicious tampering, and ensures the integrity of the data during the writing process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119068933A_ABST
    Figure CN119068933A_ABST
Patent Text Reader

Abstract

The invention discloses a control circuit and a control method. The control circuit comprises a storage circuit, a temporary memory and a write-in protection logic circuit, the storage circuit stores data, an enable setting value and a mode setting value. The register stores a protection set value. The write protection logic circuit determines whether to change at least one of the enable setting value, the mode setting value and the protection setting value according to the mode setting value when receiving a write instruction. When the mode setting value accords with a preset value, the write protection logic circuit changes at least one of the enabling setting value, the mode setting value and the protection setting value according to the write instruction and the protection setting value. When the mode setting value does not accord with the preset value, the write protection logic circuit does not change the enabling setting value and the mode setting value. According to the invention, the data storage security of the memory can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a control circuit, in particular to a control circuit providing a safety protection function. Background Art

[0002] Generally speaking, computer memory is divided into volatile memory and non-volatile memory. Non-volatile memory includes read-only memory (ROM), programmable read-only memory (PROM), electrically erasable programmable read-only memory (EPROM) and flash memory. Volatile memory includes dynamic random access memory (DRAM) and static random access memory (SRAM).

[0003] However, whether it is a volatile memory or a non-volatile memory, a user may mistakenly write the data stored in the memory, causing the memory to store erroneous data. In addition, the data in the memory may also be maliciously tampered with. Summary of the invention

[0004] One embodiment of the present invention provides a control circuit, including a storage circuit, a register, and a write protection logic circuit. The storage circuit stores a data, an enable setting value, and a mode setting value. The register stores a protection setting value. When receiving a write instruction, the write protection logic circuit determines whether to change at least one of the enable setting value, the mode setting value, and the protection setting value according to the mode setting value. When the mode setting value meets a preset value, the write protection logic circuit changes at least one of the enable setting value, the mode setting value, and the protection setting value according to the write instruction and the protection setting value. When the mode setting value does not meet the preset value, the write protection logic circuit does not change the enable setting value and the mode setting value.

[0005] The present invention further provides a control method, which is applicable to a write protection logic circuit, for adjusting at least one of an enable setting value, a mode setting value, and a protection setting value. The enable setting value and the mode setting value are stored in a storage circuit. The protection setting value is stored in a register. The register is independent of the storage circuit. The control method of the present invention includes receiving and decoding an input instruction; when the input instruction is a write instruction, reading the mode setting value; determining whether the mode setting value meets a preset value; when the mode setting value meets the preset value, changing at least one of the enable setting value, the mode setting value, and the protection setting value according to the write instruction and the protection setting value; when the mode setting value does not meet the preset value, maintaining the enable setting value and the mode setting value.

[0006] The control method of the present invention can be implemented through the control circuit and write protection logic circuit of the present invention, which are hardware or software that can execute specific functions, and can also be recorded in a recording medium in the form of a program and implemented in combination with specific hardware. When the program is loaded and executed by an electronic device, processor, computer or machine, the electronic device, processor, computer or machine becomes a control circuit and write protection logic circuit for implementing the present invention.

[0007] The present invention can improve the security of data stored in the memory. BRIEF DESCRIPTION OF THE DRAWINGS

[0008] Figure 1A is a schematic diagram of a control circuit of the present invention.

[0009] Figure 1B FIG. 4 is another schematic diagram of the control circuit of the present invention.

[0010] Figure 2 It is a flow chart of the control method of the present invention.

[0011] Description of Figure Numbers:

[0012] 100: Control circuit

[0013] 110: Write protection logic circuit

[0014] 111: Decoding circuit

[0015] 112: Judgment circuit

[0016] 120, 140: register

[0017] 121, 141 protection setting value

[0018] 130: Storage circuit

[0019] 131: Control circuit

[0020] 132: Storage Array

[0021] 150: Specific pin

[0022] DA: Data

[0023] CFG_ENABLE: Enable setting value

[0024] CFG_LEVEL: Mode setting value

[0025] BK1~BK6: storage blocks

[0026] CM_IN: Input command

[0027] VP: Voltage level

[0028] S211~S215: Steps DETAILED DESCRIPTION

[0029] In order to make the purpose, features and advantages of the present invention more obvious and easy to understand, the following embodiments are specifically cited and described in detail with the accompanying drawings. The present invention specification provides different embodiments to illustrate the technical features of different implementations of the present invention. Among them, the configuration of each component in the embodiment is for illustrative purposes and is not intended to limit the present invention. In addition, the repetition of the reference numerals in the embodiments is for the purpose of simplifying the description and does not mean the correlation between different embodiments.

[0030] Figure 1A Schematic diagram of the control circuit of the present invention. As shown in the figure, the control circuit 100 includes a write protection logic circuit 110, a register 120 and a storage circuit 130. The storage circuit 130 stores an enable setting value CFG_ENABLE, a mode setting value CFG_LEVEL and a data DA. The present invention does not limit the architecture of the storage circuit 130. In a possible embodiment, the storage circuit 130 includes a control circuit 131 and a storage array 132.

[0031] The present invention does not limit the type of the memory array 132. In some embodiments, the memory array 132 is a non-volatile memory (NVM). In this embodiment, the memory array 132 has blocks BK1 to BK6, but this is not intended to limit the present invention. In other embodiments, the memory array 132 has more or fewer memory blocks.

[0032] The memory block BK2 stores the enable setting value CFG_ENABLE. The enable setting value CFG_ENABLE is used to indicate which memory blocks of the memory array 132 have data that are protected. In this embodiment, the control circuit 131 copies the enable setting value CFG_ENABLE to the register 120 as the protection setting value 121.

[0033] The memory block BK3 stores a mode setting value CFG_LEVEL. The mode setting value CFG_LEVEL is used to indicate the operation mode of the write protection logic circuit 110. In this embodiment, the write protection logic circuit 110 enters a corresponding protection mode according to the mode setting value CFG_LEVEL.

[0034] The storage block BK5 stores data DA. In some embodiments, the control circuit 131 accesses the data DA according to the input command CM_IN. For example, when the input command CM_IN is a read command, the control circuit 131 enters a read mode. In the read mode, the control circuit 131 reads the data of the corresponding storage block (such as the storage block BK5) according to a bit address information of the input command CM_IN. When the input command CM_IN is a write command, the control circuit 131 enters a write mode. In the write mode, the control circuit 131 writes a data information of the input command CM_IN into the corresponding storage block (such as the storage block BK5) according to a bit address information of the input command CM_IN.

[0035] The present invention does not limit the storage location of the enable setting value CFG_ENABLE and the mode setting value CFG_LEVEL. In some embodiments, the enable setting value CFG_ENABLE and the mode setting value CFG_LEVEL may be stored in the same storage block. In other embodiments, the enable setting value CFG_ENABLE and the mode setting value CFG_LEVEL are binary values. The enable setting value CFG_ENABLE and the mode setting value CFG_LEVEL may have multiple bits.

[0036] In one possible embodiment, when a specific event occurs, the control circuit 131 enters an erase mode. In the erase mode, the control circuit 131 performs an erase operation, such as a mass erase operation, to erase the data of the memory blocks BK1 to BK6. After the erase operation, the mode setting value CFG_LEVEL is equal to a first initial value, and the enable setting value CFG_ENABLE is equal to a second initial value. In this example, the control circuit 131 may change the enable setting value CFG_ENABLE and the mode setting value CFG_LEVEL according to the input command CM_IN.

[0037] The register 120 stores the protection setting value 121. In the present embodiment, the register 120 is independent of the storage circuit 130. When the control circuit 100A is powered off, the protection setting value 121 of the register 120 will be cleared. Therefore, after the control circuit 100A is powered on, the control circuit 131 copies the enable setting value CFG_ENABLE of the storage block BK2 to the register 120 as the new protection setting value 121.

[0038] The write protection logic circuit 110 reads the mode setting value CFG_LEVEL of the block BK3 through the control circuit 131, and enters the corresponding protection mode according to the mode setting value CFG_LEVEL. For example, when the mode setting value CFG_LEVEL meets a first preset value, the write protection logic circuit 110 enters a first protection mode. In the first protection mode, the write protection logic circuit 110 changes at least one of the mode setting value CFG_LEVEL, the enable setting value CFG_ENABLE, and the protection setting value 121 according to the input command CM_IN.

[0039] For example, in the first protection mode, when the input command CM_IN is a write command and the address information of the write command corresponds to the register 120, the write protection logic circuit 110 changes the protection setting value 121 according to the data information of the input command CM_IN. In one possible embodiment, the write protection logic circuit 110 writes the data information of the input command CM_IN into the register 120 to replace the protection setting value 121. When the address information of the input command CM_IN corresponds to the storage block BK2 or BK3, the write protection logic circuit 110 provides the input command CM_IN to the storage circuit 130. The control circuit 131 changes the enable setting value CFG_ENABLE or the mode setting value CFG_LEVEL according to the data information of the input command CM_IN.

[0040] In another possible embodiment, in the first protection mode, when the input command CM_IN is a write command and the address information of the input command CM_IN corresponds to the storage block BK2 or BK3 , the write protection logic circuit 110 determines whether to change the enable setting value CFG_ENABLE or the mode setting value CFG_LEVEL according to the protection setting value 121 .

[0041] Taking the enable setting value CFG_ENABLE as an example, it is assumed that the address information of the write instruction corresponds to the storage block BK2. In this example, the write protection logic circuit 110 determines whether the protection setting value 121 meets a first specific value. When the protection setting value 121 meets a first specific value, it means that the storage block BK2 is protected. Therefore, the write protection logic circuit 110 does not provide the input instruction CM_IN to the storage circuit 130. If the protection setting value 121 is not equal to the first specific value, it means that the storage block BK2 is not protected. Therefore, the write protection logic circuit 110 provides the input instruction CM_IN to the storage circuit 130. The control circuit 131 changes the enable setting value CFG_ENABLE according to the address information and data information of the input instruction CM_IN.

[0042] In addition, in the first protection mode, the write protection logic circuit 110 determines whether to change the data of the storage blocks BK1, BK4-BK6 according to the protection setting value 121. For example, it is assumed that the protection setting value 121 indicates that the storage block BK5 is a protected block. In this example, since the storage blocks BK1, BK4 and BK6 are unprotected blocks, when the input command CM_IN is a write command and points to the storage block BK1, BK4 or BK6, the write protection logic circuit 110 provides the input command CM_IN to the storage circuit 130. The control circuit 131 changes the data stored in the storage block BK1, BK4 or BK6 according to the data information of the input command CM_IN. However, when the address information of the input command CM_IN points to the storage block BK5, since the storage block BK5 is a protected block, the write protection logic circuit 110 does not provide the input command CM_IN to the storage circuit 130. Since the control circuit 131 does not change the data DA, the integrity of the data DA can be protected, and the user can be prevented from accidentally rewriting the data DA, and the data DA can also be prevented from being maliciously tampered with.

[0043] In other embodiments, when the mode setting value CFG_LEVEL does not meet the first preset value, the write protection logic circuit 110 does not change the enable setting value CFG_ENABLE and the mode setting value CFG_LEVEL. At this time, even if the address information of the input command CM_IN points to the storage block BK2 or BK3, the write protection logic circuit 110 does not provide the input command CM_IN to the storage circuit 130. Therefore, the storage circuit 130 maintains the enable setting value CFG_ENABLE and the mode setting value CFG_LEVEL. In this example, the write protection logic circuit 110 determines whether to change the data of the storage blocks BK1, BK4-BK6 according to the protection setting value 121. For example, it is assumed that the protection setting value 121 indicates that the storage block BK5 is a protected block. In this example, since the memory blocks BK1, BK4, and BK6 are unprotected blocks, when the address information of the input command CM_IN points to the memory blocks BK1, BK4, or BK6, the write protection logic circuit 110 provides the input command CM_IN to the storage circuit 130. The control circuit 131 changes the data stored in the memory blocks BK1, BK4, or BK6 according to the input command CM_IN. When the address information of the input command CM_IN points to the memory block BK5, since the memory block BK5 is a protected block, the write protection logic circuit 110 does not provide the input command CM_IN to the storage circuit 130. Therefore, the control circuit 131 maintains the data DA.

[0044] In some embodiments, when the input command CM_IN points to the storage circuit 130, the write protection logic circuit 110 directly provides the input command CM_IN to the control circuit 131. The control circuit 131 decodes the input command CM_IN and changes the data stored in the corresponding storage block according to the decoded address information and data information. In another possible embodiment, when the input command CM_IN is a read command, the control circuit 131 reads and outputs the data of the corresponding storage block according to the address information of the input command CM_IN.

[0045] In other embodiments, when the mode setting value CFG_LEVEL does not meet the first preset value, the write protection logic circuit 110 determines whether the mode setting value CFG_LEVEL meets a second preset value (different from the first preset value). When the mode setting value CFG_LEVEL meets the second preset value, the write protection logic circuit 110 enters a second protection mode.

[0046] In the second protection mode, the write protection logic circuit 110 does not change the enable setting value CFG_ENABLE, the mode setting value CFG_LEVEL, and the protection setting value 121. In this mode, even if the address information of the input command CM_IN points to the register 120, the storage block BK2 or BK3, the write protection logic circuit 110 does not change the protection setting value 121, and does not provide the input command CM_IN to the storage circuit 130. Therefore, the data of the register 120, the storage blocks BK2 and BK3 are protected.

[0047] When a specific event occurs, the control circuit 131 enters an erase mode. In the erase mode, the control circuit 131 erases the memory blocks BK1-BK6. Since the mode setting value CFG_LEVEL of the memory block BK3 does not meet the second preset value, the write protection logic circuit 110 leaves the second protection mode. In some embodiments, after erasing the memory block BK3, the control circuit 131 sets the mode setting value CFG_LEVEL to be equal to the first preset value. Therefore, the write protection logic circuit 110 enters the first protection mode.

[0048] The present invention does not limit the architecture of the write protection logic circuit 110. In one possible embodiment, the write protection logic circuit 110 includes a decoding circuit 111 and a determination circuit 112. The decoding circuit 111 decodes the input command CM_IN to obtain the type of the input command CM_IN (write command or read command), an address information, and a data information. The present invention does not limit the architecture of the decoding circuit 111. Any circuit architecture with a decoding command function can be used as the decoding circuit 111.

[0049] The judgment circuit 112 enters the corresponding protection mode according to the mode setting value CFG_LEVEL. For example, when the mode setting value CFG_LEVEL meets the first preset value, the judgment circuit 112 enters the first protection mode. In the first protection mode, when the input instruction CM_IN is a write instruction, the judgment circuit 112 modifies the mode setting value CFG_LEVEL, the enable setting value CFG_ENABLE or the protection setting value 121 according to the address information of the write instruction. For example, when the address information of the write instruction corresponds to the register 120, the judgment circuit 112 changes the protection setting value 121 according to the data information of the write instruction. When the address information of the write instruction corresponds to the storage block BK2 or BK3, the judgment circuit 112 provides the input instruction CM_IN to the storage circuit 130 to change the data of the storage block BK2 or BK3.

[0050] In other embodiments, in the first protection mode, the judgment circuit 112 judges whether the protection setting value 121 meets a first specific value. When the protection setting value 121 meets the first specific value, even if the address information of the write command corresponds to the register 120, the storage block BK2 or BK3, the judgment circuit 112 does not modify the protection setting value 121 according to the write command, nor does it provide the input command CM_IN to the storage circuit 130. When the protection setting value 121 does not meet the first specific value, the judgment circuit 112 may change the protection setting value 121, or provide the input command CM_IN to the storage circuit 130.

[0051] In the second protection mode, when the input command CM_IN is a write command and the address information of the write command points to the storage block BK2 , BK3 or the register 120 , the determination circuit 112 does not provide the input command CM_IN to the storage circuit 130 and does not modify the protection setting value 121 .

[0052] In the first and second protection modes, the judgment circuit 112 determines whether to change the data of the storage blocks BK1, BK4-BK6 according to the protection setting value 121. For example, it is assumed that the protection setting value 121 indicates that the storage block BK5 is a protected block. In this example, since the storage blocks BK1, BK4 and BK6 are unprotected blocks, when the address information of the write instruction points to the storage block BK1, BK4 or BK6, the judgment circuit 112 provides the input instruction CM_IN to the storage circuit 130. Therefore, the control circuit 131 changes the data stored in the storage block BK1, BK4 or BK6 according to the data information of the write instruction. However, when the address information of the write instruction points to the storage block BK5, since the storage block BK5 is a protected block, the judgment circuit 112 does not provide the input instruction CM_IN to the storage circuit 130. Therefore, the control circuit 131 maintains the data DA to protect the integrity of the data DA.

[0053] Figure 1B FIG. 2 is another schematic diagram of the control circuit of the present invention. Figure 1B resemblance Figure 1A , the difference is that, Figure 1B A register 140 is added. The register 140 is independent of the storage circuit 130. In this embodiment, the register 140 stores a protection setting value 141. The protection setting value 141 is used to indicate whether the register 120 is protected.

[0054] For example, in the first protection mode, when the address information of the write instruction points to the register 120, the write protection logic circuit 110 determines whether the protection setting value 141 meets a second specific value. When the protection setting value 141 meets the second specific value, it means that the register 120 is protected. Therefore, the write protection logic circuit 110 does not modify the protection setting value 121. In this example, since the protection setting value 121 is fixedly equal to the first specific value, the data of the specific storage block in the storage circuit 130 can be prevented from being tampered with. When the protection setting value 141 does not meet the second specific value, it means that the register 120 is not protected. At this time, if the address information of the write instruction points to the register 120, the write protection logic circuit 110 replaces the protection setting value 121 with a data information of the write instruction.

[0055] In other embodiments, the write protection logic circuit 110 determines whether the mode setting value CFG_LEVEL meets a third preset value. When the mode setting value CFG_LEVEL meets the third preset value, the write protection logic circuit 110 enters a third protection mode. In the third protection mode, the write protection logic circuit 110 detects a voltage level VP of a specific pin 150.

[0056] When the voltage level VP of the specific pin 150 meets a specific level (such as a high level), it indicates that the protection setting value 121 of the register 120 is protected. At this time, if the address information of the write command points to the register 120, the write protection logic circuit 110 does not modify the protection setting value 121 according to the write command.

[0057] However, when the voltage level VP of the specific pin 150 does not meet a specific level (such as the voltage level VP is a low level), it means that the protection setting value 121 is not protected. At this time, if the address information of the write command points to the register 120, the write protection logic circuit 110 modifies the protection setting value 121 according to a data information of the write command.

[0058] In addition, in the third protection mode, the write protection logic circuit 110 does not modify the mode setting value CFG_LEVEL and the enable setting value CFG_ENABLE. In this example, even if the address information of the write command points to the memory block BK2 or BK3, the write protection logic circuit 110 does not provide the input command CM_IN to the storage circuit 130.

[0059] In the third protection mode, the write protection logic circuit 110 accesses the storage circuit 130 according to the protection setting value 121. For example, assume that the protection setting value 121 indicates that the storage blocks BK1 and BK5 are a protected block. In this example, since the storage blocks BK4 and BK6 are unprotected blocks, when the address information of the write instruction points to the storage block BK4 or BK6, the write protection logic circuit 110 provides the input instruction CM_IN to the storage circuit 130. The control circuit 131 changes the data stored in the storage block BK4 or BK6 according to the data information of the write instruction. However, when the address information of the write instruction points to the storage block BK1 or BK5, since the storage blocks BK1 and BK5 are protected blocks, the write protection logic circuit 110 does not provide the input instruction CM_IN to the storage circuit 130. Therefore, the control circuit 131 maintains the data of the storage blocks BK1 and BK5.

[0060] In other embodiments, the write protection logic circuit 110 determines whether the mode setting value CFG_LEVEL meets a fourth preset value. When the mode setting value CFG_LEVEL meets the fourth preset value, the write protection logic circuit 110 enters a fourth protection mode. In the fourth protection mode, the write protection logic circuit 110 detects the voltage level VP of the specific pin 150.

[0061] When the voltage level VP of the specific pin 150 meets a specific level (such as a high level), it indicates that the register 120 is protected and the storage circuit 130 is not allowed to perform an erase operation. At this time, if the address information of the write instruction points to the register 120, the write protection logic circuit 110 does not change the protection setting value 121. In addition, when a specific event occurs, the storage circuit 130 does not perform an erase operation.

[0062] However, when the voltage level VP of the specific pin 150 does not meet a specific level (e.g., the voltage level VP is a low level), it indicates that the register 120 is not protected, and the storage circuit 130 is allowed to perform an erase operation. At this time, if the address information of the write command points to the register 120, the write protection logic circuit 110 may write a data information of the write command into the register 120 to replace the protection setting value 121. In addition, when a specific event occurs, the storage circuit 130 enters an erase mode to perform an erase operation.

[0063] The present invention does not limit how the storage circuit 130 determines whether a specific event has occurred. In one possible embodiment, the storage circuit 130 knows that a specific event has occurred based on the value of a specific register (not shown). For example, when a specific event occurs, a central processing unit (not shown) sets the value of the specific register to a third specific value (such as 1). Therefore, the storage circuit 130 enters an erase mode. In the erase mode, the storage circuit 130 performs an erase operation to clear the data of the storage blocks BK1~BK6 of the storage array 132. However, when the specific event does not occur, the central processing unit sets the value of the specific register not to the third specific value. Therefore, the storage circuit 130 does not perform an erase operation.

[0064] In some embodiments, in the fourth protection mode, when the voltage level VP of the specific pin 150 meets a specific level, even if a specific event occurs, the CPU does not set the value of the specific register to the third specific value. In another possible embodiment, the write protection logic circuit 110 sets the value of the specific register to a fourth specific value. Since the value of the specific register is not the third specific value, the storage circuit 130 does not perform an erase operation. In this example, even if a specific event occurs, the CPU cannot change the value of the specific register.

[0065] The present invention does not limit the type of specific event. In one possible embodiment, the specific event refers to the storage circuit 130 being illegally accessed or a specific instruction (such as an ISP instruction) being executed. For example, when the user accesses the data of the storage circuit 130 multiple times and the number of accesses reaches a target value, it means that the storage circuit 130 is illegally accessed. Therefore, a central processing unit sets the value of the specific register to the third specific value to trigger the control circuit 131 to perform an erase operation.

[0066] In one possible embodiment, after the erase operation is completed, the enable setting value CFG_ENABLE is equal to an initial value, and the mode setting value CFG_LEVEL meets the first preset value. At this time, a legitimate user may rewrite the enable setting value CFG_ENABLE and the mode setting value CFG_LEVEL by inputting the command CM_IN, and write the new data into the corresponding storage block (such as BK5). When the control circuit 100 is powered on again, before receiving the input command CM_IN, the write protection logic circuit 110 requires the storage circuit 130 to output the enable setting value CFG_ENABLE to the register 120. At this time, the enable setting value CFG_ENABLE is used as the new protection setting value 121. Therefore, before the input command CM_IN enters the write protection logic circuit 110, the data of the storage blocks BK1 to BK6 have been protected.

[0067] In addition, in the fourth protection mode, the write protection logic circuit 110 does not modify the mode setting value CFG_LEVEL and the enable setting value CFG_ENABLE. In this example, even if the address information of the write command points to the memory block BK2 or BK3, the write protection logic circuit 110 does not send the input command CM_IN to the storage circuit 130.

[0068] In the fourth protection mode, the write protection logic circuit 110 accesses the storage circuit 130 according to the protection setting value 121. For example, assume that the protection setting value 121 indicates that the storage blocks BK5 and BK6 are protected blocks. In this example, since the storage blocks BK1 and BK4 are unprotected blocks, when the address information of the write instruction points to the storage block BK1 or BK4, the write protection logic circuit 110 provides the input instruction CM_IN to the storage circuit 130. Therefore, the control circuit 131 changes the data stored in the storage block BK1 or BK4 according to the data information of the write instruction. However, when the address information of the write instruction points to the storage block BK5 or BK6, since the storage blocks BK5 and BK6 are protected blocks, the write protection logic circuit 110 does not provide the input instruction CM_IN to the storage circuit 130. Therefore, the data of the storage blocks BK5 and BK6 will not be changed.

[0069] In other embodiments, the control circuit 100 has a plurality of pins (not shown). Any one of the plurality of pins can be used as the specific pin 150. In this example, when the write protection logic circuit 110 operates in the third or fourth protection mode, the write protection logic circuit 110 decodes the mode setting value CFG_LEVEL to obtain a pin information, and selects one of the plurality of pins according to the pin information, and uses the selected pin as the specific pin 150.

[0070] Figure 2 The control method of the present invention can be implemented by a program. When the program code is loaded and executed by a machine, the machine becomes a write protection logic circuit for implementing the present invention. The write protection logic circuit of the present invention is coupled to a storage circuit and a first register. The first register is independent of the storage circuit.

[0071] In a possible embodiment, the storage circuit has a plurality of storage blocks and stores a mode setting value and an enable setting value. The mode setting value and the enable setting value may be stored in the same or different storage blocks. The mode setting value is used to indicate the operation mode of the write protection logic circuit. The enable setting value is used to indicate which storage blocks of the storage circuit are protection blocks. For the convenience of explanation, it is assumed that the enable setting value is stored in a first storage block and the mode setting value is stored in a second storage block. In addition, the first register stores a first protection setting value.

[0072] First, an input instruction is received and decoded (step S211). In one possible embodiment, step S211 decodes the input instruction to obtain the type of the input instruction (read instruction or write instruction). In addition, the write protection logic circuit obtains an address information and a data information according to the input instruction.

[0073] When the input command is a write command, the write protection logic circuit reads the mode setting value in the storage circuit (step S212), and determines whether the mode setting value meets a first preset value (step S213). When the mode setting value meets the first preset value, the write protection logic circuit enters a first protection mode (step S214).

[0074] In the first protection mode, the write protection logic circuit changes at least one of the enable setting value, the mode setting value, and the first protection setting value according to the input instruction (i.e., a write instruction). For example, when the address information of the write instruction points to the first or second storage block, the write protection logic circuit provides the input instruction to the storage circuit. The storage circuit then updates the enable setting value of the first storage block or the mode setting value of the second storage block according to the data information of the input instruction. When the address information of the write instruction points to the first register, the write protection logic circuit updates the first protection setting value of the first register according to the data information of the write instruction.

[0075] In another possible embodiment, when the address information of the write instruction points to the first or second storage block, the write protection logic circuit determines whether to update the enable setting value and the mode setting value according to the first protection setting value. For example, when the first protection setting value meets a first specific value, it indicates that the data of the first and second storage blocks are protected. Therefore, even if the address information of the write instruction points to the first or second storage block, the write protection logic circuit does not provide input instructions to the storage circuit. Therefore, the data of the first or second storage block (i.e., the enable setting value or the mode setting value) will not be changed. When the first protection setting value does not meet the first specific value, it indicates that the data of the first and second storage blocks are not protected. Therefore, the write protection logic circuit 110 provides input instructions to the storage circuit. The storage circuit then updates the first or second storage block according to the address information of the write instruction.

[0076] In other embodiments, in the first protection mode, the write protection logic circuit reads a second protection setting value stored in a second register. The write protection logic circuit determines whether the second protection setting value meets a second specific value. When the second protection setting value meets the second specific value, it means that the first protection setting value stored in the first register is protected. Therefore, even if the address information of the write instruction points to the first register, the write protection logic circuit does not modify the first protection setting value of the first register. When the second protection setting value does not meet the second specific value, it means that the first protection setting value stored in the first register is not protected. Therefore, when the address information of the write instruction points to the first register, the write protection logic circuit modifies the first protection setting value of the first register according to the data information of the write instruction.

[0077] When the mode setting value does not meet the first preset value, the write protection logic circuit maintains the enable setting value and the mode setting value (step S215). In one possible embodiment, even if the address information of the write instruction points to the first or second storage block, the write protection logic circuit does not provide the input instruction to the storage circuit. Therefore, the data of the first and second storage blocks will not be changed. In other embodiments, step S215 further maintains the first protection setting value of the first register. In this example, even if the address information of the write instruction points to the first register, the write protection logic circuit does not change the first protection setting value.

[0078] In some embodiments, when the address information of the write instruction points to a specific storage block of the storage circuit, the write protection logic circuit determines which specific storage blocks of the storage circuit are protected according to the first protection setting value. For example, when the protection setting value meets the first specific value, it means that the data of at least one specific storage block of the storage circuit is protected. Therefore, when the address information of the write instruction points to the protected specific storage block, the write protection logic circuit does not provide the input instruction to the storage circuit. Therefore, the data of the protected storage block in the storage circuit will not be changed.

[0079] In other embodiments, when the mode setting value does not meet the first preset value, the write protection logic circuit determines whether the mode setting value meets a second preset value. When the mode setting value meets the second preset value, the write protection logic circuit enters the second protection mode. In the second protection mode, even if the address information of the write instruction points to the first storage block, the second storage block or the first register, the enable setting value, the mode setting value or the first protection setting value will not be changed.

[0080] In some embodiments, when the mode setting value does not meet the second preset value, the write protection logic circuit determines whether the mode setting value meets a third preset value. When the mode setting value meets the third preset value, the write protection logic circuit enters the third protection mode. In the third protection mode, the write protection logic circuit detects the voltage level of a specific pin among multiple pins. When the voltage level of the specific pin meets a specific level, it indicates that the first protection setting value stored in the first register is protected. Therefore, even if the address information of the write instruction points to the first register, the write protection logic circuit does not modify the first protection setting value of the first register. However, when the voltage level of the specific pin does not meet the specific level, it indicates that the first register is not protected. Therefore, when the address information of the write instruction points to the first register, the write protection logic circuit may replace the first protection setting value with the data information of the write instruction.

[0081] In addition, in the third protection mode, even if the address information of the write instruction points to the first or second storage block, the data of the first or second storage block will not be changed. In one possible embodiment, in the third protection mode, the write protection logic circuit determines whether to change the data of the third storage block of the storage circuit according to the first protection setting value of the first register. For example, when the first protection setting value indicates that the third storage block is protected, even if the address information of the write instruction points to the third storage block, the write protection logic circuit does not provide an input instruction to the storage circuit. Therefore, the data of the third storage block will not be changed. When the first protection setting value indicates that the third storage block is not protected, if the address information of the write instruction points to the third storage block, the write protection logic circuit provides an input instruction to the storage circuit. The storage circuit then changes the data of the third storage block according to the data information of the write instruction.

[0082] In other embodiments, when the mode setting value does not meet the third preset value, the write protection logic circuit determines whether the mode setting value meets a fourth preset value. When the mode setting value meets the fourth preset value, the write protection logic circuit enters a fourth protection mode. In the fourth protection mode, the write protection logic circuit detects a voltage level of a specific pin among the plurality of pins.

[0083] In the fourth protection mode, when the voltage level of the specific pin meets a specific level, it means that the first protection setting value stored in the first register is protected, and the storage circuit is prohibited from performing an erase operation. At this time, even if the address information of the write instruction points to the first register, the write protection logic circuit does not modify the first protection setting value of the first register. In another possible embodiment, even if the address information of the write instruction points to the first or second storage block, the storage circuit does not change the enable setting value and the mode setting value. In addition, in the fourth protection mode, when the voltage level of the specific pin meets a specific level, even if a specific event occurs, the storage circuit does not perform an erase operation. Therefore, the data in the storage circuit remains unchanged.

[0084] In the fourth protection mode, when the voltage level of the specific pin does not meet the specific level, it indicates that the first register is not protected, and the storage circuit can perform an erase operation. Therefore, when the address information of the write instruction points to the first register, the write protection logic circuit modifies the first protection setting value of the first register according to the data information of the write instruction. In a possible embodiment, the write protection logic circuit replaces the first protection setting value with the data information of the write instruction.

[0085] In addition, when a specific event occurs, the storage circuit performs an erase operation to erase the data of all storage blocks. After the erase operation, the storage circuit sets the enable setting value of the first storage block to an initial value, and sets the mode setting value of the second storage block to a first preset value. At this time, the user writes data to other storage blocks of the storage circuit. The user sets the enable setting value of the first storage block according to the importance of the data to protect the data of a specific storage block.

[0086] In other embodiments, in the fourth protection mode, the write protection logic circuit decodes the mode setting value to obtain a pin information. The write protection logic circuit selects one of the plurality of pins as a specific pin according to the pin information and detects the voltage level of the specific pin.

[0087] Since the first protection setting value and the erase operation of the first register are protected, the data security of the storage circuit can be improved. Furthermore, the voltage level of the specific pin is set by a trusted external device, which is convenient for the user to activate the protection function. In different protection modes, the write protection logic circuit provides different levels of protection, which increases the setting flexibility of the user.

[0088] The control method of the present invention, or a specific form or part thereof, may exist in the form of program code. The program code may be stored in a physical medium, such as a floppy disk, an optical disk, a hard disk, or any other machine-readable (such as computer-readable) storage medium, or a computer program product that is not limited to an external form, wherein when the program code is loaded and executed by a machine, such as a computer, the machine becomes used to participate in the control circuit and write protection logic circuit of the present invention. The program code may also be transmitted through some transmission media, such as wires or cables, optical fibers, or any transmission mode, wherein when the program code is received, loaded and executed by a machine, such as a computer, the machine becomes used to participate in the control circuit and write protection logic circuit of the present invention. When implemented in a general-purpose processing unit, the program code combines with the processing unit to provide a unique device that operates similarly to the application-specific logic circuit.

[0089] Unless otherwise defined, all terms (including technical and scientific terms) herein are generally understood by those skilled in the art to which the present invention belongs. In addition, unless expressly indicated, the definitions of terms in general dictionaries should be interpreted as consistent with the meanings in articles in the relevant technical field, and should not be interpreted as ideal or overly formal. Although the terms "first", "second", etc. may be used to describe various elements, these elements should not be limited by these terms. These terms are only used to distinguish one element from another element.

[0090] Although the present invention has been disclosed as above with preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art may make some changes and modifications without departing from the spirit and scope of the present invention. For example, the system, device or method described in the embodiments of the present invention may be implemented in a physical embodiment of hardware, software or a combination of hardware and software. Therefore, the scope of protection of the present invention shall be subject to the scope defined by the claims.

Claims

1. A control circuit, characterized in that: include: a storage circuit storing a data, an enable setting value and a mode setting value; a first register storing a first protection setting value; and a write protection logic circuit, which, upon receiving a write instruction, determines whether to change at least one of the enable setting value, the mode setting value and the first protection setting value according to the mode setting value; in: When the mode setting value meets a first preset value, the write protection logic circuit changes at least one of the enable setting value, the mode setting value and the first protection setting value according to the first protection setting value; When the mode setting value does not meet the first preset value, the write protection logic circuit does not change the enable setting value and the mode setting value.

2. The control circuit according to claim 1, characterized in that: When the mode setting value matches the first preset value and the first protection setting value does not match a first specific value, the write protection logic circuit replaces one of the enable setting value, the mode setting value and the first protection setting value with a data information of the write instruction according to an address information of the write instruction.

3. The control circuit according to claim 1, characterized in that: Also includes: A second register storing a second protection setting value; in: When the mode setting value matches the first preset value and an address information of the write instruction corresponds to the first register, the write protection logic circuit determines whether the second protection setting value matches a second specific value; When the second protection setting value matches the second specific value, the write protection logic circuit maintains the first protection setting value.

4. The control circuit according to claim 1, characterized in that: When the mode setting value meets a second preset value, the write protection logic circuit fixes the enable setting value, the mode setting value and the first protection setting value.

5. The control circuit according to claim 4, characterized in that: The storage circuit comprises: a storage array storing the data, the enable setting value and the mode setting value; and A control circuit clears the data, sets the enable setting value to an initial value, and sets the mode setting value to the first preset value when a specific event occurs.

6. The control circuit according to claim 5, characterized in that: Also includes: a plurality of pins, wherein when the mode setting value matches a third preset value, the write protection logic circuit detects a voltage level of a specific pin among the plurality of pins; When the voltage level of the specific pin meets a specific level, the write protection logic circuit replaces the first protection setting value with a data information of the write instruction.

7. The control circuit according to claim 6, characterized in that: When the mode setting value matches a fourth preset value, the voltage level of the specific pin matches the specific level, and the specific event occurs, the write protection logic circuit maintains the data, the enable setting value, and the mode setting value.

8. The control circuit according to claim 6, characterized in that: The write protection logic selects one of the plurality of pins as the specific pin according to pin information of the mode setting value.

9. A control method, characterized in that: A write protection logic circuit is used to adjust at least one of an enable setting value, a mode setting value and a first protection setting value, wherein the enable setting value and the mode setting value are stored in a storage circuit, and the first protection setting value is stored in a first register, which is independent of the storage circuit. The control method includes: receiving and decoding an input instruction; When the input command is a write command, reading the mode setting value; Determining whether the mode setting value meets a first preset value; When the mode setting value matches the first preset value, changing at least one of the enable setting value, the mode setting value and the first protection setting value according to the write command and the first protection setting value; and When the mode setting value does not meet the first preset value, the enable setting value and the mode setting value are maintained.

10. The control method according to claim 9, characterized in that: The step of changing at least one of the enable setting value, the mode setting value, and the first protection setting value comprises: Determining whether the first protection setting value meets a first specific value; When the first protection setting value matches the first specific value, a data information of the write command replaces one of the enable setting value, the mode setting value and the first protection setting value according to an address information of the write command.