Hi all, i am designing a system in which we have a bram block,microblaze processor and other essential component. i have written a verilog code for bram controller (successfully compiled)to interface bram block to opb bus.now i have to write a c code to perform read write operation in bram block.i have written following code #include <stdio.h> #include <mb_interface.h> #include <xutil.h> int main(){ printf("Hello this is the start, printing using print\n"); volatile char *pointer = ( volatile char *) 0x10013405; *pointer = 'c'; char temp = *pointer; printf("%c %c\n",temp , *pointer); return 0 ; } which is not working so regarding this i have following question 1-in c ,is it possible to assign address to a pointer according to us ???? 2-is it necessary to use gpio function to read write operation in a peripheral ?? if you find some conceptual mistake in code then please reply with regards Ajay
read/write in bram block
Started by ●July 4, 2007
Reply by ●July 4, 20072007-07-04
> Hi all, > i am designing a system in which we have a bram block,microblaze > processor and other essential component. > i have written a verilog code for bram controller (successfully > compiled)to interface bram block to opb bus.now i have to write a c > code to perform read write operation in bram block.i have written > following code > > #include <stdio.h> > #include <mb_interface.h> > #include <xutil.h> > int main(){ > printf("Hello this is the start, printing using print\n"); > volatile char *pointer = ( volatile char *) 0x10013405;You shouldn't need a cast here and both volatile keywords add nothing additional in this context and could hide errors. You should also look into xil_printf()'s.> *pointer = 'c'; > char temp = *pointer; > printf("%c %c\n",temp , *pointer); > return 0 ; > } > which is not workingBut, you never said what the output of the printf() actually was.> so regarding this i have following question > 1-in c ,is it possible to assign address to a pointer according to > us ????Yes, it's valid but not because of C, but because you are using a flat non-managed memory model. Try this kind of shenanigans in Windows and you most likely will get a SEG Fault.> 2-is it necessary to use gpio function to read write operation in a > peripheral ??You could write your own.> if you find some conceptual mistake in code then please reply > > with regards > Ajay
Reply by ●July 4, 20072007-07-04
On Jul 4, 12:23 pm, rajiv...@gmail.com wrote:> Hi all, > i am designing a system in which we have a bram block,microblaze > processor and other essential component. > i have written a verilog code for bram controller (successfully > compiled)to interface bram block to opb bus.now i have to write a c > code to perform read write operation in bram block.i have written > following code > > #include <stdio.h> > #include <mb_interface.h> > #include <xutil.h> > int main(){ > printf("Hello this is the start, printing using print\n"); > volatile char *pointer = ( volatile char *) 0x10013405; > *pointer = 'c'; > char temp = *pointer; > printf("%c %c\n",temp , *pointer); > return 0 ; > > } > > which is not working > so regarding this i have following question > 1-in c ,is it possible to assign address to a pointer according to > us ???? > 2-is it necessary to use gpio function to read write operation in a > peripheral ?? > > if you find some conceptual mistake in code then please reply > > with regards > AjayCould it be the IP core you wrote? Why write custom BRAM interface controller when one already comes with EDK (opb_bram_if_cntlr)? Alternatively, if you have no other masters that need access to the BRAM other than the Microblaze, you might want to consider interfacing via the LMB through the lmb_bram_if_cntlr. This approach has better performance since the single-master nature of the LMB requires no arbitration.