Abstract:
In a pipelined processor, when a conditional branch is effected in accordance with a state of calculation generated by immediately previous instruction, it is necessary for a conventional technique to insert a NOP (no operation) instruction before a conditional branch instruction. This lowers the processing efficiency. In order to solve this problem, a delay circuit generates a clock signal φ&#39; which is supplied to a program counter and an instruction memory. The clock signal φ&#39; is delayed behind a system clock φ. This obviates the need to insert such a NOP instruction and the processing efficiency is improved.

Description:
BACKGROUND OF THE INVENTION 
     The present invention relates to a signal handling processor and, in particular, a processor for enabling the decoding and execution of instructions through a pipeline system. 
     FIG. 6 is a block diagram of a conventional microprocessor. Like reference numerals are employed to designate like parts or elements throughout the specification and any further explanation is omitted for similar parts or elements above. 
     The microprocessor shown in FIG. 6 comprises a program counter (PC) 1, an instruction memory 2, an instruction decoder 3, a data memory 4, a register file 5, a calculation circuit 6, [such as an arithmetic logic unit (ALU)], an accumulator 7, and a flag register 8. 
     The program counter 1 outputs an address signal P, which is applied to an address signal input terminal of the instruction memory 2. The instruction memory 2 allows the reading of an instruction Q stored in an address corresponding to the address signal P and writing of the instruction Q to an instruction register IR (not shown). 
     The instruction Q stored in the instruction register IR is applied to an instruction input terminal of the instruction decoder 3. The instruction decoder 3 decodes the content of the instruction and applies control signals g, h, i, j and k corresponding to the instruction Q to control terminals of the data memory 4, the register file 5, the calculation circuit 6, the program counter 1 and the instruction memory 2, respectively. 
     The data input and output terminals of the data memory 4, the register file 5 and the calculation circuit 6 are connected to a data bus. Data D is transferred between the data memory 4, the register file 5 and the calculation circuit 6 via the data bus. A system clock signal φ is applied to the clock input terminals of the program counter 1, the instruction memory 2, the data memory 4, the register file 5, the accumulator 7 and the flag register 8. The program counter 1, the instruction memory 2, the data memory 4, the register file 5, the accumulator 7 and the flag register 8 are operated in synchronism with a rise of a system clock signal φ. 
     The calculation circuit 6 performs a calculation on data A&#39; stored in the accumulator 7 and the data D supplied via the data bus. The result of the calculation is data A, which is stored in the accumulator 7. Any specific state, occurring upon the calculation, such as overflowing, sign of a result, zero as a result, and a carry output, is represented as a state signal of one bit called a &#34;flag&#34;. The calculation circuit 6 collects such flags, and produces a flag signal F. 
     The flag register 8 stores the flag signal F. An output signal F&#39; of the flag register 8 is applied as a calculated flag signal to a flag input terminal of the instruction decoder 3. The instruction decoder 3 utilizes the calculated flag signal F&#39; as a branching condition of a conditional branch instruction. The conditional branch instruction is used when an instruction execution procedure is controlled. 
     The above-mentioned state signal is allocated to the calculated flag signal F&#39; in the following way: 
     A third bit F3&#39;: an overflow flag V is &#34;1&#34; at an overflowing time and otherwise &#34;0&#34;. 
     A second bit F2&#39;,: a signal flag S is &#34;1&#34; for a negative result and otherwise &#34;0&#34;. 
     A first bit F1&#39;: a zero flag Z1 for a result of all 0s and otherwise &#34;0&#34;. 
     A zero-th bit F0&#39;: a carry flag C is &#34;1&#34; at a carry from the most significant digit and otherwise &#34;0&#34;. 
     For the instruction set of the processor, the following conditional branch instructions are prepared for controlling an instruction execution procedure in accordance with the respective flags. 
     JUMPV LABEL1; at F3&#39;=&#34;1&#34;, branch to an address LABEL1 
     JUMPS LABEL1; at F2&#39;=&#34;1&#34;, branch to an address LABEL1. 
     JUMPZ LABEL1; at F1&#39;=&#34;1&#34;, branch to an address LABEL1. 
     JUMPC LABEL1; at F0&#39;=&#34;1&#34;, branch to an address LABEL1. 
     In order to enhance the processing efficiency of the processor, a conventional technique is used for performing the instruction decode processing and instruction execute processing through a pipeline system. According to this technique, except for a first instruction reading step, a subsequent instruction reading and instruction executing step can be simultaneously effected. For this reason, a processor can achieve processing throughput about two times higher than a processor not using any pipeline system. 
     In such a processor using the pipeline system, the period in which an instruction described immediately before the conditional branch instruction is superimposed on the period in which the conditional branch instruction is decoded. It is, therefore, impossible, based on the instruction described immediately before the conditional branch instruction, to effect branching with the use of a content-varied flag. 
     The following is an example of a program with a combined calculation instruction and conditional branch instruction. 
     ADD A, R0; add the content of the register R0 to the accumulator&#39;s content A. 
     NOP; not operated. 
     JUMPV LABEL1; at an overflow flag F3&#39;=&#34;1&#34; branch to LABEL1. 
     For this exemplary program, at a first line the content of the register R0 at a zero-th of the register file 5 is applied to the input terminal of the calculation circuit (ALU) 6 via the data bus. The calculation circuit 6 adds the content in the register R0 and the content in the accumulator ACC 7 together and again stores the result of the addition into the accumulator 7. 
     At a second line, nothing is executed. This is a NOP (no operation) instruction, which is used for timing matching. Such an NOP instruction is included in an instruction set of most processors. 
     At a third line, detection is made to determine whether any overflowing occurs, and, if YES, a branch is made to LABEL1 address. 
     FIG. 7 shows a timing chart for executing the above-mentioned program with a calculation instruction and conditional branch instruction combined in a conventional processor using a pipeline system. This timing chart shows a time variation of an address signal P output from the program counter 1, an instruction Q held in the instruction requester IR, data D at the data bus, and a flag calculation signal F&#39; held at the flag register 8. T represents a machine cycle. 
     As shown in FIG. 7, at a time T, an ADD instruction is read from an n address in the instruction memory 2 and written to the instruction register IR. 
     Then an ADD instruction is decoded and, at a time 2T, the content (R0) of the register R0 is read onto the data bus. Further, an NOP instruction is read from an n+1 address in the instruction memory 2 and written to the instruction register IR. 
     Subsequently, the content A&#39; held in the accumulator 7 and data (R0) on the data bus are added together in the calculation circuit 6. At a time 3T, the result of the addition is written to the accumulator 7 and a flag F is written to the flag register 8. The flag register 8 outputs the flag signal F as a calculated flag signal F&#39;. And at the time 3T a JUMPV instruction is read out from n+2 address in the instruction memory 2 and written to the instruction register IR. 
     Then the JUMPV instruction is decoded. At a time 4T, the instruction decoder 3 decides, with the use of an overflow flag F3&#39; output from the flag register, whether or not any overflowing occurs. If YES, using the control signal j, the instruction decoder 3 causes an address signal, which is output from the program counter 1, to vary. 
     As evident from the above, the time 3T at which an overflow flag F3&#39; is varied by the addition instruction is 2 machine cycles after the time T at which the ADD instruction is read out as the instruction Q. Therefore, if the conditional branch instruction is described immediately after the addition instruction, the output flag signal F&#39; of the flag register 8 varies after the conditional branch instruction has been decoded by the instruction decoder 3. As a result, it becomes impossible to use, as a branching condition, the variation of a flag resulting from the addition instruction. In order to prevent this, the NOP instruction is inserted so that a result of the ADD instruction can be used as a condition of the JUMPV instruction. 
     In the conventional processor, in order to use the result of the addition instruction as the condition of the branch instruction, it is necessary to insert the NOP instruction as described above, thereby lowering the processing efficiency. In the case where, the conditional branch is executed in the repeating loop, its adverse effect appears prominent. As a result, the actual execution speed of the program becomes slower and an unexpected error actually occurs. 
     BRIEF SUMMARY OF THE INVENTION 
     It is accordingly an object of the present invention to provide a processor which can execute the branching of a program in accordance with the state of calculation done by an instruction immediately previous to a conditional branch instruction in a pipeline processor and improve processing efficiency. 
     Accordingly, the processor of the present invention comprises a delay circuit, which receives at its input terminal a system clock signal, and outputs a delay clock signal as a delayed replica of the system clock signal. A program counter receives at a clock terminal the delay clock signal, receives at a control terminal a control signal, and outputs an address signal in synchronism with the delay clock signal. An instruction storage device receives at a clock terminal the delay clock signal and at an address terminal the address signal. The instruction storage device stores a calculation procedure and data transfer procedure as an instruction and outputs the instruction. A calculator performs a calculation operation and outputs a state signal in accordance with a result of the calculation operation. A state storage device receives at a clock terminal the system clock signal, and stores a state signal which is output from the calculator. A state decoder receives the state signal stored in the state storage device and an instruction output from the instruction storage device and outputs a state decision result in accordance with the these two signals. An instruction decoder receives the state decision result and an instruction from the instruction storage device and outputs the control signal. A conditional branch operation is performed in accordance with the state signal which is based on an execution of an instruction described immediately previous to a conditional branch instruction. 
     Additional objects and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. The objects and advantages of the invention may be realized and obtained by means of the instrumentalities and combinations particularly pointed out in the appended claims. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate presently preferred embodiments of the invention, and together with the general description given above and the detailed description of the preferred embodiments given below, serve to explain the principles of the invention. 
     FIG. 1 is a block diagram showing a processor according to an embodiment of the present invention; 
     FIG. 2 is a timing chart of a conditional instruction executed by the processor shown in FIG. 1; 
     FIG. 3 is a schematic of a flag decoder of the processor of FIG. 1 according to the present invention; 
     FIG. 4 shows a schematic of a first embodiment of a clock delay circuit of the processor of FIG. 1 according to the present invention; 
     FIG. 5 shows a schematic of a second embodiment of the clock delay circuit of the processor of FIG. 1 according to the present invention; 
     FIG. 6 is a block diagram of a conventional microprocessor; and 
     FIG. 7 is a timing chart of the conventional microprocessor of FIG. 6. 
    
    
     DETAILED DESCRIPTION OF THE INVENTION 
     An embodiment of the present invention will be explained below with reference to the accompanying drawings. 
     FIG. 1 shows a block diagram of a processor according to the present invention. The processor comprises a program counter (PC) 1, an instruction memory 2, an instruction decoder 3, a data memory 4, a register file 5, a calculation circuit 6 [e.g. an arithmetic logic unit (ALU)], an accumulator 7, a flag register 8, a flag decoder 9 and a clock delay circuit 10. 
     The program counter 1 outputs an address signal P. 
     The address signal P output from the program counter 1 is applied to an address signal input terminal of the instruction memory 2. The instruction memory 2 reads out an instruction Q from an address corresponding to the address signal P and writes it to an instruction register IR (not shown). 
     The instruction Q stored in the instruction register IR is applied to an instruction input terminal of the instruction decoder 3. The instruction decoder 3 decodes the content of the instruction Q and applies control signals g, h, i, j and k corresponding to the instruction Q to control terminals of the data memory 4, the register file 5, the calculation circuit 6, the program counter 1 and the instruction memory 2, respectively. 
     The data input/output terminals of the data memory 4, the register file 5 and the calculation circuit 6 are connected to the data bus. Data D is transferred between the data memory 4, the register file 5 and the calculation circuit 6 via the data bus. 
     The calculation circuit 6 receives data A&#39; stored in the accumulator 7 and data D applied via the data bus and executes a calculation on the data A&#39; and D. The result of the calculation is data A, which is stored again in the accumulator 7. 
     Any specific state produced upon the calculation, such as overflowing, sign of a result, zero as the result and carry output, is represented as a state signal of one bit called a &#34;flag&#34;. The calculation circuit 6 collects such flags, and produces a flag signal F. 
     The flag register 8 stores the flag signal F, which is output from the calculation circuit 6. The flag register 8 has its stored signal output as a calculated flag signal F&#39;. 
     The calculated flag signal F&#39; output from the flag register 8 is applied to a flag input terminal of the flag decoder 9. And the instruction Q output from the instruction memory 2 is applied to an instruction input terminal of the flag decoder 9. The flag decoder 9 generates a control signal e in accordance with the instruction Q and calculated flag signal F&#39; and applies it to a control terminal of the instruction decoder 3. 
     The instruction decoder 3 varies the control signals j and k in accordance with the input control signal e and executes a branch instruction or conditional branch instruction. A time taken for the flag decoder 9 to decode the flag and for the instruction decoder 3 to output the control signals j and k is hereinafter referred to as a flag decode time τ. 
     A system clock signal φ is applied to an input terminal of the clock delay circuit 10 and the clock delay circuit 10 delays the system clock signal φ by an amount Δt for instance and outputs a delay signal φ&#39;. The amount Δt is set to be greater than the flag decode time τ. 
     The delay clock signal φ&#39; is applied to the program counter 1 and the instruction memory 2. The system clock signal φ is applied to the input terminals of the data memory 4, the register file 5, the accumulator 7 and the flag register 8. The program counter 1, the instruction memory 2, the data memory 4, the register file 5, the accumulator 7 and the flag register 8 are operated in synchronism with a rise of the system clock signal φ applied to the clock input terminal. 
     In the embodiment shown in FIG. 1, the clock signal φ&#39; obtained by delaying the clock signal φ at the clock delay circuit 10 is applied to the program counter 1 and the instruction memory 2. On the other hand, the underlying clock signal φ is applied to the flag register 8. Therefore, by terminating the decoding at the flag decoder 9 during a time period from the rise of the system clock signal φ to the rise of the delayed clock signal φ&#39;, a branch operation can be executed based on a flag variation which is based on an immediately previous calculation. 
     FIG. 2 shows a timing chart when a conditional instruction is executed by the processor shown in FIG. 1. The timing chart shows a time variation of the system clock φ, its delayed clock signal φ&#39;, an address signal P output from the program counter register 1, an instruction Q held in the instruction register IR and data D on the data bus. The time T is one machine cycle. 
     The following shows an example of a program corresponding to the timing chart shown in FIG. 2. 
     ADD A, R0; add the content of the register R0 to the content A of the accumulator. 
     JUMPV LABEL1: At an overflow flag 3&#39;=&#34;1&#34;, branch to a LABEL1. 
     For the exemplary program, at a first line, the content of 0th register R0 in the register file 5 is applied via the data bus to the calculation circuit 6 and added to the content of the accumulator 7. A result of the addition is stored in the accumulator 7. At a second line, detection is made to determine whether any overflowing occurs, and, if YES, branching is made to the LABEL1 address. 
     As shown in FIG. 2, at a time T&#39; an ADD instruction is read from an n address in the instruction memory 2 and written to the instruction register IR. Then the instruction decoder 3 decodes an ADD instruction and outputs the control signal h and other appropriate control signals. 
     Then at a time 2T&#39;, the JUMPV instruction is read from an n+1 address of the instruction memory 2 and written to the instruction register IR. Then the instruction decoder 3 decodes a JUMPV instruction. 
     In the calculation circuit 6, the content A&#39; held in the accumulator 7 is added to the data (R0) on the data bus, and, at a time 3T, a result of addition is written to the accumulator 7. And at the time 3T, a flag signal F is written to the flag register 8. The flag register 8 applies the flag signal F as a calculated flag signal F&#39; to the flag input terminal of the flag decoder 9. The flag decoder 9 decodes the JUMPV instruction and calculation flag signal F&#39; by a time 3T&#39; and outputs a control signal e representing whether or not a corresponding condition is established. 
     Thereafter, at the time 3T&#39;, the instruction decoder 3 executes a conditional branch instruction in accordance with the instruction decoder 3. 
     Since, in the present embodiment, the delay circuit 10 is used for generating the delayed clock signal φ&#39;, the operation timing of the program counter 1 is controlled in accordance with the delayed clock signal φ&#39;, so that the address signal output from the program counter 1 is delayed. Further, the delayed clock signal φ&#39; is input to the instruction memory 2, so that the instruction memory 2 outputs its instruction Q delayed by the delay time of the delayed clock φ&#39;. The flag decoder 9 generates a control signal e in accordance with the instruction Q and the calculation flag signal F&#39;, and the instruction decoder 3 executes a branch instruction or conditional branch instruction. On the other hand, the flag register 8 receives the undelayed, system clock signal φ. Thus, by terminating the decoding at the flag decoder 9 during a time period from the rise of the system clock signal φ to the rise of the delayed clock signal φ&#39;, a branch operation can be executed based on the flag variation which is based on the immediately previous calculation. That is, by terminating the decoding at the flag decoder 9 during such a time period as described above, the output flag signal F&#39; of the flag register 8 varies before the conditional branch instruction is decoded by the instruction decoder 3. As a result, it becomes possible to use, as a branching condition, the variation of a flag resulting from the immediately previous calculation. Accordingly, in the present invention, it is possible to, without providing any no operation (NOP) instruction, sequentially execute the branch condition generating calculation instruction and conditional branch instruction. Thus, high-speed processing is achieved and the coding of the program becomes easier because it is unnecessary to insert the NOP instruction. 
     FIG. 3 shows a circuit of one embodiment of the flag decoder 9 according to the present invention. 
     Lower four bits Q3, . . . , Q0 of an instruction Q for instance are applied to the first input terminals of respective exclusive NOR gates 11a to 11d. Three bits F3&#39;, . . . F0&#39; of the calculated flag signal F&#39; are applied to second input terminals of the respective exclusive NOR gates 11a to 11d. The output terminals of the exclusive NOR gates 11a, . . . , 11d are connected to the respective first, . . . , fourth input terminals of an AND gate 12. The AND gate 12 generates the control signal e. An AND gate 13 outside the broken line in FIG. 3 constitutes part of the instruction decoder 3. The control signal e is applied to a first input terminal of the AND gate 13 and a signal Z generated from a different section (not shown) of the instruction decoder 3 is applied to the second input terminal. The AND gate 13 generates a control signal j of the program counter 1. 
     When the flag decoder as shown in FIG. 3 is used, the lower four bits Q3, . . . , Q0 of the conditional branch instruction JUMPV are set as &#34;1&#34;, &#34;0&#34;, &#34;0&#34;, &#34;0&#34;, respectively. When the JUMPV instruction is decoded, F3&#39;=&#34;1&#34; and, if F2&#39; to F0&#39; are &#34;0&#34;, the control signal e becomes &#34;1&#34; and the corresponding branch is executed. Further, F3&#39;=&#34;0&#34;, the control signal e becomes &#34;0&#34; and no branch is executed. 
     FIG. 4 shows a schematic of a first embodiment of the clock delay circuit 10 according to the present invention. 
     The clock delay circuit 10 comprises exclusive NOR gates 14a, . . . , 14d and AND gates 15, 16. The system clock signal φ is applied to the first input terminal of the exclusive NOR gate 14a. A power supply potential VDD is connected to the second input terminal of the exclusive NOR gate 14a and to the first and second input terminals of the exclusive NOR gates 14b, . . . , 14d. The exclusive NOR gates 14a, . . . , 14d and AND gates 15, 16 are connected in a manner similar to that of the exclusive NOR gates 11a, . . . , 11d and AND gates 12, 13 shown in FIG. 3. The second input terminal of the AND gate 16 is connected to the power supply potential VDD and the AND gate 16 outputs the delay clock signal φ&#39;. 
     When a time difference Δt between the rise of the system clock signal φ and that of the delay clock signal φ&#39; is greater than an operation time τ of the instruction decoder 3 including the flag decoder 9, an excessive operation time is increased by Δt-τ. As a result, the machine cycle T becomes longer by Δt-τ than an originally required length and the operation speed is lowered by that extent. As shown in FIG. 4, however, by setting the delay time of the clock delay circuit 10 approximately equal to the delay time of the flag decoder 9 and instruction decoder 3, Δt is made approximate to τ, so that the operation speed can be improved. 
     FIG. 5 shows a second embodiment of the clock delay circuit 10 according to the present invention. The clock delay circuit 10 shown in FIG. 5 is a maximal delay path (critical path) of the clock delay circuit 10 shown in FIG. 4. 
     As shown in FIG. 5. the system clock signal φ is applied to a first input terminal of an exclusive NOR gate 14a and a power supply potential VDD is applied to a second input terminal of the exclusive NOR gate 14a. The output terminal of the exclusive NOR gate 14a is connected to the first input terminal of an AND gate 15 and the output terminal of the AND gate 15 is connected to a first input terminal of an AND gate 16. The second, . . . , fourth input terminals of the AND gate 15 and a second input terminal of the AND gate 16 are connected to a power supply potential VDD. The AND gate 16 outputs the delay clock signal φ&#39;. 
     By thus deleting the critical path-constituting gates of the circuit of FIG. 4 and properly connecting the input terminals of these gates to the power supply potential VDD or ground potential, it is possible to obtain the same effect as that of the embodiment shown in FIG. 4 and to reduce the size of the delay circuit. 
     As set out above, according to the present invention, it is possible to describe a branch instruction-deciding instruction immediately previous to the conditional branch instruction and to improve the processing efficiency of the processor because it obviates the necessity of inserting the NOP instruction for timing matching. 
     Additional advantages and modifications will readily occur to those skilled in the art. Therefore, the invention in its broader aspects is not limited to the specific details and representative embodiments shown and described herein. Accordingly, various modifications may be made without departing from the spirit or scope of the general inventive concept as defined by the appended claims and their equivalents.