1 /*
2  * Copyright (c) 2011 Stephen Williams (steve@icarus.com)
3  *
4  *    This source code is free software; you can redistribute it
5  *    and/or modify it in source code form under the terms of the GNU
6  *    General Public License as published by the Free Software
7  *    Foundation; either version 2 of the License, or (at your option)
8  *    any later version.
9  *
10  *    This program is distributed in the hope that it will be useful,
11  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *    GNU General Public License for more details.
14  *
15  *    You should have received a copy of the GNU General Public License
16  *    along with this program; if not, write to the Free Software
17  *    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 
20 # include  "architec.h"
21 # include  "expression.h"
22 # include  "sequential.h"
23 # include  <fstream>
24 # include  <iomanip>
25 # include  <typeinfo>
26 
27 using namespace std;
28 
dump(ostream & out,perm_string of_entity,int indent) const29 void Architecture::dump(ostream&out, perm_string of_entity, int indent) const
30 {
31       out << setw(indent) << "" << "architecture " << name_
32 	  << " of entity " << of_entity
33 	  << " file=" << get_fileline() << endl;
34 
35       dump_scope(out);
36 
37       for (list<Architecture::Statement*>::const_iterator cur = statements_.begin()
38 		 ; cur != statements_.end() ; ++cur) {
39 	    (*cur)->dump(out, indent+3);
40       }
41 }
42 
dump(ostream & out,int indent) const43 void Architecture::Statement::dump(ostream&out, int indent) const
44 {
45       out << setw(indent) << "" << "Architecture::Statement at file=" << get_fileline() << endl;
46 }
47 
dump(ostream & out,int indent) const48 void ComponentInstantiation::dump(ostream&out, int indent) const
49 {
50       out << setw(indent) << "" << "Component Instantiation "
51 	  << "instance=" << iname_
52 	  << " of component=" << cname_
53 	  << ", file=" << get_fileline() << endl;
54 
55       for (map<perm_string,Expression*>::const_iterator cur = port_map_.begin()
56 		 ; cur != port_map_.end() ; ++cur) {
57 	    out << setw(indent+2) <<""<< cur->first << " => ..." << endl;
58 	    if (cur->second)
59 		  cur->second->dump(out, indent+6);
60 	    else
61 		  out << setw(indent+6) <<""<< "OPEN" << endl;
62       }
63 
64 }
65 
dump_statements(ostream & out,int indent) const66 void GenerateStatement::dump_statements(ostream&out, int indent) const
67 {
68       for (list<Architecture::Statement*>::const_iterator cur = statements_.begin()
69 		 ; cur != statements_.end() ; ++cur) {
70 	    Statement*curp = *cur;
71 	    curp->dump(out, indent);
72       }
73 }
74 
dump(ostream & out,int indent) const75 void ForGenerate::dump(ostream&out, int indent) const
76 {
77       out << setw(indent) << "" << "for " << genvar_
78 	  << " in" << endl;
79       msb_->dump(out, indent+4);
80       lsb_->dump(out, indent+4);
81       out << setw(indent) << "" << "generate" << endl;
82       dump_statements(out, indent+4);
83       out << setw(indent) << "" << "end generate" << endl;
84 }
85 
dump(ostream & out,int indent) const86 void SignalAssignment::dump(ostream&out, int indent) const
87 {
88       out << setw(indent) << "" << "SignalAssignment file=" << get_fileline() << endl;
89       lval_->dump(out, indent+1);
90       out << setw(indent+2) << "" << "<= <expr>..." << endl;
91 
92       for (list<Expression*>::const_iterator cur = rval_.begin()
93 		 ; cur != rval_.end() ; ++cur) {
94 	    (*cur)->dump(out, indent+2);
95       }
96 }
97 
dump(ostream & out,int indent) const98 void CondSignalAssignment::dump(ostream&out, int indent) const
99 {
100       out << setw(indent) << "" << "CondSignalAssignment file=" << get_fileline() << endl;
101       lval_->dump(out, indent+1);
102       out << setw(indent+2) << "" << "<= <expr>..." << endl;
103 
104       for(list<ExpConditional::case_t*>::const_iterator it = options_.begin();
105               it != options_.end(); ++it) {
106           (*it)->dump(out, indent+2);
107       }
108 }
109 
dump(ostream & out,int indent) const110 void StatementList::dump(ostream&out, int indent) const
111 {
112       out << setw(indent+3) << "" << "sequence of statements:" << endl;
113 
114       for (list<SequentialStmt*>::const_iterator cur = statements_.begin()
115 		 ; cur != statements_.end() ; ++cur) {
116 	    (*cur)->dump(out, indent+4);
117       }
118 }
119 
dump(ostream & out,int indent) const120 void InitialStatement::dump(ostream&out, int indent) const
121 {
122       out << setw(indent) << "" << "InitialStatement file=" << get_fileline() << endl;
123 
124       StatementList::dump(out, indent);
125 }
126 
dump(ostream & out,int indent) const127 void FinalStatement::dump(ostream&out, int indent) const
128 {
129       out << setw(indent) << "" << "FinalStatement file=" << get_fileline() << endl;
130 
131       StatementList::dump(out, indent);
132 }
133 
dump(ostream & out,int indent) const134 void ProcessStatement::dump(ostream&out, int indent) const
135 {
136       out << setw(indent) << "" << "ProcessStatement name_=" << iname_
137 	  << " file=" << get_fileline() << endl;
138 
139       out << setw(indent+3) << "" << "Sensitivity_list:" << endl;
140 
141       for (list<Expression*>::const_iterator cur = sensitivity_list_.begin()
142 		 ; cur != sensitivity_list_.end() ; ++cur) {
143 	    (*cur)->dump(out, indent+4);
144       }
145 
146       StatementList::dump(out, indent);
147 }
148