titoinus Posted March 25, 2013 Report Share Posted March 25, 2013 I, new learner in system C, have been trying to read 16 raw data under (ram_data[16]) from a text file without success. Could you please help? Also I need to learn more about ifstream for systemC. Thanks for your help. Tito, Phoenix, AZ I have sc_lv<8 > ram_data[16]; ============ //In my cpp file: void ram :: OpenToReadFile() { ifstream infile; while(true) { infile.open("storeData.txt"); if(!infile) { cerr << "Unable to open file textfile.doc\n"; sc_stop(); } else { while(infile) { int i; for (i=0; i<16; i++) { infile.getline (ram_data, I, ‘/n’); cout << ram_data<<'\n'; wait (10,SC_NS); } } infile.close(); ========================= // storeData.txt 00001001 00001010 00001011 00001100 00001101 00001010 00001111 00010000 00010001 00010010 00010011 00010100 00010101 00010110 00010111 00011000 Quote Link to comment Share on other sites More sharing options...
apfitch Posted March 26, 2013 Report Share Posted March 26, 2013 ifstream is part of C++, nothing to do with SystemC. So you may need to learn more C++. As we don't have your complete code, it's hard to tell what's happening. However my basic question would be why are you writing this code in an SC_THREAD? Why not just open the file and load the array in the constructor of the class? regards Alan Quote Link to comment Share on other sites More sharing options...
titoinus Posted March 26, 2013 Author Report Share Posted March 26, 2013 Greetings to all Thanks Alan for yuor suggestion. I will try to open the file and load the array in the constructor of the class. Thanks again for yuor help. Regards Tito Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.