signed multiplication

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hi everybody

   

my problem is using DFB assembler to multiply two signed number.

   

my project is attached

   

when I put two positive number in bus1 and dataramB the multiplication result is correct, but when I put negative number(for example cff001) the output is incorrect

   

in this project after run simulation in simulator in cycle10 the output is incorrect

   

furthermore when I input the negative numer in simulatot this number is shown as 32 bit number for example for cff001 it shows ffcff001

0 Likes
31 Replies
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Looks like result sign extended into 32 bits.

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable
        
   
        
   

all of the 32 bits are incorrect when signed multiply is execute

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

But you are aware of the fact that the result represents a number between -1 and 1 ?

   

 

   

Bob

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

A 24-bit number has got six (6) hex digits and not only five (5) as your input to the filter is. The sign expansion will treat all your numbers as positive.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

yes, the 24'th bit is the sign bit

   

my first input is(0x23456) and my firs coefficient (in the end of my assembly code) is 0xcff001(negative nymber) and defined by dw 0xcff001 but the Mac output in the 10'th cycle is FFFF2C19 (this is incorrect result)

0 Likes
Anonymous
Not applicable

yes,the 24'th bit is the sign bit

   

my first input in bus1 is 0x23456(positive number) and my coefficient is 0xcff001(negative number) and defined in the end of my assembly code

   

but the mac output in the 10'th cycle is FFFF2C19  and that is incorrect

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Since the digital filter in the PSoC is widely used and working without complains you should concentrate on interpreting the results you have got. In the datasheet on pg. 22 is described that the integer values have to be interpreted as values between -0.99999 and +0.99999 which in turn implies a scaling when two of the numbers are multiplied. Adding or subtracting works without scaling since the denominator is the same for both summands.

   

