DSPRelated.com
Forums

sample-by-sample FIR optimized

Started by Wojciech Rewers September 17, 2003
My comments were in general, and to be clear and not directed
at the understanding or lack of, for any one individual in
particular. This was not my aim. I was tring to be clear.
Hope I did not annoy anybody. At the same point I did not
want to leave anybody out. First of all appologies to all,
Wojciech Rewers in particular, if I came across as being so.

The reason that the stack pointer needs to be double word
aligned, is to facilitate running code across multiple
platforms in particular C62x code on C67x, the reason being
that C67x can perform LDDW to load registers from the stack.

Even then the correct way to do it is to pre-decrement the
stack by the number of words you intend to use upfront, and
not decrement it one at a time. However the code shown on
Page 8-12 is correct because within an ISR unless you re-enable
GIE {shown on next page of PRG} you do not respond to interrupts.
Further, since an even number of registers are pushed and popped,
if the stack pointer is double-word aligned to begin with,
it will be double-word aligned at the end as well. So, this
example "happens" to work.

However the "best" way to do it would be the way the C compiler
does it {yet another reason why tools are better }. I will show
the assembly statements used by the C compiler to accomplish
maintenance of the stack. Notice that even the loads from the
stack are being done using load double words. Notice the pre-
decrement and post increment.

Saves to stack:

MV .S1X SP,A9 ; |5|
|| STW .D2T1 A10,*SP--(24) ; |5|

STW .D2T2 B13,*+SP(20)

MVK .S2 32,B5
|| STW .D2T2 B12,*+SP(16)

SUB .L2X A4,B5,B5
|| STW .D2T2 B11,*+SP(12)

MV .S1X DP,A10 ; save dp
|| STW .D1T1 A14,*-A9(20)
|| MV .L2 B4,B11
|| STW .D2T2 B10,*+SP(8)
|| MVC .S2 CSR,B4

ADD .L2 4,B5,B12
|| LDDW .D2T2 *B11++(32),B7:B6 ; |47| (P) <0,1>
|| MV .S1X B4,A8
|| AND .S2 -2,B4,B4

SHR .S1 A6,3,A4 ; |47|
|| MV .L1X B5,A6
|| MVC .S2 B4,CSR ; interrupts off
|| LDW .D2T2 *++B12(32),DP ; |47| (P) <0,0>

Restores from the stack:

MV .S1X SP,A9 ; |55|
|| ADDSP .L2 B7,B1,B1 ; |47| (E) <3,14> ^

ADDSP .L2 B4,B2,B2 ; |47| (E) <3,15> ^

ADDSP .L1 A5,A0,A0 ; |47| (E) <3,16> ^
|| ADDSP .L2 B4,B13,B13 ; |47| (E) <3,16> ^

LDDW .D2T2 *+SP(8),B11:B10 ; |55|
|| MV .S1X B10,A8
|| MV .S2X A8,B4

MV .S2X A10,DP ; restore dp
MVC .S2 B4,CSR ; interrupts on

LDDW .D2T2 *+SP(16),B13:B12 ; |55|
|| ADDSP .L1X A8,B13,A6 ; |54|

NOP 3

LDW .D1T1 *+A9(4),A14 ; |55|
|| MV .S2X A14,B3 ; |55|
|| ADDSP .L1X B3,A6,A3 ; |54|

LDW .D2T1 *++SP(24),A10 ; |55|

Regards
Jagadeesh Sankaran



Hi all, and Wojciech Rewers,

>yeah - all squares are rectangles, but not all

>rectangles are squares - logic taught to a 10 year old...

May be iam slightly old fashioned here...but are'nt we supposed to be respectful to people who are trying to help us? and not be cynical/spiteful?

Wow, it makes me wonder what will happen if someone gives a wrong answer to your question,you would mow them down? intellectually,perhaps? what with all your "i need know why am doing what am doing,or ill kill you attitude"?

Btw,Mr.sankaran has been one of the brightest and most erudite ti engineer to participate in the group.And if you notice he doesnt give CLEVER one line answers-He is a great teacher who PROVES most things he says.I agree, he dint initially fall into the "sample-by-sample" drift right away, but cmon man...cut him some slack here!

Anyways, to your credit,(i hope...) i have to say, you seem(?) to be the kind who could take as much as you can give!

So,friends? adults?

So,Dont bother apologising, or may be you should!

Hah!

 Bhooshan

 



MSN Hotmail now on your Mobile phone. Click here.


> Hi all, and Wojciech Rewers,

hi all...

>> yeah - all squares are rectangles, but not all
rectangles are squares - logic taught to a 10 year
old...

> May be iam slightly old fashioned here...but are'nt
we supposed to be respectful to people who are trying
to help us? and not be cynical/spiteful?

well... as I said before - I do respect all
participants of this group and all people in
general... I admit - my remark was a bit "cynical" but
spitful? hm... after all - I only rephrased what
Jagadeesh said and I quote:
All double-word addresses are word_aligned. Not all
word aligned addresses are double word aligned.

well - for me this is a logic taught to a 10 year old
and there is nothing spitful in it... and my comment
was not to insult Jagadeesh or anybody else - it was
rather in the tone of "yeah - let's skip the obvious
and get to the point"...

