Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
17249 Discussions

Problem reading a big txt file using system console and loading it to a SDRAM

Altera_Forum
Honored Contributor II
2,074 Views

Hi forum, 

 

I'm trying to load a txt file containing 1350000 32 bits words to the SDRAM of a DE0 nano dev board but system console is freezing or crashing. I've tried to read the whole file and loading it to a variable (set data [split $file_data "\n"]) and then write it to the SDRAM in a single command (master_write_32 $m $sdram $data) but that crashes system console instantly. Then i tried to read the file line by line and, on each line, i would write it to the SDRAM, using the following code: 

 

--- Quote Start ---  

while { [gets $fp line] >= 0 } { 

foreach word [split $line] { 

master_write_32 $m [expr $SDRAM+[expr ($i*4)]] $line 

incr i 

 

 

--- Quote End ---  

 

 

I left the code running for a whole day just to find that system console froze :( the code worked perfectly for a file with only 10k lines. 

 

So i came to ask for help, is there any other way to do this? Is there a way to break the big file into small files using tcl? 

 

Thanks for the help.
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
659 Views

I analyzed the JTAG-to-Avalon-ST/MM protocol 

 

http://www.ovro.caltech.edu/~dwh/correlator/pdf/altera_jtag_to_avalon_analysis.pdf 

 

and found that master_read/write_memory work significantly faster than master_read/write_32. If you are using an older version of Quartus, you can use master_read/write_memory to improve your performance. 

 

If you are using the latest version of Quartus, look in the latest version of the handbook 

 

http://www.altera.com/literature/hb/qts/qts_qii53028.pdf 

 

master_write_from_file and master_read_to_file (see p38 of this PDF). 

 

I suspect they will be optimized for file transfers too. 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
659 Views

I was using version 13.0, i was not aware of those new commands, master_write_from_file and master_read_to_file, in 13.1. 

 

I will upgrade to the latest version and try, thanks!
0 Kudos
Altera_Forum
Honored Contributor II
659 Views

It worked wonders, took 55 seconds to read 6M lines with 4 bytes each line.  

 

Thanks dwh!
0 Kudos
Altera_Forum
Honored Contributor II
659 Views

 

--- Quote Start ---  

It worked wonders, took 55 seconds to read 6M lines with 4 bytes each line.  

 

--- Quote End ---  

 

Yeah, I noticed that memory_read/write_bytes was significantly faster too :) 

 

Cheers, 

Dave
0 Kudos
Reply