cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Adventurer
Adventurer
6,283 Views
Registered: ‎11-09-2010

read & write on FSL bus

Jump to solution

hi,

I added an special multiplier on fsl bus,  it takes some operand and return some others.

all operands MUST be wrritten and all results  MUST be read, if no, then next time hardware will not work correctly.

I wrote a macro to work with that hardware :

 

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

// a and b and c are double precision.

 

it works OK when compiler optimization is off but whenever I turn it on, it does not work good.

I guess optimization clear away something, ?

I also tried below ASM code but nothing changed :

 

 

#define  fsl_fpu64( a,  b, c, cmd, status  );\
{\
    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"( *( (unsigned int *)(void *)(&c))       ), \
      "=d"( *( (unsigned int *)(void *)(&c) + 1 ) ), \
      "=d"( status                                   ) \
    : "d"(  cmd                                    ), \
      "d"(*( (unsigned int *)(void *)(&a))         ), \
      "d"(*( (unsigned int *)(void *)(&a) + 1)    ), \
      "d"(*( (unsigned int *)(void *)(&b))        ), \
      "d"(*( (unsigned int *)(void *)(&b) + 1)    )   ); \
      \
}\

 

this code also works OK when optimization is off but ........

 

thanks

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Adventurer
Adventurer
7,619 Views
Registered: ‎11-09-2010

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

0 Kudos
4 Replies
Highlighted
Xilinx Employee
Xilinx Employee
6,280 Views
Registered: ‎08-13-2007

This question is really more appropriate for the EDK or Embedded Processing boards.

But regardless, you should become familiar with the C keyword "volatile"

There are many related discussions here or can be found elsewhere with google.

 

Here's an AR:

http://www.xilinx.com/support/answers/16633.htm (3.1 EDK - There appears to be a bug in the ppc/mb compiler?? (The "volatile" keyword is possibly required in the declaration))

bt

 

0 Kudos
Highlighted
Adventurer
Adventurer
6,271 Views
Registered: ‎11-09-2010

thanks

I will continue in Proper Place in EDK section :

http://forums.xilinx.com/t5/EDK-and-Platform-Studio/software-Optimization-problem-for-a-hardware-on-FSL-bus/td-p/152976

 

I also test your solution but problem still is there,

may you please go there, I continue to explain my problem better there,

0 Kudos
Highlighted
Adventurer
Adventurer
7,620 Views
Registered: ‎11-09-2010

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

0 Kudos
Highlighted
Observer
Observer
4,579 Views
Registered: ‎01-02-2014

i am implementing dual microblaze processor using  fsl commn., 

 while using fsl macro it shows that line 3 does not execute

 

line 1 & 2 execute, while macro line is not...

as the console output display only lines 1 & 2 and dont  display line 3

 

code 1  (microblaze 0) :

 

#include <mb_interface.h>
#include <xutil.h>
#include <stdio.h>

#include "platform.h"

int main(void)
{
    int i = 0;
    print("Hello World\n\r");                  // line 1
    while(i<10)
    {
        print("Hello......\n\r");             // line 2
        putfsl(i, 0);
        getfsl(i, 0);
        //xil_printf("pong %d\n\r", i);
        xil_printf("pong %d\n\r", i);          // line 3
    }

}
---------------------------------------------------------------------------------

code 2 (microblaze 1):-

 

#include <mb_interface.h>
#include <xutil.h>
#include <stdio.h>

#include "platform.h"

int main(void)
{
    int i;
    print("22222222222  \n\r");             //line 4
    while(1)
    {
        getfsl(i, 0);
        print("Hello World\n\r");             // line 5
        xil_printf("ping %d\n\r", i++);
        putfsl(i, 0);
    }
}
-----------------------------------------------------------------------

 

even if code 2 is executed only line 4 is shown on uart and not line 5.

 

 

0 Kudos