DSPRelated.com
Forums

Cascading FIR

Started by Vasilius September 25, 2016
On Sun, 25 Sep 2016 14:23:13 -0700 (PDT), radams2000@gmail.com wrote:

>If you use the normal forward FIR structure, you have to send the delayed-b= >y-1000 input data as well as the partial sum-of-products from dsp1 to dsp2,= > unless you don't care about wasting memory in dsp2. However if you use the= > transposed form of FIR filtering then you only have to send one number acr= >oss the boundary.=20
I had in mind that both processors get the input stream, so both just do their 1/2 of the computations. The 2nd processor then delays it's output (to save half of the delay memory) to match the partial product that comes from the first. There are lots of ways to do it.
>Another consideration is that in fixed-point math, the accumulator often ov= >erflows or under-flows many times during the sequence of multiply-accumulat= >es but as long as it comes back within range at the end, you don't care. So= > when you break the FIR in two, you may need to transmit all the bits of th= >e accumulator from dsp1 to dsp2, which might require multiple data transact= >ions, assuming the dsp allows all bits of the accumulator to be sent to the= > serial port, which is not always the case.=20 > >Bob
Yeah, there are always details that may or may not get in the way. Just to answer the "Is this possible" question, though, the answer is certainly "yes". Unknown constraints that may apply can always change an answer made without those details.
On Sun, 25 Sep 2016 09:47:29 -0500, Vasilius wrote:

> Hello > > I have two DSP connected in serial mode. > Have FIR with 2000 coefficients . > Need to recalc and divide coefficients of FIR by 1000 for 2 DSP, so that > in serial application give result of FIR with 2000 points. > Delay of FIR here dont work, bcs FIR of each DSP is 1000 points maximum.
I had thought I saw someone suggest it, but you could factor the polynomial defined by the FIR, then rebuild two filters using half of the roots in each. At least for an 8-point moving average, the result is a very nicely perverse pair of filters that only an academic would love -- it's the kind of thing you'd want to implement if you secretly hated your boss but still wanted to stay employed. I suspect that a filter with softer edges would give saner results. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com I'm looking for work -- see my website!
On Sunday, September 25, 2016 at 11:50:45 AM UTC-4, Evgeny Filatov wrote:
> On 25.09.2016 17:47, Vasilius wrote: > > > > I have two DSP connected in serial mode. > > Have FIR with 2000 coefficients . > > Need to recalc and divide coefficients of FIR by 1000 for 2 DSP, so that > > in serial application give result of FIR with 2000 points. > > Delay of FIR here dont work, bcs FIR of each DSP is 1000 points maximum. > > > > > > Is this possible? > > > > Assuming you have H(z) = sum (in k from 1 to 2000) a_k * z^(-k), you can > split it in multiple ways. The simplest would be > H(z) = H1(z) + H2(z)*z^(-1000), where > H1(z) = sum (in k from 1 to 1000) a_k * z^(-k), and > H2(z) = sum (in k from 1 to 1000) a_{k+1000} * z^(-k) > > It's not exactly "serial", but you just need to add the output of filter > H1 with the delayed output of filter H2. > > I'm afraid to ask why do you need a FIR with 2000 coefficients... >
an FIR that is that long should maybe be done with "fast convolution" using the FFT. r b-j
On Mon, 26 Sep 2016 12:06:24 -0700, robert bristow-johnson wrote:

> On Sunday, September 25, 2016 at 11:50:45 AM UTC-4, Evgeny Filatov > wrote: >> On 25.09.2016 17:47, Vasilius wrote: >> > >> > I have two DSP connected in serial mode. >> > Have FIR with 2000 coefficients . >> > Need to recalc and divide coefficients of FIR by 1000 for 2 DSP, so >> > that in serial application give result of FIR with 2000 points. >> > Delay of FIR here dont work, bcs FIR of each DSP is 1000 points >> > maximum. >> > >> > >> > Is this possible? >> > >> > >> Assuming you have H(z) = sum (in k from 1 to 2000) a_k * z^(-k), you >> can split it in multiple ways. The simplest would be H(z) = H1(z) + >> H2(z)*z^(-1000), where H1(z) = sum (in k from 1 to 1000) a_k * z^(-k), >> and H2(z) = sum (in k from 1 to 1000) a_{k+1000} * z^(-k) >> >> It's not exactly "serial", but you just need to add the output of >> filter H1 with the delayed output of filter H2. >> >> I'm afraid to ask why do you need a FIR with 2000 coefficients... >> >> > an FIR that is that long should maybe be done with "fast convolution" > using the FFT. > > r b-j
He could have some limited-flexibility device that only allows FIRs or some such (I recall looking at the data sheet for a DSP chip that was specifically for hearing aids -- it was not, in any sense, a general- purpose processor. It was more a fixed architecture set of filters into which you could stuff coefficients.) 'course, if he DOES have something ordinary, and if he's doing something more complicated than a moving average, yes, 'fast convolution' may be the answer. Only the shadow (er, I mean the OP) knows. -- Tim Wescott Control systems, embedded software and circuit design I'm looking for work! See my website if you're interested http://www.wescottdesign.com
Tim Wescott <seemywebsite@myfooter.really> writes:

