
Design alternatives for barrel shifters Matthew R. Pillmeier Rushmore Pro cessor 2 Unisys Corp oration Blue Bell, PA 19424 Michael J. Schulte and E. George Walters I I I Computer Architecture and Arithmetic Lab oratory Computer Science and Engineering Department Lehigh University Bethlehem, PA 18015, USA ABSTRACT Barrel shifters are often utilized byemb edded digital signal pro cessors and general-purp ose pro cessors to ma- nipulate data. This pap er examines design alternatives for barrel shifters that p erform the following functions: shift right logical, shift right arithmetic, rotate right, shift left logical, shift left arithmetic, and rotate left. Four di erent barrel shifter designs are presented and compared in terms of area and delayforavariety of op erand sizes. This pap er also examines techniques for detecting results that over ow and results of zero in parallel with the shift or rotate op eration. Several Java programs are develop ed to generate structural VHDL mo dels for each of the barrel shifters. Synthesis results show that data-reversal barrel shifters have less area and mask- based data-reversal barrel shifters have less delay than other designs. Mask-based data-reversal barrel shifters are esp ecially attractivewhenover ow and zero detection is also required, since the detection is p erformed in parallel with the shift or rotate op eration. Keywords: barrel shifters, rotators, masks, data-reversal, over ow detection, zero ag, computer arithmetic. 1. INTRODUCTION Shifting and rotating data is required in several applications including arithmetic op erations, variable-length co ding, and bit-indexing. Consequently, barrel shifters, which are capable of shifting or rotating data in a single cycle, are commonly found in b oth digital signal pro cessors and general-purp ose pro cessors. Several patents [1{ 10] and research articles [11{15] have b een written on ecient designs and implementations for barrel shifters. In [16], several 32-bit barrel shifters are compared in terms of delay,power, and p ower-delay pro duct. This pap er examines design alternatives for barrel shifters that p erform the following op erations: shift right logical, shift right arithmetic, rotate right, shift left logical, shift left arithmetic, and rotate left. These designs are optimized to share hardware for di erent op erations. Techniques are also presented for detecting results that over ow and results of zero in parallel with the shift or rotate op eration. Section 2 describ es the basic shift and rotate op erations and gives examples of each op eration. Section 3 presents designs for several typ es of barrel shifters. Section 4 gives area and delay estimates for eachtyp e of barrel shifter as the op erand size varies. Section 5 presents conclusions. Further details on the designs presented in this pap er are given in [17]. 2. SHIFT AND ROTATE OPERATIONS In this pap er, we de ne A to be the input op erand, B to be the shift/rotate amount, and Y to be the shifted/rotated result. We de ne A to be an n-bit value, where n is an integer power of two. Therefore, B is a log (n)-bit integer representing values from 0 to n 1. The barrel shifters presented in this pap er 2 perform the following six op erations: shift right logical, shift right arithmetic, rotate right, shift left logical, shift left arithmetic, and rotate left. Table1gives an example for each of these op erations. In this table, the bit vector for A is denoted as a a a a a a a a and the shift/rotate amount, B , is 3 bits. As illustrated in this 7 6 5 4 3 2 1 0 table: Op eration Y 3-bit shift right logical 0 0 0 a a a a a 7 6 5 4 3 3-bit shift right arithmetic a a a a a a a a 7 7 7 7 6 5 4 3 3-bit rotate right a a a a a a a a 2 1 0 7 6 5 4 3 3-bit shift left logical a a a a a 0 0 0 4 3 2 1 0 3-bit shift left arithmetic a a a a a 0 0 0 7 3 2 1 0 3-bit rotate left a a a a a a a a 4 3 2 1 0 7 6 5 Table 1. Shift and rotate examples for A = a a a a a a a a and B =3. 7 6 5 4 3 2 1 0 3-bit Op co de lef t r otate ar ithmetic Op eration 0 0 0 shift right logical 0 0 1 shift right arithmetic 0 1 X rotate right 1 0 0 shift left logical 1 0 1 shift left arithmetic 1 1 X rotate left Table 2. Op eration control bits. A B -bit shift right logical op eration p erforms a B -bit right shift and sets the upp er B bits of the result to zeros. A B -bit shift right arithmetic op eration performs a B -bit right shift and sets the upp er B bits of the result to a ,which corresp onds to the sign bit of A. n1 A B -bit rotate right op eration p erforms a B -bit right shift and sets the upp er B bits of the result to the lower B bits of A. A B -bit shift left logical op eration p erforms a B -bit left shift and sets the lower B bits of the result to zeros. A B -bit shift left arithmetic op eration p erforms a B -bit left shift and sets the lower B bits of the result to zeros. The sign bit of the result is set to a . n1 A B -bit rotate left op eration p erforms a B -bit left shift and sets the lower B bits of the result to the upp er B bits of A. 3. BARREL SHIFTER DESIGNS This section discusses barrel shifter designs. Basic shifter and rotator designs are describ ed rst in Section 3.1. Mux-based data-reversal barrel shifters, mask-based data-reversal barrel shifters, mask-based two's complement barrel shifters, and mask-based one's complement barrel shifters are then discussed in Sections 3.2 through 3.5. In the following discussion the term multiplexor refers to a 1-bit 2-to-1 multiplexor, unless otherwise stated. The op eration p erformed by the barrel shifters is controlled by a 3-bit op co de, which consists of the bits lef t, r otate,andar ithmetic, as summarized in Table 2. Additional control signals, sr a and sl a, are set to one when p erforming shift right arithmetic and shift left arithmetic op erations, resp ectively. 3.1. Shifters and Rotators An n-bit logarithmic barrel shifter uses log (n) stages [1, 2]. Each bit of the shift amount, B ,controls a di erent 2 k stage of the shifter. The data into the stage controlled by b is shifted by2 bits if b = 1; otherwise it is not k k Figure 1. 8-bit logical right shifter. Figure 2. 8-bit right rotator. shifted. Figure 1 shows the blo ck diagram of an 8-bit logical right shifter, which uses three stages with 4-bit, 2-bit, and 1-bit shifts. To optimize the design, eachmultiplexor that has '0' for one of its inputs can b e replaced b as inputs. by a 2-input and gate with the data bit and k A similar unit that performs right rotations, instead of right shifts, can be designed by mo difying the connections to the more signi cantmultiplexors. Figure 2 shows the blo ck diagram of an 8-bit right rotator, which uses three stages with 4-bit, 2-bit, and 1-bit rotates. The right rotator and the logical right shifter supply di erent inputs to the more signi cantmultiplexors. With the rotator, since all of the input bits are routed to the output, there is no longer a need for interconnect lines carrying zeros. Instead, interconnect lines are k k inserted to enable routing of the 2 low order data bits to the 2 high order multiplexors in the stage controlled by b . Changing from a non-optimized shifter to a rotator has no impact on the theoretical area or delay. The k longer interconnect lines of the rotator, however, can increase b oth area and delay. The logical right shifter can b e extended to also p erform shift right arithmetic and rotate right op erations by adding additional multiplexors. This approach is illustrated in Figure 3, for an 8-bit right shifter/rotator with three stages of 4-bit, 2-bit, and 1-bit shifts/rotates. Initially, a single multiplexor selects b etween '0' for logical k right shifting and a for arithmetic right shifting to pro duce s. In the stage controlled by b ,2 multiplexors n1 k k select b etween s for shifting and the 2 lower bits of the data for rotating. Figure 3. 8-bit mux-based right shifter/rotator. A right shifter can b e extended to also p erform left shift op erations by adding a rowof n multiplexors b oth b efore and after the right shifter [4]. When a left shift op eration is p erformed, these multiplexors reverse the data into and out of the right shifter. When a right shift op eration is p erformed, the data into and out of the shifter is not changed.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages12 Page
-
File Size-