28
28
* With that said, only the DSPs' declaration are printed.
29
29
*/
30
30
31
- #include < sstream> // std::stringstream
31
+ #include < sstream> // std::stringstream
32
32
33
33
#include " Verilog.hpp"
34
34
#include " odin_globals.h"
35
35
#include " hard_blocks.h"
36
- #include " vtr_util.cpp "
36
+ #include " vtr_util.h "
37
37
38
38
Verilog::Writer::Writer ()
39
39
: GenericWriter() {
40
- this ->models_declaration = sc_new_string_cache ();
41
- }
40
+ this ->models_declaration = sc_new_string_cache ();
41
+ }
42
42
43
43
Verilog::Writer::~Writer () {
44
44
if (this ->models_declaration )
@@ -56,9 +56,7 @@ inline void Verilog::Writer::_create_file(const char* file_name, const file_type
56
56
this ->output_file = create_verilog (file_name);
57
57
}
58
58
59
-
60
59
void Verilog::Writer::_write (const netlist_t * netlist) {
61
-
62
60
// to write the top module and netlist components
63
61
if (netlist) {
64
62
/* [TODO] */
@@ -67,9 +65,9 @@ void Verilog::Writer::_write(const netlist_t* netlist) {
67
65
// print out the rest od models, including DSPs in the target architecture
68
66
t_model* model = Arch.models ;
69
67
70
- while (model) {
68
+ while (model) {
71
69
int sc_spot;
72
- if ((sc_spot = sc_lookup_string (this ->models_declaration , model->name )) != -1 ){
70
+ if ((sc_spot = sc_lookup_string (this ->models_declaration , model->name )) != -1 ) {
73
71
fprintf (this ->output_file , " %s" , (char *)this ->models_declaration ->data [sc_spot]);
74
72
fflush (this ->output_file );
75
73
}
@@ -100,7 +98,6 @@ FILE* Verilog::Writer::create_verilog(const char* file_name) {
100
98
return (out);
101
99
}
102
100
103
-
104
101
/* *
105
102
*-------------------------------------------------------------------------------------------
106
103
* (function: declare_blackbox)
@@ -122,13 +119,13 @@ long Verilog::Writer::declare_blackbox(const char* bb_name) {
122
119
123
120
t_model* bb = find_hard_block (bb_name);
124
121
if (bb == NULL ) {
125
- error_message (UTIL, unknown_location,
126
- " Odin-II failed to find DSP module \" %s\" in the target device." , bb_name);
122
+ error_message (UTIL, unknown_location,
123
+ " Odin-II failed to find DSP module \" %s\" in the target device." , bb_name);
127
124
}
128
125
129
126
std::stringstream bb_declaration;
130
127
131
- // need to specify "(* blackbox *)" tag if Yosys
128
+ // need to specify "(* blackbox *)" tag if Yosys
132
129
// is going to elaborate the Verilog file
133
130
if (elaborator_e::_YOSYS) {
134
131
bb_declaration << BLACKBOX_ATTR << NEWLINE;
@@ -141,8 +138,8 @@ long Verilog::Writer::declare_blackbox(const char* bb_name) {
141
138
bb_declaration << END_MODULE << NEWLINE << std::endl;
142
139
143
140
int sc_spot;
144
- if ((sc_spot = sc_add_string (this ->models_declaration , bb->name )) != -1 ) {
145
- this ->models_declaration ->data [sc_spot] = (void *) vtr::strdup (bb_declaration.str ().c_str ());
141
+ if ((sc_spot = sc_add_string (this ->models_declaration , bb->name )) != -1 ) {
142
+ this ->models_declaration ->data [sc_spot] = (void *)vtr::strdup (bb_declaration.str ().c_str ());
146
143
return (sc_spot);
147
144
}
148
145
@@ -168,12 +165,12 @@ std::string Verilog::Writer::declare_ports(t_model* model) {
168
165
169
166
std::stringstream input_stream;
170
167
t_model_ports* input_port = model->inputs ;
171
- while (input_port) {
168
+ while (input_port) {
172
169
input_stream << TAB
173
170
<< INPUT_PORT << TAB
174
- << OPEN_SQUARE_BRACKET
175
- << input_port->size << COLON << " 0"
176
- << CLOSE_SQUARE_BRACKET
171
+ << OPEN_SQUARE_BRACKET
172
+ << input_port->size << COLON << " 0"
173
+ << CLOSE_SQUARE_BRACKET
177
174
<< TAB << input_port->name
178
175
<< COMMA << std::endl;
179
176
@@ -183,12 +180,12 @@ std::string Verilog::Writer::declare_ports(t_model* model) {
183
180
184
181
std::stringstream output_stream;
185
182
t_model_ports* output_port = model->outputs ;
186
- while (output_port) {
187
- output_stream << TAB
183
+ while (output_port) {
184
+ output_stream << TAB
188
185
<< OUTPUT_PORT << TAB
189
- << OPEN_SQUARE_BRACKET
190
- << output_port->size << COLON << " 0"
191
- << CLOSE_SQUARE_BRACKET
186
+ << OPEN_SQUARE_BRACKET
187
+ << output_port->size << COLON << " 0"
188
+ << CLOSE_SQUARE_BRACKET
192
189
<< TAB << output_port->name
193
190
<< COMMA << std::endl;
194
191
@@ -199,17 +196,17 @@ std::string Verilog::Writer::declare_ports(t_model* model) {
199
196
std::string input_str = input_stream.str ();
200
197
std::string output_str = output_stream.str ();
201
198
202
- // check the value of input/output ports declaration
199
+ // check the value of input/output ports declaration
203
200
// to trim extra last semicolon if required
204
201
std::stringstream ports_declaration;
205
202
if (!input_stream.str ().empty () && output_stream.str ().empty ()) {
206
- input_str[input_str.find_last_not_of (COMMA)- 1 ] = ' \0 ' ;
203
+ input_str[input_str.find_last_not_of (COMMA) - 1 ] = ' \0 ' ;
207
204
ports_declaration << input_str;
208
205
} else if (!output_stream.str ().empty ()) {
209
206
if (!input_stream.str ().empty ())
210
207
ports_declaration << input_str;
211
208
212
- ports_declaration << output_str.substr (0 , output_str.find_last_not_of (COMMA)- 1 );
209
+ ports_declaration << output_str.substr (0 , output_str.find_last_not_of (COMMA) - 1 );
213
210
}
214
211
215
212
// return the string value
0 commit comments