-
Notifications
You must be signed in to change notification settings - Fork 213
QEP: Multiple Simulator Support
o(this is multiple simulator support as in "native support for multiple simulators" not as in "support for another two simulators").
(none of this is very novel or surprising. it's just using C++ in an object oriented fashion, close to the way it is intended, c.f. QEP: Enhancement of code structure and software design for related ideas and pointers)
This QEP introduces a class Simulator
. This class has an interface for things we want a simulator to do, and all things a simulator can do are listed here.
class Simulator(){
public:
virtual ~Simulator();
virtual SimOutputData const* getResults() const;
virtual SimOutputData const* getBiasPoints() const;
Props const& properties() const;
setProperty( something );
virtual netlister const* netLister() const;
// and whatever else
private:
// internal stuff
}
From this class one can derive other classes, such as
class Qucsator : public Simulator(){
public:
~Qucsator();
SimOutputData const* getResults(Schematic const*) const;
SimOutputData const* getBiasPoints(Schematic const*) const;
netLang const* netLang() const{return &qucsatorlang;}
OutputData const* outputParser(QString filename);
// and whatever else
private:
// internal stuff
}
with this one can easily implement code that does different things for different simulators, such as
void Schematic::netList(NetLang const*, TextStream){
...
}
but is still free from netlist language specific code. all you need is to choose your simulator
Simulator const* s = getMySimulator(); // or maybe Document->getCurrentSimulator()?
Schematic->netlist(s->NetLang(), TextFile(path));
and this code will then always (=independent of the simulator) work.
NOTE currently it's not clear whether we need/want a void Schematic::netlist(NetLang const*, someStreamType&) const
or an independent class NetLister, implementing that function (with the possibility to override/replace stuff).
NOTE during the discussion, i noticed that "NetLang" and "NetLister" are misleading names. the infrastructure could also be used to e.g. write out the schematic in the pseudo-xml ".sch" format, or to print to png/ps. this is certainly not "netlisting". maybe "SchematicSerializer" makes a good name for something that implements a NetLister or any of the others mentioned.
further, consider you want to simulate. implement the function
OutputData const* Qucsator::getData(Schematic const* s){
dumpintofile(s);
startsomeprocess(callbacktoprogressbar(), s);
return outputparser(s+"dat");
}
this can now simulate with
Simulator const* s = getMySimulator(); // or maybe Document->getCurrentSimulator()?
schematic->getResults(s)
and this code will then always work.
it will for example still work, if you bypass the dat file parser that won't work for most simulators
OutputData const* Gnucap::getData(Schematic const* s);
clear();
run(s);
return data_wrapper();
}
might just do the trick.
Examples for Simulators
- qucsator
- qucsator (as a shared library)
- icarus verilog (vvp run time)
- gnucap
- gnucap (as a shared library)
- xyce (does it provide a shared library?!)
- ngspice (does it provide a functional shared library?)
- hundreds of commercial simulators (that i do not care about)
[ Home | Development | Examples ]