How can i convert char* / string to sc_lv<16> ?

Hello,

i am beginner in SystemC and have to programm a lawa simulation. My Problem is, i have to read the commands from a file in the following form :

8 * 16 Bits:

1111111111111111 0000000000000000 ...1111111111111111 .. ..

I read the bits in string, copy this in char*, then convert in sc_lv .But it's not what i read..

how can i convert it ?

I have this code:

void readCmd(){ sc_lv cmd; string str[8]; // the line string s[10]; // Count of Commands on a line size_t found; size_t pos ; int i, j; char z[170]; // Char on a line.. char tmp[16]; int waittime ; string st ; ifstream infile; infile.open ("test.txt", ifstream::in); infile.seekg(0, ifstream::beg) ; i = 0 ; pos = 0 ; if (infile.good()) while (!infile.eof()) { infile.getline(z, 170); // read a line str[i] += z ; found=str[i].find_first_of(" "); j = 0 ; waittime=1; while (found!=string::npos) { s[j] = str[i].substr(pos, found-pos); // save the 16 Bits in s[j] pos = found+1 ; s[j].copy(tmp, 16,0); // copy here the 16 Bits in tmp st = s[j].substr(0,4); // need for the waittime if (!st.compare("0101") || !st.compare("0110") || ! st.compare("1100") || !st.compare("1011") || !st.compare("0100")) waittime = 3; else waittime = 2; cmd = tmp ; // char to sc_lv !!!! then here CMD[j].write(cmd); // and here : e.g.

000000000000000XZXZ j++; found = str[i].find_first_of(" ",found+1); } //wait(waittime); i++; } infile.close(); }

---------------------------------------------------------------- OUTPUT:

s[j]1111111111111111 tmp1111111111111111?? cmd0000000000010XXX CMD[J]0000000000010XXX

Best Regards, Taner

Reply to
taner.cosar
Loading thread data ...

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.