Abstract:
A vector processor has a discriminator for determining in one machine cycle of an operation unit whether a bit pattern of elements of vector data meets a predetermined condition or not. An output of a register having a predetermined value loaded only into bits to be extracted from the vector data and each of the elements of the vector data are ANDed or ORed so that the bit pattern is determined. The operation and determination are sequentially carried out in one machine cycle.

Description:
CROSS REFERENCE TO OTHER APPLICATION 
     This application relates to U.S. Pat. No. 4 ,773,006 entitled &#34;Vector Processor&#34; and issued on Sept. 20, 1988. 
     BACKGROUND OF THE INVENTION 
     The present invention relates to a program controlled digital computer, and more particularly to a vector processor which is suitable for carrying out a vector operation at a high speed. 
     A vector processor has been used for high speed calculation, such as a large scale matrix calculation of the type frequently called for in scientific and technical calculations. In such a vector processor, an operation such as that shown in the following FORTRAN instruction is vector-processed at a high speed. 
     
         ______________________________________      DO 10 i=1, N      IF (A(i).EQ. 3)      THEN B(i)=1      10 CONTINUE______________________________________ 
    
     Namely, (A(i).i=1, N) is defined as a vector A and (B(i).i=1, N) is defined as a vector B. When a vector element (A(i)) of the vector A is equal to 3, &#34;1&#34; is substituted for the corresponding vector element (B(i)) of the vector B. The vector processor carries out such a vector operation at a high speed by using a vector processing technique. 
     However, when a part of a structure of the following PL/I instruction is to be compared with contents of FLAGS 1 and 2, the process is very complex. 
     
         ______________________________________DCL         1     FLAG (50),       2     FLAG 1     BIT (1),       2     *          BIT (30),       2     FLAG 2     BIT (1);DO i=1 TO 50;     IF  FLAG 1     (i) = `1`B &amp;         FLAG 2     (i) = `1`B     THEN A(i) = B(i);END;______________________________________ 
    
     If this PL/I instruction is executed by using the above vector processing technique, the following vector instruction objects are generated. 
     
         ______________________________________VL                VR0, FLAGVEO               VR4, VR0, SR0VCEQ              VMR0, VR4, SR4VL                VR8, BVSTN              VR8, A______________________________________ 
    
     Of those fine instructions, the upper three correspond to the IF clause and the lower two correspond to the THEN clause. 
     The abbreviations of the above instructions are explained below. 
     
         ______________________________________VL:        VECTOR LOAD,VEO:       VECTOR-ELEMENTWISE OR,VCEQ:      VECTOR COMPARE EQUAL,VSTN:      VECTOR STORE NEGATIVE MASKVRi:       i-th vector registerSRi:       i-th scalar registerVMRi:      i-th vector mask register______________________________________ 
    
     A 4-byte hexadecimal number `7FFFFFFE` is preset in SR0, and a 4-byte hexadecimal number `FFFFFFFF` is preset in SR4. 
     DO i=1 TO 50 in the PL/I instruction is considered as one vector column, and the decision for the next IF clause is carried out by a VL instruction, VE0 instruction and VCEQ instruction. In accordance with the result thereof, a substitution of A(i)=B(i); described by the THEN clause is stored in an array A, while all elements of an array B are loaded by the VL instruction, and data satisfying the condition in the If sentence are is selected by a masked VSTN instruction. 
     However, as seen from the above example, three vector registers VR0, VR4, VR8 in the DCL clause, two scalar registers SR0 and SR4 in the IF clause and one mask register VMR0 in the THEN clause are occupied for one decision by the program. This impedes effective utilization of registers. The instruction sequence also takes two steps only for a decision. These circumstances makes it difficult to vectorize for a structured programming language, such as PL/I. 
     Such a technique is disclosed in JP-A-60-15772. 
     Such a vector processor is described in &#34;Hitach Super Computer S-810 Array Processor System&#34; by Toshihiko Okada et al, Elsevier Science Publishers B.V. (North-Holland), 1986, pages 113-136. 
     The prior technique does not pay attention to bit determination in a structure as frequently used in the structured programming language represented by PL/I and has problems in that the instruction sequence is complex and many register resources are used. 
     A reason therefor is that the vector processor is usually utilized for speed-up of processing of a language for carrying out a numeric operation represented by FORTRAN and it is not utilized for speed-up of PL/I which requires complex logical operations. This is because a large capacity array for a large scale matrix operation which is a base of vectorization is easy to handle in FORTRAN. However, in recent years, the large capacity array is required even in PL/I in a field of a data base and the vectorization of the bit determination for a structure is becoming feasible. 
     SUMMARY OF THE INVENTION 
     It is an object of the present invention to provide a vector processor which carries out bit determination in a structure necessary for speeding up processing for a structured programming language, such as PL/I, by the vector processor with a small number of register resources at a high speed. 
     The above object is achieved by providing in the vector processor an operation unit which extracts a group of any bit positions for a vector element in a data vector and determines whether the bits are all 0&#39;s, all 1&#39;s or a mixture of l&#39;s and 0&#39;s. 
     In order to determine whether both bit positions i and j of a vector V1 are 0 or not, a mask R1 having &#34;1&#39;s&#34; at the bit positions i and j and 0&#39;s&#34; at other bit positions is prepared. In an operation unit C1, a logical AND function of the mask R1 and each of the vector elements of the vector V1 is determined, and if all of the results are zero, &#34;1&#34; is set into the corresponding element of decision result R2, and otherwise &#34;0&#34; is set. As a result, it is determined that both the bit positions i and j of the vector elements of the vector V1 are zero when the decision result R2 is &#34;1&#34;. Thus, the determination is easily done by designating any of the bit positions in any number by the mask R1. 
    
    
     BRIEF DESCRIPTION 
     FIG. 1 shows processing in the present invention, 
     FIG. 2 shows one embodiment of the present invention, and 
     FIG. 3 shows a convolution chart to show a parallel operation of a series of arithmetic operations and comparison in one machine cycle. 
    
    
     DESCRIPTION OF THE PREFERRED EMBODIMENTS 
     An outline of the present invention is explained with reference to FIG. 1. In FIG. 1, when it is to be determined whether bit positions i and j of a vector V1 are both &#34;0&#34; an extract condition register R1 having &#34;1&#39;s&#34; at bit positions i and j and &#34;0&#39;s&#34; at other positions is provided. An operation unit C1 calculates a logical AND function between the extract condition and each vector element of the vector V1. If all results are zero, &#34;1&#34; is set into a corresponding element of a decision result R2, and if not, &#34;0&#34; is set into the corresponding element. As a result, it is determined that the bit positions i and j of the vector element of the vector V1 are both zero when the decision result R2 is &#34;1&#34;. In this manner, the determination is easily obtained by designating any number of bit positions by the extraction condition or scalar register R1. When it is to be determined whether the bit positions i and j are both &#34; 1&#34; a scalar register R1 having &#34;0&#39;s&#34; set in the bit positions i and j and &#34;1&#39;s&#34; set in the other bit positions is provided, and the operation unit C1 calculates a logical OR function of the register R1 and each of the vector elements. 
     FIG. 2 shows one embodiment of the vector processor of the present invention. In FIG. 2, R13 denotes an instruction register which is divided into four fields. An OP field contains an operation code which is sent to an operation control unit C12 through a line l1 to control instruction execution. An i field designates one of the vector register 11, register VMR 11 and scalar register SR 11 to store a result. It is supplied to a distributor D12 through a line l2 and the distributor supplies the result provided by the operation unit C12 through a line l9 to the designated register. A j field designates a register to be used for the operation from the vector register VR11, mask register VMR11 and scalar register SR11. It is supplied to the selector S11 through a line l3 and the selector S11 selects one of the registers. The selected content is sent over the line l5. A k field is identical to the j field and it is supplied to a selector S12 and the selected content is sent over a line l6. The mask register holds a condition mask for the vector for the operation or decision to be carried out in the next step. 
     R12 denotes a data register for holding data, R11 denotes an operation mask register for holding an operation mask, and the operation unit C11 carries out the operation through a line l8. The line l7 is a data line over which the content of the data register R12 is sent; the line l8 is the data line over which the content of the operation mask register R11 is sent; the line l9 is the data line over which the result of operation by the operation unit C2 is carried; the line l10 is the control line to indicate read or write of each register; and the line l11 is the control line to control the operation unit C11. 
     The vector register VR11, scalar register SR11 and vector mask register VMR11 correspond to V1, R1 and R2 of FIG. 1, respectively. The VMR11 is a one-bit register which contains only &#34;0&#34; or &#34;1&#34;. 
     The operation is now explained. When an instruction which specifies the execution of the present operation is loaded into the instruction register R13, the contents of the OP, i, j and k fields are sent to the operation control unit C12, distributor D12, selector S11 and selector S12, respectively. The distributor D12, selector S11 and selector S12 select the registers designated by the fields i, j and k, respectively, to establish a distribution route and a selection route. In the present embodiment, the field i designates the vector mask register VMR11, the field j designates the vector register VR11 and the field k designates the scalar register SR11. 
     The operation control unit C12 sends the read or write command to the appropriate register through the line l10 and reads the vector register VR11 designated by the field j sequentially one vector element at a time at an appropriate timing. The content of the scalar register SR11 designated by the field k is initially read only once. For example, SR0 is hexadecimal `7FFFFFFE` and SR4 is `FFFFFFFF`. Writing to the mask register VMR11 designated by the field j is sequentially carried out. 
     The data sequentially loaded into the data register R12 is supplied to the operation unit C11 through the line l7. The operation mask to be used in the present operation is supplied to the operation mask register R11 and it is supplied to the operation unit C11 through the line l8. The operation unit C11 carries out the logical operation by the operation mask for the data in accordance with the operation code set in the OP field and makes a decision for the designated bit positions in accordance with the operation result. The decision is sent out to the line 9, supplied to the distributor D12, and stored in one of the vector mask registers VMR11. This vector mask register VMR is repeatedly used as a mask through the line l20 in the operation which uses various masks as the condition so that execution of a complex instruction for all vector elements is attained. 
     In accordance with the present embodiment, the determination of bit positions, which is frequently required in the structured program, can be attained by the vector processing by one instruction using one vector register, one mask register and one scalar register in approximately one machine cycle as shown in FIG. 3. The determination is due to the provision of the comparator C23 in the operation unit C11 which compares the value &#34;1&#34; with the operation result of the content of the two input means C21 and C22. 
     At the timing shown in the box 31 of FIG. 3, the AND or OR operation is carried out, and at the timing shown in the box 32, the result is determined so that the decision result as shown in FIG. 1 is obtained. The two input means C21 and C22 each has a function to operate the inputs of the vector elements which are shifted by approximately 1/m cycle from each other as shown by stages 1, 2, 3, ---, m in FIG. 3. 
     While the binary vector data has been explained, the present invention is equally applicable to the determination of a bit pattern by a ternary logic.