CENTRAL PROCESSING UNIT

Abstract: The central processing unit comprises a main memory (MEM), an arithmetic/logic operation unit (ALU), internal data buses (B1,B2,B3), an instruction decoder (IDEC), a discriminator (DIS), a pair of registers (R1,R2) and other registers (R3,R4). When a write (RIW) or data transfer (MOVE) instruction is given, the discriminator (D(S) outputs write instructions (RIW,R2W) to both registers (R1,R2) so that a new data is written to the first register (R1) whilst its old content is transferred to the second register (R2). When an operation instruction is given, the decoder (IDEC) outputs read instructions (RIR, R2R) so that the data are transferred to the operation unit (ALU) without changing the contents of the registers.

Description: The present invention relates to a central processing unit by which an effective operation is carried out without the need for a complex program. The present invention is applicable to a central processing unit of any type of computer, whether it is a general purpose large scale computer or a microcomputer. A central processing unit (hereinafter referred to as a CPU) is provided with an arithmetic unit and a plurality of registers, and executes processes such as adding data transferred from a memory to a register and storing the result in a register. For such processes, the CPU is provided with an arithmetic and logic unit, a plurality of registers, a program counter for reading out each instruction from a main memory, a decoder for decoding the read instruction, and so forth. In the program stored in the main memory, instructions to command a data transfer between a certain register and a main memory or another register, and an operation on data between registers, etc. are included. To improve the processing function of a CPU, the number of registers must be increased. However, when the number of registers is increased, the number of addresses specifying registers is also increased, and accordingly, the bit length of an instruction is increased, and this requires the use of a large storage area in a main memory. To overcome this problem, a so-called stack system is provided in which a stored-type logical address is specified instead of increasing the number of registers, data is added to the stack in the transferred sequence, and finally an operation is carried out with the transferred data and the previous data. However, a data transfer or an operation cannot be effected by the stack system unless the transferred sequence is memorized. Further, when data is read out from the stack by a pop operation, the data disappears from the stack. Therefore, when the data is to be kept in the stack after popping, complex programming becomes necessary, for example, the same data must be written by a new pushing or a new instruction must be made to double the amount of data to be pushed. Therefore, the conventional method utilizing the assembler language cannot be used, and support such as using a high-level language must be reinforced, and thus it is not entirely appropriate for effectively forming a small-scale program. US-A-4 266 270 discloses a central processing unit having the features of the preamble of accompanying claim 1. IBM Technical Disclosure Bulletin, vol. 28, no. 6, Nov. 1985 pages 2727-8, discloses a first general purpose register connected to an internal bus, and a second general purpose register loaded exclusively from the first register. According to the present invention, there is provided a central processing unit comprising: an internal data bus, an arithmetic and logic unit, connected to said internal data bus, for executing an arithmetic operation and a logical operation; a plurality of registers, connected to said internal data bus, for storing the operated results and necessary data; and an instruction decoder, connected to said internal data bus, for decoding each instruction of the processing program read from a main memory; said plurality of registers comprising a pair of registers; characterised in that: a discriminating means is provided for discriminating whether or not the decoded instruction output from said instruction decoder is a data transfer instruction from said internal data bus to a selected register of said pair whereby: when the decoded instruction is discriminated to be said data transfer instruction, the data from said internal data bus is transferred to either register of said pair, while the data which has been held in said selected register is held in whichever register is not used to hold the data from said internal data bus; and when the decoded instruction is discriminated not to be said data transfer instruction, data is transferred, in response to a read instruction addressed to one or both registers of said pair, from that register or from both registers to said internal data bus without changing the contents of at least one of the registers. An embodiment of the present invention may, in view of the above-mentioned problems in the conventional stack system, and based on the concept of carrying out a push operation on a pair of registers during writing and reading out not by pop operation but directly from each register during reading, make it possible to increase the number of registers in a central processing unit without increasing the bit length of the instructions. An embodiment of the present invention may also provide a register construction in the above-mentioned central processing unit in which even a small-scale assembler language can be programmed and thus the performance of the CPU be improved. Reference is made, by way of example, to the accompanying drawings in which:- Figure 1 is a block diagram illustrating a construction of a CPU which is applicable to the present invention; Fig. 2 is a block diagram showing an embodiment of the present invention; Fig. 3 is a diagram explaining the operation of the device shown in Fig. 2; Fig. 4 is a block diagram showing another embodiment of the present invention; Fig. 5 is a waveform diagram explaining the operation of the device shown in Fig. 4; and Fig. 6 is a diagram explaining the operation of the device shown in Fig. 4. In Fig. 1, an architecture of a 16-bit bus is illustrated as an example of a CPU applicable to the present invention. The CPU applied to the present invention has connected, between an internal address bus A and an internal data bus D, a temporary register TEMP, an arithmetic and logic unit ALU, a lower-bit register PSL for a program status word, an incrementer & decrementer ID, a program counter PC, a stack pointer SP, an index register IX, and so forth. Other registers R1 and R2 are also connected to the data bus. The internal data bus D is connected, through a data buffer memory DB, to a main memory MEM, and the internal address bus A is connected through an address buffer memory AB to an address bus. The instruction decoder IDEC decodes each instruction read from the main memory MEM and accesses the necessary unit. For example, when an addition is to be effected, the adding number and the added number are read from the main memory MEM and are set in the registers, for example, R1 and R2. By an adding instruction, the ALU adds the data in the registers R1 and R2 and sets the result in the R1. This operation is controlled by a processing program stored in the main memory MEM. The program counter PC is used to read each instruction from the main memory MEM to the instruction decoder IDEC, and during an execution of the instruction, it specifies an address of the main memory MEM at which the next instruction is located. The present invention intends to realize a write operation to, for example, the two registers R1 and R2, by substantially a single address. Figure 2 is a block diagram illustrating a central processing unit according to an embodiment of the present invention. In Fig. 2, the same parts in Fig. 1 are provided with the same reference symbols. In Fig. 2, B1, B2, and B3 are internal data buses, DIS is a discriminating unit for the output of the instruction decoder IDEC, and R3 and R4 are other registers. To simplify the drawing, the address bus A, the data buffer memory DB, the address buffer memory AB, and so forth are omitted. In the embodiment, the registers R1 and R2 are constituted as a pair of registers. The register R1 is a master register and the register R2 is a slave register. The output port O of the master register R1 is electrically connected to the input port I of the slave register R2. The instruction decoder IDEC is used for decoding each instruction of the processing program read from the main memory MEM, and the decoded result is, for example, a write instruction R1W to the register R1 or a read instruction from the register R2. Also, in addition to the write instruction or read instruction, the data transfer instruction MOVE between registers or between the main memory and the register, or a calculation instruction such as addition or subtraction, are output from the instruction decoder. When the output of the instruction decoder IDEC is a write instruction R1W to the master register R1 and the data transfer instruction MOVE, the discriminating unit DIS generates the write instruction R1W to the register R1 and the write instruction R2W to the register R2. As a result, data is written to the master register R1 from the main memory MEM or the other registers R2 and R3 through the data bus B3; and the data which is stored in the master register R1 is automatically transferred to the slave register R2 through the output port O and the input port I. When the data is transferred from the master register R1 to the slave register R2, data which has been stored in the slave register R2 is sequentially pushed and superseded. When the instruction decoder IDEC is not outputting the data transfer instruction MOVE but is outputting a calculation instruction, the discriminating unit DIS does not generate the write instruction R2W to the slave register R2, and when a calculation is effected on the data in the master register R1 and the slave register R2, read instructions R1R and R2R are given from the instruction decoder IDEC to the master register R1 and the slave register R2, respectively. The read data is transferred through an internal bus B2 to the arithmetic and logic unit ALU. When the result calculated by the ALU is to be written into the master register R1, the discriminating unit DIS generates the write instruction R1W only and does not generate the write instruction R2W to the slave register R2. As a result, the calculated result is written into the master register R1, but the data which has been in the master register is not transferred to the slave register. Accordingly, in this case, the contents of the slave register R2 are not changed. Also, even when data is transferred from the register R1 to the memory MEM and so forth, different from the case of a stack memory, the data is not returned from the slave register R2 to the master register R1, that is, the data transfer between R1 and R2 is unidirectional. By providing such an additional register R2, the calculation between two data can be effectively carried out. This is explained with reference to Fig. 3, wherein as shown in (1), in a state when data b is set in the master register R1 and data a is set in the slave register R2, if a transfer instruction MOVE for data c from, for example, the memory MEM to the register R1, is provided, and if executed, the data c is entered into the register R1 and the data b is entered into the register R2 so that the data a in the register R2 is superseded. This state is shown in (2). Next, if an addition instruction for the data in the register R1 and R2 is provided, the data c and b are sent through the buses B1 and B2 to the ALU and are added. The result (b + c) is stored in the register R1. The contents of the register R2 are not changed at this time. This state is shown in (5). Next, in the state (3) (which is the same as (5)), if a data transfer instruction is sent from the register R1 to, for example, the memory MEM, the data (b + c) in the register R1 are sent through the bus B1 to the memory MEM. The data in the register R2 is not changed. As described above, when a calculation of two data b and c is to be effected, it is sufficient to transfer the data b and c to only the master register R1 and then to provide a calculation instruction on the data in the registers R1 and R2. It is not necessary to transfer the data to the two registers R1 aid R3 (for this instruction, addresses designating the registers R1 and R3 are necessary) and to provide the addition instruction on the data in the registers R1 and R3, so that an efficient processing becomes possible. Not only the register R1 but also the registers R3 and R4 may have the additional register. Since it is not necessary for the additional register to have the address during writing, the number of address bits is not increased and the bit length of an instruction is not increased even when the additional register is added. Figure 4 is a block diagram showing a central processing unit according to another embodiment of the present invention. In Fig. 4, to simplify the drawing, the internal bus is illustrated by a single line, and only two registers T1 and T2 are illustrated; that is, the others are omitted. In this embodiment, by changing the write address and the read address of the two registers T1 and T2, an operation substantially equivalent to the data transfer between the registers T1 and T2 is carried out. To this end, the discriminating unit DISa consists of an AND gate 40 which receives a data transfer instruction and a write instruction R1W from an instruction decoder IDEC, a flip-flop 41 having an output which is inverted when the output of the AND gate 40 turns to a high level, an inverter 42 for obtaining an inverted signal A of the output A, and four logic circuits 43, 44, 45, and 46 each consisting of two AND gates and one OR gate. The logic circuit 43 consists of AND gates 431 and 432 and an OR gate 433 for receiving the outputs thereof. The AND gate 431 receives a signal A and a read instruction R1R. The AND gate 432 receives a signal A and a read instruction R2R. The AND gate 441 receives the signal A and a write instruction R1W. The AND gate 442 receives the signal A and a write signal R2W. The AND gate 451 receives the signal A and the read signal R2R. The AND gate 452 receives the signal A and the read signal R1R. The AND gate 461 receives the signal A and the write signal R2W. The AND gate 462 receives the signal A and the write signal R1W. The output of the OR gate 433 becomes a read instruction T1R to the register T1. The output of the OR gate 443 becomes a write instruction to the register T1. The output of the OR gate 453 becomes a read instruction to the register T2. The output of the OR gate 463 becomes a write instruction to the register T2. Figure 5 is a waveform diagram explaining the operation of the unit in Fig. 4. In Fig. 5, CL is a clock signal for the internal of the central processing unit. In a state when the output signal A of the flip-flop 41 is at a high level, it is assumed that, at a time t₁ , a data transfer instruction MOVE and a write instruction R1W are output from the instruction decoder IDEC. These instructions are instructions for transferring data from the main memory MEM or other registers (not shown in Fig. 4) to either one of the registers T1 and T2. When the AND gate 40 receives these instructions, it turns the output signal A of the flip-flop 41 to the low level. As a result, the output signal of the inverter 42 turns to the high level so that the write signal R1W passes through the AND gate 462 and the OR gate 463 and is applied as T2W to the register T2. In this state, when a read instruction R1R is output from the instruction decoder IDEC, the R1R is applied as T2R through the AND gate 452 and the OR gate 453 to the register T2. When a read instruction R2R is output, the R2R is applied as T1R through the AND gate 432 and the OR gate 433 to the register T1. Also, the write instruction R2W is applied as T1W through the AND gate 442 and the OR gate 443 to the register T1. That is, after a time t₁ and until the next R1W and MOVE are given, the register R1 viewed from the instruction decoder IDEC is equivalent to the register T2, and the register R2 is equivalent to the register T1. After the time t₂ , when the data transfer instruction MOVE and the write instruction R1W are output again, the output signal A of the flip-flop 41 is turned to the high level, and the resulted R1W and R1R are respectively applied as the T1W and the T1R to the register T1, and the R2W and the R2R are respectively applied as the T2W and the T2R to the register T2. That is, after a time t₂ and until the next R1W and MOVE are given, the register R1 viewed from the instruction decoder IDEC is equivalent to the register T2. This means that it is equivalent that, by the write instruction R1W and the data transfer instruction MOVE given at the time t₂ , the register corresponding to the register R1 is changed from T2 to T1, and the contents of the register R1 are transferred to the register R2. The embodiment of Fig. 4 is further described with reference to Fig. 6. In the state (1), the register R1 is assumed to correspond to the register T1, and the register R2 is assumed to correspond to the register T2. Therefore, data b is set in the register T1, and data a is set in the register T2. From this state, when the instructions of R1W and MOVE are given, the register R1 turns to correspond to the register T2 and the register R2 turns to correspond to the register T1. Therefore, as shown in (4), the data b of the register T1 corresponding to the register R2 is set in the register R2. That is, this is equivalent to the case when the data b is transferred from the register R1 to the register R2, and by the write instruction R1W, the data a which has been in the register T2 corresponding to the register R1 is updated by a new data c by the write instruction R1W. This state is shown in (2). Next, when an add instruction is given on the data in the registers R1 and R2, the data c is sent from the register T2 and the data b is sent from the register T1 to the ALU, and the added result (b + c) is stored in the register T2. The contents of the register T1 are not changed. This state is shown in (5) and (3). Next, in the state (3), when a data transfer instruction is sent from the register R1 to, for example, the MEM, as shown in (6), the data (b + c) in the register T2 is sent to the memory MEM. The data b in the register T1 is not changed. Therefore, in this embodiment also, when a calculation of data stored in the two registers T1 and T2 is to be carried out, a write operation to the two registers can be executed by applying only the write instruction R1W to the single register R1. The registers constituting a pair are not of course limited to T1 and T2. As described above, according to the present invention, in a central processing unit, by making a single write address correspond to a pair of registers, such advantages are obtained that calculations can be effectively executed and the programming may use small-scale assembler language.

Claims: 1. A central processing unit comprising: an internal data bus (B1,B2,B3;D), an arithmetic and logic unit (ALU), connected to said internal data bus, for executing an arithmetic operation and a logical operation; a plurality of registers (R1,R2;T1,T2), connected to said internal data bus, for storing the operated results and necessary data; and an instruction decoder (IDEC), connected to said internal data bus, for decoding each instruction of the processing program read from a main memory (MEM); said plurality of registers comprising a pair of registers (R1,R2;T1,T2); characterised in that:- a discriminating means (DIS,DISa) is provided for discriminating whether or not the decoded instruction output from said instruction decoder (IDEC) is a data transfer instruction (MOVE) from said internal data bus to a selected register of said pair (R1,R2;T1,T2), whereby: when the decoded instruction is discriminated to be said data transfer instruction, the data from said internal data bus is transferred to either register of said pair, while the data which has been held in said selected register is held in whichever register is not used to hold the data from said internal data bus; and when the decoded instruction is discriminated not to be said data transfer instruction, data is transferred, in response to a read instruction addressed to one or both registers of said pair, from that register or from both registers to said internal data bus without changing the contents of at least one of the registers. 2. A central processing unit as claimed in claim 1, wherein said pair of registers (R1,R2) are constructed by a master register (R1) and a slave register (R2), the output port (O) of said master register being electrically connected to the input port (I) of said slave register, and when said discriminating means (DIS) discriminates said data transfer instruction (MOVE), data is transferred from said internal data bus (B1,B2,B3) to said master register (R1) and the data which has been in said master register is transferred through said output port and said input port to said slave register (R2). 3. A central processing unit as claimed in claim 1, wherein said discriminating means (DISa) comprises means for changing, at each time said data transfer instruction (MOVE) is received, the write address and the read address from either one of said pair of registers (e.g. T1) to the other (e.g. T2). 4. A central processing unit as claimed in claim 1 or 3, wherein when said discriminating means discriminates said data transfer instruction (MOVE), the data held in one of the registers (e.g. T1) and the data from said internal data bus (D) is written into the other register (e.g. T2) of the pair; and until the next data transfer instruction is given, the data in said other register (T2) is read in response to a read instruction from said one register (T1); when said discriminating means discriminates said next data transfer instruction, the data held in said other register (T2) is kept to be held in said other register (T2) and the data from said internal data bus (D) is written in said one register (T1) of said pair of registers; and until a further next data transfer instruction is given, the data is read from said one register (T1) in response to a read instruction from said one register (T1).

Inventors: IGARASHI, TOSHIYUKI, ISOBE, HIDEKI, KUBO, YOSHIHIRO, MURAKAMI, JOJI, YAMADA, KENJI
Applicants: FUJITSU LIMITED
Application year: 1987
Main classification: G06F9
IPC codes: G06F9