Jump to content

Please Help this new member


Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...