Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how to read address in RAM

Status
Not open for further replies.

amitabh262002

Member level 2
Member level 2
Joined
Jul 24, 2007
Messages
49
Helped
8
Reputation
16
Reaction score
7
Trophy points
1,288
Activity points
1,661
Hi,
In Leon3's testbench, I am putting some C program in PROM (i.e. replacing PROM.srec with my C program lets say add.srec).
The code of C prog is follows
---------------------------------------------------
#include <stdio.h>

#include <stdlib.h>

int main(void)

{

int a=2,b=3,c;

c=a+b;

printf("Sum=%d",c);

printf("c address =%p",&c);

return 0;
------------------------------------------------------
After compilation in BCC(TSIM) i am getting correct output.
Means c's value 5 and address for c is something 0x4000af60.
Now I am compiling this C program in testbench with the help of ModelSim.
I want to see the same address or value of C in ModelSim also.
Please tell me how to do this?

Please also tell how to validate the result in BCC and ModelSim?
 

You can not expect the address of variables to be the same for different environments and compilers. If you depend on the address value, your C code is non-portable, and that should be avoided in general, not just in this case. It is OK to depend on the value of the variable c.
 

You can not expect the address of variables to be the same for different environments and compilers. If you depend on the address value, your C code is non-portable, and that should be avoided in general, not just in this case. It is OK to depend on the value of the variable c.

Then how i can read the value or address in the modelsim?
 

Then how i can read the value or address in the modelsim?
You can let the C code store the value of the variable to a fixed address:

*((int *) 0x1234) = c;

Replace 0x1234 with the address you want.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top