On-chip/off-chip memory switching using system configuration bit
CROSS-REFERENCE TO RELATED APPLICATION 
     This application is a continuation of application Ser. No. 07/454,289, filed Dec. 21, 1989, now abandoned. 
    
    
     BACKGROUND OF THE INVENTION 
     The present invention relates generally to semiconductor microprocessors and microcontrollers, and more particularly to such devices having on-chip program memory. 
     In microcontroller or microprocessor devices having on-chip or on-board program memory, it is necessary during the execution of certain programs to switch from the on-chip memory, which may be ROM, EPROM, EEPROM or other program memory, to off-chip program memory, and vice versa. The conventional technique for accomplishing this system configuration is to use a pin on the semiconductor device package, such as a 40-pin or a 68-pin package, to which a &#34;1&#34; or a &#34;0&#34; is written depending on whether the execution is to be from internal or external memory. This pin is customarily referred to in the industry as MC/MP (short for MicroController orMicroProcessor mode), or EA (for External Access). 
     The prior art technique may be explained by reference to the block diagram of FIG. 1. A microcontroller 10 addresses the data bus 12, latches data sent to a specific address via a latch 15, and brings a bit back on the MC/MP pin. A program executing from internal memory is required to write a &#34;0&#34; to switch to execution from external memory, and a program executing from external memory is required to write a &#34;1&#34; to switch to execution from internal memory. A latch is necessary because the effect must be delayed until the next instruction begins execution. The need for an additional pin to accommodate MC/MP is wasteful in that there is generally a desire to conserve pin outs of the package for various essential purposes. 
     Accordingly, it is a principal object of the present invention to provide improvements in techniques for switching between internal and external memory in semiconductor microcontrollers and microprocessors. 
     Another important object of the invention is to provide a semiconductor device requiring program execution from on-chip memory and off-chip memory, in which simplified switching between the two memories is employed for such purpose. 
     SUMMARY OF THE INVENTION 
     Briefly, according to the present invention, the switching between internal and external memory during program execution by the microcontroller (or microprocessor) is accomplished by using a system configuration (SYSCON for short) bit which can be written as either a &#34;1&#34; or a &#34;0&#34; depending on whether the on-chip program memory or the off-chip program memory is to be used in executing the program or a part of the program. The effect is tantamount to taking the latch and the MC/MP pin functionality of the prior art implementation and bringing them into the chip. Beyond the saving of a pin in the package into which the device is assembled, the invention also provides the advantage of placing the execution from either memory selectively under the program control. 
     Therefore, it is still another object of the invention to provide a semiconductor device in which programs are executed using either on-chip program memory or off-chip program memory according to the value written into a system configuration (SYSCON) bit. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     The above and still further objects, features and attendant advantages of the present invention will become apparent to those skilled in the art to which the invention pertains from a consideration of the following detailed description of a presently preferred embodiment thereof, taken in conjunction with the accompanying drawings, in which: 
     FIG. 1 is a simplified block diagram of the prior art arrangement used for executing internal and external program memories, using an MC/MP or EA pin, as described above; 
     FIG. 2 is an exemplary three cycle instruction showing bus contents and related items useful for explaining one advantage of the invention; 
     FIG. 3 is an illustrative embodiment of a single chip processor device having both on-chip and off-chip program memory; and 
     FIG. 4a and FIG. 4b are sequence diagrams useful for describing the technique for writing the SYSCON bit according to the invention. 
    
    
     DETAILED DESCRIPTION OF THE PRESENTLY PREFERRED EMBODIMENT 
     Referring now to the Figures of drawing, consider the illustrative three cycle instruction depicted in FIG. 2, which is useful to point out a significant difficulty encountered with the prior art MC/MP pin, and to aid the understanding of how the technique of the present invention overcomes it. The instruction presented in FIG. 2 is part of a program utilized in a single silicon chip microcontroller with both on-chip memory and off-chip program memory. For the specific exemplary microcontroller to which this applies, the instruction TBLR (table read) transfers data out of the program memory into the data memory for further data processing. This TBLR instruction is a three cycle instruction. The program data bus is approximately one-half cycle behind the program address bus. In the first cycle, the program address bus has a program count corresponding to the table address. The data returned from the program memory corresponding to this address is the TBLR instruction. In the second cycle, the TBLR instruction seeks data from the program memory and, to that end, the address corresponding to that program memory location is put on the program address bus. 
     If the device in which this instruction is executed were to use the prior art MC/MP pin, the state of that pin (logic level &#34;0&#34; or logic level &#34;1&#34;) during the second cycle will determine whether this address points to an internal program memory or an external memory. The state of the MC/MP pin during the first cycle determines whether the TBLR instruction being executed originated in the internal memory or the external memory. The data is retrieved from the program memory onto the program data bus, and put into the data memory. During that operation, the next instruction is fetched to be executed in the cycle. 
     The significance of this three cycle instruction, which is presented solely by way of example, is that it is essential for purposes of faithful execution of the program, to know whether a given address is pointing to an internal (on-chip) memory location or an external (off-chip) memory location. In devices that use an MC/MP pin, the pin can be flipped from a &#34;0&#34; to a &#34;1&#34; in mid-stream during the time that the address is pointing to internal memory. This is tantamount to pirating from a program that is resident in the chip. Such piracy is undesirable since considerable effort is necessary in developing the program. 
     As noted above, the present invention avoids the need to provide a pin-out external to the package for the microcontroller (or any other processor) using both on-chip program memory and off-chip program memory, to switch between the two. According to the invention, a system configuration bit is written to be either &#34;0&#34; or &#34;1&#34; throughout the instruction to be executed. If this SYSCON bit is &#34;0&#34; during the instruction, execution is from the outside program memory, and if it is &#34;1&#34; the execution is from internal memory. 
     In the illustrative embodiment (FIG. 3) a processor chip or controller chip 17 includes an I/O memory 18, a program memory 19 and a data memory 20. The I/O memory and the program memory are partly on-chip and partly off-chip. In essence, each of these memories has a mirror image on- and off-chip, but, in each case, execution relative to locations in the respective memory may take place either on-chip or off-chip, but not both on-chip and off-chip simultaneously. For the sake of example, the I/O memory has eight locations, the program memory has 4,096 locations, and the data memory has 256  locations. The SYSCON bit resides in the I/O memory in the illustrative embodiment. This is not essential, however, the significant aspect being that the SYSCON bit must be in a memory location that is capable of being shared on-chip and off-chip. Otherwise, once the program sequence were shifted or switched from on-chip memory to off-chip memory, or vice versa, there would be no possibility for return. With the SYSCON bit in I/O memory, any suitable instruction may be used to change its value from logic level &#34;0&#34; to logic level &#34;1&#34; or vice versa, to achieve the desired switch between the on-chip and off-chip memory locations according to the program being executed. 
     If the SYSCON bit value change were to take effect immediately, the immediately following instruction will be executed from the opposite memory. For example, if the program is being executed on-chip (with the SYSCON bit being a &#34;1&#34;), and the SYSCON bit is then changed to &#34;0&#34;, the next instruction executed will be from the external program memory. This immediate change may be undesirable because it involves considerable program segmentation. The effect of the SYSCON bit is therefore delayed for a number of cycles which is appropriate for the particular instruction repertoire of the processor of interest, i.e., for the device being used. In the preferred embodiment of the invention, the SYSCON bit is written to a desired value, and two instruction cycles later, the program is shifted to the memory designated by that value. Further, the bit value is held during the execution of each instruction, which is to be contrasted with the situation that exists with the use of an MC/MP pin, where a memory switch could be made in mid-instruction which inevitably leads to program errors. The only method heretofore used to avoid this undesirable operation has been to place a cautionary warning in the instruction manual or data sheet for the device, that the user should not attempt or allow a switch in logic levels for the MC/MC pin while an instruction is being executed. 
     Referring now to FIG. 4a, which illustrates two pages, one of which is on-chip memory 25 and the other of which is external program memory 28, the most effective technique for achieving the holding of the SYSCON bit for the two cycles of the instruction is to write the SYSCON bit and execute a branch (program sequence change), or a call, to a specific location in the other program memory. The branch instructions are then executed in two cycles. 
     In FIG. 4b, utility routines are stored in internal memory 25 and the external program of memory 28 varies from application to application. When the application program desires to perform a task that requires a utility program to cycle inside the on-chip memory 25, it writes the SYSCON bit to &#34;1&#34; and then calls the routine in that memory. The routine performs its task, such as supplying dial tone for a telephone, and, at the end of the routine, writes the SYSCON bit to &#34;0&#34; and does a return to the external program 28. This is the point at which the external program was exited, so the application program may now continue from that point. This is an efficient utilization of the on-chip memory, and provides flexibility for different application programs. 
     It will be understood from the foregoing specification, then, that the present invention is significant in at least two respects; namely, that switching between on-chip memory and off-chip memory is achieved without need for using a special pin on the device package, and that there is no possibility of such switching occurring in mid-instruction with attendant errors in execution. 
     Although a presently preferred embodiment of the invention has been described, it will be recognized by those skilled in the field to which the invention pertains from reading the foregoing description, that variations and modifications of the preferred embodiment may be made without departing from the true spirit and scope of the invention. It is therefore desired that the invention shall be limited only as and to the extent required by the appended claims and the rules and principles of applicable law.