hi i am srinivas..
i got stuck with the following code while parsing my below text file.could you please give me the errors what i did in the code.the following code is description of the circuit.
From the above text file i want to extract the design information of each gate i.e what are the inputs going into particular gate and the corresponding output of that gate.
L.H.S represents the output of the gate and R.H.S (with in the brackets) represents the inputs of the gate.
at the same time i want to display the INPUTS & OUTPUTS in the design.
signed int i;
ifstream stream;
string my_file = "c17.bench";
string data_set;
vector<int> vObject;
// Open stream.
stream.open(my_file.c_str());
while (!stream.fail())
{
// Search for next data_set
stream >> data_set;
// Start looking for Objects.
if (data_set.find( "INPUT" ) != string::npos)
{
parse(stream,vObject);
}
/* Start looking for Textures.
if (data_set.find( "INPUT" ) != string::npos)
{
parse(stream,vObject);
}*/
}
// Print it out.
cout << "Extracted Data is >>>>" << endl;
for (i = 0; i <= vObject.size();++i)
{
cout << vObject[i] << endl;//"\t" << vObject[i + 1] << endl;
}
/*cout << "\n another design Data" << endl;
for (i = 0; i < vObject.size();)
{
cout << vObject[i] << endl;
i += 1;
}*/
return EXIT_SUCCESS;
}
For the above code i got the output but its wrong.
The above code im using for displaying the INPUTS of design.
but its giving the output like this
2
3
6
7
it is skipping the input 1.
I would have two functions - one function to sort out the INPUT / OUTPUT as these linea are similar and one to scan for the LOGIC bit (the lines with the = sign).
My idea would be to scan the file line by line and for each line I would call the Input/Ouput function - if this function succeeds then get the next line if this function fails then try the logic function (while should succeed or you have a faulty formatted line) - get next line.......