cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
rikusleroux
Explorer
Explorer
6,424 Views
Registered: ‎05-21-2009

PowerPC file handling

Hi.

 

I was hoping someone could provide some insight to a problem I'm having. I want simulate my PowerPC 440 code on a Virtex 5 FPGA using ModelSim 6.5 SE.

 

My setup is as follows:

 

I've written code which reads a value from a file (Read.txt) on my desktop PC. The read value is then incremented with 2, and the resulting value is then written into another file (Write.txt). The code is:

 

#include "stdio.h" FILE *My_read_file ; FILE *My_write_file ; int read_value = 0 ; int write_value = 0 ; int main(void) { My_write_file = fopen("C:\\Write.txt","w") ; if((My_read_file = fopen("C:\\Read.txt","r")) == NULL) { print("Could not open file");

} else

{ print("File opened"); while((read_value = getc(My_read_file))!=EOF) { write_value = read_value + 2 ; putc(write_value,My_write_file); } } fclose(My_read_file); fclose(My_write_file); return 0; }

Now, the problem is that since the PowerPC is an embedded processor how would it know where to find these files? I'm assuming that I would have to specify where to find these files, but how do I do it? I only want to use these files for simulation, and in the physical system these values would come from elsewhere. Is this even possible?

 

Thanks.

Tags (3)
0 Kudos
4 Replies
brianhill
Xilinx Employee
Xilinx Employee
6,418 Views
Registered: ‎04-23-2008

Simulation isn't something I usually do, but I suspect that you could accomplish something like what you want using the Xilinx Memory File System

http://www.xilinx.com/support/documentation/sw_manuals/xilinx11/sa_xilmfs_v1_00_a.pdf

 

I suppose it's possible to somehow get the pre-initialized blob of memory containing these files into your simulation?

 

-Brian

 

rikusleroux
Explorer
Explorer
6,400 Views
Registered: ‎05-21-2009

Hi Brian,

 

Thanks for the reply. I've read through the user guide on the MFS, and I've used mfsgen to convert my text file into an mfs file.

 

Any suggestions on how to use this mfs file in an simulation? I have no idea on how to use the file I've created since the MFS libraries only supports the internal RAM/ROM/Flash of the PowerPC.

 

Thanks

Message Edited by rikusleroux on 06-19-2009 06:34 AM
0 Kudos
xiaofeip
Xilinx Employee
Xilinx Employee
6,359 Views
Registered: ‎08-07-2007

Hi,

 

You can actually place the MFS image into an external memory. There should be an parameter to specify where the MFS is mapped to.

 

As for simulation, I think you can load the mfs image into the external memory with ModelSim. It's supported by ModelSim.

 

-XF

rikusleroux
Explorer
Explorer
6,227 Views
Registered: ‎05-21-2009

Thanks guys for all your replies. After much consideration, I found an easier way of achieving the results I want.

 

I instantiated ROM on the FPGA and preloaded it with the initial values I wanted to read from the file and the results I sent to a terminal via RS232.

 

Thanks anyway!

0 Kudos