Modulo address generator and a method for implementing modulo addressing

Abstract: A modulo address generator, for allowing a contiguous set of memory locations within a memory bank to be accessed as a circular buffer, the circular buffer can be located in any predetermined location within the memory bank and is bounded by a starting address BEGIN and an end address END, the modulo address signal generator is initiated by receiving either one of BEGIN and END, the length LENGTH of the circular buffer and a initial target address PTR(0). The modulo address generator provides a current target address after receiving a displacement DISP between a prior target address PTR(n-1) and the current target address PTR(n) to be accessed within the circular buffer. The modulo address generator provides an absolute address and a wrapped address, and determines which of these addresses is within the boundaries of the circular address, the determination involves comparing either one of the wrapped address and the absolute address to one of the circular buffer boundaries. If the determination involves the comparison of BEGIN to either one of the wrapped address and the absolute address then if DISP is positive, the wrapped address is compared to BEGIN, and if DISP is negative, the absolute address is compared to BEGIN. If the determination involves the comparison of END to either one of the wrapped address and the absolute address then if DISP is negative, the wrapped address is compared to END, and if DISP is positive, the absolute address is compared to END.

Description: Field of the Invention The present invention relates generally to an modulo address generator for allowing contiguous set of memory locations to be accessed as a circular buffer, and for a method for implementing modulo addressing, especially within a processor. Background of the Invention Modulo addressing allows a contiguous set of memory locations within a memory bank to be accessed as a circular buffer. The circular buffer is bounded by a starting address, and an end address within the memory bank. A modulo address generator provides target addresses within the circular buffer. The modulo address generator usually stores data regarding the location and the length of circular buffer, and usually produces a target instruction when given a displacement between the current target address to the next target address. Modulo address generators are a part of the critical path of addressing units within data processing units and Digital Signal Processors (i.e.- processors). Digital signal processing and data processing require extensive use of modulo addressing. In order to decrease the power consumption of processors, and in order to increase their speed of operation, many implementations of modulo addressing restrict either the starting address of the circular buffer, the size of the circular buffer, or the displacement value. Prior art modulo address generators implement the following equations : PTR(n) = (PTR(n-1) + DISP), if DISP>0, and (PTR(n-1)+DISP)≤ END. PTR(n) = (PTR(n-1) + DISP - END - 1+BEGIN), if DISP>0, and (PTR(n-1)+DISP)> END. PTR(n) = (PTR(n-1) + DISP), if DISP<0, and (PTR(n-1)+DISP)≥ BEGIN. PTR(n) = (PTR(n-1) + DISP + END + 1 - BEGIN), if DISP<0, and (PTR(n-1)+DISP)< BEGIN. Wherein PTR(n-1) is the current target address, PTR(n) is the next target address, DISP is the displacement between the current target address to the next target address, BEGIN is the starting address of the circular buffer, END is the end address of the circular buffer. This equations and other derivative equations used to implement modulo addressing are disclosed in "True Modulo Address Generators for Digital Signal Processors", The Proceedings of the 8 th International Conference on Signal Processing Applications & Technology, 1997, pg. 843 by Mohit K. Prasad and Ravi K. Kolagotla. The implementation of these equations required to store both END and BEGIN, wherein the selection of the next target address required comparisons to both END (when the displacement is positive) and to BEGIN (when the displcaement is negative). Two types of modulo address generators implementing these equations are disclosed in U.S. Pat. No. 5,623,621 of Garde. The first type of modulo address generator disclosed in U.S. Pat. 5,623,621 is tailored to either positive displacements or to negative displacements, thus it restricts the displacement value. A first modulo address generator handles positive displacement, the first modulo address generator determines the next target address by comparing a wrapped address to BEGIN. A second modulo address generator handles negative displacement, the second modulo address generator determines the next target address by comparing a wrapped address to END. A second type of modulo address generators, for example as disclosed in US 5,659,700, can handle both positive and negative displacements, but requires additional hardware, such as an additional adder and multiplexer, thus increasing the power consumption of modulo address generator and limiting the speed of operation of the modulo address generator and of the processor in which the modulo address is included. This addition of hardware is more acute in processors having a plurality of modulo address generators. Accordingly, there is a need for improved and compact modulo address generator, which can handle arbitrary displacements, starting address and end addresses, as in claims 1 and 7. Brief Description of the Drawings While the invention is pointed out with particularity in the appended claims, other features of the invention are disclosed by the following detailed description taken in conjunction with the accompanying drawings, in which: FIG. 1 is a schematic diagram of a portion of a memory bank and an modulo address generator according to an embodiment of the invention; FIG. 2 is a schematic description of a modulo address generator, according to a preferred embodiment of the invention; FIG. 3 is a schematic description of a modulo address generator, according to a further embodiment of the invention. Detailed Description of the Drawings It should be noted that the particular terms and expressions employed and the particular structural and operational details disclosed in the detailed description and accompanying drawings are for illustrative purposes only and are not intended to in any way limit the scope of the invention as described in the appended claims. FIG. 1 a schematic diagram of a portion of memory bank 15 and an modulo address generator 17 according to an embodiment of the invention. Circular buffer 19 is located within the portion of memory bank 15, and is bounded by a starting address BEGIN, and an end address END. Circular buffer 19 can be located in any predetermined location within memory bank 15. Modulo address generator 17 and memory bank 15 are coupled via address bus 112, and can also be coupled via data bus 110. When there is a need to access one of the memory words within circular buffer 19, modulo address generator generates a target address within circular buffer 19, the address is sent, via address bus 112 to memory bank 15, and allows to access the said memory word, preferably via data bus 110. Modulo address generator 17 is coupled to data bus 110, for receiving BEGIN, END, DISP. Modulo address generator 17 can also receive via data bus 110 a target address, usually during the initialization of modulo address generator 17. Modulo address generator 17 is compact and can handle arbitrary DISP (both positive and negative), END and BEGIN. Modulo address generator 17 produces a absolute address and a wrapped address and compares one of these address to BEGIN, in order to determine which of these addresses is within circular buffer 19. Modulo address generator 17 comprising : First logic circuit 9, coupled to data bus 110, for storing PTR(n-1), wherein it can also store a target address send to modulo address generator 17 via data bus 110. First logic circuit 9 is also for storing DISP and PTR(n), and for storing information which defines the boundaries of the circular buffer. The information can define two out of BEGIN, END, LENGTH. Preferably, first logic circuit stores BEGIN and LENGTH. First circuit logic 9 has a first register (not shown in FIG. 1) for storing PTR(n). Sign unit 50, coupled to first logic circuit 9, for determining the sign of DISP; Second logic circuit 8, coupled to first logic circuit 9, for generating an absolute address DISP+PTR(n-1). Third logic circuit 7, coupled to the first and second logic circuits 9 and 8, and to sign unit 50, for generating a wrapped address, wherein the generation of the wrapped address involves adding the length of the circular buffer LENGTH to the absolute address when DISP is negative and involves subtracting LENGTH from the absolute address when DISP is positive. Fourth logic circuit 6, coupled to third logic circuit 7 and to second logic circuit 8, for determining which of the wrapped address and the absolute address is within the circular buffer 19 and for loading the first register with the address which is within circular buffer 19. Fourth logic determines which of these two addresses is within circular buffer by comparing the wrapped address to BEGIN if DISP is positive, and by comparing the absolute address to BEGIN, if DISP is negative. Modulo address generator 17 implements the following equations : PTR(n) = (PTR(n-1) + DISP), if DISP>0, and (PTR(n-1)+DISP-LENGTH)< BEGIN. PTR(n) = (PTR(n-1) + DISP - LENGTH), if DISP>0, and (PTR(n-1)+DISP-LENGTH)≥ BEGIN. PTR(n) = (PTR(n-1) + DISP), if DISP<0, and (PTR(n-1)+DISP)≥ BEGIN. PTR(n) = (PTR(n-1) + DISP +LENGTH), if DISP<0, and (PTR(n-1)+DISP)< BEGIN. FIG. 2 is a more detailed schematic description of modulo address generator 17 , according to a preferred embodiment of the invention. First logic circuit 8 further comprising : second register 20 for storing BEGIN, third register 30 for storing LENGTH, and fourth register 40 for storing DISP. First register 10 has inputs 12 and 14 and output 18. Second register 20 has input 22 and output 24. Third register 30 has input 32 and output 34. Fourth register 40 has input 42 and output 44. Second logic circuit 8 has adder 60, adder 60 has two inputs 62, 64 and output 66. Inputs 14, 22, 32 and 42 of first to fourth registers 10, 20 30 and 40 are coupled to data bus 110. Output 18 of first register 10 is coupled to address bus 112 and to input 62 of adder 60. Input 64 of adder 60 is coupled to output 44 of fourth register 40. Third logic circuit 7 has adder and subtractor unit 70, for providing a wrapped address. Adder and subtractor unit 70 has inputs 72 and 76, a control input 74 and output 78. Input 76 of adder and subtractor unit 70 is coupled to output 34 of third register 30, for receiving LENGTH. Input 72 of adder and subtractor unit 70 is coupled to output 66 of adder 60, for receiving absolute address PTR(n-1)+DISP. Sign unit 50 has input 52 and output 54. Input 52 of sign unit 50 is coupled to output 44 of fourth register 40, for receiving DISP. Output 54 of sign unit 50 is coupled to control input 74 of adder and subtractor unit 70, for indicating whether DISP is positive or negative. If DISP is negative, adder and subtractor unit 70 produces a wrapped address by adding LENGTH to PTR(n-1)+DISP, if DISP is positive, adder and subtractor unit produces a wrapped address by subtracting LENGTH from PTR(n-1)+DISP. Fourth logic circuit 6 comprising : first multiplexer 90, second multiplexer 80, comparator 100 and XOR logic gate 120 (i.e.- XOR). First multiplexer 90, for selecting whether to send comparator 90 a wrapped address, provided by adder and subtractor unit 70 or send an absolute address, provided by adder 60. First multiplexer has inputs 94 and 92, a control input 98 and output 96. Input 92 is coupled to output 78 of adder and subtractor unit 70, for receiving the wrapped address. Input 94 is coupled to output 66 of adder 60 for receiving the absolute address. Control input 98 is coupled to output 54 of sign unit, for having two inputs, a control input and an output, for selecting one of the absolute address and the wrapped address. Comparator 100 to compare the address sent to it by adder and subtractor unit 70 to BEGIN, provided by second register 20. Comparator 100 has inputs 102 and 104 and output 106. Input 102 coupled to output 24 of second register 20, input 104 coupled to output 96 of first multiplexer 90. Second multiplexer 80, having inputs 82 and 86, a control input 84 and output 88, for receiving a wrapped address from adder and subtractor unit 70 and for receiving an absolute address from adder 60 and for selecting either one of these two addresses according to control signals received in input 84, the selected address is sent to first register 10. Input 82 is coupled to output 78 of adder and subtractor unit 70, input 86 is coupled to output 66 of adder 60 and output 88 is coupled to input 12 of first register 10. XOR 120, having inputs 124 and 122 and output 126, input 124 is coupled to output 54 of sign unit 50, input 122 is coupled to output 106 of comparator 100 and output 126 is coupled to input 84 of second multiplexer. XOR 120 sends control signals, for selecting which of the wrapped address and absolute address is selected by second multiplexer 80, the control signals are the result of a XOR operation between the output of sign unit 50 and the output of comparator 100. FIG. 3 is a detailed schematic description of modulo address generator 170, according to another preferred embodiment of the invention. Modulo address generator 170 of FIG. 2 is analogues to modulo address generator 17, but second register 20 stores END, inputs 94 and 92 of first multiplexer 70 are coupled to output 78 of adder and subtractor unit and output 66 of adder 60, accordingly. Modulo address generator 17 implements the following equations : PTR(n) = (PTR(n-1) + DISP), if DISP>0, and (PTR(n-1)+DISP)< END. PTR(n) = (PTR(n-1) + DISP - LENGTH), if DISP>0, and (PTR(n-1)+DISP)≥ END. PTR(n) = (PTR(n-1) + DISP), if DISP<0, and (PTR(n-1)+DISP+LENGTH)≥ END. PTR(n) = (PTR(n-1) + DISP +LENGTH), if DISP<0, and (PTR(n-1)+DISP+LENGTH)< END. FIG. 4 is a flow chart of a method 200 for implementing modulo addressing. Method 200 comprising the following steps : Determining 210 the location of a circular buffer, and receiving the one of the boundaries (either the starting address BEGIN or the end address END) of the circular buffer, the length LENGTH of the circular buffer, and an initial target address PTR(0) within the circular buffer. As indicated by path 215, step 210 is followed by step 220. Receiving 220 a displacement DISP, between the previous target address PTR(n-1) within a circular buffer and the current target address PTR(n) within the circular buffer. As indicated by path 225, step 220 is followed by step 230. Determining 230 whether DISP is positive or negative and producing accordingly sign signal, and producing an absolute address by adding DISP to PTR(n-1). As indicated by path 235, step 230 is followed by step 240. Producing 240 a wrapped address, according to the sign signal, whereas the wrapped address equals DISP+PTR(n-1)-LENGTH if the sign signal indicates that DISP is positive, else, the wrapped address equals DISP+PTR(n-1)+LENGTH. As indicated by path 245, step 240 is followed by step 250. Determining 250 which of the addresses (the wrapped address and the absolute address) is within the circular buffer, by comparing either one of the wrapped address and the absolute address to one of the circular buffer boundaries. Wherein if the determination involves the comparison of BEGIN to either one of the wrapped address and the absolute address then if DISP is positive, the wrapped address is compared to BEGIN, and if DISP is negative, the absolute address is compared to BEGIN. Wherein if the determination involves the comparison of END to either one of the wrapped address and the absolute address then if DISP is negative, the wrapped address is compared to END, and if DISP is positive, the absolute address is compared to END. As indicated by path 255, step 250 is followed by step 260. Giving 260 the current target address the value of the address which is within the boundaries of the circular buffer. As indicated by path 265, step 260 is followed by step 220. Thus, there has been described herein an embodiment including at least one preferred embodiment of an improved method and apparatus for a modulo address generator and a method for implementing modulo addressing. It will be apparent to those skilled in the art that the disclosed subject matter may be modified in numerous ways and may assume many embodiments other than the preferred form specifically set out and described above. Accordingly, the above disclosed subject matter is to be considered illustrative and not restrictive, and to the maximum extent allowed by law, it is intended by the appended claims to cover all such modifications and other embodiments which fall within the true scope of the present invention. The scope of the invention is to be determined by the broadest permissible interpretation of the following claims rather than the foregoing detailed description.

