Program control circuit

Abstract: A program control circuit comprises a register for hold­ ing the repetition number of a program operation to be repea­ ted, a counter receiving the content of the register and adap­ ted to decrement in response with each execution of the program operation to be repeated, a memory for storing a sequence of instructions, and a controller for transferring an instruction read from the memory means without modifica­ ton in a normal condition and for modifying the instruction read from the memory into a no-operation instruction when the content of the counter becomes a predetermined content

Description: Background of the Invention Field of the Invention The present invention relates to a program control circuit for use in a program controlled apparatus such as a microcomputer. Description of related art Advance of integrated circuit technology has made it possible to assemble a considerably complicated logic circuit in a single chip of integrated circuit. Such an integrated circuit can be exemplified by a single chip microcomputer, which has in turn become very complicated and diversified because of complication of logic circuits which can be realized in an integrated circuit chip. On the other hand, microcomputers are adapted to execute programs read from an internal memory or an external memory. In such a program controlled computer, how short and how clean a program is described is very significant to high speed processing of data. One typical example of operation which requires a short and clean program is a numerical data processing, which requires a solution having a high degree of precision, For the purpose of elevating the precision of a solution, it is an ordinary practice to repeatedly execute the same processing. In this case, if the same program to be repeatedly executed is continuously described at the times corresponding to the number of repetitions a short and simple program cannot be obtained. At present, therefore, there has been actually widely used such a method as to combine a processing program to be repeated and a conditional jump instruction so as to shorten a program to be prepared. For example, the number of repetition "N" of an operation program to be repeatedly executed is set in a register, and the operation program is repeatedly executed while decrementing the value held in the register by "1" each one execution of the operation program. Then, when the value held in the register becomes "0", the repeated execution of the operation program is completed, and the next processing will be executed. In the above mentioned repeated program execution, however, each time the operation program to be repeatedly executed is executed, not only the value held in the register must be decremented, but also, discrimination must be made on whether or not the value of the decremented register fulfils a given condition, so that it is decided on the basis of the discrimination whether the operation should be returned to the operation program to be repeatedly executed or should go to the next program away from the operation program to be repeatedly executed. For discrimination on the content of the register, a logic circuit for discrimination should additionally be provided. Further, an instruction for executing the discrimination is required, and if the instruction is described in a program as one independent instruction, such a discrimination instruction must be executed the times of the same number as the repetition number required for a repeated operation. Therefore, the larger the repetition number of the operation becomes, the time of the executions of the discrimination instruction increases, so that a total operation time of a program will inevitably become long. In addition, if a repeated operation program contains therein another repeated operation subprogram, the time of the executions of discrimination instructions increases further, so that the number of program steps and a necessary processing time will become very large. A program control circuit according to the preamble of claim 1 is disclosed in "IBM TECHNICAL DISCLOSURE BULLETIN", vol. 25, No. 9, February 1983, pages 4569-4571. This article discloses a program control circuit, requiring no JUMP instruction for closing the loop, which comprises a loop counter (Ni) being set with the repetition number of a program sequence and modifying its content in response to each execution of the program sequence to be repeated. At the end of a loop, as long as the counter differs from the predetermined repetition value, the address of the next instruction to be read - the first instruction following the sequence to be repeated - is modified into the start address of the loop, and when the repetition counters becomes the predetermined value, the next following address is left unmodified and used for leaving the loop. The hardware counter of D1 solves the problem of overhead caused by the conditional (loop) branch instruction in the prior art. However the detection of the loop end requires an address comparison. Furthermore, an additional register has to be used for the target address. It is an object of the invention to provide a program control circuit which can execute a repeated program operation with a small number of program steps. Another object of the invention is to provide a program control circuit which can simultaneously perform executing of a program operation to be repeated and the decrement of a set number for repetition of a program execution. These objects are achieved by a program control circuit as defined in claim 1; the dependent claims relate to further developments of the invention. With the above arrangement, when the content of the register is not equal to the predetermined content, the content of the register is modified simultaneously with execution of the instruction stored in the instruction register. Namely, since the modification of the content of the register (i.e., increment or decrement of the register) and the program operation are concurrently carried out, the number of required program steps can be decreased by one in each repetition of program operation. The above and other objects, features and advantages of the present invention will be apparent from the following description of preferred embodiments of the invention with reference to the accompanying drawings. Brief Description of the Drawings Figure 1 is a block diagram of a processing unit which can incorporate therein the program control circuit in accordance with the present invention; Figure 2 is a block diagram of one embodiment of the program control circuit in accordance with the present invention; Figure 3 is a flow chart of an operation executed in the program control circuit shown in Figure 2; and Figure 4 is a circuit diagram of another embodiment of the program control circuit; and Figure 5 is a chart showing one example of instruction stream whch can be executed in the present invention. Description of the Preferred Embodiments Referring to Figure 1, there is shown one example of a processing unit of a microcomputer, which can incorporate therein the program control circuit in accordance with the present invention. The shown processing unit 1 includes a CPU internal bus 10 and an input/output (I/O) device 12 which are coupled between the CPU internal bus 10 and an external bus 14, which is coupled to an instruction read only memory (ROM) 36 of a microcomputer. Furthermore, to the CPU internal bus 10 are coupled an accumulator 16, a temporary register 18 and a status register 20. Outputs of the accumulator 16 and the temporary register 18 are coupled to inputs of an arithmetic and logic unit (ALU) 22 which is controlled by the status register 20. An output of the ALU 22 is coupled to the CPU internal bus 10. These elements 16 to 22 carries out the arithmetic logical processing. The show processing unit 1 also comprises an instruction register 24 having an input coupled to the CPU internal bus 10 and an output coupled to an input of an instruction decoder 26. The instruction decoder 26 supplies its output to a timing controller 28 for supplying and receiving various kinds of control signals. In addition, there is a group of registers 32 including a program counter, which register group is coupled between the CPU internal bus 10 and an address buffer 34 having an output coupled to an address bus 30 of the microcomputer. In operation, the shown processing unit will operate in a manner similar to that of a conventional processing unit. Briefly, the timing controller 28 generates timing signals and operates on the basis of the generated timing signals and various kinds of control signals received from the instruction decoder 26 so as to control the turn-on and turn-off of various gates (not shown) in the processing unit and at the same time to cause the address buffer 34 to supply the address and data onto the address bus 30. Also, the timing controller 26 operates to control transfer of various control signals between the I/O ports 30 and the external bus 14. On the other hand, the instruction is fed from the external bus 14 to the I/O device 12 and is written to the instruction register 24 through the CPU internal bus 10. The written instruction is decoded by the instruction decoder 26 and then furnished to the timing controller 28. Turning to Figure 2, there is shown one embodiment of the program control circuit in accordance with the present invention, which can be located between the internal bus 10 and the instruction register 24 or the I/O device 12 in the processing unit shown in Figure 1, The shown program control circuit comprises a register 40 adapted to be stored with information necessary for program control, such as the repetition number of a program operation to be repeatedly executed. A content of the register 40 is sent to a counter 42, which is in turn decremented or incremented in response to a signal S. When the counter 42 is of the count-down type it will generate a borrow signal to an instruction controller 44. When the counter 42 is of the count-up type, it will generate a carry signal to the instruction controller 44. This instruction controller 44 is coupled to a memory 46 storing a sequence of programmed instructions which corresponds to the instruction ROM 36. The controller 44 is adapted to respond to the output signal of the counter 42 so as to transfer the instruction read from the memory 46 as an effective instruction to an instruction register 48 or to modify the instruction read from the memory into a different instruction such as a no-operation instruction, which is fed to the instruction register 48. Operation will be described with reference to the flow chart shown in Figure 3. The repetition number of an operation execution is set to the register 40, and then transferred to the counter 42. On the other hand, a sequence of instructions stored in the memory 46 is made such that a signal S is generated when an instruction just before a jump instruction for operation repetition is executed or set in the instruction register 48. Thus, an instruction is sequentially read out from the memory 46 and is transferred through the instruction controller 44 to the instruction register 48 if the counter 42 generates neither a borrow signal nor a carry signal, so that the instruction set in the instruction register 48 is sequentially executed. When instructions excluding the instruction just before the jump instruction are executed, since the signal S is not generated, the value of the counter 42 is maintained as it is. Therefore, neither a borrow signal nor a carry signal is outputted from the counter 42, the instruction is read from the memory 46 and then transferred as it is through the instruction controller 44 to the instruction register 48. But, when the instruction just before the jump instruction is executed, a signal S of a logical level "1" is supplied to the counter 42 so as to decrement the counter 42 in the case that the counter 42 is of the decrement type. As the result of the decrement of the counter 42, if the counter 42 does not generate a borrow signal, the instruction controller 44 supplies the instruction, i.e., the jump instruction, stored in the memory 46 to the instruction register 48, so that the jump instruction will be executed. In other word, the operation is returned to the repetition sequence including a plurality of instructions. Thus, the operation which has already executed one time will be executed again. As a result, when the instruction just before the jump instruction is executed again, the signal S is generated again so as to decrement the counter 42. Such a repeated execution of the same operation is performed until the counter 42 generates a borrow signal. Then, the instruction controller 44 modifies the instruction, i.e., the jump instruction read from the memory to a no-operation instruction, and supplies the no-operation instruction to the instruction register 48. As a result, the jump instruction is not executed, and so, the operation goes out of the repeated operation, Thereafter, an instruction next to the jump instruction is read from the memory 46 and transferred through the instruction controller 44 to the instructions register 48 so that the next instruction will be executed. If the counter 42 is of the increment type, the counter 42 is incremented in response to the signal S, and until the counter 42 generates a carry signal, the instructions read out of the memory 46 are fed without modification to the instruction register 48, so that, if a jump instruction is contained in the instructions read from the memory 46, an operation will be repeatedly performed in accordance with the jump instruction, As seen from the above, the instructions to be executed are controlled in accordance with the output (borrow or carry) of the counter 42, so that a repeated operation execution is selectively allowed or inhibited. As mentioned hereinbefore, the conventional system requires one independent instruction for counting one execution of an operation to be repeated. But, the shown program control circuit makes it possible to concurrently perform the operation of the counter and the execution of the program operation, as seen from the following examples. For example, a repeated operation will be performed in the conventional system in the following program step sequence: A-1: set a necessary value to a register A. A-2: execute a numerical data operation, A-3: decrement the register A. A-4: go to the step A-5 if the value of the register A is "0" or to the step A-2 otherwise. A-5: go to next operation. As seen from the above, the numerical data operation and the decrement of the register cannot be executed simultaneously, because a specific instruction is required for the decrement of the register A. Further, to carry out the program step A-4, there is required a discrimination instruction for determining whether or not the value of the register A is "0" Therefore, one program step is needed for the discrimination instruction. Furthermore, another program step is also required for jumping on the basis of the result of the discrimination. On the other hand, if the shown program control circuit is used, a repeated operation can be performed in the following program step sequence. B-1: set a necessary value to a register A (register 40) B-2: execute a numerical data operation, and decrement the value of the register A (counter 42) if the control signal of the register A is "1". B-3: go to the step B-4 if a borrow is generated as the result to the decrement or to step B-2 otherwise. B-4: go to next operation. As seen from the above, if the shown program control circuit is used, the length of program steps required for a repeated operation can be shortened by one program step. The conventional system requires one independent instruction for designating the program step A-3. But, in the operation of the shown program control circuit, the control signal S for decrementing the counter 42 needs only one bit. This control signal S can therefore be given by one bit included in an instruction code consisting of a considerable number of bits, while the remaining bits can sufficiently designate one instruction. In other words, the instruction for numerical data operation and the decrement of the register A can be designated by the same one Instruction code. Specifically, assune that a sequence to be repeated is composed of program steps N to N + M as shown in Figure 5. In Figure 5, the program step N + M is a jump instruction going to the program step N. The program step N + M - 1 contains a count-down bit of one bit, from which the signal S is generated when the step N + M - 1 is executed. Thus, the steps N to N + M is sequentially executed, and when the step N + M - 1 is executed, the signal S is generated to decrement the counter 42. If a borrow signal is not generated, the step N + M is executed so that the operation is returned to the step N for repeating the sequence of N to N + M. But, if a borrow signal is generated, the jump instruction of the step N + M is modified to a no-operation instruction, so that the operation goes out of a loop for repeatedly executing the sequence N to N + M. Here, reviewing the conventional manner, it requires between the steps N + M - 1 and N + M one program step for discriminating whether or not the register A is "0". Furthermore, in the step N + M, whether or not the jump should be executed is discriminated, and, if necessary, a jump operation is executed in the succeeding step N + M + 1. Thus, the shown program control circuit can decrease the number of the program steps for a repeated operation, and can simplify the discrimination operation and speed up the program operation. The embodiment shown in Figure 2 is such that the instruction is modified into the no-operation instruction before it is supplied to the instruction register. But, the instruction can be modified to the no-operation instruction after it is outputted from the instruction register. Referring to Figure 4, there is shown another embodiment of the program control circuit. The shown circuit includes an instruction read only memory (ROM) 50 corresponding to the memory 46. The instruction ROM 50 has 12 bits of outputs, which are connected through an instruction ROM register array 52 to a gate array 54 corresponding to the instructions controller 44. Each gate of the gate array 54 has a NAND gate having a first input connected to an output of a corresponding register of the register array 52 and a second input connected to receive a borrow signal. An output of the NAND gate 56 is connected through an inverter 58 to a corresponding terminal to instruction terminals IR0-IR11. Further, the shown circuit includes a 5-bit down counter 60 which receives in parallel the data on an internal bus line IB0-IB4. The counter 60 includes five cascaded one-bit register-counters, each of which contains a plurality of tristates, a plurality of inverters and a plurality of transfer gates connected as shown in Figure 4. Since the one-bit register-counters excluding that for the least significant bit has the same circuit structure, the circuit structure is shown only on the one-bit register-counter for the most significant bit. The shown counter 60 is adapted so that the data on the but IB0-IB4 is written into a register portion of the counter in response to a signal CD, and the data stored in the counter is read out to the bus IB0-IB4 in response to the a signal CS. Further, the counter is of the precharge type driven by clocks C1, C1 , C2 and C2 , but is counted down by only the clock C1. The counter 60 has a borrow signal output 62 which is maintained at a logical level "0" as long as at least one of the five register-counters holds "1". Namely, when all the five register-counters become "0", a borrow signal of "1" is outputted, which is fed through one inverter 64 and two tristate inverters 66 and 68 to the gate array 54. Thus, when the signal CD is applied, the data on the internal bus IB0-IB4 is stored in the register portion of the counter 60. The stored data represents the repetition number of a given operation. When there is executed an instruction just before a jump instruction for operation repetition, the clock C1 is applied to the counter 60. If the counter 60 maintains the borrow signal output 62 at the logical "0", i.e., if a borrow signal is not generated, a high level signal "1" is applied to the NAND gates 56 so that the instruction, the jump instruction held in the ROM register 52 is outputted to the terminals IR0-IR11 without modification. Therefore, the jump instruction is executed, so that the given operation will be repeatedly executed. But, if the operation repetition is performed the preset times, the borrow signal of "1" is generated by the counter 60 when the instruction just before the jump instruction is executed. As a result, all the output of the gate array 54 becomes "0". In other words, the jump instruction is modified to a no-operation instruction consisting of only "0". Therefore, the jump instruction is not executed, and an instruction just after the jump instruction will be executed. In the above mentioned embodiment, the no-operation instruction is composed of only "0". But, the no-operation instruction can be in any bit pattern which can inhibit the jump operation and go to the next instruction. Futher, in the embodiment shown in Figure 4, the inverters 64, 66 and 68 function as a delay circuit. Therefore, the signal S can be generated when there is executed an instruction which is located prior to the jump instruction by the number of program steps corresponding to the delay given by the inverters 64, 66 and 68. Thus, the number of the inverters 64 to 68 can be increased or decreased.