I calculated the numbers you provided using windows calculator (set to programmer's mode) and I got as result 0xffff2c1a.

   

Do not forget that you have to observe

   

1. expanding to qwords including the sign

   

2. scaling the result by dividing by 0x7fffff

   

 

   

 

   

Bob

0 Likes
Anonymous
Not applicable

I can't understand the result of multiply is here and after deviding the result is 394c5

   

how you can get thjat answer?

   

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

0x23456 * 0xFFFFFFFFFFCFF001 = FFFFFF960C9CD456

   

FFFFFF960C9CD456 / 0x7FFFFF = FFFFFFFFFFFF2C1A

   

 

   

OK?

   

 

   

Bob

0 Likes
Anonymous
Not applicable

yes,it's Ok

   

but my number is cff001 not 0xFFFFFFFFFFCFF001

   

I want to calculate the result of 0x23456*0xcff001

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

0xcff001 has to be sign extended to get a qword since bit 23 is on it is a negative number. and 0xfffffcff001 is quite the same.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Thanks Bob,

   

Your answer was very helpfull for me

   

I have one question:

   

 when I want to multiply(in decima) -5*-5=25 what should i do?

   

I know that the DFB assmes a point after MSB, then I shoul put 0x805000 in Bus1 and 0x805000 in coefficient memory in my assembly code,

   

result of multiply is 3FB019000000(0x19=25,but what is teh 3FB in the first?) .

   

after dividing 3FB019000000 by 7FFFFF the result is 7F6032,this is the same as the simulator result but I want to obtain the real result of multiplicatin

   

I want to implement the algorithm with many filters,These filters have fixed coefficient for example one of this filter's cosfficient is -0.1294   0.2241   0.8365    0.4830

   

how I can get this coefficent anf achive the result of multiplication

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You get the coefficients by multiplying your number 0.1294 by 0x7FFFFF which is

   

0.1294 * 8388607 = 1085486 (rounded) = 0x10902E

   

Negation delivers

   

- 0x10902E =  0xEF6FD2

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Thank you so much Bob,

   

your help was great for me.I multiplied any coefficient by 7FFFFF and my output is correct for lowpass filtering.

   

my algorithm is here. I have been sucessed in lowpass filtering in any stage but I can't get the high pass filter the same as the matlab's result. the g is lowpass and the h is high pass and I have any filter coefficient from matlab toolbox

   

I just get the filter coefficient and then MACC with any input.

   

for lowpass filterin I get the correct result but for highpass I didn't.

   

for example my highpass filter's coefficient is -0.4830    0.8365     -0.2241    -0.1294

   

I don't know what is incorrect in my code

   

0 Likes
lock attach
Attachments are accessible only for community members.
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

The filter coeffs seem to be correct, I entered them into the Filter component.

   

Have a look at

   

 

   

Bob

0 Likes
Anonymous
Not applicable

yes, the coef is correct but the ouput of multipling in matlab in 2'th level(for highpass filtering) is -3.41*(10^-13) and this answer is very small and i can't see it in macc output

   

I see 0 in output of mac

   

what can I do?

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

The result of the multiplication is zero. When you multiply your given value with your well-known 8388607 you see that the result is less than 1. That is integer zero. the precision of your matlab seems to be better than that of the filter.

   

 

   

Bob

0 Likes
Anonymous
Not applicable
    
     yes,but i have to implement my algorithm in psoc5lp    
and I need both of lowpass and highpass filtering output   
   

there isn't any way ?

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Your way is correct, what does in your case a difference in the result of 10^-5 make?

   

 

   

Bob

0 Likes
Anonymous
Not applicable

I don't know

   

for lowpass filtering I trace the output by muktiply accumulate input by any coeffs

   

for example 2010*(sum of lowpass coeffs) and this is correct

   

but for highpass filtering result of multiply and the add didn't get me the correct result

   

2010*(sum of highpass coeffs) isn't equal with matlab output

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

What is the overall difference between what you get and what you should have?

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hello Bob,

   

my problem is resolved,my assembly code works good.

   

now I want to write the main.c code for implemneting my topdesign scheme

   

I used from 2 DMA in my project but when I put the DMA wizard code generated in main.c it couln't work

   

I attached my project

   

Thanks

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

You have not put any code into your project, so nothing I can comment on. There is an app note dealing with DMA, did you have a look at? www.cypress.com/

   

You have connected the (-) input of the ADC to the (+) input of your PGA, which will that signal leave floating.

   

 

   

Some of your componentst are outdated, I would suggest you to update Crteator to latest version or even upgrade to the co-existent version 3.1.

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

sorry

   

this is my project

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

There are DMA example projects you can draw from, just open them

   

in your project, then close that workspace after you are done pulling code

   

from them. Start page of Creator, find "Find example project" link.

   

 

   

    

   

          

   

http://www.cypress.com/?rID=37793     AN52705     Getting Started with DMA

   

http://www.cypress.com/?rID=82680     AN84810     PSoC® 3 and PSoC 5LP Advanced DMA Topics

   

http://www.cypress.com/?rID=44335     AN61102 PSoC® 3 and PSoC 5LP - ADC Data Buffering Using DMA

   

http://video.cypress.com/video-library/search/dma/     Videos on DMA

   

https://www.youtube.com/results?search_query=dma+psoc Videos on DMA (some overlap)

   

 

   

 

   

Regards, Dana.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

All API-names are precieded by the component's name, so best is to change the names by removing the trailling "_1" which have been inserted automatically.

   

The declartion for DMA_Config is missing and must appear before the first reference to it.

   

main() is of type int (as conforming to standard C-language)

   

 

   

When that's corrected we will help you further...

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Be careful when removing the _n suffix on a name, more specifically

   

check your name is not a reserved word for Compiler when you do

   

as not all named objects Compiler has will error flag you on a compile.

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable
        
   
        
   
        
   
        
   
        
   
        
   

 

   

I want to transfer the output of DFB to host

   

I tried oll of creator example methods but I couldn't get success

   

I installed suit usb but I think it can't show the value of the endpoint

   

I'm very confused

   

please get some help

   

Thanks

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Please post your actual project. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.



Bob

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

BTW: Which development kit do you use? CY8CKit-001?? CY8CKit-050???

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

sorry

   

this is my project

   

my device is CY8C5868AXI-LP035

0 Likes