-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
now it can be repurposed to dispatch other things, such as NetLang.
- Loading branch information
1 parent
13b7e11
commit 92eb34c
Showing
9 changed files
with
139 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/*************************************************************************** | ||
verilog.cc | ||
---------- | ||
begin : yes | ||
copyright : (C) 2015 by Felix Salfelder | ||
email : felix@salfelder.org | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 3 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "sim.h" | ||
#include "../components/component.h" | ||
#include "node.h" | ||
#include <QString> | ||
|
||
namespace { | ||
class Verilog : public NetLang | ||
{ | ||
virtual void printInstance(Component const*, QTextStream&) const; | ||
} V; | ||
|
||
static Dispatcher<NetLang> p("verilog", &V); | ||
|
||
/*! | ||
* print Components in Verilog | ||
*/ | ||
void Verilog::printInstance(Component const* c, QTextStream& s) const | ||
{ | ||
if(c->isOpen()) { | ||
// nothing. | ||
}else if(c->isShort()){ | ||
// replace by some resistors (hack?) | ||
int z=0; | ||
QListIterator<Port *> iport(c->ports()); | ||
Port *pp = iport.next(); | ||
QString Node1 = pp->Connection->Name; | ||
while (iport.hasNext()){ | ||
s << "R:" << c->label() << "." << QString::number(z++) << " " | ||
<< Node1 << " " << iport.next()->Connection->Name << " R=\"0\"\n"; | ||
} | ||
}else{ | ||
QString netlist(c->getNetlist()); | ||
if(netlist!="obsolete") { | ||
// still using obsolete netlister here. | ||
std::cerr << "incomplete, see verilog.cpp"; | ||
assert(false); | ||
// throw exceptionIncomplete("verilog: cannot netlist c->type()"); | ||
}else{ // normal netlisting | ||
s << c->type() << " #("; | ||
|
||
QString comma=""; | ||
for(auto p2 : c->params()) { | ||
if(p2->Name != "Symbol") { // hack. | ||
s << comma << "." << p2->Name << "(" << p2->Value << ")"; | ||
comma = ", "; | ||
} | ||
} | ||
s << ") " << c->label() << "("; | ||
|
||
// what about port names? | ||
comma = ""; | ||
for(Port *p1 : c->ports()){ | ||
s << comma << p1->Connection->Name; | ||
comma = ", "; | ||
} | ||
|
||
s << ");\n"; | ||
} | ||
} | ||
} | ||
} | ||
|
||
// vim:ts=8:sw=2:noet |