A microprocessor makes use of code memory and data memory to store instructions and temporary data, respectively. The codes, or instructions, stored in the code memory are fetched, decoded, and executed on data from scratch-pad registers or from temporary data memory, such as cache or main memory, and then store them back into registers, caches, or main memory. In a general electronic system (e.g., computer), the whole code memory is normally stored in a non-volatile memory such as hard disk drive or solid state flash drive. A subset of code memory, such as main memory or instruction cache, are built in volatile memories such as DRAMs, SRAMs, or even integrated with the microprocessor. For most embedded systems, the code memory tends to have small size and can be implemented in flash memory embedded with its Micro-Controller Unit (MCU) to reduce cost.
For System-on-Chips (SoCs), there are always embedded processors built in to do complicated tasks, rather than depending on hard-wired random logic. For high-end SoCs, the code memory is very large that tends to be stored in an external flash memory, but the boot ROM, or kernel of the boot ROM, is built in the SoCs to jump start the embedded processor. The kernel or boot ROM is very crucial to an SoC, because if the kernel or boot ROM has bugs, the SoC will not be started.
The ideal kernel of boot ROM in an SoC is probably an embedded flash or Multiple-Time-Programmable (MTP) memory so that the boot code can be modified several times in most applications. Flash memory can usually be programmed about 20,000 times, but flash memory tends to be two to three generations behind the advanced CMOS process and requires about 7-8 most masks to fabricate, which makes it too expensive. MTP memory can be built in the same logic process with a few added masks, but the cell size is very large, about ten times (10×) larger than an SRAM cell in the same technology, which makes MTP memory impractical from being used for boot code kernels. One-Time-Programmable (OTP) memory has small size, simple process, low cost, but the memory cell can only be programmed once, which is not sufficient to serve as code memory or kernel of a boot ROM.
Accordingly, there is a need for improved designs for boot code kernels, boot code or code memory for storage of instructions executed by a processor which facilitates fast time to market, robust design, and reduced costs as compared to conventional flash or MTP for boot code kernel, boot code, or even code memory.
The invention pertains to a method, device and system of using an One-Time-Programmable (OTP) memory as an Multiple-Time Programming (MTP) memory equivalent to allow code to be updated one or more times and yet remain small in size and relatively easy to process (fabricate). The code can be program code for a processor, such as boot code, boot code kernel or other instruction code. For example, the OTP memory can be fabricated with standard CMOS processes as memory to replace the costly FLASH memory or Multiple-Time-Programmable (MTP) memory for processors, such as microprocessors, Micro-Controller Unit (MCU), embedded processors, or Digital Signal Processors (DSP).
According to one aspect, an OTP memory is able to functionally operate as if it were a MTP memory through intelligent use of NOPs, which are no operations. During normal operations, the NOPs are executed but nothing happens, except wasting a few clock or processing cycles. The processor's NOP code needs to be coincident with an instruction word of OTP's virgin state, i.e., NOP has all 0s and 0 is the virgin state of OTPs.
In one embodiment, program code is stored in the OTP memory. The program code is made modular with many subroutines or functions under a main program so that each module can be patched. One or more NOPs can be inserted in the beginning of those subroutines or functions in the program code that might be changed. Then, if a particular subroutine or function in the program code needs to be modified, an instruction (e.g., JUMP instruction) can be programmed into the NOP so that certain existing instructions can be bypassed and the execution of instructions of a new module can be performed. The new module can also be programmed into an unused space a memory map. Similarly, a block of code can be inserted by programming such into a new subroutine and programming a NOP instruction to call this subroutine. A block of code can be deleted by programming a JUMP instruction with a suitable target address into a NOP space so that a block of instructions following that NOP can be bypassed.
The invention can be implemented in numerous ways, including as a method, system, device, apparatus (including computer readable medium and graphical user interface). Several embodiments of the invention are discussed below.
As an integrated circuit, one embodiment can, for example, include: a processor; a One-Time-Programmable (OTP) memory as a part or all of a memory operatively coupled to the processor; and an instruction code for the processor. The instruction code can be programmed into the OTP memory, and the instruction code can have a plural of modules and at least one of the modules can have at least one No-Operation (NOP) instruction. The at least one module can having at least one NOP instruction being configured to be updated by programming a new module into an unused portion of the OTP memory and by programming a module-calling or branch instruction into the at least one NOP instruction to jump to a starting address of the new module or to a new target address upon execution.
As an electronics system, one embodiment can, for example, include: a processor; a One-Time-Programmable (OTP) memory as a part or all of a code memory operatively coupled to the processor; and an instruction code for the processor.
The instruction code can be programmed into the OTP memory, and the instruction code can have a plural of modules and at least one of the modules can have at least one No-Operation (NOP) instruction. The at least one module can having at least one NOP instruction being configured to be updated by programming a new module into an unused portion of the OTP memory and by programming a module-calling or branch instruction into the at least one NOP instruction to jump to a starting address of the new module or to a new target address upon execution.
As a method of providing an OTP memory configured to be updateable, one embodiment can, for example, include at least: storing instruction code into the OTP memory, the instruction code to be executed by a processor operatively connect to the OTP memory, the instruction code having a plural of modules, and at least one of the modules having at least one No-Operation (NOP) instruction at a NOP location; subsequently programming a new module into a previously unused portion of the OTP memory to stored additional instruction code to the OTP memory; and programming a module-calling or branch instruction into the NOP location to subsequently direct program execution to the additional instruction code of the new module.
As a non-transitory computer readable medium including at least computer program code stored thereon for programming an OTP memory configured to be updateable, one embodiment can, for example, include: computer program code for storing instruction code into the OTP memory, the instruction code stored being to be executable by a processor operatively connect to the OTP memory, the instruction code having a plural of modules, and at least one of the modules having at least one No-Operation (NOP) instruction at a NOP location; computer program code for subsequently programming a new module into a previously unused portion of the OTP memory to stored additional instruction code to the OTP memory; and computer program code for programming an instruction into the NOP location to subsequently redirect program execution to the additional instruction code of the new module.
Various aspects and advantages of the invention will become apparent from the following detailed description taken in conjunction with the accompanying drawings which illustrate, by way of example, the principles of the invention.
The present invention will be readily understood by the following detailed descriptions in conjunction with the accompanying drawings, wherein like reference numerals designate like structural elements, and in which:
a) shows modifying codes for an OTP used as MTP equivalent in accordance with one embodiment.
b) shows inserting codes for an OTP used as MTP equivalent in accordance with one embodiment.
c) shows deleting codes for an OTP used as MTP equivalent in accordance with one embodiment.
a) shows one embodiment of a method to prepare a program for an OTP to be used as MTP equivalent in accordance with the present invention.
a) shows a method to modify codes for an OTP to be used as MTP equivalent in accordance with one embodiment.
b) shows a method to insert codes for an OTP to be used as MTP equivalent in accordance with one embodiment.
c) shows a method to delete codes for an OTP to be used as MTP equivalent in accordance with one embodiment.
The invention pertains to a method, device and system of using an One-Time-Programmable (OTP) memory as an Multiple-Time Programming (MTP) memory equivalent to allow code to be updated one or more times and yet remain small in size and relatively easy to process (fabricate). The code can be program code for a processor, such as boot code, boot code kernel or other instruction code. For example, the OTP memory can be fabricated with standard CMOS processes as memory to replace the costly FLASH memory or Multiple-Time-Programmable (MTP) memory for processors, such as microprocessors, Micro-Controller Unit (MCU), embedded processors, or Digital Signal Processors (DSP).
According to one aspect, an OTP memory is able to functionally operate as if it were a MTP memory through intelligent use of NOPs, which are no operations. During normal operations, the NOPs are executed but nothing happens, except wasting a few clock or processing cycles. The processor's NOP code needs to be coincident with an instruction word of OTP's virgin state, i.e., NOP has all 0s and 0 is the virgin state of OTPs.
In one embodiment, program code is stored in the OTP memory. The program code is made modular with many subroutines or functions under a main program so that each module can be patched. One or more NOPs can be inserted in the beginning of those subroutines or functions in the program code that might be changed. Then, if a particular subroutine or function in the program code needs to be modified, an instruction (e.g., JUMP instruction) can be programmed into the NOP so that certain existing instructions can be bypassed and the execution of instructions of a new module can be performed. The new module can also be programmed into an unused space a memory map. Similarly, a block of code can be inserted by programming such into a new subroutine and programming a NOP instruction to call this subroutine. A block of code can be deleted by programming a JUMP instruction with a suitable target address into a NOP space so that a block of instructions following that NOP can be bypassed.
a) shows a program 50 having modified codes in an OTP memory according to one embodiment. The program 50 is provided as an MTP equivalent in code memory in accordance with one embodiment. The program 50 has a main module 51 with two subroutine calls SUB_A and SUB_B in a memory map as shown in
To make this method effective, an instruction word of an OTP's virgin state needs to be coincident with the NOP code in a microprocessor (or processor). In most microprocessors, the NOP code is a word of all 0s. As long as the virgin state of an OTP is set as 0, this method can work satisfactorily. The above description is for illustrative purpose. Those skilled in the art understand that the same bypass scheme can be applied to one or more instruction groups, modules, subroutines or functions, and they can be nested.
b) shows one embodiment of inserting codes in a program 50′ in an OTP memory operating as MTP equivalent in accordance with one embodiment. The program 50′ is built in a memory map having a module abc 51′. A NOP instruction has been inserted in at memory address 102H, where H refers to hexadecimal. This NOP instruction allows a block of instructions to be inserted between 101H and 103H by programming a new instruction “CALL SUBZ” into 102H and programming a block of instructions in a subroutine SUB_Z 53′ into a blank space of the OTP. When executing the instruction “CALL SUB_Z” at 102H, the execution flow will jump to the start address of the newly created subroutine SUB_Z 53′ and continue execution, and then on completion of the subroutine SUB_Z 53′ the execution flow can return to 103H. In effect, a block of instructions in SUB_Z 53′ is inserted between 101H and 103H. The above description is for illustrative purposes only. Those skilled in the art understand that the NOPs can be inserted in any memory addresses such as main program, subroutine, or functions in any numbers to insert one or more instructions after re-program, and the subroutine or functions may be nested.
c) shows one embodiment of deleting codes in a program 50″ in an OTP memory operating as MTP equivalent in accordance with one embodiment. The program 50″ is built in a memory map having a module abc 51″. A NOP instruction has been inserted in at memory address 102H. This NOP instruction allows a block of instructions to be deleted between 101H and 105H by programming a “JUMP 106H” into 102H. With the instruction “JUMP 106H” replacing a NOP, the program execution at 102H will jump to 106H and bypass instructions between 102H and 106H. In essence, a block of instructions between 102H and 106H are effectively deleted, or bypassed. The target address in the JUMP instruction for most microprocessors can be an absolute memory address, relative memory address, or a memory address in a register with an offset. If only a few instructions are deleted or bypassed, a jump instruction referring to the current address with an offset can be achieved in one NOP space; otherwise, more than one NOPs may be needed to build the target address. The above description is for illustrative purposes only. Those skilled in the art understand that the NOPs can be inserted in any memory addresses such as main program, subroutine, or functions in any numbers to delete one or more instructions after re-program, and the subroutine or functions may be nested.
Alternatively, more than one modification can be made to a program by providing one or more NOPs in any new modules programmed into the OTP. The new modules can then be further modified through programming of the one or more NOPs.
a) shows one embodiment of a method 70 for preparing a program so that an OTP memory can be used as an MTP equivalent in according with one embodiment. The first step 71 is to write a structured program, which is a program that contains modules with many subroutines or functions. The structured programming can be modified with relative ease if there are any updates. The subroutines or functions can also be nested in many levels. After a program is prepared, the program can be compiled into assembly language in step 71. The second step 72 can insert n blank words, or NOPs, in the beginning or any place of those subroutines or functions that are likely to be modified. For example, of an initial memory address is A, then NOPs can be inserted at memory address A, A+1, . . . , A+(n−1). The “n” blank words allow that subroutine or function to be modified, for example by effectively inserting or deleting codes of the program up to n-times in the same OTP memory. The third step 73 is to update pointers of the subroutines or functions that are amended with the inserted NOPs. The starting addresses of the subroutines or functions could be shifted in the memory map after inserting NOPs. Hence, the target addresses of the calling instructions are likewise shifted. The fourth step 74 is to convert the resulting assembly code into binary. The last step 75 is to program the binary into an OTP memory. The above description is for illustrative purpose. Those skilled in the art understand that the number of NOPs can be arbitrary and can be put in any place in some or all of the subroutines or functions, depending on the needs.
b) shows a method 80 for preparing a program so that an OTP memory can be used as MTP equivalent in accordance with another embodiment. The first step 81 is to write a structured program, which is a program that contains modules with many subroutines or functions. The second step 82 is to insert n NOPs of assembly code into the beginning or any place of the subroutines or functions that are likely to be modified. Inserting assembly codes into the program written in high-level language is called “in-lining.” The third step 83 is to compile the mixed high-level language with assembly code into a full assembly code. The fourth step 84 is to convert the assembly code into binary. The last step 85 is to program the binary into an OTP memory. The above description is for illustrative purpose. Those skilled in the art understand that the number of NOPs can be arbitrary and can be put in any place in some or all of the subroutines or functions, depending on the needs.
a) shows one embodiment of a method 90 updating an OTP memory when a portion of code stored therein needs to be modified. In the first step 91, determine which subroutine or function to modify. As an example, subroutine A will be modified for the i-th time, n>=i>0. The second step 92 determines if the number of modifications exceed an allowable limit, i.e. determine if i is larger than n. If yes, stop the method 90 with an error at state 99. In this case, the OTP memory cannot be further modified. If not, proceed to the third step 93 where new subroutine code Ai can be built into a spare memory space in the OTP memory. Then, in the fourth step 94 the subroutine A is changed to program a calling instruction to point to the new subroutine Ai. This call instruction can be inserted into the subroutine A by modifying the (n−i)-th entry of subroutine A to point to Ai, i.e. change the NOP in M[A+n−i] to “CALL SUB_Ai”. In other words, re-programming NOPs should in most cases start with the latest available NOPs in execution order. In the last step 95, new code for the subroutine Ai is programmed into the same OTP memory. After step 95, the code in the OTP memory has been successfully modified and the method 90 can stop at state 98. The above description is for illustrative purpose, those skilled in the art understand that the number of NOPs can vary, the number of subroutines or functions can vary, and the subroutines or functions can be nested.
b) shows one embodiment of a method 90′ updating an OTP memory when a portion of code needs to be inserted. In the first step 91′, determine which block of code to be inserted into a memory address having n NOPs at M, M+1, M+2, . . . , M+n−1. Inserting starts with programming NOPs in the address M+n−1, M+n−2, . . . , till M. The second step 92′ determines if the number of insertion exceeds the allowable limits, i.e. determine if i is larger than n. If yes, stop the method 90 with an error at state 99′. In this case, the OTP memory cannot be further modified. If not, proceed to the third step 93′ where a block of new code can be programmed into new subroutine code SUB_Ai in a spare memory space in the OTP memory. Then, in the fourth step 94′ the NOP in the address M+n−i can be changed to CALL SUB_Ai. In other words, re-programming NOPs should in most cases start with the latest available NOPs in execution order. In the last step 95′, the new added code can be programmed into the same OTP. After step 95′, the code in the OTP memory has been successfully modified and the method 90′ can stop at state 98′. The above description is for illustrative purpose, those skilled in the art understand that the number of NOPs can vary, the number of subroutines or functions can vary, and the subroutines or functions can be nested.
c) shows one embodiment of a method 90″ updating an OTP memory when a portion of code needs to be deleted. In the first step 91″, determine which block of code to be deleted near a memory address having n NOPs at M, M+1, M+2, . . . , M+n−1. Deleting starts with programming NOPs in the address M+n−1, M+n−2, . . . , till M. The second step 92″ determines if the number of deletion exceeds the allowable limits, i.e. determine if i is larger than n. If yes, stop the method 90″ with an error at state 99″. In this case, the OTP memory cannot be further modified. If not, proceed to the third step 94″ to change the latest NOP in the address M+n−i can be changed to “JUMP At”, where At is the target address. All instructions between memory address M+n−i and At will be effectively deleted or, more precisely, bypassed. Re-programming NOPs should in most cases start with the latest available NOPs in execution order. In the last step 95″, the new added code is programmed into the same OTP memory. After step 95″, the code in the OTP memory has been successfully modified and the method 90″ can stop at state 98″. The above description is for illustrative purpose, those skilled in the art understand that the number of NOPs can vary, the number of subroutines or functions can vary, and the subroutines or functions can be nested, and that are still within the scope of this invention.
To select a row for program or read, select proper X-address signals to travel from X-address buffers 113, through X-decoders 112 to turn on a row. To select a column for program or read, select proper Y-address signals to travel from Y-address buffers 116, through Y-decoders 115 to turn on Y-pass gates 114. To read at least one memory cell, cell data goes through Y-pass gates 114, sense amplifiers 117 with buffers, if necessary, to an output signal Q. To program at least one cell memory, input data D go through a program circuit 118, Y-pass gates 114, to the OTP memory cells. The control logic 119 is responsible to generate suitable signals to turn on X/Y-decoders, row/columns, program circuits or sense amplifiers. For a larger OTP memory, X- or Y-predecoders may be needed. There may be high voltage involved in programming an OTP memory. Therefore, the control logic 119 may be responsible to trigger charge pump circuits and there may be high voltage circuits in the X-decoders 112, Y-decoders 115, or program circuits 118.
The electronic system 200 can include a processor 202 and an OTP memory 204. The OTP memory 204 stores code (or instructions) that can be executed by the processor 202. The code can be for any purpose, include boot code, utility code, operating system code, device drivers, etc. As shown in
Hence, at some time later, it can be learned that the initial code stored in the initially programmed section 206 of the OTP memory 204 and being executed by the processor 202 at appropriates times requires modification for whatever reason. In such case, one or more of the NOPs in the initially programmed section 206 of the OTP memory 204 can be then programmed to an active instruction, such as a branch, call or jump instruction. The active instruction can serve to alter the code execution by the processor 202. The active instruction can jump or branch to other parts of the initial code in the initially programmed section 206, or can jump or branch to new code (e.g., subroutine or function) that has been stored in the initially un-programmed section 208 of the OTP memory 204 which was initially left empty. This operation can be repeated or continued so long as NOPs are available to be programmed (or reprogrammed).
The various aspects, features, embodiments or implementations of the invention described above can be used alone or in various combinations.
The invention is preferably implemented by software, hardware, or a combination of hardware and software. The invention can also be embodied as computer readable code on a computer readable medium. The computer readable medium is any data storage device that can store data which can thereafter be read by a computer system. Examples of the computer readable medium generally include read-only memory and random-access memory. More specific examples of computer readable medium are tangible and include Flash memory, OTP memory, EEPROM memory, memory card, CD-ROM, DVD, hard drive, magnetic tape, and optical data storage device. The computer readable medium can also be distributed over network-coupled computer systems so that the computer readable code is stored and executed in a distributed fashion.
The many features and advantages of the present invention are apparent from the written description and, thus, it is intended by the appended claims to cover all such features and advantages of the invention. Further, since numerous modifications and changes will readily occur to those skilled in the art, it is not desired to limit the invention to the exact construction and operation as illustrated and described. Hence, all suitable modifications and equivalents may be resorted to as falling within the scope of the invention.
This application claims priority benefit of U.S. Provisional Patent Application No. 61/375,667, filed on Aug. 20, 2010 and entitled “Method and System of Using One-Time Programmable Memory as Multi-Time Programmable in Code Memory of Microprocessors,” which is hereby incorporated herein by reference.
Number | Date | Country | |
---|---|---|---|
61375667 | Aug 2010 | US |