90 string errorMsg =
"Empty input netlist.";
104 const std::string& dstDirectory)
const {
109 outFile.open(fileName.c_str(), ofstream::out);
116 << param.
type() <<
" := " << param.
value() <<
";" << endl;
149 string errorMsg =
"Unable to create file: " + fileName;
156 outFile.open(fileName.c_str(), ofstream::out);
158 outFile <<
"library IEEE;" << endl;
159 outFile <<
"use IEEE.std_logic_1164.all;" << endl;
160 outFile <<
"use IEEE.std_logic_arith.all;" << endl;
161 outFile <<
"use work.tce_util.all;" << endl;
164 outFile <<
"use work." << block.
package(i) <<
".all;" << endl;
175 outFile <<
"entity " + entityName +
" is" << endl;
184 outFile << endl <<
"end " << entityName <<
";" << endl;
188 string architectureName =
"structural";
189 outFile <<
"architecture " << architectureName <<
" of "
190 << entityName <<
" is" << endl << endl;
196 outFile <<
"begin" << endl << endl;
200 outFile <<
"end " + architectureName +
";" << endl;
216 const std::string& indentation, std::ostream& stream) {
220 <<
"generic (" << endl;
224 << param.
name() <<
" : " << param.
type();
231 stream << param.
value();
259 const std::string& indentation, std::ostream& stream) {
263 for (
size_t i = 0; i < block.
portCount(); i++) {
265 string portName = port.
name();
268 << portName <<
" : " << direction <<
" ";
270 stream <<
"std_logic";
272 stream <<
"std_logic_vector(";
282 stream <<
" downto 0)";
303 typedef std::set<const BaseNetlistBlock*, NetlistBlockNameComparator>
310 subBlocks.insert(&block.
subBlock(i));
315 for (BlockSet::const_iterator iter = subBlocks.begin();
316 iter != subBlocks.end(); iter++) {
319 for (
size_t i = 0; i < subBlock->
portCount(); i++) {
323 std::pair<out_edge_iterator, out_edge_iterator> edges =
324 boost::out_edges(vertexDescriptor, block.
netlist());
326 if (edges.first != edges.second) {
329 boost::target(edgeDescriptor, block.
netlist());
333 boost::out_degree(vertexDescriptor, block.
netlist()) >
370 set<const BaseNetlistBlock*, NetlistBlockNameComparator> subBlocks;
372 subBlocks.insert(&block.
subBlock(i));
375 typedef std::vector<edge_descriptor> EdgeTable;
376 EdgeTable handledEdges;
380 for (
size_t i = 0; i < subBlock.
portCount(); i++) {
383 std::pair<out_edge_iterator, out_edge_iterator> edges =
384 boost::out_edges(vertexDescriptor, block.
netlist());
386 while (edges.first != edges.second) {
390 handledEdges, edgeDescriptor)) {
392 boost::source(edgeDescriptor, block.
netlist());
394 boost::target(edgeDescriptor, block.
netlist());
399 if (boost::out_degree(
400 vertexDescriptor, block.
netlist()) > 1) {
408 block, stream, edgeDescriptor, srcPort,
420 handledEdges.push_back(edgeDescriptor);
422 std::pair<edge_descriptor, bool> opposite =
424 dstVertex, srcVertex, block.
netlist());
426 assert(opposite.first != edgeDescriptor);
427 handledEdges.push_back(opposite.first);
430 block, stream, edgeDescriptor, srcPort, dstPort);
449 if (property.fullyConnected()) {
456 <<
" <= " << dstPort->
name() <<
";" << endl;
468 string srcPortSignal;
477 int high =
property.port1FirstBit() +
property.width() - 1;
478 int low =
property.port1FirstBit();
483 string dstPortSignal;
486 dstPortSignal = dstPort->
name();
496 int high =
property.port2FirstBit() +
property.width() - 1;
497 int low =
property.port2FirstBit();
504 <<
" <= " << srcPortSignal <<
";" << endl;
507 <<
" <= " << dstPortSignal <<
";" << endl;
522 std::set<string> declaredModules;
533 declaredModules.insert(component.
moduleName());
551 for (
size_t i = 0; i < component.
portCount(); i++) {
556 stream <<
"std_logic";
558 stream <<
"std_logic_vector(";
565 stream <<
" downto 0)";
574 stream <<
indentation(1) <<
"end component;" << endl << endl;
600 stream <<
indentation(2) <<
"generic map (" << endl;
607 stream << param.
value();
610 stream <<
")" << endl;
612 stream <<
"," << endl;
619 for (
size_t i = 0; i < component.
portCount(); i++) {
622 std::pair<out_edge_iterator, out_edge_iterator> edges =
623 boost::out_edges(vertexDescriptor, block.
netlist());
625 string srcConn = port.
name();
627 if (edges.first != edges.second) {
630 boost::target(edgeDescriptor, block.
netlist());
633 block.
netlist()[edgeDescriptor];
638 if (!property.fullyConnected() &&
641 index =
property.port2FirstBit();
646 dstConn = dstPort->
name() +
"(" +
652 dstConn = dstPort->
name();
658 if ((!property.fullyConnected() ||
661 vertexDescriptor, block.
netlist()) > 1) {
664 dstConn = dstPort->
name();
673 stream <<
indentation(3) << srcConn <<
" => " << dstConn;
675 stream <<
"," << endl;
678 stream <<
");" << endl << endl;
713 int length = formula.length();
714 for (
int i = 0; i < length; i++) {
715 if (!isdigit(formula[i])) {
752 unsigned int indentationLevel,
753 const std::string& indentation) {
755 string generatedInd(
"");
756 for (
size_t i = 0; i < indentationLevel; i++) {
771 string signalName =
"";
780 signalName =
"'" + bit +
"'";
782 signalName =
"(others => '" + bit +
"')";
804 return "std_logic_vector" +
813 return "std_logic_vector(" + port.
widthFormula() +
"-1 downto 0)";
831 if (
generic.startsWith(
"\"") &&
generic.endsWith(
"\"")) {
834 std::vector<TCEString> unallowed;
835 unallowed.push_back(
".");
836 unallowed.push_back(
"__");
837 for (
size_t i = 0; i < unallowed.size(); i++) {
838 if (
generic.find(unallowed.at(i)) != TCEString::npos) {
840 quoted <<
"\"" <<
generic <<
"\"";
862 msg <<
"High (" << high <<
") boundary is smaller than low (" << low
868 if (allowShort && high == low) {
871 range << high <<
" downto " << low;
904 (indexDst ? string(
"(0) <= ") : string(
" <= ")) +
906 (indexDst ? string(
";") : string(
"(0);"));