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 () = default ;
44
44
@@ -53,9 +53,7 @@ inline void Verilog::Writer::_create_file(const char* file_name, const file_type
53
53
this ->output_file = create_verilog (file_name);
54
54
}
55
55
56
-
57
56
void Verilog::Writer::_write (const netlist_t * netlist) {
58
-
59
57
// to write the top module and netlist components
60
58
if (netlist) {
61
59
/* [TODO] */
@@ -64,9 +62,9 @@ void Verilog::Writer::_write(const netlist_t* netlist) {
64
62
// print out the rest od models, including DSPs in the target architecture
65
63
t_model* model = Arch.models ;
66
64
67
- while (model) {
65
+ while (model) {
68
66
int sc_spot;
69
- if ((sc_spot = sc_lookup_string (this ->models_declaration , model->name )) != -1 ){
67
+ if ((sc_spot = sc_lookup_string (this ->models_declaration , model->name )) != -1 ) {
70
68
fprintf (this ->output_file , " %s" , (char *)this ->models_declaration ->data [sc_spot]);
71
69
fflush (this ->output_file );
72
70
}
@@ -97,7 +95,6 @@ FILE* Verilog::Writer::create_verilog(const char* file_name) {
97
95
return (out);
98
96
}
99
97
100
-
101
98
/* *
102
99
*-------------------------------------------------------------------------------------------
103
100
* (function: declare_blackbox)
@@ -119,13 +116,13 @@ long Verilog::Writer::declare_blackbox(const char* bb_name) {
119
116
120
117
t_model* bb = find_hard_block (bb_name);
121
118
if (bb == NULL ) {
122
- error_message (UTIL, unknown_location,
123
- " Odin-II failed to find DSP module \" %s\" in the target device." , bb_name);
119
+ error_message (UTIL, unknown_location,
120
+ " Odin-II failed to find DSP module \" %s\" in the target device." , bb_name);
124
121
}
125
122
126
123
std::stringstream bb_declaration;
127
124
128
- // need to specify "(* blackbox *)" tag if Yosys
125
+ // need to specify "(* blackbox *)" tag if Yosys
129
126
// is going to elaborate the Verilog file
130
127
if (elaborator_e::_YOSYS) {
131
128
bb_declaration << BLACKBOX_ATTR << NEWLINE;
@@ -138,8 +135,8 @@ long Verilog::Writer::declare_blackbox(const char* bb_name) {
138
135
bb_declaration << END_MODULE << NEWLINE << std::endl;
139
136
140
137
int sc_spot;
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 ());
138
+ if ((sc_spot = sc_add_string (this ->models_declaration , bb->name )) != -1 ) {
139
+ this ->models_declaration ->data [sc_spot] = (void *)vtr::strdup (bb_declaration.str ().c_str ());
143
140
return (sc_spot);
144
141
}
145
142
@@ -165,12 +162,12 @@ std::string Verilog::Writer::declare_ports(t_model* model) {
165
162
166
163
std::stringstream input_stream;
167
164
t_model_ports* input_port = model->inputs ;
168
- while (input_port) {
165
+ while (input_port) {
169
166
input_stream << TAB
170
167
<< INPUT_PORT << TAB
171
- << OPEN_SQUARE_BRACKET
172
- << input_port->size << COLON << " 0"
173
- << CLOSE_SQUARE_BRACKET
168
+ << OPEN_SQUARE_BRACKET
169
+ << input_port->size << COLON << " 0"
170
+ << CLOSE_SQUARE_BRACKET
174
171
<< TAB << input_port->name
175
172
<< COMMA << std::endl;
176
173
@@ -180,12 +177,12 @@ std::string Verilog::Writer::declare_ports(t_model* model) {
180
177
181
178
std::stringstream output_stream;
182
179
t_model_ports* output_port = model->outputs ;
183
- while (output_port) {
184
- output_stream << TAB
180
+ while (output_port) {
181
+ output_stream << TAB
185
182
<< OUTPUT_PORT << TAB
186
- << OPEN_SQUARE_BRACKET
187
- << output_port->size << COLON << " 0"
188
- << CLOSE_SQUARE_BRACKET
183
+ << OPEN_SQUARE_BRACKET
184
+ << output_port->size << COLON << " 0"
185
+ << CLOSE_SQUARE_BRACKET
189
186
<< TAB << output_port->name
190
187
<< COMMA << std::endl;
191
188
@@ -196,17 +193,17 @@ std::string Verilog::Writer::declare_ports(t_model* model) {
196
193
std::string input_str = input_stream.str ();
197
194
std::string output_str = output_stream.str ();
198
195
199
- // check the value of input/output ports declaration
196
+ // check the value of input/output ports declaration
200
197
// to trim extra last semicolon if required
201
198
std::stringstream ports_declaration;
202
199
if (!input_stream.str ().empty () && output_stream.str ().empty ()) {
203
- input_str[input_str.find_last_not_of (COMMA)- 1 ] = ' \0 ' ;
200
+ input_str[input_str.find_last_not_of (COMMA) - 1 ] = ' \0 ' ;
204
201
ports_declaration << input_str;
205
202
} else if (!output_stream.str ().empty ()) {
206
203
if (!input_stream.str ().empty ())
207
204
ports_declaration << input_str;
208
205
209
- ports_declaration << output_str.substr (0 , output_str.find_last_not_of (COMMA)- 1 );
206
+ ports_declaration << output_str.substr (0 , output_str.find_last_not_of (COMMA) - 1 );
210
207
}
211
208
212
209
// return the string value
0 commit comments