Claims: A modulo address generator (17), for allowing a contiguous set of memory locations within a memory bank (15) to be accessed as a circular buffer (19), the circular buffer (19) bounded by a starting address BEGIN and an end address END, the modulo address signal generator (17) comprising : a first logic circuit (9) for storing a previous address PTR(n-1) accessed within the circular buffer (19), a displacement DISP between PTR(n-1) and the next address PTR(n) to be accessed within the circular buffer (19), and for storing information which defines the boundaries of the circular buffer (19); wherein the first logic circuit (9) has a first register (10) for storing PTR(n); a sign unit (50), coupled to the first logic circuit (9), for determining the sign of DISP; a second logic circuit (8), coupled to the first logic circuit (9), for generating an absolute address DISP+PTR(n-1); a third logic circuit (7), coupled to the first and second logic circuits (9), (8) and to the sign unit (50), for generating a wrapped address, wherein the generation of the wrapped address involves adding the length of the circular buffer LENGTH to the absolute address when DISP is negative and involves subtracting LENGTH from the absolute address when DISP is positive; and characterised by the starting address BEGIN and the end address END being arbitrary addresses within the memory bank (15) and a fourth logic circuit (6), coupled to the second and third logic circuits (8), (7), for determining which of the wrapped address and the absolute address is within the circular buffer register (19) and for loading the first register (10) with the address which is within the circular buffer (19), the determination involves comparing either one of the wrapped address and the absolute address to one of the circular buffer boundaries. The modulo address generator (17) of claim 1 wherein if the determination involves the comparison of BEGIN to either one of the wrapped address and the absolute address then if DISP is positive, the wrapped address is compared to BEGIN, and if DISP is negative, the absolute address is compared to BEGIN; and wherein if the determination involves the comparison of END to either one of the wrapped address and the absolute address then if DISP is negative, the wrapped address is compared to END, and if DISP is positive, the absolute address is compared to END. The modulo address generator (17) of claim 2 wherein the first logic circuit (19) further comprising : a second register for storing BEGIN (20); a third register for storing LENGTH (30); a fourth register for storing DISP (40); wherein each register has an input and an output; wherein the second logic circuit (8) has an adder (60), having two inputs and an output; wherein the two inputs of the adder (60) are coupled to the outputs of the first and fourth registers (10), (40), accordingly; wherein the third logic circuit (7) has an adder and a subtractor unit (70); wherein the sign unit (50) has an output; wherein the adder and subtractor unit (70) has two inputs, a control input and an output; wherein the first input of the adder and subtractor unit (70) is coupled to the output of the adder (60), for receiving PTR(n-1)+DISP; wherein the second input of the adder and subtractor unit (70) is coupled to the output of the third register (30), for receiving LENGTH; wherein the control input of the adder and subtractor unit (70) is coupled to the output of the sign unit (150); and wherein the signals provided to the control input of the adder and subtractor unit (70) determine when to add the LENGTH to PTR(n-1)+DISP and when to subtract LENGTH from PTR(n-1)+DISP. The modulo address generator (17) of claim 3 wherein the fourth logic circuit (6) comprising: a first multiplexer (90), having two inputs, a control input and an output, for selecting one of the absolute address and the wrapped address; a comparator (100), having two inputs and an output, for comparing BEGIN to the address selected by the first multiplexer (90); a second multiplexer (80), having two inputs, a control input and an output, for selecting one of the absolute address and the wrapped address and for sending the selected address to the first register (10); a XOR logic gate (120), having two inputs and an output, for performing a XOR operation; wherein the output of the adder (60) is coupled to the first input of the first and second multiplexers (80); wherein the output of the adder and subtractor unit (70) is coupled to the second input of the first and second multiplexers (90), (80); wherein the control input of the first multiplexer (90) and the first input of the XOR logic gate (120) are coupled to the sign unit (50); wherein the output of the comparator (100) is coupled to the second input of the XOR logic gate (120); wherein the control input of the second multiplexer (80) is coupled to the output of the XOR logic gate (120); wherein the first input of the comparator (100) is coupled to the second register (20); and wherein the second input of the comparator (100) is coupled to the output of the first multiplexer (90). The modulo address generator (17) of claim 2 wherein the first logic circuit (9) further comprising : a second register for storing END (20); a third register for storing LENGTH (30); a fourth register for storing DISP (40); wherein each register has an input and an output; wherein the second circuit (18) has an adder (60), having two inputs and an output; wherein the two inputs of the adder (60) are coupled to the outputs of the first and fourth registers (101), (40), accordingly; wherein the third logic circuit (7) has an adder and subtractor unit (70); wherein the sign unit (50) has an output; wherein the adder and subtractor unit (70) has two inputs, a control input and an output; wherein the first input of the adder and subtractor unit (70) is coupled to the output of the first adder (60), for receiving PTR(n-1)+DISP; wherein the second input of the adder and subtractor unit (70) is coupled to the output of the third register (30), for receiving LENGTH; wherein the control input of the adder and subtractor unit (70) is coupled to the output of the sign unit (50); and wherein the signals provided to the control input of the adder and subtractor unit (70) determine when to add the LENGTH to PTR(n-1)+DISP and when to subtract LENGTH from PTR(n-1)+DISP. The modulo address generator (17) of claim 5 wherein the fourth logic circuit (6) comprising: a first multiplexer (90), having two inputs, a control input and an output, for selecting one of the absolute address and the wrapped address; a comparator (100), having two inputs and an output, for comparing END to the address selected by the first multiplexer (90); a second multiplexer (80), having two inputs, a control input and an output, for selecting one of the absolute address and the wrapped address and for sending the selected address to the first register (10); a XOR logic gate (120), having two inputs and an output, for performing a XOR operation; wherein the output of the adder (160) is coupled to the second input of the first multiplexer and to the first input of the second multiplexer (80); wherein the output of the adder and subtractor unit (70) is coupled to the first input of the first multiplexer (90) and to the second input of the second multiplexer (80); wherein the control input of the first multiplexer (90) and the first input of the XOR logic gate (120) are coupled to the sign unit (50); wherein the output of the comparator (100) is coupled to the second input of the XOR logic gate (120); wherein the control input of the second multiplexer (80) is coupled to the output of the XOR logic gate (120); wherein the first input of the comparator (100) is coupled to the second register (20); and wherein the second input of the comparator (100) is coupled to the output of the first multiplexer (90). A method for implementing modulo addressing, by producing a target address within a circular buffer, the method comprising the following steps of : determining the location of the circular buffer(19), and receiving the one of the boundaries of the circular buffer (19), the length LENGTH of the circular buffer (19), and an initial target address PTR(0) within the circular buffer (19); receiving a displacement DISP, between a previous target address PTR(n-1) within a circular buffer (19) and the current target address PTR(n) within the circular buffer (19), n being a positive integer; determining whether DISP is positive or negative and producing accordingly sign signal; producing an absolute address by adding DISP to PTR(n-1); producing a wrapped address, according to the sign signal, whereas the wrapped address equals DISP+PTR(n-1)-LENGTH if the sign signal indicates that DISP is positive, the wrapped address equals DISP+PTR(n-1)+LENGTH if the sign signal indicates that DISP is negative; characterised by the starting address BEGIN and the end address END being arbitrary addresses within the memory bank (15) and characterised by the steps of: determining which of the absolute address and the wrapped address is within the circular buffer (19); wherein the determination involves the comparison of one of the wrapped address and the absolute address to one of the circular buffer boundaries; giving the current target address PTR(n) the value of the address, out of the wrapped address and the absolute address which is within the boundaries of the circular buffer; and jumping to the step of receiving a displacement DISP when a new displacement is received. The method of claim 7 wherein if DISP is positive, the wrapped address is compared to BEGIN, and if DISP is negative, the absolute address is compared to BEGIN.

Inventors: ELNEKAVE MARK, FABRICE AIDAN, SALANT YORAM, TOKAR YAKOV, TSUKERMAN LEONID, ELNEKAVE, MARK, FABRICE, AIDAN, SALANT, YORAM, TOKAR, YAKOV, TSUKERMAN, LEONID
Applicants: FREESCALE SEMICONDUCTOR INC, FREESCALE SEMICONDUCTOR, INC.
Application year: 1999
Main classification: G06F5
IPC codes: G06F5, G06F9