Abstract:
A new class of shift registers that shift the contents of a 2 n  bit length register up to 2 n  -1 positions in n cycles. Shift registers according to the present invention can be constructed to shift left, shift right, or to shift either left or right. A general implementation of this class of shift registers comprises the following hardware: 2 n  D flip-flops or D latches for the data register positions of the shift register; logic for each of the 2 n  positions to determine the input value to which the position should take on at each of the n cycles; an n bit shift count register to store a value indicating the number of positions to shift; control lines specifying whether to shift left or right; n control lines which are sequentially raised for one cycle to select a bit in the shift count register for the current cycle beginning with the most significant bit and continuing sequentially to the least significant bit; and a clock to set the selected input data to each position in the shift register.

Description:
This invention pertains to digital electronics, and more particularly to a new class of shift registers. 
     BACKGROUND 
     Shift registers are widely used in digital electronics. Shift registers shift the values in a series of registers a defined number of positions either to the left or to the right as determined by a control signal. A common application of shift registers is to convert data between serial and parallel formats. Data can be loaded into a shift register in parallel and then shifted out of the register one bit at time serially, and data can also be loaded into a shift register serially and output from the shift register can be provided in parallel format. 
     Serial shift registers are comprised of a series of interconnected flip-flops or latches that form registers. At each clock cycle the value in each register is shifted to the adjacent register. A control signal determines whether the register values are shifted to the left or to the right. A major drawback of serial shift registers is that serial shift registers only shift one register location per clock cycle. Therefore, to shift seven positions requires seven clock cycles. 
     Parallel shift registers perform the complete shift operation in a single clock cycle. Thus in contrast to a serial shift register where a seven position shift requires seven clock cycles, a parallel shift register performs the seven position shift operation in a single clock cycle. The trade-off for this improved performance is that parallel shift registers require substantially more hardware than serial shift registers. A typical implementation for a parallel shift register uses four layers of AND gates to implement the control logic which moves the register values to the appropriate positions based on the number of positions of the shift operation and the direction of the shift. In addition to the control logic hardware, there is also hardware required for loading new values into the shift register and providing clock control for the different hardware stages. 
     A new class of shift registers that provides higher performance than serial shift registers and requires less hardware than parallel shift registers would be highly desirable. 
     SUMMARY 
     The present invention provides a new class of shift registers that requires substantially less hardware than parallel shift registers, and provides higher performance than serial shift registers. The shift registers of the present invention can shift the contents of a 2 n  bit length register up to 2 n  -1 positions in n cycles, and are therefore referred to as logarithmic shift registers. By contrast, serial shift registers require a cycle for each position shifted. Shift registers according to the present invention can be constructed to shift left, shift right, or to shift either left or right. The number of cycles to complete the shift is n cycles for a shift register of length 2 n  bit positions. 
     A general implementation of this class of shift registers comprises the following hardware: 2 n  D flip-flops or D latches for the data register positions of the shift register; logic for each of the 2 n  positions to determine the input value to which the position should take on at each of the n cycles; an n bit shift count register to store a value indicating the number of positions to shift; control lines specifying whether to shift left or right; n control lines which are sequentially raised for one cycle to select a bit in the shift count register for the current cycle beginning with the most significant bit and continuing sequentially to the least significant bit; and a clock to set the selected input data to each position in the shift register. 
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS 
     FIG. 1 illustrates a block diagram of an eight bit shift register according to one embodiment of the present invention. 
     FIG. 2 illustrates a circuit diagram of an eight bit shift register according to one embodiment of the present invention. 
     FIG. 3 illustrates the movement of the data register values for the three shift cycles in a shift left operation for an eight bit shift register according to one embodiment of the present invention. 
     FIG. 4 illustrates the movement of the data register values for the two shift cycles in a shift right operation for a four bit shift register according to one embodiment of the present invention. 
     FIG. 5A illustrates the shift register mappings for each cycle of a shift left operation for an eight bit shift register for all of the count bit values 000 to 111 according to one embodiment of the present invention. 
     FIG. 5B illustrates the shift register mappings for each cycle of a shift left operation for a four bit shift register for all of the count bit values 00 to 11 according to one embodiment of the present invention. 
    
    
     DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS 
     The present invention provides a new class of shift registers that requires substantially less hardware than parallel shift registers, and provides higher performance than serial shift registers. The shift registers of the present invention can shift the contents of a 2 n  bit length register up to 2 n  -1 positions in n cycles, and are therefore referred to as logarithmic shift registers. By contrast, serial shift registers require a cycle for each position shifted. Shift registers according to the present invention can be constructed to shift left, shift right, or to shift either left or right. The number of cycles to complete the shift is n cycles for a register of length 2 n  bit positions. 
     A block diagram of an eight bit shift register according to one embodiment of the present invention is illustrated in FIG. 1. Shift count bits b 2 , b 1  and b 0  define the number of shift register positions to shift, and these values are stored in shift count register 122. Control lines shift right and shift left define the shift direction. Data lines a 0  -a 7  provide the values for data registers A 0  110-A 7  117, also referred to as shift register positions. 
     In operation, the load shift control signal loads the a 0  -a 7  values into data registers A 0  110-A 7  117. The load count signal loads new shift count values b 2 , b 1  and b 0  into shift count register 122. Three cycle generator 124 provides three one cycle signals to control logic block 120 over the course of three clock periods. Control logic block 120 executes shift operations in each of the cycles as defined by the shift count bit values stored in shift count register 122 to shift the contents of the eight data registers up to seven positions in three cycles. 
     According to one embodiment of the present invention the shift position mappings for a 2 n  bit number are described by the following table: 
     
                       TABLE 1______________________________________                 Sink PositionShift Direction      Count Bit  (Modulo 2.sup.n)                           Source Position______________________________________Right or Left      0          2i        iRight or Left      0          2i + 1    2.sup.n-1 + iRight      1          2i - 1    iRight      1          2i        2.sup.n-1 + iLeft       1          2i + 1    iLeft       1          2i + 2    2.sup.n-1 + i______________________________________ 
    
     where i ranges from 0 to 2 n-1  -1. These shift mappings describe the shift operations to be performed at each cycle. In a shift operation there is one cycle for each count bit. For an m bit number the initial value is of the form S 0  =(a m-1 , a m-2 , a m-3 , . . . a 2 , a 1 , a 0 ) with m=2 n  and a i  ={0,1}. S 1  is then the value after the shift count bit n-1 is applied, and S j  is the value after the shift count bit n-j is applied. For example, applying the equations in table 1 for a shift left cycle, the value of data register 3 in an eight bit shift register, i=1 and n=3, for count bit 2=1, is S 1  (a 3 )=a 1  which means the value of data register 1 in the shift register is moved to data register 3 in the shift register. Note that the shift register data registers are labeled from 0 to m-1, thus the fourth bit in the shift register is labeled data register 3. Also note that in any shift left operation the input to data register 0 is zeroed out. 
     The following table illustrates the shift register source and sink positions for shift left, shift right, and zero shift operations in an eight bit shift register: 
     
                       TABLE 2______________________________________Source/Sink                  Count BitPosition Shift Register Position                        Shift Left/Right______________________________________sink position    7     6     5   4   3   2   1   0source position    3     6     2   5   1   4   0   7   count bit = 1                                        left shiftsource position    7     3     6   2   5   1   4   0   count bit = 0                                        left or right shiftsource position    0     7     3   6   2   5   1   4   count bit = 1                                        right shift______________________________________ 
    
     The source position is the shift register position from which the value is taken, and the sink position is the shift register position to which the value is moved. For example, for a shift left operation with the count bit equal to one, the value of shift register position 5 is moved to shift register position 4. For a right shift operation with the count bit equal to one, the value of shift register position 5 is moved to shift register position 2. The shift mapping defined by Table 2 applies to all shift count bit positions. For example, for an eight bit shift register for a shift count value of 111, the same shift register position mappings are applied for each of the three count bits. 
     The shift register position contents are also shifted when a count bit is zero. Thus for a shift count value of 100 shift left, in the first clock cycle, the shift left count bit equal to one operations defined by Table 2 are performed. Then in each of the next two clock cycles shift operations for a count bit equal to zero are performed. The end result of these operations is that the contents of the shift register are shifted to the left four shift register positions. The same shift operations are performed for a zero count bit value for both shift left and shift right operations. 
     FIG. 3 illustrates the movement of the data register values for the three shift cycles in a shift left operation for an eight bit shift register. The bold arrows indicate the shift position mapping for a count bit equal to one shift left operation. The non-bold arrows indicate the shift position mapping for a count bit equal to zero shift operation. FIG. 3 graphically illustrates the shift left position mappings defined in Table 2. 
     FIG. 4 illustrates the movement of the data register values for the two shift cycles in a shift right operation for a four bit shift register. As in FIG. 3, the bold arrows indicate the shift position mapping for a count bit equal to one shift left operation, and the non-bold arrows indicate the shift position mapping for a count bit equal to zero shift operation. 
     FIG. 5A illustrates the shift register mappings for each cycle of a shift left operation for an eight bit shift register for all of the count bit values 000 to 111. Each cell represents a shift register position, and the number in the cell indicates the shift register position contents that is in the labeled shift register position at the cycle indicated by the column. The third column in each of the tables therefore represents the shift register contents at the end of the operation. For example, the third column of Table 5A-2 illustrates the final shift register positions for a shift left one operation. Similarly, FIG. 5B illustrates the shift register mappings for each cycle of a shift left operation for a four bit shift register for all of the count bit values 00 to 11. 
     In addition to the shift register mapping described by FIGS. 3, 4, 5A and 5B, bits that should be shifted &#34;out&#34; of the shift register should be eliminated and reset to zero. For example, for a shift left four positions operation, shift register positions 0-3 should be zeroes at the end of the operation. This process is described in more detail in regard to the shift register embodiment of FIG. 2. 
     A circuit diagram for an eight bit shift register according to one embodiment of the present invention is illustrated in FIG. 2. The shift register includes data registers A 0  210-A 7  217, shift count registers B 0  283-B 2  285, three cycle generator registers C 0  286-C 2  288, control logic, and control signals including shift left, shift right, load shift register, and load count signals. The initial data register values are provided by signals a 0  -a 7  through AND gates 240-247. A first of three rows of AND gates 251-257 are used in shift left cycles to determine both the shift register position that a value should be shifted to as well as whether a shift register position should be zeroed out. The second row of AND gates 260-267 control the zero shift operation in both shift left and shift right operations. For zero shift operations no shift register positions are zeroed out. The third row of AND gates 270-276 are used in shift right operations to determine both the shift register position that a value should be shifted to as well as whether a shift register position should be zeroed out. 
     In operation the load shift register loads the values provided by signals a 0  -a 7  into shift registers A 0  210-A 7  217. The shift left or shift right control signals then indicate the direction of the shift operation. The load count control signal then loads the b 2 , b 1  and b 0  shift count values into shift registers B 2  285, B 1  284 and B 0  283. The shift count values define the number of positions to shift. The load count signal also starts the three cycle generator. When the load count signal is high at a rising clock edge C 2  288 outputs a logic high level signal. The output of C 2  288 is coupled to one of the inputs of AND gate 205, whose output is an input to C 1  287. At the next clock cycle after load count switches high, both of the inputs to AND gate 205 are high and the C 1  287 output switches high. The output of C 1  287 is coupled to the input of AND gate 204. Therefore at the next cycle after C 1  287 switches high C 0  286 switches high. The load count control signal is high for one cycle for each three cycle shift operation, therefore each of the three cycle generator registers C 0  286-C 2  288 output a high level signal for one cycle. Three cycle generator 296 provides the three cycle signals for performing the three shift operations corresponding to the three shift count bits. 
     The operation of the eight bit shift register embodiment of FIG. 2 is illustrated using an example of a shift left operation with a 101 shift count value, which corresponds to a shift left five positions operation. When the load count signal goes high the 101 shift count values are loaded into shift count registers B 2  285, B 1  284 and B 0  283. In the first cycle of the three cycle shift operation, the outputs of C 2  288 and B 2  285 switch high. With the outputs of C 2  288 and B 2  285 high, the output of AND gate 294 switches high which is one input to OR gate 281. OR gate 281 then switches high. With OR gate 281 high and the shift left control signal high, two of the three inputs to each of the AND gates 251, 253, 255 and 257 are high. The third input to each of the AND gates 251, 253, 255 and 257 is the value of the corresponding shift left source data register. For example, the third input to AND gate 251 is the value stored in data register A 0  210. If the value from A 0  210 is high then the output of the AND gate 251 is high, which causes the OR gate 231 output to switch high. With the OR gate 231 output high, AND gate 221 provides a high signal output at the next rising clock edge, which sets the value of data register A 1  211 to a one. The other three AND gates 253, 255 and 257 and associated control logic operate similarly. In this manner the four low order data register values are shifted in the first cycle of the three cycle shift operation as shown in Table 2. 
     The four high order data register values are not shifted, instead they are replaced by zeroes since the outputs of OR gates 230, 232, 234 and 236 do not switch high during this first cycle of the shift operation because the OR gate 281 output is not connected to AND gates 252, 254 and 256. Because in this example, the most signficant bit of the shift count, b 2 , equals one, the most significant half (the left half) of the data register contents are to be shifted out of the data register. In other words, only the least significant half of the data register contents are retained in the data registers. 
     In the second cycle of the three cycle 101 shift left operation, the high output of cycle register C 2  288 is clocked into C 1  287 which causes the C 1  287 output to switch high. With the load count signal low the C 2  288 output then switches low. The true output of B 1  284 is coupled to an AND gate 291 input. With the B 1  284 true output low the AND gate 291 output is low. The output of AND gate 291 is coupled to an OR gate 281 input. All three inputs to OR gate 281 are low which causes the OR gate 281 output to be low. With the OR gate 281 output low, the output of AND gates 251, 253, 255 and 257 are low. The output of AND gate 291 is also an input to OR gate 280. Both inputs to OR gate 280 are low which causes the OR gate 280 output to be low. With the OR gate 280 output low, the outputs of AND gates 252 and 256 are low. The output of C 0  286 is coupled to an input of AND gate 290. In the second cycle, the C 0  286 output is low, therefore the AND gate 290 output is low. The AND gate 290 output is coupled to an input of AND gate 254, which causes AND gate 254 to be low. Thus all of the first row AND gates 251-257 are low. 
     As to the second row of AND gates 260-267, the complement output of B 1  284 is coupled to an input of AND gate 292. The second AND gate 292 input is coupled to C 1  287. Both inputs to AND gate 292 are therefore high which causes the output to be high. The AND gate 292 output is coupled to OR gate 282 which causes the OR gate 282 output to be high. The OR gate 282 output is coupled to a first input of each of the second row AND gates 260-267. The third input to each of the second row AND gates 260-267 is coupled to the OR gate 297 output which ORs the shift left and shift right control signals. The OR gate 297 output is high. With these two inputs to each of the second row AND gates 260-267 high the output of each of these AND gates depends on the second input. The second input to each of the second row AND gates 260-267 is the source data register value for the corresponding sink data register, as defined by the zero shift mapping shown in Table 2. Thus in the second cycle of the 101 shift left operation the Table 2 zero shift mapping is implemented by the second row of AND gates 260-267. 
     In the third cycle of the three cycle 101 shift left operation, the high output of cycle register C 1  287 is clocked into C 0  286 which causes the C 0  286 output to switch high. The C 0  286 output and the B 0  283 true output are coupled to the two AND gate 290 inputs. With the C 0  286 output high and the B 0  283 output high the AND gate 290 output is high. The AND gate 290 output is coupled to an OR gate 281 input, which makes the OR gate 281 output high. The OR gate 281 output is coupled to a third input of AND gates 251, 253, 255 and 257, as noted in the first cycle. The AND gate 290 output is also coupled to an OR gate 280 input which causes the OR gate 280 output to be high. The OR gate 280 output is coupled to a third input of AND gates 252 and 256. The AND gate 290 output is also coupled to the third input of AND gate 254. Thus the third input of each of the first row AND gates 251-257 is high. The second input of each of the first row AND gates 251-257 is the shift left control signal which is also high. The first input of each of the first row AND gates 251-257 is the source data register for the corresponding sink register as shown for shift left count bit equal to one in Table 2. The highest order data register value is not shifted, but is replaced by zero, for there is no AND gate to connect a left shift input to OR gate 230 when the count bit value b 0  is equal to one. This being the least significant bit of the shift register only a single data register value would be shifted out of the data register. 
     For shift register values that should be shifted &#34;out&#34; of the shift register, zeroes are inserted in the appropriate sink data register positions. The zeroing out process is performed based on the shift count register values in each of the three cycles in a shift operation. For a shift left operation, in the first cycle if shift count bit b 2  is equal to one then the inputs to data registers A 0  210, A 2  212, A 4  214 and A 6  216 are zeroed out. These four data registers are the sink positions for the outputs from the four left most data registers. As shown in Table 2, the inputs to data registers A 0  210, A 2  212, A 4  214 and A 6  216 are A 7  217, A 4  214, A 5  215 and A 6  216 respectively for a left shift in a cycle with the count bit equal to one. Similarly, in the second cycle if shift count bit b 1  equals one then the inputs to data registers A 0  210 and A 4  214 are zeroed out. In the third cycle if shift count bit b 0  equals one then the input to data register A 0  210 is zeroed out. 
     The bit elimination process for a right shift is as follows: in the first cycle, if shift count bit b 2  is equal to one then the inputs to data registers A 1  211, A 3  213, A 5  215 and A 7  217 are zeroed out. In the second cycle, if shift count bit b 1  is equal to one then the inputs to data registers A 3  213 and A 7  217 are zeroed out. In the third cycle, if shift count bit b 0  is equal to one then the input to data register A 7  217 is zeroed out. 
     The outputs of the shift count registers B 0  283-B 2  285 control the zeroing out process through the outputs of OR gates 280-282, and AND gate 290. Each shift count register has two outputs. The output on the left is the true value, and the output on the right is the complement value. Each of the AND gates in the three rows of AND gates 251-257, 260-267 and 270-276 has three inputs. One of these inputs is the value of the data register that may be shifted into the data register that the output of the AND gate is coupled to. A second input is either a shift left control signal, a shift right control signal, or an OR function of the shift left and shift right control signals. The third input is the output of one of the three OR gates 280-282 or the output of AND gate 290. A zero is written into a data register by making the three inputs into the corresponding OR gate 230-237 from the three rows of AND gates 251-257, 260-267 and 270-276 low. Then with the load shift register signal low, at the rising clock edge one input to the corresponding AND gate 220-227 is low and therefore a zero is written into the corresponding data register. 
     The following describes the data register values that are retained and the data register values that are zeroed out in an eight bit shift register three cycle shift operation. In the first cycle the four right most data register values are retained. The shift count bit b 2  indicates whether the shift register contents should be shifted by four positions. If the shift is a left shift and the b 2  shift count bit is a one, then in the first cycle of the three cycle shift operation when cycle register C 2  288 is asserted, both inputs to AND gate 294 are asserted. The first input to AND gate 294 is the true value of B 2  285 which is a one. The second input to AND gate 294 is the value of cycle register C 2  288 which is also a one. The output of AND gate 294 is coupled to one input of OR gate 281. With AND gate 294 high, the output of OR gate 281 is high. The output of OR gate 281 is coupled to an input of AND gates 251, 253, 255, 257, 270, 272, 274, and 276. Of this group, AND gates 251, 253, 255, and 257 are in the first of the three rows of AND gates and are used in shift left operations. AND gates 270, 272, 274, and 276 are in the third row of AND gates and are used in shift right operations. In a shift left operation the second input, which is the shift left control signal, to each of the first row of AND gates 251-257 is high. The third input to AND gates 251, 253, 255, and 257 is coupled to the output of OR gate 281. The first input of the first row of AND gates 251-257 is coupled to the source data register whose contents may be shifted into the sink data register coupled to the output of the given AND gate if all the inputs of that AND gate are high. Therefore in a shift left operation when OR gate 281 is high the values in the source data registers are shifted into the destination data registers corresponding to AND gates 251, 253, 255, and 257, which corresponds to sink data registers A 1  211, A 3  213, A 5  215 and A 7  217. The source data registers corresponding to these sink data registers are A 0  210, A 1  211, A 2  212, and A 3  213 respectively. Thus in the first cycle of a shift left operation with shift count register B 2  285 asserted the four right most data register values are retained. 
     In the first cycle of a shift left operation with B 2  285 asserted the four left most data register values are zeroed out. In the first cycle of the shift left operation with B 2  285 asserted, the only AND gate of the AND gates 290-294 with a high output is AND gate 294, all the other of these AND gates have a low output. Therefore the output from OR gate 281 is high while the OR gates 280 and 282 and AND gate 290 outputs are all low. As a consequence the third input of each of the AND gates 252, 254 and 256 is low, therefore their outputs cannot be high. Therefore the output of OR gates 230, 232, 234 and 236 also cannot be high. So zeroes are set into registers A 0  210, A 2  212, A 4  214 and A 6  216. In this manner, all four of the initially left most bits of the data register are zeroed out in a shift left B 2  285 count bit equal to one shift cycle. 
     In the second cycle of a shift left operation with shift count register B 1  284 asserted the inputs from data registers A 5  215 and A 7  217 are zeroed out. As shown in Table 2 if in the first cycle the shift count bit b 2  equals one, then A 7  217 holds the initial a 3  value, and A 5  215 holds the initial a 2  value. If shift count bit b 2  equals zero then A 7  217 holds the initial a 7  value and A 5  215 holds the initial a 6  value. The zeroed out bits are in either case the two most significant bits of the current shift register data values, since in the case where b 2  equals one, the initial shift register data values a 7 , a 6 , a 5  and a 4  would already have been zeroed out. In the second cycle C 2  288 equals zero, C 1  287 equals one, and C 0  286 equals zero, so if b 1  equals one then AND gates 289, 290, 292, 293 and 294 have low outputs, but AND gate 291 has a high ouput. Therefore the OR gate 280 and 281 outputs are high. Because the output of AND gate 290 is low the third input to AND gate 254 is low, and thus the OR gate 234 output is low, which causes a zero to be inserted into A 4  214. The A 5  215 output is coupled to A 4  214, therefore this zeroes out the data from A 5  215. With b 1  equal to one, the OR gate 282 output is low. As a result, the output of AND gate 260 is low. The other two inputs to OR gate 230 are also low, therefore a zero is inserted into A 0  210. Zeroing out A 0  210 is effectively zeroing out the output of A 7  217, because as shown in Table 2, A 7  217 is listed as the source for A 0  210 for a shift left count bit equal to one cycle. However in practice because for a shift left cycle the contents of A 7  217 should be shifted out of the shift register, the A 7  217 output is not coupled to A 0  210. 
     In the third cycle of a shift left operation with shift count register B 0  283 asserted the input from A 0  210 is zeroed out. As described above in the second cycle of the shift left operation description, with b 0  equal to one, the OR gate 282 output is low. As a result, the output of AND gate 260 is low. The other two inputs to OR gate 230 are also low, therefore a zero is inserted into A 0  210. 
     While the present invention has been described with reference to a few specific embodiments, the description is illustrative of the invention and is not to be construed as limiting the invention. Various modifications may occur to those skilled in the art without departing from the true spirit and scope of the invention as defined by the appended claims. For example, in an alternative embodiment OR gate 297 and the corresponding AND gates inputs are removed. Also numerous other logic configurations can be used to implement the logarithmic shift register function.