> Wow, it makes me wonder what will happen if someone
gives a wrong answer to your question,you would mow
them down? intellectually,perhaps? what with all your
"i need know why am doing what am doing,or ill kill
you attitude"?

well... I'm not going to mow anybody down or
anything... plus - I don't consider the goups as a
number 1 source of knowledge - I have been
parcicipating in the group for many months now and I
was trying to help much more often than I actually
asked about anything... now I asked about this
sample-by-sample FIR and with the help from the group
I managed to develop the code I needed - I appreciate
the group's help... that's all... but my point is - I
don't demand any help from anybody - if you can help
me - or have something to add in the subject - go
ahead and do so - but I'm not going to mow you down if
your contribution is of no value... I didn't mow down
Rick when he tried to help me - we both agreed that
neither of us is an expert on C6x assembly... so - to
sum up - I don't think I'm spitful towards anybody -
and even if I was, here it goes:
I do apologize to Jagadeesh and anybody else that I
ever offended on this group...

> BTW,Mr.sankaran has been one of the brightest and
most erudite ti engineer to participate in the group.

I'm sorry - it's just my sense of humour - I can't
resist... is it about mr Sankaran or TI engineers? ;-)

> And if you notice he doesnt give CLEVER one line
answers-He is a great teacher who PROVES most things
he says.

well - this will not be about mr Sankaran or anyone
else in particular - rather a general statement about
being clever... I think being a good teacher means
giving clever one-line answers wherever you can! I
believe my help on this group is like that - I try not
to give lectures to people - rather point to the
source or even just give one hint from which the
person in need can solve his problem... because after
all - I'm not going to solve anybody's problems, but I
do offer a hint wherever I can...

> Anyways, to your credit,(i hope...) i have to say,
you seem(?) to be the kind who could take as much as
you can give!
> So,friends? adults?
> So,Dont bother apologising, or may be you should!

well... as I said - I don't hold anything against
anybody on this group - on the contrary - I appreciate
a good discussion as it's just another stimulus for my
brain... that's all...

so - now I wish everybody a nice day ;-) I know it's
morning out there in the US ;-)

Wojciech Rewers

__________________________________


Agreed!. It is hard to know the expertise level of the person
from an e-mail, so I erred in the direction of providing more
information. But, let's move on!.

I do look forward to stimulating discussions on optimizations
for C62x, C64x and C67x. I will keep my answers fairly general,
so that everybody in the user's group can benefit.

Regards
Jagadeesh Sankaran


Hi Wojciech Rewers,

>well... as I said before - I do respect all participants of this group and all people in
>general... I admit - my remark was a bit "cynical" but  spitful?

Am sorry, you have misunderstood the word i used here! I meant spiteful(showing a disposition or inclination to annoy or hurt) i guess its a lot different from spitful!!!!!!

anyways,i will have to concede, even spitful was probably over the top.So sorry abt that! Just wanted to prove a point!

>well... I'm not going to mow anybody down or  anything... plus - I don't consider the goups >as a number 1 source of knowledge - I have been parcicipating in the group for many >months now and I  was trying to help much more often than I actually asked about anything...

I agree, you are trying to be an active member,No qualms there either.

>I didn't mow down  Rick when he tried to help me - we both agreed that
>neither of us is an expert on C6x assembly...

Well, even there i was slightly uneasy with your tongue in cheek comment about whether rick had ever programmed c6000 at all...but ill let that one pass...

>sum up - I don't think I'm spitful towards anybody -

Not spiteful perhaps,may be more like cynical, if you will...

>and even if I was, here it goes:
>I do apologize to Jagadeesh and anybody else that I ever offended on this group...

Thats a nice gesture,just sankaran nobody else...

>I'm sorry - it's just my sense of humour - I can't
>resist... is it about mr Sankaran or TI engineers? ;-)

Am there with you on that. :)

>well - this will not be about mr Sankaran or anyone else in particular - rather a general >statement about being clever... I think being a good teacher means
>giving clever one-line answers wherever you can! 

Not always,definetly not all the time?

>believe my help on this group is like that I try not to give lectures to people

 
Some people, even if they try, cant give good lectures.And some people give great lectures.
Its an altogether different issue whether you like lectures or not!

>well... as I said - I don't hold anything against anybody on this group - on the contrary - I >appreciate a good discussion as it's just another stimulus for my brain... that's all...

Couldnt agree with you more(notwithstanding my desire to disagree!) on that.Your current thread has been a great stimulus alrigh,It has opened up my eyes to so many new things

>so - now I wish everybody a nice day ;-) I know it's morning out there in the US ;-)

Good day to you to Mr.Rewers. But hey, i live in India.Its night here.So,good night will do fine.

Ps:You are a good engineer and you  seem to have all the right things.Iam sure you will make it in the field for sure.Come to india??!!
 
Bhooshan


Get personal loans. It's hassle-free. It's approved instantly.

Jagadeesh-

> Agreed!. It is hard to know the expertise level of the person
> from an e-mail, so I erred in the direction of providing more
> information. But, let's move on!.
>
> I do look forward to stimulating discussions on optimizations
> for C62x, C64x and C67x. I will keep my answers fairly general,
> so that everybody in the user's group can benefit.

You know of course that any time the discussion focuses on optimization, that I
will
drag out your name and refer to your original Nov/Dec '02 posts, which I have
memorized.

That's what you get for being an expert :-)

-Jeff