Claims: A program control circuit comprising: A register (40) for holding the repetition number of a program operation to be repeated, a counter (42) receiving the content of said register and configured to change the received content in a predetermined counting direction in response to each execution of the operation to be repeatedly executed, said counter generating an active output signal when the content of the generating an active output signal when the content of the counter reaches a predetermined value, and a memory (46) for storing a sequence of instructions including one or more instructions corresponding to the program operation to be repeatedly executed, characterized in that said sequence comprises an unconditional jump instruction, following said one or more instructions corresponding to the operation to be repeatedly executed, for returning to the begin of said operation, in that said active output signal is generated by said counter at the end of the operation to be repeated, and by means (44, 48) receiving an instruction read from said memory and controlled by said output signal of said counter so as to transfer the received instruction without modification when said output signal of said counter is not active, said receiving and transfering means (44) operating to convert the received instruction into a no-operation instruction when said output signal of said counter is active. A circuit as claimed in claim 1 wherein the counter (42) is adapted to be decremented in response to each execution of the operation to be repeatedly executed, the transfering means (44) being in response to a borrow signal from the counter so as to modify the instruction read from the memory. A circuit as claimed in claim 1 wherein the counter (42) is adapted to be incremented in response to each execution of the operation to be repeatedly executed, the transfering means (44) being in response to a carry signal from the counter so as to modify the instruction read from the memory. A circuit as claimed in claim 1 wherein the memory includes an instruction read only memory (50) and the transfering means includes a gate array (54) coupled to the read only memory, the gate array being put in a signal blocking condition in response to the output signal of the counter. A circuit as claimed in claim 4 wherein the gate array includes a plurality of two-input gates (56), each gate having a first input connected to a corresponding bit output of the read only memory, a second input of all the gates being connected to receive the output signal from the counter. A circuit as claimed in claim 5 wherein each gate includes a two-input NAND gate and an inverter (58) connected to an output of the NAND gate.

Inventors: KURODA ICHIRO C O NEC CORPORAT, OHDE YUKO C O NEC CORPORATION, TANAKA HIDEO C O NEC CORPORATI, KURODA, ICHIRO C/O NEC CORPORATION, OHDE, YUKO C/O NEC CORPORATION, TANAKA, HIDEO C/O NEC CORPORATION
Applicants: NIPPON ELECTRIC CO, NEC CORPORATION
Application year: 1987
Main classification: G06F9
IPC codes: G06F9