US 4,471,426 AGrant
Microcomputer Which Fetches Two Sets of Microcode Bits at One Time
Issue Date:1984-09-11
•23 Claims
•35 Drawing Sheets
Abstract
A microcomputer device contains a CPU with an arithmetic/logic unit and data/address registers on a single semiconductor integrated circuit having on-chip macrocode and microcode storage. A macrocode word is fetched from an on-chip ROM and stored in an instruction register in the CPU, then a sequence of microcode words is fetched from microcode store based on this macrocode word. In some machines, microcode for two states is fetched at one time, and then applied to the ALU register and bus controls in the next two successive cycles. In this manner, the microcode store can be the same as macrocode store.
Metadata
Assignee
- Texas Instruments Incorporated
Inventor
- Kevin C. McDonough
Application Information
Application Number:US 2800225
Filing Date:1981-07-02
Priority Date:1981-07-02
Art Unit:237
Classifications
IPC:
G06F 922
Field of Search:
364200 MS File;900 MS File
Patent Drawings (35 sheets)
Description
Related cases: This application discloses and claims subject matter also disclosed in copending applications Ser. No. 280,034, Ser. No. 280,049, Ser. No. 297,924, Ser. No. 279,902, Ser. No. 280,588, all filed herewith and assigned to Texas Instruments.
BACKGROUND OF THE INVENTION
This invention relates to integrated semiconductor devices and systems, and more particularly to features used in an electronic digital processing system of the single-chip microprocessor or microcomputer form.
A microprocessor device is a central processing unit or CPU for a digital processor which is contained in a single semiconductor integrated circuit, usually fabricated by "MOS/LSI" technology, as shown in U.S. Pat. No. 3,757,306 issued to Gary W. Boone and assigned to Texas Instruments. The Boone patent shows an 8-bit CPU on a chip including a parallel ALU, registers for data and addresses, an instruction register and a control decoder, all interconnected using a bidirectional parallel bus. U.S. Pat. No. 4,074,351, issued to Gary W. Boone and Michael J. Cochran, assigned to Texas Instruments, shows a single-chip "microcomputer" type device which contains a 4-bit parallel ALU and its control circuitry, with on-chip ROM and RAM for program and data storage. The term microprocessor usually refers to a device employing external memory for program and data storage, while the term microcomputer refers to a device with on-chip ROM and RAM for program and data storage; the terms are also used interchangeably, however, and are not intended as restrictive as to this invention.
Subsequent to 1971 when U.S. Pat. Nos. 3,757,306 and 4,074,351 were originally filed, many improvements have been made in microprocessors and microcomputers to increase the speed and capability of these devices and reduce the cost of manufacture, providing more circuitry in less space, i.e., smaller chip size. Improved photolithographic techniques allow narrower line widths and higher resolution, providing added circuit density, but circuit and system improvements also contribute to the goals of increased performance with smaller chip size. Some of these improvements in microprocessors are disclosed in the following U.S. Patents, all assigned to Texas Instruments: U.S. Pat. Nos. 3,991,305 issued to Edward R. Caudel and Joseph H. Raymond Jr.; 4,156,927 issued to David J. McElroy and Graham S. Tubbs; 3,934,233 issued to R. J. Fisher and G. D. Rogers; 3,921,142 issued to J. D. Bryant and G. A. Hartsell; 3,900,722 issued to M. J. Cochran and C. P. Grant; 3,932,846 issued to C. W. Brixey et al; 3,939,335 issued to G. L. Brantingham, L. H. Phillips and L. T. Novak; 4,125,901 issued to S. P. Hamilton, L. L. Miles, et al; 4,158,432 issued to M. G. VanBavel; 3,757,308 and 3,984,816.
Additional examples of microprocessor and microcomputer devices in the evolution of this technology are described in publications. In Electronics, Sept. 25, 1972, p. 31-32, a 4-bit P-channel MOS microcomputer with on-chip ROM and RAM is shown which is similar to U.S. Pat. No. 3,991,305. Two of the most widely used 8-bit microprocessors like that of U.S. Pat. No. 3,757,306 are described in Electronics, Apr. 18, 1974 at pp. 88-95 (the Motorola 6800) and pp. 95-100 (the Intel 8080). A microcomputer version of the 6800 is described in Electronics, Feb. 2, 1978 at pp. 95-103. Likewise, a single-chip microcomputer version of the 8080 is shown in Electronics, Nov. 25, 1976 at pp. 99-105 and a 16-bit microprocessor evolving from the 8080 is described in Electronics, Feb. 16, 1978, pp. 99-104. Another single-chip microcomputer, the Mostek 3872, is shown in Electronics, May 11, 1978, at pp. 105-110. An improved version of the 6800 is disclosed in Electronics, Sept. 17, 1979 at pp. 122-125, while a 16-bit microprocessor identified as the 68000 which evolved from the 6800 is described in Electronic Design, Sept. 1, 1978 at pp. 100-107.
The technology of integrated circuit design and manufacture has progressed to a point where virtually any electronic system having digital processing or control functions can employ a microcomputer or microprocessor chip. The cost of designing and manufacturing the devices is a limiting factor, however. Semiconductor manufacturing is oriented toward production of large quantities of a single device type, rather than production of a few of many different specialty items, and so to be economical a chip design must be adaptable for a wide variety of uses, not only by changing the ROM code but also by providing many input/output options and similar features. Thus, a device as in U.S. Pat. No. 3,991,305 has been manufactured in quantities of millions of units for many different electronic calculators, electronic games, appliance controllers, and the like. Not only the semiconductor manufacturing cost is minimized by use of the same device, but also the design cost is minimized because very little circuit design is needed (only external to the chip) and the programming effort employs an instruction set and commonly-used subroutines and algorithms in which a high level of experience is acquired. Nevertheless, the design cost for using a microcomputer device in a new application may be prohibitive even though only assembly language programming is needed, this software cost is unduly high because of the number of different and incompatable programming languages used on the wide variety of device types.
It is the principal object of this invention to provide an improved microcomputer or microprocessor device which is adaptable for a wide variety of uses but yet is constructed to facilitate low-cost manufacture and to minimize programming costs.
Another object is to provide a microcomputer device that is more flexible in the variety of different uses that can be programmed into a standard chip type. In particular, it is an object to provide a microcomputer device, in which the amount of microcoding employed in instruction execution can be varied without changing any masks in the manufacturing process other than a gate mask.
SUMMARY OF THE INVENTION
In accordance with one embodiment of the invention, a microcomputer device is provided in which the "user" ROM is combined with the "control" ROM. The user ROM ordinarily contains the program written in macrocode and the control ROM ordinarily contains the microcode used to execute the macrocode. This combined ROM containing both macrocode and microcode is addressed in two ways; first the program counter and memory address registers used to access the logical address space via address busses can access the combined ROM, and second the entry point circuitry used to generate control ROM addresses can access this combined ROM. In one form, the Y decoders are separate because the macrocode output from the combined ROM is one byte wide whereas the microcode output is about six to eight or more bytes wide. For memory access cycles to the combined ROM address space, controls are generated which select either macrocode or microcode output; the controls can be generated from the current microcode output, for example. By combining the macro and microcode in a single ROM, the amount of microcoding of the particular device can be selected for optimum execution speed, customer programming ease, security, or other factors. The amount of microcode could vary from a standard microinstruction set all the way to virtually 100% microcode, i.e. many complex macroinstructions in a greatly expanded instruction set. Also, at the low end, almost no microcoding could be utilized, providing few microcode states for each macrocode, i.e., a simple macroinstruction set.
The combined macrocode and microcode memory may be a RAM instead of a ROM, so the user could down-load microcode as well as macrocode from external disc, tape or ROM, or via phone lines, to define the system functions according to his immediate job. Or, different instruction sets may be used during different parts of a job. A terminal may be microprogrammed at one point to do floating point or BCD arithmetic, then at another point to do move-double type instructions for efficient data transfer, for example.
An important feature of the invention is that the microcode can be accessed in byte-wide sections by the memory data bus for ALU operations or transfer to external. That is, the microcode stored in the combined ROM can be applied to the ALU temporary registers or written to the external ports, one byte at a time. This is very useful for test purposes. Otherwise, the only way to test the microcode is to execute every possible function to see if the correct result is obtained.
BRIEF DESCRIPTION OF THE DRAWINGS
The novel features believed characteristic of the invention are set forth in the appended claims. The invention itself, however, as well as other features and advantages thereof, will be best understood by reference to the detailed description which follows, read in conjunction with the accompanying drawings, wherein:
FIGS. 1A and 1B are electrical diagrams in block form of an MOS/LSI microcomputer chip including CPU, ROM and RAM and utilizing features of the invention;
FIG. 2 is a memory map for the logical address space for the microcomputer of FIG. 1 and FIGS. 2a-2c are detailed memory map like FIG. 2 for the peripheral page for microcomputer and expansion modes;
FIG. 3 is a greatly enlarged plan view of the semiconductor chip containing the microcomputer of FIG. 1 showing the physical layout of the various parts of the device;
FIG. 3a is an enlarged detail view of a part of the layout of FIG. 3 showing the regular pattern of the ALU and register strip;
FIG. 3b is a pictorial view of the microcomputer chip of FIG. 3 mounted in a 40-pin dual-in-line package;
FIG. 4 is a timing diagram showing voltage vs. time for various events in operation of the system of FIG. 1;
FIG. 4a is a timing diagram like FIG. 4 for a macrocode access cycle;
FIG. 5 is a detailed electrical diagram of the CPU, including ALU, shifter S, registers and busses, in the microcomputer of FIG. 1;
FIG. 6 is a detailed electrical diagram of the combined user ROM and control ROM used in the microcomputer of FIG. 1;
FIG. 6a is a detailed electrical diagram of the combined memory according to another embodiment;
FIG. 6' is a detailed electrical diagram of the combined memory according to another embodiment;
FIG. 7 is an electrical diagram of the group decode and memory control circuitry of the system of FIG. 1;
FIGS. 8a-8j are a logic flow chart of the execution of the microinstructions of Tables B and C in the system of FIG. 1;
FIG. 9 is a map of macroinstructions for the example instruction set of Table A;
FIGS. 10a-10c are electrical diagrams of systems using the microcomputer of FIG. 1;
FIG. 10d is a timing diagram for operation of the systems of FIGS. 10b or 10c;
FIGS. 11a-11b are logic flow charts for execution of a keyscan routine in the system of FIG. 10; and
FIG. 11c is an electrical diagram of the system using the program of FIGS. 11a and 11b.
DETAILED DESCRIPTION OF SPECIFIC EMBODIMENT
The Microcomputer Chip
With reference to FIG. 1, a microcomputer chip 10 is shown which employs features according to one embodiment of the invention. The chip 10 is a semiconductor integrated circuit of the MOS/LSI type including a silicon bar of less than about 200 mils on a side, mounted in a standard 40-pin package. Totally contained within the chip 10 is a digital processor having a combined user ROM and control ROM 11 according to the invention. This ROM or read-only memory 11 is used both for program storage and for microcode storage. A RAM or read/write memory 12 is used for data storage. The chip includes a CPU 13 which consists of an arithmetic logic unit or ALU 14 with its working registers 15 and busses 16, along with the control ROM output of the ROM 11 which generates microinstructions or control signals on lines 18. The CPU 13 accesses the ROM 11 and RAM 12 by three busses: a memory data bus MD, a high address bus AH, and a low address bus AL, along with three of the control lines 18. In addition, a microaddress bus uA accesses the ROM 11 for microcode fetch. Communication with devices external to the chip is by means of four memory-mapped 8-bit ports A, B, C and D which are accessed by the MD bus and activated by control circuitry responsive to the AH and AL addresses. In this embodiment, the MD, AH and AL busses are each eight bits wide, as are the ALU 14, the registers 15 and the ports, although of course concepts herein described would be applicable to 4-bit, 16-bit or 32-bit devices, for example.
The registers 15 in the CPU 13 include an instruction register IR, a status register ST; a shift circuit S which receives the output of the ALU 14, a register T/MAH which functions as both a temporary store for operands and for the high order byte of the memory address (memory address high), a sixteen bit program counter split into two eight bit registers PCH and PCL (program counter high and low), a stack pointer SP, and a memory address low register MAL. Address buffers 19 generate true and complement address signals on busses AH' and AL' from the address busses AH and AL. Operands are for the most part stored in the RAM 12 which functions as a register file RF, rather than in temporary registers 15 associated with the CPU 13.
The busses 16 interconnect the various registers 15, and ALU 14 and MD, AH' and AL' busses. The ALU 14 always receives a P input from a P bus and an N input from an N bus, and produces an output via shifter S to an output or O bus. Access to these P, N and O busses 16, to the registers 15 and ALU 14, and to the MD, AH and AL busses is controlled by the microcode, i.e. control signals 18 from the ROM 11.
The microcomputer chip 10 operates on the basis of 8-bit macroinstruction words stored in the ROM 11 and transferred to the instruction register IR one at a time. One of many possible examples of a macroinstruction set executed in the CPU 13 is described in Table A. The Table gives the instruction word in mneumonics, also referred to as assembly language or source code, and also gives the machine-language opcode in binary (this is like object code except object is in hex). Usually an opcode plus one or more address bytes are used to execute an instruction. An instruction word or opcode held in IR is an input to an entry point circuit 21 which produces an 8-bit address on micro address lines uA coupled to address circuitry 11x and 11y' for the ROM 11, accessing one of 256 possible addresses for the ROM 11 (in the example embodiment) to produce signals 18 defining one of the microinstructions such as set forth in the example of Tables B and C. One macroinstruction of Table A produces a sequence of microinstructions. A part of each of the microinstructions (i.e. some of outputs 18) is used to generate the next uA address for the ROM; a microjump address is fed back to the entry point circuit 21 via lines 23, and dispatch control information is fed back via lines 24. Thus, a sequence of microinstructions is generated from each macroinstruction loaded into IR; the sequence is also dependent upon status bits in the status register ST and other conditions. Addresses for operands, if needed, are contained in macrocode words from ROM 11 following the opcode and are transferred to MAL or MAH while the opcode stays in IR during this sequence of microcode states. Each address applied to the combined ROM 11 produces either a microcode output 18 via Y decode 11Y' or a macrocode output via Y decode 11Y to memory data bus MD. The CPU cannot access both macrocode and microcode in the same machine state.
A map of the logical address space for the microcomputer of FIG. 1 is shown in FIG. 2. The example embodiment employs 8-bit AH and AL addresses, providing a 16-bit address, and so 2.sup.16 or 65,536 bytes are available in this space (often referred to as "64K" bytes where one "K" is 1,024). The addresses are shown in four hexidecimal digits, ranging from the first address 0000 to the last FFFF. In this description memory addresses will be given in hex, unless noted. A page is 2.sup.8 or 256 bytes, i.e. all addresses on a page are defined by AL and the page is selected by AH. The microcomputer 10 uses the zero page (addresses 0000 to 00FF) for the register file RF in RAM 12, the "one" page (addresses 0100 to 01FF) for the peripheral file PF, and the F0 to FF pages (addresses F000 to FFFF) for the combined program and microcode memory, ROM 11. Macrocode is 8-bits wide, while microcode in this example is about eight bytes or 64-bits wide, so each address for microcode occupies eight bytes in the map of FIG. 2. Thus, if 256 microinstructions are needed, this will occupy 2048 bytes or 16K bits of the ROM 11. For the example instruction sets, it will be assumed that micro addresses 00 to FF are used for microcode (corresponding to macro addresses F000 to F7FF) and the remainder of the address F800 to FFFF used for macrocode. Some of the alloted spaces for RF and ROM 11 may not be populated, depending upon the size of the ROM and RAM chosen. Other space such as 0200 to EFFF is available for the expansion modes as set forth in copending application Ser. No. 253,624, filed Apr. 13, 1981.
Although not related to this invention and thus not described in detail herein, a microcomputer such as that of FIG. 1, includes control circuitry responsive to the AH' and AL' busses and control bits 18 to define the way in which the CPU 13 accesses the peripheral file PF including external ports, a timer/event counter, reset and interrupt functions. An I/O and interrupt control register at a memory location 0100 of FIG. 2 is loaded directly by the MD bus would be part of the ALU/register strip; this register may contain two memory mode control bits to define memory expansion modes, as well as interrupt masks and flags. A programmable timer and event counter may also included in this peripheral control circuitry, accessed by the MD bus and eight bits wide, advantageously constructed as part of the ALU/register strip.
In this peripheral control circuitry, a group decode circuit 27 and memory control circuit 28 receive the AH' and AL' address bits and three control signals 18 (#MEM, #WR and #MEMCNT) and produce controls which select between the ROM 11 (microcode or macrocode), RAM 12, ports A, B, C or D, etc. for access by a given address. Only one of these is activated in any one cycle.
Two or more interrupt input pins INT usually are provided, in addition to a timer interrupt. These INT inputs are connected to interrupt control circuitry 29 which is also responsive to other conditions on the chip. A reset input RST is used to zero or initiallize the microcomputer, overriding any function or interrupt, as is conventional. Microinterrupts may be included as explained below.
The peripheral control circuitry provides a selection of the operating modes defined by the internally-loaded bit-7 and bit-6 of the I/O control register 0100. The address space of FIG. 2 is configured in unique ways for these modes although the register file address space RF remains the same for all modes. The modes are: (1) single-chip microcomputer mode of FIG. 2a where all memory is on-chip in the ROM 11 and RAM 12; (2) a peripheral expansion mode of of FIG. 2b where some additional off-chip circuitry may be accessed in the PF space via ports B and C; or (3) a full expansion mode of FIG. 2c where about 61K bytes of off-chip memory may be accessed by ports B and C, the RF and ROM 11 being the same as FIG. 2. Other modes are available as explained in application Ser. No. 253,624, assigned to Texas Instruments. The various modes allow a wide variety of different functions to be provided by one basic chip type without design, layout or microcode modifications, thus greatly reducing the cost. Input/output buffers 30 connect the ports A, B, C, D to the the MD bus, as defined by direction control registers P7, P9, P11 (FIG. 2a), for some modes and by the mode control arrangement via group decode 27 and memory control circuitry 28. The buffers 30 include data registers at P6, P8, P10 and P11, accessed by the MD bus.
THE STRIP ARCHITECTURE
In FIG. 3, the microcomputer of FIG. 1 is illustrated in chip layout form. A major part of the area of the chip 10 is occupied by the memory including the combined ROM 11 and RAM 12 with their address decoders. The ROM 11 has associated with it a combined X address decoder 11X and separate Y address decoders 11y and 11y' for macroinstructions and microcode; twelve address bits are used to define one of 4096 eight-bit bytes in the ROM 11, so an address for the ROM 11 needs both the MAL and MAH registers, i.e., address bits from both AL and AH busses for macroinstructions access. In one example, microcode access via uA would require only one page or 256 locations, accessed by an 8-bit address, although additional address space may be added by increasing the uA address width; a 9-bit uA would access 512 locations, for example. The RAM has an X address decoder 12X which selects 1-of-32 row lines, and a Y address decoder 12Y which selects 1-of-4 column lines, so only seven bits are needed for the RAM select (eight if a 256 byte RAM is used).
A primary feature is that the number of microcode states may be varied without a new chip design, layout, mask-making and production effort. In the example, the ROM 11 is 4096.times.8 or 32K bits in size. If fully populated, when an 8-bit microcode address uA is used, the number of bits in the ROM 11 used for microcode would be 256 times the number of output lines 18. Sixty-four output lines 18 are used for the example instruction set of Table A, and 256 microinstruction addresses or states are reserved (although in one example like in Tables B and C less than 150 are needed), so the microcode part of the ROM is 256.times.64 or 16K bits. The remainder is available for macrocode (32-16K=16K bits or 2K bytes).
The output ports A, B, C, and D each have eight bonding pads on the chip (total of thirty-two) for connection to external, and the areas of the chip around these bonding pads seen in FIG. 3 are occupied by the buffers 30 used for the ports. It will be noted that the port A is only used for input, so the space needed for the input buffers for this port is much less than for the remaining ports B, C, and D which require tri-state output buffers.
Between the RAM 12 and the microcode buffers 11b on the chip 10 of FIG. 3 is the "strip" which is an array of rows (parallel to control lines 18) and columns (parallel to metal bus lines 16 and ALU/register bits 14, 15) containing all of the 8-bit registers, ALU bits, and like circuitry associated with the busses 16 and control lines 18. As set forth in prior application Ser. No. 210,109, filed Nov. 24, 1980 by McDonough and Guttag, assigned to Texas Instruments, an important feature is that the ALU 14 and its associated registers IR, ST, S, T/MAH, PCH, PCL, SP, and MAL as described above are laid out on the MOS/LSI chip 10 in a regular strip pattern as seen in FIG. 3. Other circuitry connected to the busses and having controls 18 shared by eight bits is also in the strip, such as entry point 21 and, address buffers 19. Each of these registers as well as the ALU contains eight bits or stages which are laid out in a pattern like memory cells, the bits arranged horizontally and alligned vertically as seen in FIG. 3. The MD, AL, AH, O, N and P busses of FIG. 1 are each eight parallel metal strips on top of the cells of the ALU and registers (rather than beside the registers as depicted in FIG. 1), and all of the dozens of control lines 18 are horizontal polysilicon lines typically used as the control gates for transistors in the ALU 14 and its registers and like circuitry. The number of control lines 18 needed for the ALU 14 is greater than for a single register such as the MAL register, for example, and conveniently the space needed to lay out the ALU stages is greater than for a single register, so waste space in minimized. That is, the space needed in the control ROM 17 to generate the controls 18 is about the same as the space needed for the controlled circuitry. This layout arrangement is indeed advantageous because the ALU and registers fit alongside the control ROM with virtually none of the wasted space used merely for routing conductors in conventional construction of microprocessors. All bus lines MD, AL, AH, O, N and P, and all control lines 18 are routed over functional regions or cells of the chip rather than over unused silicon, and almost all 90 degree turns are produced inherently at functional cells rather than in conductor routing. In the prior devices, the control ROM, the registers, the ALU, etc., were islands of circuitry connected by busses or conductors. The enlarged view of FIG. 3a shows a small part of the strip, two-bits wide, illustrating the metal bus lines and the polysilicon control lines 18 for an N-channel silicon gate MOS device made generally by a single-level polysilicon process according to U.S. Pat. No. 4,055,444, assigned to Texas Instruments. Various contacts (not shown) would be made within each register bit or stage from metal to silicon or to polysilicon. It is significant to note that most of the connecting lines from registers to busses illustrated in FIG. 1 are not physically lines or elongated conductors at all but instead are merely metal-to-silicon or metal-to-poly contact areas along the metal bus lines of FIG. 3a. That is, routing of 8-bit sets of parallel conductors is minimized by the strip feature, and the size of the chip 10 is reduced. The busses 16 are staggered so that all six busses are not needed in any one part of the strip, and thus the pitch or maximum width of cells of the strip is minimized since the metal-to-metal spacing is a critical limiting factor in bit density. To this end, the placement of the registers 15 is such that the N bus need not co-exist in any register with the AL or AH busses, and the P bus ends where the AL bus starts, as illustrated in FIGS. 1 and 3a. Some of the clocks needed in the registers and ALU of the strip are run in metal lines like the busses 16 (H1 and H4 are shared by adjacent cells in FIG. 3a) so these place further constraints on the density and make the strip concept and bus/register optimum placement more significant. Connections from MD to P or N busses are made by transistors located in the strip like a register and labelled MDtP, MDtN; since this logic requires eight parallel bits of transfer gates, tied to sets of eight parallel busses, and using CROM outputs 18 as controls, it fits well in the strip.
The ROM 11 fits alongside the strip to provide the microcode controls 18 in the control-intensive areas of the ALU and register/bus connections, and alongside the entry point circuit 21 where the address control and jump address lines 23, 24 are needed. The design is oriented toward the ROM 11 as the source of all controls rather than employing random logic for this purpose, and the chip layout of FIGS. 3 and 3a illustrates that the area of the chip is dominated by the RAM and combined ROM with their decoders, plus the strip containing a regular array of ALU/register bits, with little space occupied by other control logic. This design approach is enhanced by and enhances the microprogramming facility which makes the microcomputer 10 particularly easy to modify by changing the micro and macrocode, or changing the partitioning of the ROM 11 between micro and macrocode.
The microcomputer 10 may be modified at four levels, plus the mode control. The first level is changing the macro code or program in the ROM 11, and of course this is the most widely practiced modification. The macro code is defined by a single mask in the manufacturing process as set forth for example in U.S. Pat. Nos. 3,541,543, 4,208,726 or 4,230,504, assigned to Texas Instruments. By rewriting the macrocode, keeping the microinstruction and macroinstruction sets the same, a wide variety of different functions and operations are available. As the second level, the macroinstruction set of Table A may be supplemented (keeping the same microinstruction set of Tables B and C and adding some microinstructions), by using more of the ROM 11 for microcode store. The microcode in the ROM 11 is defined by a single mask in manufacture, the same mask that defines the macrocode, so physically it is just as easy to change the macro or microinstruction sets; however, the macro assemblers and micro assemblers (computer programs used as design aids for customers) then are different. A micro assembler can be written for all likely useful microstates, then only a selected number (256 or less in this example) chosen for a given version. In addition to these ways of altering the device 10, of course, the size of the ROM may be increased to allow more complex algorithmns to be programmed, utilizing the ROM for additional microcode or macrocode. The main feature of the invention, however, is that the ratio of micro to macrocode in ROM 11 may be changed to provide more or less complex micro- and/or macro-instruction sets.
SYSTEM TIMING
The microcomputer chip 10 operates from a basic clock frequency referred to as Xtal in FIG. 4. This frequency of about 5 MHz is supplied by an internal oscillator 33 controlled by an external crystal coupled to two pads labelled Xtal in FIG. 1 or 3. From the clock Xtal, clock generator circuitry 33 produces four basic overlapping half-cycle clocks H1, H2, H3 and H4 for each microinstruction cycle or state time S1, S2, etc., as seen in FIG. 4. Each state time equals two complete cycles of the clock Xtal. H4 overlaps two state times. Quarter cycles Q1, Q2, Q3 and Q4 are also defined in each state time.
Access to the RAM 12 occurs concurrently with the microcode accesses from the ROM 11. Short memory cycles to access the RAM 12 are completed in one state time such as S1 of FIG. 4; the control #MEMCNT is low and all bits of the AH bus are low during H1, and the RAM address is valid on the AL bus while #MEM is high. The write control #WR is high for write or low for read. The data accessed is then valid on the MD bus during H4 at the end of the cycle, extending over into the beginning of the next cycle, so the data may be loaded into the registers T or IR at the end of a cycle or gated onto the P or N busses at the beginning of the next cycle. All memory references to the register file RF in the RAM 12 use this short cycle.
All other memory references (i.e. to the on-chip ROM 11 for macrocode, the peripheral file PF, and extended memory in expansion modes) require two microinstruction cycles and are called along memory cycles as illustrated in FIG. 4. For long cycles, the memory continue command #MEMCNT is high during the first state time and low during the second. The memory command #MEM must be high during H1 of both cycles, and the address valid on AH and AL during H1 of the first cycle. For read, the write command #WR is low from the beginning of the first cycle through H1 of the second, and the data is valid during H4 beginning at the end of the second cycle. For long write, #WR is high, and the write data is gated onto the MD bus for H4 of both first and second cycles.
Within a given state time or microinstruction cycle, the address on the AH' and AL' busses becomes valid during H2. This address is based on the address loaded onto AH and AL during H1. In the ROM 11, the array is precharged during Q1 with all row or X lines going to Vss and all column or Y lines going to Vcc, then the ROM X address is gated into the array from decoder 11X beginning at Q2 and the ROM Y address coming valid at the beginning of Q2, so the ROM output is valid by Q4, either microcode or macrocode.
In executing the macroinstruction set of Table A, typically from five to ten microcode states such as S1, S2, etc., are needed for an instruction such as add, move, compare, and the like, depending upon the addressing mode, while multiply or divide require many more microcode states.
As seen in FIGS. 4 and 4a, the timing for microcode access to ROM 11 is different during a macrocode fetch. During short memory cycles and all other machine cycles except for macrocode fetch, a GROM' command is asserted (MUXCNTL is low) and the decoders for the ROM 11 accept the uA address which was generated in entry point circuit 21 in the prior cycle. This is illustrated in the center of FIG. 4 and in FIG. 4a. The GROM command does not occur and the address from AH, AL does not activate the ROM 11 decoders 11x, and no output reaches MD via latches 11c. However, if #MEMCNT and an AH address in the F0 to FF pages occurs, a MUXCNTL and a GROM command are asserted and the decoders 11x and 11y accept the AH', AL' address; this means a long memory cycle for macrocode fetch is occurring so the microcode access is modified as shown at the bottom of FIG. 4 and in FIG. 4a. The micro address uA output from entry point circuit 21 generated in the last cycle is valid during Q2 of the state previous to S1 and is gated into the ROM 11 decoders by GROM' during Q4 when MUXCNTL is low, producing the microcode output on lines 18 for executing in the S1 state. The address for the macrocode to be fetched becomes valid by Q2 on AL, AH and is latched in buffers 19. The micro address uA to be produced by this state S1 from lines 23, 24 is valid at S1Q1 to S2Q4 and is held by maintaining the lines 23, 24 valid by latching in the buffers 11b due to the absence of a GROM' command, as seen in FIGS. 4 and 4a. This latched uA is used beginning at S2Q1 for the microaddress for the S3 state. During S2, the ROM 11 is accessed for the macrocode at the address produced on AL, AH during S1. The macrocode data is latched in an 8-bit latch 11c during S1, and the latch produces an 8-bit macrocode output to MD bus when GROM is asserted at S2Q4. The microcode executed in S2' of the macrocode fetch cycle is generated in response to microcode from state S1, and will usually increment PCH, and either load the data coming via MD from ROM 11 into IR or T, or else leave it on MD for use in the next state S3 as an address on AH or AL; this S2' microcode is fetched during S1 at the same time as the fetch of microcode for S2.
THE CPU
The CPU 13 in the microcomputer 10 of FIG. 1 consists of the ALU 14, the registers 15 and the busses 16 controlled by the microcode output of the ROM 11. In FIG. 5 a more detailed block diagram of the ALU and shifter S and the associated busses is shown, and FIG. 6 shows the ROM 11 and its microinstruction output bits 18. Control of the ALU and access to the busses is defined entirely by these microinstructions or bits 18, identified in FIG. 6 for the illustrative embodiment. An 8-bit micro address on lines .mu.A from the entry point circuitry 21 contains a 6-bit X address on lines 21X going to the X decoder 11X via a multiplex circuit 11m, and also contains a 2-bit Y address on lines 21Y going to Y decoder 11y'. The X decoder 11X in the example selects one of 64 of the X lines in the array of ROM bits of the ROM 11. The Y decoder 11Y' selects 1-of-4 in each group of four Y lines (up to sixty-four groups available). Thus, for each 8-bit address on lines .mu.A, a different "microinstruction" is output on the lines 18; a microinstruction may have any number of the lines 18 active, but usually a combination of only a few lines 18 is active for a given microinstruction. Each line 18 goes to a buffer 11b to drive a higher capacitance load than the array output Y line itself would allow, and to clocked gates and other such logic as needed. All microinstruction bits (control lines 18) in FIG. 6 and elsewhere in this description are referred to with a prefix "#". Some bits are active low and thus have a minus sign prefix, like #-OtST. In the microinstruction bits of FIG. 6, the letter "t" means "to", so #-OtST means "O bus to ST register", i.e., the gates connecting the O bus to the status register are activated by this bit. The eight bit jump address on the lines 23 is denoted #JmpAddr (7-0), while the 3-bit jump control on the lines 24 used for dispatch addressing is denoted #JmpCntl (2-0); these eleven bits are used in the entry point circuit 21 to generate the next micro address .mu.A. All of the twenty bits 18 from #OtPCH down to #ONEtAH in FIG. 6 control the access to registers 15 from busses 16. Of these, #LowWrite0 and #LowWrite1 are decoded to produce pseudo-microinstructions OtPCL, OtMAL and OtSP. The bits #ONEtAL and #ONEtAH place a "1" on the AL or AH busses to generate the B register address 0001 or the PF page address 0100 (hex) in a microinstruction. Default to all 0's on AL and AH is the A register address in the register file. Connections between registers 15 and busses 16 are described in more detail below. The #MEMCNT bit is a "memory continue" control for long memory cycles; the RAM 12 can be accessed for read or write in one state time, but macrocode from the ROM 11 or access to peripherals in PF use two states, so for this reason control line #MEMCNT is active in the first state of every long memory cycle as seen in FIG. 4. #MEMCNT is used to form several other control signals, and always identifies the first or second state of a long memory cycle. The #MEM bit signifies a memory cycle and is active whenever ROM 11, RAM 12 or external memory is accessed. The #WR bit is a write command, so if #MEM and #WR are active a memory write condition exists, while if #MEM is active and #WR is not, a memory read condition exists. The #-LST signal is a load status command for ALU operations; the status register ST can also be located from the O bus by the #-LST command. The ALU is controlled by nine bits labelled #ShiftCntl (3-0), #AluCntl (3-0) and #ABL; these controls will be described below in more detail.
The microinstruction bits 18 are physically arranged in the order used in the strip and not necessarily in the order shown in FIG. 6, so that a control bit 18 is generated as close as possible to the point it is used in the strip.
As seen in FIG. 6, the microcode output includes microcode #uC bits such as #PCHtP', etc., which are applied to a buffer circuit 11b' which delays one state to generate the bits needed for microcode in the second state of a macrocode fetch (S2' in FIG. 4a). These bits are output from buffer 11b' on lines 18b and are the same as some of the bits 18. The second state of a macrocode fetch almost always does one of three things:
(1) the opcode part of the upcoming instruction is loaded into IR and PCH is incremented;
(2) an address byte is loaded onto MD for use via AH or AL during the next state, and PCH is incremented; or
(3) the byte accessed from ROM 11 via MD is loaded into T register for use in a later machine state, and PCH is incremented.
To increment PCH, the ALU and micro carry controls are generated as explained below; very few active #.mu.C bits are needed from buffer 11b' because virtually all of the bits 18 are zeros to define the necessary microcode. These operations are illustrated in the microinstruction sequences of Table C by the IAQ-0, IAQ-1 set, as well as BtoPPL-0, BtoPPL-1 and ItoA-0, ItoA-1, for example.
The part of the ROM output buffer 11b receiving lines 23 and 24 is latched to hold the micro address .mu.A for one state time whenever a GROM' command is asserted; thus, the next address generated from lines 23, 24 in S1 is held until the end of S2 to be used at the beginning of S3. The GROM' command is generated from the microcode bit #MEMCNT and the AH' bits.
FIG. 6 further shows an 8-bit constant output #C (7-0), and a #CtN command to apply the 8-bit constant to the N bus. This constant function is not used in the microinstructions of Table C, but could be used in place of immediate fetches for offsets and the like.
The microinstruction control of access to the registers 15, busses 16 and ALU 14 will now be described in reference to FIGS. 5 and 6.
P Bus
The P bus is one of the inputs to the ALU 14. It is called `P` for "Positive", because in a subtract operation where the ALU 14 only computes P-N the P bus contains the positive, or left-hand, operand. Referring to FIG. 5, the P bus is loaded from the MD bus via sets of eight each of transistors 16a, 16b, and 16c, loaded from the AL bus via transistor 16d (FIG. 5), loaded from the PCH register via transistor 16e, or from the PCL register via transistor 16f. Any of the AL bus sources may be placed on the P bus by gating them on the AL bus and asserting the #PAL microinstruction bit going to the gates of transistors 16d, connecting the P bus to the AL bus. If no source is specified, i.e., "default", the P bus assumes the value of all zeros. The P bus is loaded in the beginning of a microinstruction cycle, on phase H1. All of the possible P bus sources and the microinstruction bits or outputs 18 needed for each are as follows:
N Bus
The N bus is the other input to the ALU 14. It is called N for "negative", since on the ALU subtract operation it contains the negative, or right-hand, operand. It is loaded from the MD bus via sets of eight transistors 16a, and 16g and 16h, loaded from the T/MAH register via transistor 16i, loaded from the IR register via transistor 16j, the status register ST via transistors 16k, or the 8-bit constant #C (7-0) when #CtN is asserted. It is understood, of course, that there are sets of eight of each of the transistors 16a to 16j, one for each of the eight bits of each bus and each register. Only four transistors in the set 16k are needed. The source of the N bus is indicated directly by a bit in the microinstruction word, as shown below. If the bit is `1`, the source is gated onto the N bus. If no source is specified, the N bus assumes the value of all zeros. The N bus is also loaded at the beginning of a microinstruction cycle, on phase H1.
AL Bus
The AL or address low bus holds the lower eight bits of all memory addresses. This comprises the entire address for references to the register file RF in RAM 12, or the lower byte for references to the peripheral file PF, on-chip ROM 11 and extended memory in expansion modes. The AL bus is loaded during the phase H1. The sources of the AL bus are the MAL register via transistor 16n, the SP register via transistor 16p, or the constant 01 via transistor 16q. The constant is provided to efficiently address RAM location 01 which is the "B" register. If no source is specified, "default", the AL bus assumes the value 00 which is the A register in the RAM.
The AL bus may also be connected to the P bus via transistor 16d by asserting the #PAL microinstruction bit. In this manner, the AL bus sources (MAL, SP, and the constant 01) may be gated onto the AL bus and then onto the P bus to be operated on by the ALU. Likewise, the P bus sources (PCH, PCL, and MD bus contents) may be gated onto the P bus and then onto the AL bus via transistors 16d and #PAL to serve as low order address lines. The MD bus contents moved in this case are those present at the start of the microinstruction. In summary, all of the possible sources of the AL bus are listed below:
AH Bus
The 8-bit AH (Address High) bus contains the high-order byte of the address referenced by the CPU, loaded during H1. It may be loaded with the contents of the PCH register via transistors 16r, the T/MAH register via transistors 16s, or the constant 01 via transistor 16t. The high byte of the program counter is usually transferred to the buffers 19 for use in the memory control and circuitry, and the T/MAH register is used to hold the high byte of other memory addresses for use in a later microinstruction state. The constant 01 is provided to efficiently access addresses in the peripheral file in this embodiment (i.e. page-one addresses of the form 01xx in hex). If no source is explicitly specified in the microinstruction word, "default", the AH bus takes on the value 00; this is useful for referencing the on-chip register file RF in RAM 12. The sources of the AH bus are summarized below:
O Bus
The O or output bus always contains the output of the ALU 14 and shifter S combination. As seen in FIG. 5, the O bus contents may be loaded onto the MD bus via transistors 16u and OtM, or into the PCH, PCL, MAL, or SP registers via sets of eight each of transistors 15a to 15d, respectively. The status register ST is loaded from O bus by the true-low microinstruction bit #-OtST and four transistors 15e. The PCH register is loaded by the true-high microinstruction bit #OtPCH. The load signals for the other destination registers (MAL, PCL, SP) are encoded in the two microinstruction bits #Low-Write(1-0), according to the combinations of #LowWrite(1-0) below:
There is no microinstruction bit that directly loads the MD bus from the O bus, because the MD bus contents are under control of the memory control circuitry by the OtM signal which is asserted on every memory write cycle (on-chip or extended memory), and on the first state of every long memory cycle.
The O bus may be gated onto the MD bus via a set of eight transistors 16u by specifying the appropriate values of the #MEMCNT and #WR microinstruction bits so that OtM will be asserted. The O bus contents may then be loaded into the T/MAH or IR register from the MD bus via transistors 15f and 15g.
In summary, the destinations of the O bus are described below:
The O bus is loaded during phase H4 of the microinstruction cycle. It contains the result of the ALU and shifters operations specified in the current microinstruction.
MD bus
The memory data bus MD is a bidirectional bus that transfers data to and from the CPU 13. Data is valid on MD during phase H4 of the microinstruction cycle, which spans two microinstructions. For example, data may be read via transistors 16b from the MD bus onto the P bus at the beginning of a cycle H1 and the ALU results then loaded back onto MD via transistors 16u at the end of the cycle at H4.
At the beginning of a cycle, the MD bus contents may be loaded on the P or N busses via transistors 16c or 16h, as described earlier. Thus the results of the previous microinstruction (or the data read from memory by it), may be loaded into the ALU 14.
At the end of a cycle, the MD bus may be loaded in one of three ways;
(1) The O bus contents may be gated into the MD bus via transistor 16u and OtM;
(2) The on-chip RAM 12 or ROM 11 may place data onto the MD bus; or
(3) Controls 27, 28 place data onto the MD bus from ports A, B, C or D, or other peripheral file registers, etc.
The MD bus contents are controlled by the memory control circuitry which sends the OtM signal to the CPU to signal loading this bus from the O bus. The CPU 13 requests use of the MD bus by asserting combinations of the #MEM, #MEMCNT, and #WR signals, as outlined above. The group decode and memory control 27, 28 sends signals to the on-chip ROM 11 and RAM 12 and the ports to control their accesses to the MD bus.
The timing of read and write accesses to memory is explained with reference to FIG. 4. For short memory reads, the data on MD bus is available at the end of the same microinstruction cycle that initiated the read. Data on MD may be loaded into the T/MAH or IR registers during that microinstruction by specifying the #MDtT or #-MDtIR bits, respectively, or may be loaded into the P or N bus on the next microinstruction by specifying the #MDtP or #MDtN bits in the next microinstruction. For short memory cycle writes, the O bus data is placed on the MD bus, and the #WR control asserted. For long memory reads, the desired address is placed on the AH and AL lines, and the #MEMCNT command asserted in the first of the two cycles required. At the end of the second cycle, the data is available on the MD bus. By a command "Load Address", LDADDR, the memory address on AL and AH is latched in buffers 19 going to AL' and AH' on the first cycle, and need not be asserted on the second cycle of a long memory cycle. For long memory writes, the address is specified in the first cycle, and the data is placed on the MD bus for the first and second cycles. Table H summarizes the memory controls and MD bus contents.
In summary, the destinations of the MD bus in the CPU 13 are described below:
The MD, P. N, AH, AL and O busses are precharged on H2 or H3 by transistors 16v as indicated.
ALU Operation
The arithmetic logic unit or ALU 14 as seen in block form in FIG. 5 accepts as inputs the values on the P bus and N bus and outputs its result to the shifter S during H4 of every machine state. Its operation is controlled by the #AluCntl(3-0) bits inputted via buffers 17b, and by the #ABL bit, both from the current microinstruction. The ALU operates on the values loaded on the P and N busses during H1 of the current microinstruction, and produces an 8-bit ALU output which is input to the shifter S, and also produces two carry bits. Cout, an arithmetic full byte carry bit, and Dout, a 4th-bit half-carry bit used by decimal adjust circuitry in binary coded decimal operations if BCD circuitry is included. The available operations of the ALU are defined in the Table D.
The carry-in bit Cin of the ALU 14 is specified by the #ShiftCntl(3-0) bits 18 of the microinstruction. For operations requiring no shifting of the ALU contents, #ShiftCntl(3,2) bits are zero and the possible carry-in bits are defined:
The micro carry bit uC is the carry out Cout from the ALU operation of the immediately preceding microinstruction. This is not the same as the shift-out bit Sout from the shifter S operation of the previous microinstruction. The status carry bit STC is the carry bit of the status register ST.
The first section of each ALU bit produces a "generate" and/or a "propagate". The arithmetic carry-out Cout bit from the ALU 14 is generated and/or propagated, depending upon #ABL, and if #ABL=`1` there is a carry-out during an add or subtract operation in the ALU. For the add operation, Cout=1 indicates there was a carry, i.e. the sum of the (unsigned) operands exceed 2.sup.8. For the subtract operation, Cout=0 indicates there was a borrow, i.e., the P operand was lower than the N operand (unsigned). For all other operations (i.e. logical operations), Cout is equal to 0. Cout is sent to the status register ST circuitry for possible loading into STC, the status carry bit.
As an example of ALU operation, an add operation with zero carry in (#AluCntl and #ShiftCntl all zeros) will cause the ALU to calculate the sum of the P and N bus contents. To calculate the difference between the P and N bus contents, #AluCntl=1111 and #ShiftCntl=0001. A `1` must be carried in for this subtract since no borrow was desired. As a complete example, the following two microinstructions read the current byte addressed by the PCL and PCH registers, place it in the T/MAH register, and increment the PCL and PCH registers:
First Microinstruction Cycle (Macrocode Fetch S2 of FIG. 4a):
Second Microinstruction cycle (S2' in FIG. 4a; Microcode generated by #.mu.C bits in previous micro cycle):
Notice that an increment was done in the first cycle by using an ALU carry-in of `1`. The second cycle incremented the high byte of the program counter in PCH only if the micro carry bit (uC) generated in the first cycle was `1`. Only six positive bits 18 are generated by #.mu.C bits for the second cycle.
Shifter Operation
The shifter S of FIG. 5 performs a variety of 1-bit shift operations on the 8-bit output of the ALU 14. The #ShiftCntl(3-0) bits on control lines 18 to the ALU control the following entities:
(1) the ALU carry in bit Cin;
(2) the shift direction left or right (or straight, no shift); and
(3) the bit shifted in.
The following describes the various combinations of shift control lines:
For #ShiftCntl=00xx, no shifting is performed, so the ALU output bits go directly as inputs to the O bus; the ALU carry-in bit Cin is as described in the ALU description, above. For #ShiftCntl=010X, the ALU output is rotated left, with the least significant bit, ALU(1), shifted in. For #ShiftCntl=011x, the ALU output is rotated left through the status carry bit, STC. For #ShiftCntl=100x, the ALU output is rotated right, and for #ShiftCntl=101x, the output is rotated right through the status carry bit in ST. In each case, #ShiftCntl(1) indicated the ALU carry-in bit.
The shift-out bit Sout shifted out in a rotate instruction is sent to the status register ST. It will be loaded in ST as the new status carry bit STC if the #-LST microinstruction bit is set.
IR Register
The 8-bit instruction register IR is a register intended to hold the current machine opcode (one of the macrocode words or opcodes from ROM 11 via decode 11y and MD bus, i.e. the first bytes of the Table A instructions). The opcode is loaded through a set of eight transistors 15g (FIG. 5) from the MD bus by the #-MDtIR bit in a microinstruction. IR may be loaded onto the N bus with the #IRtN bit through transistors 16j. The output of IR, including true outputs IR0 to IR7 and complement outputs -IR0 to -IR7, primarily is used in the entry point circuit 21, FIG. 6.
Status Register
The status register ST, FIG. 5, is a 4-bit register indicating various conditions of the machine. Each bit of the status register has a special meaning. Only bits 4-7 of ST are used in this example, but other embodiments could use additional bits.
STC or the "C" bit referred to in instructions of Table A is the status carry bit. It holds either the carry-out Cout of the ALU 14, the shift-out of the shifter S, or the decimal arithmetic carry-out Dout. STSB is the status sign bit ("N" in Table A), and contains the most significant bit of the O bus contents 0(7). STEZ is the status equal to zero bit, and contains a `1` when all bits of the O bus are zero which is detected by logic in shifter S. STINT is the status interrupt enable bit.
The status register bits may be modified in one of two ways:
(1) by asserting #-OtST, all bits in ST may be replaced by the contents of the O bus via transistors 15e; or
(2) by asserting #-LST the STC, STSB, and STEZ bits may be set according to their particular input circuitry via transistors 15n (the STINT bit is unaffected in this case).
When the #-LST signal is asserted, the STC bit will be loaded from one of three sources:
(1) from the ALU arithmetic carry-out bit Cout. Cout is the carry/borrow bit generated by the ALU on arithmetic operations. Cout is loaded if no shifter S operation is specified, i.e. #ShiftCntl=00xx.
(2) from the shifter S shift-out bit Sout. This is the bit shifted out on shifter operations. If a shifter operation is specified (i.e. #ShiftCntl other than 00xx), then Sout is loaded into the carry bit.
(3) from a BCD decimal carry/borrow-out bit computed by decimal adjust circuitry if used.
The status interrupt enable STINT bit may only be modified by loading the O bus contents into the status register ST when #OtST is asserted. The STINT bit corresponds to bit-4 of the O bus in this case. STINT is output from the CPU 13 to the control circuitry for interrupts. If STINT=0, the control circuitry will not pass on an interrupt to the CPU via an IACT control line. If STINT=1, the IACT control is asserted on an interrupt. By dispatching on the IACT bit, the microcode is able to test for interrupts as will be explained.
All of the status bits may be loaded from the status register ST to the N bus via transistors 16k. The STEZ, STSB and STC bits go to the entry point circuit 21.
MEMORY AND PERIPHERY CONTROL
Referring to FIG. 7, the group decode circuit 27 and memory control circuit 28 is responsive to the address busses AH' and AL' and three of the microcode bits #MEM, MEMCNT and #WR, plus the clocks of FIG. 4, to produce certain control signals.
The ports A, B, C or D are selected by signals GA, GB, GC or GD, respectively, in response to the address AH' and AL'; as seen in FIG. 2a, data for ports A, B, C or D is at locations 0104, 0106 0108 and 010A (even addresses), so one of these ports is activated by one of these addresses, allowing access to MD bus. To set direction of C or D ports, the lowest order address bit-0 of AL' is also used (adds one to 0108 or 010A) to access the direction register part of ports C or D. A "1" written into the direction register bit sets this bit of the port as output, a "0" sets the bit as input.
The RAM 12 is accessed by a GRAM command produced by the group decode 27 in response to a 0000 to 001F (page 0) address on AL' and AH', and read or write is selected by presence or absence of a "write RAM" control WRAM generated in memory control 28 from the #WR microcode.
The ROM 11 is selected for macrocode access by GROM from group decode 27 whenever the address on AH' and AL' is in the F000 to FFFF range and the first cycle of a long memory cycle is indicated as in FIGS. 4 and 4a. GROM activates the latch 11c at the Y decode and output circuit 11Y to allow an 8-bit macrocode word to be loaded onto MD bus from ROM 11. The MUXCNTL command input to the multiplexer 11m when high allows the X address from the AH' and AL' busses to be used in the X address decoder 11X, rather than from the .mu.A bus when MUXCNTL is low.
The ROM 11 is selected from microcode access by the GROM' command which occurs during every machine state except when MEMCNT and the conditions for GROM occur, i.e., except during the first state of a long memory cycle with addresses F000 to FFFF (macrocode fetch). The X decoder 11X to accepts the .mu.A address via multiplexer 11m and GROM' causes the decoder/output circuit 11Y' to be activated and allows a multibit microinstruction output on lines 18 during every machine cycle except macrocode fetch. The MUXCNTL command goes high during S2 of FIG. 4a to cause the AL', AH' address to reach the decoder 11x, instead of the .mu.A.
The circuitry of FIG. 7 also generates a load address command LDADDR to cause the addresses on AH and AL to be loaded into the address buffers 19. This occurs in every machine state except the second state of a long memory cycle. The OtM command is generated in response to the conditions discussed with reference to Table H and FIG. 5. The command LROM to latch the ROM 11 macrocode output in latch 11c is generated by the same conditions which produce GROM and MUXCNTL, but the timing is different; LROM occurs during S2Q4 of FIG. 4a. In another embodiment a "write ROM" command WROM is provided where part of the memory 11 is of the read/write type, as will be explained.
MICROINSTRUCTION SEQUENCE CONTROL WITH DISPATCHING
The micro architecture of the CPR including entry point circuit 21 and microcode outputs of the ROM 11 is designed to dispatch on various subfields of the IR contents, providing for the execution of an appropriate sequence of microcode as in the logic flow chart of FIGS. 8a-8j and Table B and C for each macrocode or machine opcode of Table A instruction. FIG. 9 shows a map of the opcodes of Table A. The opcode or macrocode loaded into IR may be considered to have two possible formats, and the entry point circuit 21 responds to these formats to produce the micro address .mu.A:
Format 0 is indicated by a `0` in IR(7), the most significant bit of the IR register (all opcodes with 0000 to 0111 for their most significant half). In this format, bits IR(6-4) form a 3-bit "group" field and bits IR(3-0) form a 4-bit "function" field. These are the basic arithmetic and logic dual-operand instructions, for the most part.
Format 1 is indicated by a `1` in IR(7) (all opcodes with 1000 to 1111 for MSH). In this format, bits IR(6-3) form a 4-bit "group" field and bits IR(2-0) form a 3-bit "function" field. These include the peripheral page instructions, single operand instructions, special addressing (direct, indirect, indexed) and traps.
The terms "group" and "function" refer to logical subsets of machine opcodes. In the example shown, the group field in an opcode indicates the addressing mode of the instruction (i.e. which "group" in FIGS. 8a-8j to go to on the first dispatch at decision point 8m, summarized in Table E), and the function field indicates the arithmetic or logical opration performed on the operands on the second dispatch at decision points 8m of FIG. 8, after the operands are fetched. Table F showns an example of function dispatch for the DOPFUN functions. The microarchitecture allows significant sharing of microinstructions among opcodes within the same group or function. In the microcode for the illustrated embodiment, for instance, all opcodes of the format 1 share a microcode state RFtoA-1 which fetches the A register and a general RF register, as seen in FIG. 8b.
Dispatching on an IR subfield may be performed on one of the first microinstructions after the IR is loaded (e.g., at IAQ-2). Thereafter, dispatching may be performed by microinstructions up to and including the next one that reloads the IR. If no dispatching is required during executing a given opcode, then the IR may be used as a general purpose 8-bit register.
The flow of control between microinstructions is determined by how the next microinstruction address .mu.A to ROM 11 is generated in the entry point circuit, in both conditional and unconditional branching.
The microinstructions of Tables B and C, stored in the combined ROM 11 on the chip, may be characterized as horizontally microprogrammed in that each microinstrution indicates the address at which the next microinstruction to be executed is located. The next micro-address .mu.A is specified by two fields of the CROM output 18 (lines 23 and 24):
(1) #JumpAddr(7-0), an 8-bit field indicating a base address in ROM 11; and
(2) #JmpCntl(2-0), a 3-bit code indicating one of eight dispatch offsets from the address of #JmpAddr(7-0).
If #JmpCntl(2-0)=`000`, then the #JmpAddr field is simply used directly as the address of the next microinstruction; an example in FIG. 8b is the BtoPPL-0 through BtoPPl-3 series. If #JmpCntl(2-0) is nonzero, it indicates which control lines will replace the low order bits of #JmpAddr, and so form the next micro-address .mu.A. This technique is refered to as dispatching in application Ser. No. 253,624, and is readily implemented in MOS technology.
In the example device, a maximum of 256 microinstructions are possible, each consisting of a multi-bit word (outputs 18) in FIG. 6, but a total of only about 150 microinstructions are required to implement an example instruction set of Table A, and so only about 150 8-byte wide words of the ROM are used. Each of these is a 64-bit word, containing a possible sixty-four outputs 18 of microinstruction control, although fewer bits may actually be used. Additional microcoded functions for the device (new macroinstructions not in Table A) may be added by implementing a subset of the Table A instruction set, or replacing it entirely. The functions executed may be expanded by using more of the ROM 11 for microcode.
The dispatch field bits actually replace the low order address bits in the #JmpAddr(7-0) field; they are not ORed with them. For example, suppose #JmpAddr was specified to be 00010001, and the #JmpCntl(2-0) lines set to `110`, indicating a dispatch on STC, the status carry bit input. If STC were `0` the next micro address would be 00010000. The possible dispatch fields implemented in the entry point circuit are summarized in Table G, and each of the dispatch possibilities is further explained below; however, the microinstruction sequences for the illustrative instruction set will be examined.
In FIGS. 8a-8j, a flow chart of the microinstructions of Tables B and C as executed to implement the macroinstruction set of Table A is illustrated. FIG. 8 references microinstructions of Table C by name, as well as the ROM micro addresses .mu.A of Table C in hex. FIG. 8 and Tables B and C are only partial listings of the microinstruction set, given as examples. Execution of each of the Table A macroinstructions begins with the instruction acquisition IAQ sequence of FIG. 8, starting at IAQ-0. Assuming no interrupt or reset is asserted, a group dispatch is performed on the group field at IAQ-2, selecting one of twenty-four addresses for one of the operand addressing modes or for miscellaneous, jumps or traps. These twenty-four alternatives are shown in FIGS. 8b-8d. Note that some of the operand fetch microinstructions are shared by several addressing modes, particularly RFtoA-1 which is used by eight different modes or paths, or "immediate-to-A", ItoA-1, used in five different paths. All four of the B-register-to-peripheral-page BtoPPL microstates are used in the A-register-to-peripheral and immediate-to-peripheral modes. For the general opcodes, after stepping through the operand fetch microstates of FIGS. 8b-8d for the appropriate addressing mode, a function dispatch is performed, using the low order bits of the instruction word (#JmpCntl=001), to select one of up to sixteen possible functions to execute on the operands which have been fetched; these are shown in the Figures: dual operand function DOPFUN, dual operand function-peripheral DOPFUNP, single operand function normal SOPFNN, single operand function special SOPFUNS, long access function LAFUN, or miscellaneous MISC. All of these end in a return to IAQ-0 at micro address 00. Note that the Table A macrocode mneumonic such as ADD, MOV, CMP, etc., is used for the microinstruction for functions in the flow chart of FIGS. 8a-8j.
Dispatch Modes for Micro Addressing
The dispatch modes as summarized in Table G include unconditional, function, test sign bit, test if zero, test if interrupt, group, test if carry, test status, and reset.
The first type of dispatch is unconditional branching. If no conditional branching of the microcode is desired, #JmpCntl=000. This causes the device to branch unconditionally to the microinstruction at the address on the eight #JmpAddr lines 23 after the current microinstruction is executed. The address is formed by the output bits 18 in the #JmpAddr (7-0) field of the current micorinstruction. This type is used for sequences like BtoPPL-0, BtoPPL-1, BtoPPl-2, etc. of FIG. 8b.
The next type is function dispatch used to select the function at decision points 8n, SOPFUNN, DOPFUN, etc. in FIGS. 8f-8j. Function dispatch is defined in Table F. When #JmpCntl=001, the next microinstruction is determined by the low four bits of the IR register. The base address for dispatch is formed in the #JmpAddr(7-0) field of the microinstruction. The next micro address is determined by replacing the bits 3-0 of the base adress with bits 3-0 of the IR register, so the offset can be up to sixteen. A function dispatch is a dispatch on the "function" field of the instruction word in the register IR. The function field indicates the arithmetic operation to be performed. This is contrasted with the `group` field, bits 7-4, which indicate the addressing mode of the macro instruction (Table A instruction). Even though format "1" instructions have a 3-bit function field (IR bits 2-1-0), the function dispatch still performs a 16-way branch on the lower four bits of the IR register. The function dispatch for format "1" opcodes thus depends on the value of the IR(3) bit.
Another type is the test sign bit dispatch. The sign bit which is the contents of bit-7 the T/MAH register, T(7), may be used for dispatch by specifying #JmpCntl=`010`. Two alternative jumps exist here. One is the 8-bit address of the microinstruction to be executed if T(7) is `1`, and the other is the address of the microinstruction to be executed if T(7) is `0`. The address for T(7)=1 is the address for T(7)=0 plus 1. The address for T(7)=0 is loaded into the #JmpAddr field, then 1 is added if the test indicates T(7)=1.
The next type of dispatch is "test if zero". The microcode may test the value on the O bus of the immediately preceding microinstruction by specifying #JmpCntl=`011`. When this code appears in microinstruction i, it tests the O bus contents of the previously executed microinstruction, i-1. The entry point logic 21 replaces #JmpAddr(0) bit with a bit which is `1` when the O bus is all zeros and `0` otherwise.
Another type of dispatch is "test if interrupt". The microcode tests for a pending interrupt by dispatching on the IACT (Interrupt Active) signal input from the interrupt control circuitry 29. This is accomplished by #JmpCntl=100 in the output 18. This type is used in FIG. 8 at IAQ-1 to branch off to INT-0 if an interrupt is signalled. As with other dispatch instructions, two alternative addresses exist, one (E1) is the microinstruction address of INT-0 to branch to if IACT=`1`, and the other (E0) is the address of IAQ-2 branched to if IACT=`0`; these are adjacent addresses. The IACT line is asserted when an interrupt condition is detected. IACT can be asserted only when STINT (Status Interrupt Enable) is `1`. Interrupts may be signalled from the external interrupts INT or an internal timer interrupt, for example.
Another type of dispatch is "group dispatch". This is done at IAQ2, decision point 8m of FIGS. 8a-8d as well as after RFtoA-1 in FIG. 8b at decision points 8p. Note that another group dispatch is possible at 8p because the opcode is still in IR. Group dispatch is defined in Table E. Dispatching on the group field of the IR register is accomplished by specifying `101` in the #JmpCntl field. The base address field is defined by the #JmpAddr field of the microinstruction. As described above, there are twenty-four groups defined, eight in format 0, IR(7)=0, and sixteen in format 1, IR(7)=`1`. The groups may be numbered as in Table E. The group dispatch performs a 24-way dispatch on the group field by replacing the low order bits of #JmpAddr lines 23 with a function of the group number. The high nibble of the IR register, IR(7-4), is placed in the low nibble of the next address, shifted by one bit. The low order bit of the next address is IR(3) OR NOT IR(7). For format `0` instructions, NOT IR(7)=`1`, and the 0 bit of the next address always equal `1`. Thus, the machine will jump to a micro address which is the base address plus (group *2)+1 for format `0` group numbers. For format `0` instructions, NOT IR(7)=`0`, and the 0 bit of the next address equals IR(3). Thus, the machine will jump to a micro address+IR(3) for format `1` group numbers.
In a group dispatch, the CROM addresses "base address", "base address+2", "base address+4", etc., may be used for other microinstructions; only alternate micro addresses are used after the 24-way group dispatch. The example microinstruction set of Tables B and C and FIGS. 8a-8j uses the group dispatch at IAQ-2 after the instruction is loaded into the IR. Each "group" corresponds to one of the addressing modes, and the microcode executed after the dispatch fetches the appropriate operands for this instruction. A "function" dispatch is then done, and the microcode branches to perform the appropriate ALU operation on the operands. In this manner, the operand fetch microinstructions are shared among the instructions, but each instruction has its own microcode to perform the function of the instruction.
A "test if carry" type of dispatch is also available. The microcode tests the value of the carry bit in status register ST by performing a dispatch on the STC bit. This is indicated by #JmpCntl(2-0)=`110`. The bit tested is the value of the STC or status carry bit after the execution of the immediately preceding microinstruction, i.e. the microinstruction executed prior to the one containing the #JmpCntl(2-0)=110 bits. The STC bit is placed in bit-(0) of #JmpAddr, and the result used as the next microinstruction address. If the STC bit is `1`, control transfers to one address, and if STC=`0`, control transfers to the next lower address.
Another available type of dispatch is "test status register" or macro jump. The contents of the status register are tested with this "macro jump" dispatch by specifying #JmpCntl(2-0)=`111`. This dispatch tests eight possible conditions of the status register, indicated by the three bits in IR(2-0). If the condition is true, control transfers to the base address plus 1. If the condition is not true, control transfers to the base address. The conditions tested for macro jump are indicated in Table I.
The base address field must be even and is placed into the #JmpAddr field of the microinstruction. The result of the condition test is placed in bit-0 of #JmpAddr to form the new microinstruction address. The macro jump dispatch is used in the microcode of Table B to implement a conditional branch instruction.
Another type of dispatch is the reset operation, microstate Reset-0 of Table B. When the RESET pin of chip 10 is asserted (driven high externally), control circuitry asserts the RST signal to the CPU. The entry point logic 21 immediately forces the next microinstruction address .mu.A to be hex FF or all ones, grounding the .mu.A lines on H1. Unlike the normal interrupt facility, the microcode does not poll the RST line; rather, the microinstruction at .mu.A address FF is unconditionally forced to be the next microinstruction executed. The sequence of microinstructions RESET-0 to RESET-3 of Tables B and C or FIG. 8e executed upon reset results in fetching a subroutine entry point address at a fixed address such as FFEE in the macrocode part of the on-chip combined ROM 11 and branching to this subroutine.
ADDRESSING MODES FOR MACROINSTRUCTIONS
The macroinstructions of Table A are shown also in an instruction map of FIG. 9 wherein the most significant half MSH of the instruction is listed across the top and the least significant half LSH is listed down the left side, in binary and hex. Thus, an ADD instruction with an addressing mode of "B, A" has an opcode of 0101000 in binary or 68 in hex; this addressing mode means that the contents of the B register or R1 in RAM 12 is added to the contents of the A register (R0 in the RAM) and the sum is written into the A register, so B is the source address and A is the destination address. The B, A addressing mode uses the least possible states in execution, and shares some of these states with several other instructions, such as MOV, AND, OR, XOR, SUB, CMP, etc., all of which have the same MSH opcode of 0110.
The ADD B,A and MOV B,A instructions (and the like) are dual operand instructions using the A and B registers. Also, single operand instructions can use the A or B register; for example the instruction DEC A (opcode=10110010) means decrement the A register, or the instruction CLR B (opcode=11000101) means clear the B register. Instructions in the 1011 column of FIG. 9 operate on the A register, and instructions in the 1100 column operate on the B register (with exceptions as noted), and these are single operand instructions. Generally, the A or B register (or B,A) addressing modes require only five machine states to execute, three of these being instruction acquisition shared by all.
Register file addressing is also available for most instructions; this mode is indentified by Rn in FIG. 9, and means that one of the 128 or 256 registers in the register file RF or RAM 12 is the source or destination address. So, for an instruction "ADD Rn, Rn" the opcode is 00111000 (FIG. 9) followed by two 8-bit addresses of the two registers Rn, Rn used for the source and destination operands; thus three bytes are needed for an ADD Rn, Rn instruction. To execute such an ADD Rn, Rn instruction, ten machine states are used, but the source and destination fetch states are shared with all other similar instructions such as AND, OR, MOV, SUB, CMP, etc., all having a MSH opcode of 0100. Register file addressing with A or B register addressing is used in the MSH columns for 0001 and 0011 opcodes, for all of the common arithmetic and logic instructions. Again, single operand Rn addressing is used for instructions of the Rn or 1101 column of FIG. 9. Thus, "ADD R113,A" means add the contents of A register to the contents of the 113th register in RF or RAM 12 and store the sum in the register R113. "MOV R5, R78" means copy the contents of R5 into R78. "DEC R78" means decrement the contents of R78. Since the A and B registers are in the register file as R0 and R1, these may be used in the Rn, Rn addressing mode.
All of the major instructions can use the immediate addressing mode which is specified by "%n" in FIG. 9, particularly the 0010, 0101, 0111 and 1010 columns for MSH. Immediate addressing uses the contents of a byte following the opcode byte as an operand. Thus, "MOV %98, R123" means replace the contents of register R123 with the hex number 98; this sequence requires three bytes to define, these being "01110010 10011000 01111011" in machine instruction format (object code in binary as actually coded in ROM 11), and the three bytes would be stored in sequential addresses in the ROM 11, accessed in sequence by incrementing the program counter.
Peripheral file addressing specifies one of the PF addresses or registers P0 to P255 (see FIGS. 2 and 2a) as an 8-bit field following the opcode. Thus, the I/O ports A, B, C, D, etc. may be accessed (depending upon the operating mode), all by the instructions in the three columns 1000, 1001, and 1010 of FIG. 9 containing a Pn notation. For example, the instruction "MOVP A, P2" means copy the contents of A register into the P2 address.
As seen in FIG. 9, there are five instructions which can use direct memory addressing, these being LDA, STA, BR, CMPA and CALL; in each of these the opcode 10001XXX is followed by two bytes which specify a 16-bit address that contains the operand. Direct memory addressing is specified by an "at" sign @, so "LDA @F47D" means copy the contents of memory location F47D (hex) into register A, or BR @F47D means branch to address in F47D.
Another addressing mode is register file indirect; the same five instructions, LDA, STA, BR, CMPA and CALL which can use direct can use register file indirect addressing, and these are in the 1001 column of FIG. 9. This mode is specified by asterisk * followed by the register name. The specified register contains the least significant half of a 16-bit address. The most significant half of the address is contained in the next higher register. Thus, STA *R45 means copy the contents of register A into address hex-43F8 (where R46 contains 43 and R45 contains F8).
These same five instructions LDA, STA, BR, CMPA and CALL can employ an indexed addressing mode in which the address of the operand is the sum of the contents of B register and a 16-bit direct address n. The address n is proceeded by @ and following by (B) so STA @ 43F8(B) means copy the contents of the A register into the memory location specified by the contents of B added to the contents of 43F8 (hex). The opcodes for all these instructions start with 1010 as seen in FIG. 9.
THE OPERATING MODES
With reference to FIG. 2a, the primary operating mode of the microcomputer 10 of FIG. 1 is the microcomputer mode in which all of the memory is contained within the ROM 11 and RAM 12. The device is initiallized by RST or reset to be in the microcomputer mode; that is, zeros are placed in the bit-7 and bit-6 of the I/O control register 0100. In this mode, only five or six bytes of the peripheral file PF are used, the remaining 250 have no function. The peripheral register numbers P0, P4, etc., and hex addresses of the peripheral file registers for the microcomputer mode are shown in FIG. 2a. Port A is used only for input and port B in only an output, while ports C and D are either output or input; thus, registers P9 and P11 define the direction of data in the ports C and D, but no such control registers are needed for ports A and B as they are unconditionally input or output. The port A, B, C, D data registers are contained within input/output buffers and are accessed by the MD bus, using addresses 04, 06, 08 and 0A (in hex) on the AL bus and page-one or 00000001 on the AH bus. Similarly, AL addresses 09 and 0B access the control registers contained in buffers for ports C and D. A "0" in the control register bit sets the port for input and a "1" sets it for output. An address applied to AL and AH in the unused areas will produce no meaningful result, so the ROM 11 program is of course written to avoid these addresses.
In FIG. 10a a system containing an eight digit display 13-1 and a keyboard matrix 31-2 is shown which uses the device of FIG. 1 in its microcomputer mode. The C port outputs are used for the segments of the display and the B port outputs drive the digits of the display 13-1 and columns of the keyboard matrix 13-2 as illustrated in U.S. Pat. Nos. 3,988,604, 3,921,142 or 4,158,431 for example. The rows of the keyboard matrix 13-2 are applied to the A port inputs. A 8.times.8=64 key matrix is possible, but usually less are needed. Other activators and sensors such as in the microwave oven controller of the Van Bavel U.S. Pat. No. 4,158,431, assigned to Texas Instruments, may be connected to the D port as inputs or outputs. An example of a program for display scan in the system of FIG. 10a is set forth in Table J and explained below.
In the peripheral expansion mode of the memory map of FIG. 2b, the peripheral page 0100 to 01FF, 256 bytes, is utilized for off-chip accesses. The C port is used as a multiplexed 8-bit address/data bus, and four bits of the B bus are dedicated as control lines ALATCH, R/W, ENABLE and Clock Out as illustrated in the system of FIG. 10b. This system employs the microcomputer 10 of FIG. 1 as the main processor in a system which uses two other attached processors. One is a video display processor 13f as described in U.S. Pat. No. 4,243,984 issued to Guttag et al, assigned to Texas Instruments. The other is a general purpose interface bus adapter chip 13g which allows the chip 10 to inteface with a standard IEEE 488 bus 13h. The chip 10 produces an 8-bit address on the C port which is latched into an 8-bit latch 13i by the address latch signal ALATCH on port B4, then the address is available on an address bus 13j for the chips 13f and 13g when the enable signal on port B6 goes active. The chips 13f and 13g are synchronized with chip 10 by the clock output on port B7. The C port is then used for data from or to the chip 10 and chips 13f and 13g, depending upon the read/write control R/W on port B5. The chips 13f and 13g are thus configured to respond to addresses 0108, 0109 and 010A to 01FF on busses AL and AH. The AH bus of FIG. 1 will always contain 01 in this mode for off chip accesses, of course. The A port functions as an input and the D port as input or output in this peripheral expansion mode, so other functions are executed aside from accessing the chips 13f and 13g; for example, actuators and sensors, or a keyboard matrix as in FIG. 10a may be used here also.
The full expansion mode of FIG. 2c and FIG. 10c provides the 8-bit address output on C port as in FIG. 10b plus another address byte on D port which may address a memory chip 13k, for example. The full expansion mode allows a full 64K (two bytes-C port and D port) of off chip address range; addresses 0108 to EFFF are available for off chip access. As above, port B at address 0106 provides the memory control and clocking on bits B4, B5, B6, B7. The memory chip 13k may be a 32K device, for example, and the lower byte address from C port is latched at 13i while the high byte goes directly to the chip 13k on lines 13m. The data bus 13n going to the C port is shared by the chips 13f, 13g and 13k. The system of FIG. 10c thus has much greater program capability, compared to that of FIG. 10b, but the D port is not available for other I/O. A keyboard matrix 13-2 could be connected to the remaining four bits of the B port (address 0106, bits 0-3) and the A port as shown, however.
KEYBOARD AND DISPLAY SCAN PROGRAM
An example of a program executed in the microcomputer 10 connected in a system of FIG. 10a is listed in Table J and shown in flow chart form in FIGS. 11a and 11b. The keyboard input part of the program could be used in the FIG. 10b-10c systems. The microcomputer 10 having features of the invention permits keyboard and display functions under control of the fixed program in the ROM 11 rather than requiring external control circuitry. The method implemented in the program uses time-multiplexing of the display 13-1 and scanning the keyboard 13-2 with the digit-actuating B-port signals as disclosed in U.S. Pat. No. 4,074,351, assigned to Texas Instruments. In this example, a single-pole push button keyboard 13-2 with twenty keys and an eight-character LED display 13-1 are used; the program can be modified to handle up to a sixty-four single-pole keyboard and sixteen character display (using D port) with minimal changes, mostly in the intiallization subroutine INIT. However, the example program uses only the twenty keys shown in FIG. 11c, so only five of the B port bits (B3-B7) and four of the A port bits (A4-A7) are used in keyboard scan. The other three B port bits (B0-B2) actuate digits of the display but not the keyboard. The asterisk key (*) is referred to in the program as "FUN" or function key.
The format of Table J includes the ROM 11 address on the left, followed by the object code in hex, then the source statement using the macroinstruction mneumonics of Table A with accompanying operands, plus comments on the operation performed. This program listed in Table J is used with a background program which would occupy the remainder of the ROM 11. The keyboard and display scan program of Table J uses only about 225 bytes of the ROM 11, particularly addresses F800 to F8EB including look-up tables, so about 1800 bytes remain for the background program. Definitions of terms used in the Table J program are given in Table K.
The initiallization routine INIT at F800 to F81E is executed during the power-up or reset operations and does not form part of the display and key scan functions implemented repeatedly by the Table J program. The background program operates with a hardware timer interrupt which uses the timer 26 in the peripheral file PF to generate INT2 interrupts at a fixed rate to insure that the display routine is called often enough so that the display characters 13-1 do not flicker. The timer P2 is set to decimal "208" and the prescaler P3 set to "3", for the internal clock mode, by the instruction MOVP %D0, P2 and MOVP %C3, P3 at F810 and F813 in the INIT routine. This setting generates an INT2 interrupt about once every millisec when the timer increments to zero; each INT2 causes the program counter PCL, PCH to be loaded with the timer interrupt vector located at FFFA and FFFB, invoking the timer interrupt routine TINTR at F859, saving A and B in the stack and leading into the display/keyscan routine, MUXSCN at F85B.
After INIT, the program as seen in FIG. 11a enters a loop at F81F to F823 which continuously checks to see if the keyscan routine has left a new debounced key entry in DEBKEY, R119. This is done by writing hex 80 or 10000000 into B register and exchanging B with DEBKEY, then a bit test of 80 and B to see if they are the same; if not jump back to F81F, "KYDD". If a new keystroke has been loaded into DEBKEY, the instruction at F829 checks to see if it is the function key, and if so the instruction at F832 to F847 are executed to show the function symbol on the display for two seconds, then return to the F81C loop to wait for the next keystroke. If the keystroke is not the function key, F82F is executed, calling the STRSEG subroutine at F849-F858 which enters the segment pattern for this key (obtained from look-up table at F8DF) into the right most digit of SARRAY-1 and moves other digits one place to the left. At F858 RETS, execution returns to F81C to enter the loop to wait for the next key.
During the execution of the program of FIG. 11a, the occurance of the interrupt INT2 at counter time-out causes execution to shift to the timer interrupt routine of FIG. 11b. This routine is listed at F859 to F8CA of Table J, and begins with saving the A and B registers then ends with restoring these registers before the return instruction F8CA RETS; the PUSH and POP instruction implement this function.
In the TINTR part of the program, the chip 10 enables only one character of the display 13-1 at a time (one bit of B port), by the MOVP A,.P6 instruction at F868, beginning with the left-most or 0 character. At that point, the appropriate segment lines for that character location are energized by loading the port C register 010A with a segment pattern obtained from a look-up table; this is performed by the MOVP A,.P8 instruction at F863. A switch closure is detected at one bit of port A by the MOVP .P4,A instruction at F86A. If no key is down in that column, detected at F871, the remaining columns are examined via the loop of F871, F888, F8A7, F8AB and back to F86A, as seen in FIG. 11b. If the function key is down and debounced as detected at F879, the function flag is set at F87C and the remaining columns looked at via the path through F8A7 at F86A as before. For keys other than the function key the path via F881 tests for debounce, and if so the location of the down key is stored by F8A4 to be then used in the main program.
Debounce is used to eliminate effects of transients when a key is pushed. When a key is detected, it is not acted upon unless it appears for the number of scans defined by DEBNCE, in this case four, stored in the function count register (FCNT) R127 or successive-read register (SUCCRD) R121. Whenever a key is detected but the number of successive detections is less than four, the register R121 or R127, as the case may be, is decremented (count is incremented) and the scan resumed via F879 or F8A1. Thus, a key must be down for about four milliseconds before an indication of its presence is passed back to the main program.
The program of Table J and FIG. 11a, 11b merely scans the keyboard and displays what is entered. The operations performed on the functional commands and numbers entered are not included. These could be included in the loops of FIG. 11a such as at F830. That is, the D port inputs could be scanned and/or outputs energized as in FIG. 10a; also, other interrupts INT1 and INT3 could be processed.
THE SELF-TEST PROCEDURE
A microcomputer 10 constructed according to the invention may contain a self-test procedure as set forth in U.S. Pat. No. 4,158,431 issued to Van Bavel et al, assigned to Texas Instruments. The procedure of U.S. Pat. No. 4,158,431 consists of exercizing all of the display characters 13-1 and keys 13-2 as well as all of the I/O devices on the D port of FIG. 10a, all under controlof a sequence of macroinstructions in the ROM 11 as manufactured. This self-test procedure establishes that all of the external elements of the system are working and gives some indication that the chip 10 itself is fully functional, but this is not an exhaustive check. Prior to connecting into such a system, however, functional testing must be done. For example, to test the contents of the ROM 11 after manufacture (either prior to delivery to the customer or by the customer as incoming material inspection) it has previously been the practice to read out the entire contents of the ROM, one word at a time, and compare each word with the desired bit pattern. Microcomputer devices which allow such testing are disclosed and claimed in U.S. Pat. No. 3,921,142 issued to John D. Bryant et al and U.S. Pat. No. 4,024,386 issued to E. R. Caudel and Joseph H. Raymond, both assigned to Texas Instruments. Such tests, however, require that the test machine store the entire ROM code, 2048 or 4096 bytes, and require a different check code for each different ROM code. Further, the check requires at least one transfer between test machine and device under test for each type of the ROM. These factors make the test unduly long, require extensive test data or software, and/or use up excessive amounts of program space in the test machine.
As set forth in co-pending Ser. No. 276,421, filed June 22, 1981 by J. D. Bellay and assigned to Texas Instruments, the microcomputer 10 may employ a test method in which a two-byte macro-code is fixed in the ROM 11 upon manufacture and used to check the remaining macro-code. This two-byte code is different for each ROM code or program and represents some function of all of the other bytes coded in the ROM. For example, it might be the LSB's of the sum of all the other bits in the ROM, or preferably some other function which provides a multiple check of all bits. This two-byte code is referred to as a cyclic redundancy code or CRC and is a 16-bit value which is a function of every bit of data used to create it. The CRC is calculated using every byte of the macrocode in the ROM except the CRC itself which is stored at a location such as F802 and F803 in a 2048 bit ROM 11 or F002 and F003 in a 4096 bit ROM 11.
The program of Table L is loaded into the RAM 12 of the chip 10 while the chip is in one of the expansion modes (FIGS. 2b or 2c), by a sequence of move double MOVD or move MOV instructions. For example, MOVD %7D02, R10 in the microprocessor mode places the first two bytes of the object code of Table L in RF locations R10, R11. In this manner, all of the code of Table L is stored in RAM 12, and then a MOV %00, P1 instruction returns the microcomputer 10 to the single-chip mode of FIG. 2a; the address of R10 had been loaded into the program counter PCL while in expansion mode and PCH is zero so execution of the Table L code begins. The two-byte address in ROM 11 being accessed for test is AL, AH (two of the RF registers, R125 and R124). The present calculation result is QL, WH (in R127, R126). The code at 0B to 1B merely checks to see if AL, AH is at the address of the CRC code in ROM 11 (F902 and F903, for example); if so AL, AH is incremented two bytes. The code at 1D to 2A checks to see if the AL, AH address has incremented past FF, in which event all of the ROM has been processed so a jump to the CHKDON sequence is executed; otherwise the pointer AL, AH is incremented and the main calculation BUILDF is executed. This calculation at 2D to 48 processes the current QH, QL value with the new byte in Reg B which was fetched from the AL, AH address, and produces a new QH, QL value. BUILDF ends in a jump back to the LOOP starting at 0B. After all bytes in ROM have been passed through BUILDF, the check is finished. The code at 4A to 4F then defines port C as an output and outputs a hex 55 (binary 01010101) to indicate to external that the calculation is finished, so the test machine is alerted to look for the 2-byte result on the C and D ports. The original code from F902, F903 is compared at 53 and 5E with the QH, QL value, and the comparison output. About 890,000 machine states are needed by the microprocessor 10 to execute this test program, but this is all internal; the test machine does not need to store unique codes and off-chip accesses are not needed for the bulk of the test.
According to one embodiment of the present invention, however, an additional test arrangement is available. The microcode itself may be accessed one byte at a time and checked against a check-code stored in ROM 11 or an externally stored representation of the microcode. To this end, the microcode part of the ROM 11 may be accessed in a decoder 11y, latch 11c, and the MD bus, to be written into a peripheral file by a MOV%n, Pn instruction, for example, or written into the A register by MOV %n, A from which it may be operated upon internally and/or written to external by a MOVP A, Pn instruction. The fetch immediate microcode is usually used to fetch operand addresses or constants for compare, but can be used to apply bytes of the microcode from ROM 11 to one of the output ports B,C or D. An instruction MOVP %FF01,P6 executes the following microcode states: IAQ-0; 1AQ-1; IAQ-2; ItoPPL-0; ItoPPL-1; BtoPPL-0; BtoPPL-1; BtoPPL-2; BtoPPL-3; STP-0; STAL-2; then goes back to IAQ-0; this sequence is seen in FIG. 8 and Tables B and C. During the ItoPPL-0 state (corresponding to S2 of FIG. 4 a), the byte of microcode at FF01 (macrocode address of FIG. 2) which is one byte out of eight bytes of one of the microcode states of Table B and C, is accessed for processing in the ALU, writing off-chip, or writing in RAM 12. In using the test program of Table L to check the microcode as well as the macrocode, the CRC code stored in F902 is calculated to take into account all bytes of the microcode part of the ROM 11, as well as the macrocode. The method operates as before, and the LDA *AL instruction at hex-21 fetches all bytes of the ROM 11, including microcode.
This method of testing of microcomputer chips is advantageous in development and more importantly in large volume production operations, which have presented several problems. The number of external pins is limited, and the data available on the pins is constrained by the instruction set and internal circuitry. Thus, hundreds of internal nodes and signals are not available externally for test in a packaged device; internal probing is meticulous and very time consuming. It had been necessary, therefore, to provide test machines which cycled through virtually every possible operation of the devices to check for defects in manufacture. Test equipment for LSI chips is of course computer-controlled, but still this type of testing has been not only excessively time-consuming in execution, but also prohibitively expensive in software costs because every different ROM code for each consumer requires a different test sequence; even so, such tests were incomplete because execution of some instruction sequences are data-dependent and all possible combinations could never be implemented or even envisioned; furthermore time and program memory limitations in the test machine impose practical constraints. Therefore, the capability of directly testing the microcode simplifies the equipment and procedures needed.
RAM STORAGE OF MICROCODE AND MACROCODE
The memory 11, instead of being a "ROM" programmed in manufacture, may be of the read/write type with static RAM cells, so that both macrocode and microcode is loaded from external to the chip. Referring to FIG. 6a, the memory 11 is the same as before except that a "write ROM" control WROM is included and the decoder 11Y is an input/output circuit instead of just an output circuit. The group decode 27 and memory control 28 produce the WROM commands when GROM AND #WR occur. A part of the memory 11 must remain permanently programed so that enough macrocode and microcode exists to perform the task of loading the reminder of the memory. To this end, the reset microcode of Table C is fixed in a permanent ROM part 11p of memory 11 along with microcode needed to execute a long read from the peripheral file PF and a long write to the memory 11. So, the reset sequence is supplemented by adding a loop in microcode (see Table C) which reads port A, for example, and writes the port A data to the memory 11 until all of the read/write addresses of the memory 11 are loaded. The microcode addresses for this function and reset would be changed so that all are in the FFFF end of the array, or other location convenient from a fabrication and programming standpoint. After the memory 11 is initally loaded, and the task for the loaded program completed, the entire read/write part 11w of the memory 11 maybe reloaded with new microcode and macrocode, or only parts of it replaced for new tasks. The permanently-programed part 11p contains whatever macrocode and microcode needed for this update task, in addition to the reset or initial loading task.
MICROINTERRUPTS
The execution of microinstructions of FIGS. 8a-8j and Tables B and C can be interrupted by a microinterrupt arrangement which is in addition to and completely separate from the function of the macrointerrupt pins INT of FIG. 1 or the INT-0 to INT-5 microinstructions of FIG. 8e. Referring to FIG. 6', a microinterrupt signal .mu.I generated by a microinterrupt control latch 36 causes the microaddress existing at S1Q2 of FIG. 4 to be saved in an 8-bit latch 31, and causes a microvector address (for example, 60 or 01100000) to be applied via lines .mu.A to the decoders of ROM 11 by control of a multiplexer 32. The vector address begins a sequence of microinstructions as set forth in Table M to:
(a) preserve all pending registers addresses, and status bits
(b) fetch Timer-1 value from an RF register (R63 in the example)
(c) decrement Timer-1 value and write back to RF (R63)
(d) if Timer-1 value equals zero, set interrupt flag-1 (R62, bit-0)
(e) continue (b) to (d) if Timer-2, Timer-3, etc. are included
(f) return to the pending microinstruction sequence
In (a), the .mu.INT-0 microinstruction merely saves the MD bus since the PCL, PCH, AML, T/MAH, IR, ST and SP registers are not used or disturbed in the sequence of Table L. Alternatively, the data on MD bus could be saved in the stack by push and pop microinstructions. The status register ST need not be stored by a microinstruction because the #LST bit is not asserted in Table M.
Instead of using an RF register as the flag, another bit of the status register ST could be employed. Or, a hardware latch could be used to generate a macrointerrupt enable. In the above embodiment microinstructions must be added to the IAW sequence to tests the microinterrupt flag (R62, bit-0) at the beginning of each new macroinstruction execution, before testing for macrointerrupts; a bit test is implemented before IAQ-0 to check the microinterrupt flag and if set dispatch to the normal interrupt routine INT-0 which, for example, can be used to write a new value in the timer register R63, etc., and perform whatever function desired, such as by a trap routine using macrocode. See IAQ-0a and IAQ-0b in Table M. If more than one timer is used, all the flags would be polled.
The number of timers operating during a given task can be variable. One of the RF registers can be designated to define the number of separate timers in operation, and the microcode of Table M written to loop a number of times set by the number in this register. Further, the interval between microinterrupts can be variable by using one or two of the PF registers such as P2 and P3 to define the count chain; in this manner (using two such registers) the time between microinterrupts can be varied over a range of 2.sup.16, under macrocode control.
To the assembly level programmer writing in macrocode the effect of the microinterrupt arrangement is exactly as it a hardware timer had timed out. Only the microprogrammer need be aware that the CPU is time-shared to implement the timer. The microinterrupt arrangement of FIG. 6' functions as a one-level microsubroutine, and of course may be used for many purposes other than timers.
CONCLUSION
The microcomputer described in detail herein is in the form of an N-channel silicon gate integrated circuit in a single silicon chip. However, features of the invention can of course be used in devices made by other processes such as metal gate, P-channel, CMOS, silicon-on-sapphire, and the like. Also, the combined memory 11 has been described as a mask-programmable ROM of the fixed-program type, but of course an electrically-programmable ROM or electrically-erasable ROM may be used. The ROM 11 is referred to as a program memory and the RAM 12 as a data memory, and these are the primary functions in many applications; it is understood, however, that "data" from the ROM 11 is used in some algorithms ("data" being numerical constants and the like), and that the device can execute macroinstruction codes from the RAM 12, macrocode or program blocks can be down-loaded into RAM 12 from external tape or disc drive, or from a telephone coupler, for example, and executed from RAM 12. Furthermore, additional control lines and functions such as READY, HOLD, bus-status code, etc. as in said application Ser. No. 210,109, now U.S. Pat. No. 4,402,044, may be used in a device having features of the invention.
While this invention has been described with reference to an illustrative embodiment, this description is not intended to be construed in a limiting sense. Various modifications of the illustrative embodiment, as well as other embodiments of the invention, will be apparent to persons skilled in the art upon reference to this description. It is therefore contemplated that the appended claims will cover any such modifications or embodiments as fall within the true scope of the invention.
TABLE K
Definition for Program of TABLE J
CHARPT=.P6=Port B; an 8-bit port used to enable, one at a time, the individual characters of the eight-character, seven-segment display, strobing the rows of the matrix keyboard at the same time.
SEGMPT=.P8=Port C; and 8-bit port to enable the seven segments and decimal point of the display.
COLNPT=.P4=Port A; five high-order bits of port A used as inputs from the keyboard return lines. Assumes a key down in the currently enabled row returns a low (zero) level.
CLRDP=Trap 4 of instruction set; writes blank characters into all display.
STRSEG=Trap 5 of instruction set; loads segment pattern from look-up table.
NDIGIT=8; the number of digits in the display.
NROWS=5; the number of rows in the keyboard matrix.
NCOLS=4; the number of columns in the kayboard matrix.
DEBNCE=4; number of scans used for debounce.
BLANK=00; code used to blank display characters.
MASK=1F; bits relevant to ENACC routine.
FCNT=.R127; register in RF used as the function debounce counter.
FNFLG=.R126; register in RF used as flag to indicate function.
ROWPAT=.R125; register in RF used to hold input pattern being rotated thru CY.
ROWCNT=.R124; register in RF used to count number of bits rotated through CY.
DETKEY=.R123; register in RF used to hold the position of last detected key.
NXTCHR=.R122; register in RF used in the position of next character to be displayed.
SUCCRD=.R121; register in RF used in the number of successive reads of same key.
BRDPOS=.R120; register in RF used as the keyboard position currently being scanned.
DEBKEY=.R119; register in RF used to carry the position of debounced key from MUXSCN routine back to background program.
FUNDLY=.R118; register in RF used to hold non-zero when display in progress; the next 8 registers (.R117 to.R111) hold the display segment patterns.
SARRAY=.R110; register in RF used to hold the base of register array for display pattern.
FLAG=.R109; register in RF used as flay to set when at least one key is detected in current search.
BTPAT=.R108; register in RF used to hold pattern to energize specific digit.
INIT=address R800=initialize subroutine to initialize the system.
SGMT=address F81F=routine to check for any new keystrokes detected. Translate each keystroke into a segment pattern and write it into the appropirate display register.
KYDD=Keyboard input subroutine. Returns after a new keystroke has been detected and debounced. Encoded value of key (rather than its position in switch matrix) is returned in A.
FUN=Function subroutine. This subroutine is entered when the function key is depressed in conjunction with another key. It points out FUN X, wherein X is the other key which is pressed.
FDELY=subroutine which hangs up for the number of complete display searches equal to the contents of A when called.
STRSEG=address F849=subroutine to enter contents of A into the rightmost digit and shift everything else one place to the left.
TINTR=Timer interrupt subroutine; call made to location FFFA when timer times out. This causes the display refresh and keyscan routine to be called periodically.
MUXSCN=multiplex scan routine; multiplexes the 8segment displays. Each call causes the next character to be displayed, according to the contents of the SARRAY register array. MUXSCN should be called at least every millisec or so.
SRCH=Keyboard search routine. During MUXSCAN, when next character is being displayed, with the current row energized, check if there are any inputs. A keydown returns-low level.
Claims
What is claimed:
1. A microcomputer device comprising: a semiconductor integrated circuit having an arithmetic/logic unit, a plurality of registers for storing data and memory addresses parallel busses for interconnecting the arithmetic/logic unit and the registers, and control means having outputs coupled to the arithmetic/logic unit, to the registers and to the busses, the control means generating sets of command signals on said outputs, each set for controlling operation of the arithmetic/logic unit and accessing the busses and registers during a machine state, all within the integrated circuit; wherein the control means includes memory means for storing macroinstruction words defining operations of the device and for storing microinstruction words defining said command signals, the memory means having a first output for the macroinstruction words and a second output for the command signals, the second output including more bits than the first output, and addressing means having output means coupled to input means of the memory means, for applying sequences of macro addresses to said input means of the memory means using said registers and busses to define operations selected by said macroinstruction words, and for applying sequences of micro addresses to said input means of the memory means derived from at least some of said macro addresses to generate sequences of said sets of command signals, at least some of said micro addresses generating two of said sets of command signals.
2. A device according to claim 1 wherein each sequence of said micro addresses includes selecting an addressing mode using one or more of said micro addresses and includes selecting an arithmetic/logic function using one or more of said micro address as controlled by parts of said instruction words.
3. A device according to claim 1 wherein the integrated circuit includes clocking means connected to said control means to establish a machine state for each of said sets of command signals, and said some of the micro addresses generate two sets of command signals in one machine state.
4. A device according to claim 3 wherein said addressing means includes means for generating said micro addresses using parts of the sets of command signals.
5. A device according to claim 4 wherein said memory means is a single memory array included in said integrated circuit for storing both said macroinstruction words and said sets of command signals.
6. A microcomputer device comprising: a semiconductor integrated circuit having: an arithmetic/logic unit, a plurality of registers for storing data and memory addresses, bus means for interconnecting the arithmetic/logic unit and the registers, and control means having outputs coupled to said arithmetic/logic unit, to said registers, and to said bus means, the control means generating sets of commands on said outputs, each set including a plurality of commands and controlling operation of the arithmetic/logic unit and accessing the bus means and registers for one microcode state, all within the integrated circuit; wherein the control means includes a memory array having an address input and first and second multi-bit outputs, and includes addressing means having output means coupled to said address input for applying sequences of addresses to said address input, each address producing a set of commands at the first output and at least some of said addresses producing a different set of commands at the second ouptut whereby one address provides commands for a plurality of microcode states.
7. A device according to claim 6 wherein said addressing means includes means for selecting some of said addresses by a plurality of bits from an instruction word.
8. A device according to claim 6 wherein the addressing means includes means for selecting a plurality of sequences of said addresses, addresses in each sequence being defined by jump address bits included in the commands and by a plurality of bits from an instruction word.
9. A device according to claim 6 including means for selecting the set of commands on the first output for one state and a set of commands on the second output during the next immediately following state.
10. A device according to claim 9 wherein the addressing means includes means for accepting an address in the state prior to said one state to produce said commands on said first and second outputs in said one state.
11. A method of operating a microcomputer system of the type having an arithmetic/logic unit, a plurality of data/address registers, an instruction register, and memory means; the memory means storing macroinstructions and microinstructions; comprising the steps of: fetching a macroinstruction from the memory means and storing it in the instruction register; generating a first multi-bit microinstruction address for the memory means based upon said instruction in the instruction register; executing a sequence of microinstructions from said memory means beginning at said first microinstruction addresss and continuing with subsequent multi-bit addresses generated in response to microinstruction outputs of the memory means; at least one of said multi-bit addresses in the sequence producing first and second microinstructions at separate outputs of the memory means, the first being executed in one state and the second being executed in a second state following said one state; and thereafter fetching another macroinstruction from said memory means for loading in said instruction register.
12. A method according to claim 11 including the step of delaying the second microinstruction to said second state.
13. A method according to claim 12 including the step of delaying a microinstruction address from said one state to a subsequent state after said second state.
14. A method according to claim 11 including the step of executing all said steps within a single semiconductor integrated circuit.
15. A method according to claim 14 including the step of clocking the system whereby each microinstruction is executed in a machine state, and a step of fetching a macroinstruction is in a different machine cycle from applying a microinstruction address to the memory means.
16. A microcomputer comprising: first memory means containing microinstructions and second memory means of the read/write type containing data, and a CPU, all in a single semiconductor unit, the CPU including arithmetic/logic means and address registers for accessing the second memory means; microprogramming control means in the unit, said control means including said first memory means and generating sequences of microinstruction states, said control means including microinstruction addressing means having outputs coupled to input means of said first memory means, first and second output means from the first memory means providing separate sets of output control signals in one microinstruction state for execution in successive states.
17. A microcomputer according to claim 16 wherein the control means includes means in said second output means for delaying the set of output control signals from the second output means for one state.
18. A microcomputer according to claim 17 including means for defining the control means defines at least a first part of a multi-bit microinstruction address from the output control signals.
19. A microcomputer according to claim 18 wherein the control means includes means in said addressing means for delaying said first part at least one state.
20. A microcomputer according to claim 19 including macroinstruction memory addressing means connected to said address registers to receive addresses from the address registers.
21. A microcomputer device comprising: a microcode memory in said microcomputer device for storing a plurality of sets of microcode bits and for outputting on first and second microcode outputs at least two sets of microcode bits in one machine state, an ALU for performing arithmetic/logic operations on operands supplied to inputs of the ALU, under control of parts of one of said sets of microcode bits received from said first or second microcode outputs, a plurality of data and address registers, data/address bus means accessing the ALU and registers under control of part of said one of said sets of bits in a machine state.
22. A device according to claim 21 including means for forming all of said elements in a single semiconductor integrated circuit.
23. A device according to claim 22 wherein the device includes microcode addressing means having output means coupled to an input of the microcode memory, and wherein one address applied to an input of the addressing means in one machine state produces said two sets of microcode bits.