Skip to content

Commit

Permalink
annotate netlist with VA modules path and names
Browse files Browse the repository at this point in the history
* Enable qucator to search for module definitions on the netlist.
  Overcome issue with ASCO, which does not propagate command line arguments.
  Without that qucastor was not able to find the needed objects.
  • Loading branch information
guitorri committed May 16, 2014
1 parent d0c0c37 commit c868974
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 39 deletions.
59 changes: 59 additions & 0 deletions qucs-core/src/ucs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <time.h>
#include <list>
#include <iostream>
#include <fstream>

#include "logging.h"
#include "precision.h"
Expand Down Expand Up @@ -125,6 +126,7 @@ int main (int argc, char ** argv) {
else if (!strcmp (argv[i], "-l") || !strcmp (argv[i], "--listing")) {
listing = 1;
}
// \todo remove command arguments
else if (!strcmp (argv[i], "-p") || !strcmp (argv[i], "--path")) {
projPath = argv[++i];
}
Expand All @@ -150,10 +152,67 @@ int main (int argc, char ** argv) {
#endif /* DEBUG */

// look for dynamic libs, load and register them
// \todo, keep this way of loading or keep only annotated netlist?
if (dynamicLoad) {
module::registerDynamicModules (projPath, vamodules);
}

else { //no argument, look into netlist

std::string sLine = "";
std::ifstream file;

std::string projPathNet ="";
std::string projVaMoules = "";

file.open(infile);

while (!file.eof()) {
getline(file, sLine);

if (sLine.find("--path") != std::string::npos) {
std::cout << sLine << std::endl;

size_t pos = 0;
pos = sLine.find("=");
sLine.erase(0, pos + 1);
std::cout << sLine << std::endl;

// projPath = const_cast<char*>(sLine.c_str());
// projPath = (char*)sLine.c_str();

// std::cout << "inside" << projPath << std::endl;

projPathNet = sLine;

}

if (sLine.find("--module") != std::string::npos) {
std::cout << sLine << std::endl;

size_t pos = 0;
pos = sLine.find("=");
sLine.erase(0, pos + 1);
//std::cout << sLine << std::endl;
projVaMoules = sLine;

// put module names into list
std::istringstream ss(sLine);
std::string token;

while(std::getline(ss, token, ' ')) {
std::cout << token << '\n';

vamodules.push_back(token);
}
}
}

module::registerDynamicModules ((char*)projPathNet.c_str(), vamodules);
file.close();
}


// create root environment
root = new environment ("root");

Expand Down
5 changes: 5 additions & 0 deletions qucs/qucs/components/opt_sim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ bool Optimize_Sim::createASCOFiles()
}

// -----------------------------------------------------------
/*!
* \brief Optimize_Sim::createASCOnetlist create ASCO netlist out or input
* input netlist.
* \return true if asco_netlist.txt created, false otherwise
*/
bool Optimize_Sim::createASCOnetlist()
{
Property* pp;
Expand Down
94 changes: 55 additions & 39 deletions qucs/qucs/dialogs/simmessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,59 @@ void SimMessage::startSimulator()
ProgText->insert(tr("done.")+"\n"); // of "creating netlist...

if(SimPorts < 0) {

// append command arguments
// append netlist with same arguments
if (! Module::vaComponents.isEmpty()) {

/*! Only pass modules to Qucsator that are indeed used on
* the schematic,it might be the case that the user loaded the icons,
* but did not compiled the module. Qucsator will not find the library.
*
* Check if used symbols have corresponing lib before running
* Qucsator? Need to search on the netlis.txt? Is there other data
* structure containig the netlist?
*
*/
QStringList usedComponents;

if (!NetlistFile.open(QIODevice::ReadOnly))
QMessageBox::critical(this, tr("Error"), tr("Cannot read netlist!"));
else {
QString net = QString(NetlistFile.readAll());

QMapIterator<QString, QString> i(Module::vaComponents);
while (i.hasNext()) {
i.next();
if (net.contains(i.key()))
usedComponents << i.key();
}
NetlistFile.close();
}

if (! usedComponents.isEmpty()) {


// \todo remvoe the command line arguments? use only netlist annotation?
//Arguments << "-p" << QucsSettings.QucsWorkDir.absolutePath()
// << "-m" << usedComponents;
//qDebug() << "Command :" << Program << Arguments.join(" ");

/// Anotate netlist with Verilog-A dynamic path and module names
///
if (!NetlistFile.open(QFile::Append | QFile::Text))
QMessageBox::critical(this, tr("Error"), tr("Cannot read netlist!"));
else {
QTextStream out(&NetlistFile);
out << "\n";
out << "# --path=" << QucsSettings.QucsWorkDir.absolutePath() << "\n";
out << "# --module=" << usedComponents.join(" ") << "\n";

NetlistFile.close();
}
}
} // vaComponents not empty

if((SimOpt = findOptimization((Schematic*)DocWidget))) {
((Optimize_Sim*)SimOpt)->createASCOnetlist();
Program = QucsSettings.AscoDir + "asco"+ executablePostfix;
Expand All @@ -457,45 +510,9 @@ void SimMessage::startSimulator()
Arguments << "-b" << "-g" << "-i"
<< QucsSettings.QucsHomeDir.filePath("netlist.txt")
<< "-o" << DataSet;

if (! Module::vaComponents.isEmpty()) {

/*! Only pass modules to Qucsator that are indeed used on
* the schematic,it might be the case that the user loaded the icons,
* but did not compiled the module. Qucsator will not find the library.
*
* Check if used symbols have corresponing lib before running
* Qucsator? Need to search on the netlis.txt? Is there other data
* structure containig the netlist?
*
*/
QStringList usedComponents;

if (!NetlistFile.open(QIODevice::ReadOnly))
QMessageBox::critical(this, tr("Error"), tr("Cannot read netlist!"));
else {
QString net = QString(NetlistFile.readAll());

QMapIterator<QString, QString> i(Module::vaComponents);
while (i.hasNext()) {
i.next();
if (net.contains(i.key()))
usedComponents << i.key();
}
NetlistFile.close();
}

if (! usedComponents.isEmpty()) {

// qDebug() << "used comps" << usedComponents.join(" ");

Arguments << "-p" << QucsSettings.QucsWorkDir.absolutePath()
<< "-m" << usedComponents;
}
}

}
} else {
}
else {
if (isVerilog) {
Program = pathName(QucsSettings.BinDir + QucsVeri);
Arguments << "netlist.txt" << DataSet
Expand Down Expand Up @@ -548,7 +565,6 @@ void SimMessage::startSimulator()
file.close();

qDebug() << "Command :" << Program << Arguments.join(" ");

SimProcess.start(Program, Arguments); // launch the program

if(!SimProcess.Running) {
Expand Down

0 comments on commit c868974

Please sign in to comment.