read/write in bram block

Jul 04, 2007 2 Replies

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 #include #include 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



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.

But, you never said what the output of the printf() actually was.

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.

You could write your own.

Could 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.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required