> On Sun, 25 Sep 2016 09:47:29 -0500, Vasilius wrote: > >> Hello >> >> I have two DSP connected in serial mode. >> Have FIR with 2000 coefficients . >> Need to recalc and divide coefficients of FIR by 1000 for 2 DSP, so that >> in serial application give result of FIR with 2000 points. >> Delay of FIR here dont work, bcs FIR of each DSP is 1000 points maximum. > > I had thought I saw someone suggest it, but you could factor the > polynomial defined by the FIR, then rebuild two filters using half of the > roots in each.
This is what I was thinking would be the most efficient way to do this. -- Randy Yates, DSP/Embedded Firmware Developer Digital Signal Labs http://www.digitalsignallabs.com
On Tue, 27 Sep 2016 01:32:27 -0400, Randy Yates wrote:

> Tim Wescott <seemywebsite@myfooter.really> writes: > >> On Sun, 25 Sep 2016 09:47:29 -0500, Vasilius wrote: >> >>> Hello >>> >>> I have two DSP connected in serial mode. >>> Have FIR with 2000 coefficients . >>> Need to recalc and divide coefficients of FIR by 1000 for 2 DSP, so >>> that in serial application give result of FIR with 2000 points. >>> Delay of FIR here dont work, bcs FIR of each DSP is 1000 points >>> maximum. >> >> I had thought I saw someone suggest it, but you could factor the >> polynomial defined by the FIR, then rebuild two filters using half of >> the roots in each. > > This is what I was thinking would be the most efficient way to do this.
I suspect it only works well for some filters. Try it with a moving average, for yuks. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com I'm looking for work -- see my website!
Tim Wescott <seemywebsite@myfooter.really> writes:

> On Tue, 27 Sep 2016 01:32:27 -0400, Randy Yates wrote: > >> Tim Wescott <seemywebsite@myfooter.really> writes: >> >>> On Sun, 25 Sep 2016 09:47:29 -0500, Vasilius wrote: >>> >>>> Hello >>>> >>>> I have two DSP connected in serial mode. >>>> Have FIR with 2000 coefficients . >>>> Need to recalc and divide coefficients of FIR by 1000 for 2 DSP, so >>>> that in serial application give result of FIR with 2000 points. >>>> Delay of FIR here dont work, bcs FIR of each DSP is 1000 points >>>> maximum. >>> >>> I had thought I saw someone suggest it, but you could factor the >>> polynomial defined by the FIR, then rebuild two filters using half of >>> the roots in each. >> >> This is what I was thinking would be the most efficient way to do this. > > I suspect it only works well for some filters. Try it with a moving > average, for yuks.
OK:
>> roots([1 1 1 1 1])
ans = 0.30902 + 0.95106i 0.30902 - 0.95106i -0.80902 + 0.58779i -0.80902 - 0.58779i Other than the fact that you have to be careful to group the results into conjugate root pairs, what's the problem? -- Randy Yates, DSP/Embedded Firmware Developer Digital Signal Labs http://www.digitalsignallabs.com
On Tue, 27 Sep 2016 07:20:35 -0400, Randy Yates wrote:

