UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Adventurer
Adventurer
3,675 Views
Registered: ‎11-09-2010

software Optimization problem for a hardware on FSL bus

Jump to solution

hi,

I have a hardware of Xilinx cores for type cast ( int 2 double ) on fsl bus,

I wrote a macro for it like below :

 

#define  fsl_fpui2d( a, c, cmd, status  );\
{\
     write_into_fsl(    cmd                       , 0);\
     write_into_fsl(   a                             , 0);\
     read_from_fsl(*( (unsigned int *)(void *)(&c))     , 0);\
     read_from_fsl(*( (unsigned int *)(void *)(&c) + 1 ), 0);\
     read_from_fsl( status                               , 0);\
}

 

I used macro because function takes too time.

 

this code works OK ( so code is right )  when optimization of my code is OFF but whenever I turn it on it does not.

I am sure that this part of code cause the problem, because whenever I replace this macro with simple  c = (double) a  then every thing is ok with or without optimization.

 

I tried to put all above codes  ( both of write_into_fsl & read_into_fsl  are assembly code of put or get )  inside a  atomic  asm volotile ( ) but nothing changed.

 

I also tried to define every variable which replace 'c' ( becase it is a macro ) to be "volatile double" but still nothing changed.

 

now what should I do? what did optimization do to my code?

 

 

0 Kudos
1 Solution

Accepted Solutions
Adventurer
Adventurer
4,672 Views
Registered: ‎11-09-2010

Re: software Optimization problem for a hardware on FSL bus

Jump to solution

I could solve problem by exact debuging of assembly code with help of mb-objdum .

and this problem was really instructive for me.

 

my hardware core on fsl bus returns a double precision number.

for reading result I read it in two 32 bit number like this

 

     read_from_fsl(*( (unsigned int *)(void *)(&c))     , 0);\
     read_from_fsl(*( (unsigned int *)(void *)(&c) + 1 ), 0);\

 

and place it in a double type variable

--------

by this type of reading result compiler could not understand the CHANGE of varialbe  c,

and this cause problem.

 

thanks

 

 

 

 

 

View solution in original post

3 Replies
Xilinx Employee
Xilinx Employee
3,659 Views
Registered: ‎08-06-2007

Re: software Optimization problem for a hardware on FSL bus

Jump to solution

Hi,

 

Have you disassembled the elf file using mb-objdump and looked what the compiler generates?

 

 

Göran

0 Kudos
Adventurer
Adventurer
3,656 Views
Registered: ‎11-09-2010

Re: software Optimization problem for a hardware on FSL bus

Jump to solution

 

thanks goran

 

I also debug assembly of my software in SDK but  I am not sure that the assembly which is shown in Optimized software is also optimized or not,  I will check ELF

but till now I found a solution for temporary solve problem,

 

I just insert some prints and some tempt varialbes to prevent compiler remove something,

like below code, I will inverstigate this code more to find the source of problem.

 

#define  fsl_fpu64( a,  b, c, cmd, status  );\
{\
    volatile int c1, c2;\
    volatile int statusV;\
    printf("\n\r\n\r-- %d",  cmd   );\
    printf("-- %d", int(100 *a) );\
    printf("-- %d", int(100 *b) );\
    asm volatile( \
    "put\t%3,rfsl" stringify(0) "\n\t" \
    "put\t%4,rfsl" stringify(0) "\n\t" \
    "put\t%5,rfsl" stringify(0) "\n\t" \
    "put\t%6,rfsl" stringify(0) "\n\t" \
    "put\t%7,rfsl" stringify(0) "\n\t" \
    "get\t%0,rfsl" stringify(0) "\n\t" \
    "get\t%1,rfsl" stringify(0) "\n\t" \
    "get\t%2,rfsl" stringify(0) "\n\t" \
    : "=d"( c1  ), \
      "=d"( c2  ), \
      "=d"( statusV                                  )  \
    : "d"(  cmd                                      ), \
      "d"(*( (unsigned int *)(void *)(&a))           ), \
      "d"(*( ((unsigned int *)(void *)(&a)) + 1)  ), \
      "d"(*( (unsigned int *)(void *)(&b))          ), \
      "d"(*( ((unsigned int *)(void *)(&b)) + 1)  )\
     ); \
      \
      *( (unsigned int *)(void *)(&c)) = c1; \
      *( (unsigned int *)(void *)(&c) + 1 ) = c2; \
      status = statusV;\
     printf("-- %d", (int)( 100 *c) );\
     printf("-- %d", c1);\
     printf("-- %d", c2);\
     printf("-- %d", status);\
}\

 

I should check ELF deeply, I will write conclusion here

 

regards,

0 Kudos
Adventurer
Adventurer
4,673 Views
Registered: ‎11-09-2010

Re: software Optimization problem for a hardware on FSL bus

Jump to solution

I could solve problem by exact debuging of assembly code with help of mb-objdum .

and this problem was really instructive for me.

 

my hardware core on fsl bus returns a double precision number.

for reading result I read it in two 32 bit number like this

 

     read_from_fsl(*( (unsigned int *)(void *)(&c))     , 0);\
     read_from_fsl(*( (unsigned int *)(void *)(&c) + 1 ), 0);\

 

and place it in a double type variable

--------

by this type of reading result compiler could not understand the CHANGE of varialbe  c,

and this cause problem.

 

thanks

 

 

 

 

 

View solution in original post