> Tim Wescott <seemywebsite@myfooter.really> writes: > >> On Tue, 27 Sep 2016 01:32:27 -0400, Randy Yates wrote: >> >>> Tim Wescott <seemywebsite@myfooter.really> writes: >>> >>>> On Sun, 25 Sep 2016 09:47:29 -0500, Vasilius wrote: >>>> >>>>> Hello >>>>> >>>>> I have two DSP connected in serial mode. >>>>> Have FIR with 2000 coefficients . >>>>> Need to recalc and divide coefficients of FIR by 1000 for 2 DSP, so >>>>> that in serial application give result of FIR with 2000 points. >>>>> Delay of FIR here dont work, bcs FIR of each DSP is 1000 points >>>>> maximum. >>>> >>>> I had thought I saw someone suggest it, but you could factor the >>>> polynomial defined by the FIR, then rebuild two filters using half of >>>> the roots in each. >>> >>> This is what I was thinking would be the most efficient way to do >>> this. >> >> I suspect it only works well for some filters. Try it with a moving >> average, for yuks. > > OK: > >>> roots([1 1 1 1 1]) > ans = > > 0.30902 + 0.95106i 0.30902 - 0.95106i > -0.80902 + 0.58779i -0.80902 - 0.58779i > > Other than the fact that you have to be careful to group the results > into conjugate root pairs, what's the problem?
Now put those back into FIR form and look at the magnitude of the taps. Think about numerical stability. That sort of thing. It may get better as the filter gets longer -- I don't know. -- Tim Wescott Control systems, embedded software and circuit design I'm looking for work! See my website if you're interested http://www.wescottdesign.com
Tim Wescott <tim@seemywebsite.com> writes:

> On Tue, 27 Sep 2016 07:20:35 -0400, Randy Yates wrote: > >> Tim Wescott <seemywebsite@myfooter.really> writes: >> >>> On Tue, 27 Sep 2016 01:32:27 -0400, Randy Yates wrote: >>> >>>> Tim Wescott <seemywebsite@myfooter.really> writes: >>>> >>>>> On Sun, 25 Sep 2016 09:47:29 -0500, Vasilius wrote: >>>>> >>>>>> Hello >>>>>> >>>>>> I have two DSP connected in serial mode. >>>>>> Have FIR with 2000 coefficients . >>>>>> Need to recalc and divide coefficients of FIR by 1000 for 2 DSP, so >>>>>> that in serial application give result of FIR with 2000 points. >>>>>> Delay of FIR here dont work, bcs FIR of each DSP is 1000 points >>>>>> maximum. >>>>> >>>>> I had thought I saw someone suggest it, but you could factor the >>>>> polynomial defined by the FIR, then rebuild two filters using half of >>>>> the roots in each. >>>> >>>> This is what I was thinking would be the most efficient way to do >>>> this. >>> >>> I suspect it only works well for some filters. Try it with a moving >>> average, for yuks. >> >> OK: >> >>>> roots([1 1 1 1 1]) >> ans = >> >> 0.30902 + 0.95106i 0.30902 - 0.95106i >> -0.80902 + 0.58779i -0.80902 - 0.58779i >> >> Other than the fact that you have to be careful to group the results >> into conjugate root pairs, what's the problem? > > Now put those back into FIR form and look at the magnitude of the taps. > Think about numerical stability. That sort of thing. > > It may get better as the filter gets longer -- I don't know.
Are you referring to the problem (in this specific example) of the coefficients being exactly representable in the original filter (i.e., "1") in fixed-point but not in the factored filters: f1(z) = z^2 - 0.61803*z + 1 f1(z) = z^2 + 1.61800*z + 1 ? That is certainly a source of error in the one that the other didn't have. How significant it would be I don't know. I would think it would get worse with longer filters. -- Randy Yates, DSP/Embedded Firmware Developer Digital Signal Labs http://www.digitalsignallabs.com
On Tuesday, September 27, 2016 at 8:22:44 AM UTC-7, Tim Wescott wrote:
> On Tue, 27 Sep 2016 07:20:35 -0400, Randy Yates wrote: > > Tim Wescott <seemywebsite@myfooter.really> writes:
(snip on factoring polynomials)
> >>> roots([1 1 1 1 1]) > > ans =
> > 0.30902 + 0.95106i 0.30902 - 0.95106i > > -0.80902 + 0.58779i -0.80902 - 0.58779i
> > Other than the fact that you have to be careful to group the results > > into conjugate root pairs, what's the problem?
> Now put those back into FIR form and look at the magnitude of the taps. > Think about numerical stability. That sort of thing.
Seems to me that some polynomials you can factor exactly, and some even into two equal factors. (That is, they have an exact square root.) But also, in most cases and FIR is not the exact solution to the desired filter, when done with finite precision. Even more, there could be two polynomials that when multiplied come out nice and close to the desired filter.
> It may get better as the filter gets longer -- I don't know.
And I suspect that it gets easier, or closer, as the filter gets longer. But the OP hasn't said why a 2000 term filter is needed.