Skip to content

Commit 847e9ce

Browse files
committed
[Yosys+Odin]: formatting the new code
Signed-off-by: Seyed Alireza Damghani <[email protected]>
1 parent a2a0e60 commit 847e9ce

File tree

4 files changed

+31
-39
lines changed

4 files changed

+31
-39
lines changed

ODIN_II/SRC/BLIFWriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ inline void BLIF::Writer::_create_file(const char* file_name, const file_type_e
7878
// validate the file_name pionter
7979
oassert(file_name);
8080
// validate the file type
81-
if (file_type != _BLIF)
81+
if (file_type != _BLIF)
8282
error_message(UTIL, unknown_location,
8383
"BLIF back-end entity cannot create file types(%d) other than BLIF", file_type);
8484
// create the BLIF file and set it as the output file

ODIN_II/SRC/VerilogWriter.cpp

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@
2828
* With that said, only the DSPs' declaration are printed.
2929
*/
3030

31-
#include <sstream> //std::stringstream
31+
#include <sstream> //std::stringstream
3232

3333
#include "Verilog.hpp"
3434
#include "odin_globals.h"
3535
#include "hard_blocks.h"
36-
#include "vtr_util.cpp"
36+
#include "vtr_util.h"
3737

3838
Verilog::Writer::Writer()
3939
: GenericWriter() {
40-
this->models_declaration = sc_new_string_cache();
41-
}
40+
this->models_declaration = sc_new_string_cache();
41+
}
4242

4343
Verilog::Writer::~Writer() {
4444
if (this->models_declaration)
@@ -56,9 +56,7 @@ inline void Verilog::Writer::_create_file(const char* file_name, const file_type
5656
this->output_file = create_verilog(file_name);
5757
}
5858

59-
6059
void Verilog::Writer::_write(const netlist_t* netlist) {
61-
6260
// to write the top module and netlist components
6361
if (netlist) {
6462
/* [TODO] */
@@ -67,9 +65,9 @@ void Verilog::Writer::_write(const netlist_t* netlist) {
6765
// print out the rest od models, including DSPs in the target architecture
6866
t_model* model = Arch.models;
6967

70-
while(model) {
68+
while (model) {
7169
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) {
7371
fprintf(this->output_file, "%s", (char*)this->models_declaration->data[sc_spot]);
7472
fflush(this->output_file);
7573
}
@@ -100,7 +98,6 @@ FILE* Verilog::Writer::create_verilog(const char* file_name) {
10098
return (out);
10199
}
102100

103-
104101
/**
105102
*-------------------------------------------------------------------------------------------
106103
* (function: declare_blackbox)
@@ -122,13 +119,13 @@ long Verilog::Writer::declare_blackbox(const char* bb_name) {
122119

123120
t_model* bb = find_hard_block(bb_name);
124121
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);
127124
}
128125

129126
std::stringstream bb_declaration;
130127

131-
// need to specify "(* blackbox *)" tag if Yosys
128+
// need to specify "(* blackbox *)" tag if Yosys
132129
// is going to elaborate the Verilog file
133130
if (elaborator_e::_YOSYS) {
134131
bb_declaration << BLACKBOX_ATTR << NEWLINE;
@@ -141,8 +138,8 @@ long Verilog::Writer::declare_blackbox(const char* bb_name) {
141138
bb_declaration << END_MODULE << NEWLINE << std::endl;
142139

143140
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());
146143
return (sc_spot);
147144
}
148145

@@ -168,12 +165,12 @@ std::string Verilog::Writer::declare_ports(t_model* model) {
168165

169166
std::stringstream input_stream;
170167
t_model_ports* input_port = model->inputs;
171-
while(input_port) {
168+
while (input_port) {
172169
input_stream << TAB
173170
<< 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
177174
<< TAB << input_port->name
178175
<< COMMA << std::endl;
179176

@@ -183,12 +180,12 @@ std::string Verilog::Writer::declare_ports(t_model* model) {
183180

184181
std::stringstream output_stream;
185182
t_model_ports* output_port = model->outputs;
186-
while(output_port) {
187-
output_stream << TAB
183+
while (output_port) {
184+
output_stream << TAB
188185
<< 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
192189
<< TAB << output_port->name
193190
<< COMMA << std::endl;
194191

@@ -199,17 +196,17 @@ std::string Verilog::Writer::declare_ports(t_model* model) {
199196
std::string input_str = input_stream.str();
200197
std::string output_str = output_stream.str();
201198

202-
// check the value of input/output ports declaration
199+
// check the value of input/output ports declaration
203200
// to trim extra last semicolon if required
204201
std::stringstream ports_declaration;
205202
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';
207204
ports_declaration << input_str;
208205
} else if (!output_stream.str().empty()) {
209206
if (!input_stream.str().empty())
210207
ports_declaration << input_str;
211208

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);
213210
}
214211

215212
// return the string value

ODIN_II/SRC/YYosys.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@
4343

4444
#include "YYosys.hpp"
4545
#include "Verilog.hpp"
46-
#include "config_t.h" // configuration
47-
#include "odin_util.h" // get_directory
48-
#include "odin_error.h" // error_message
49-
#include "hard_blocks.h" // hard_block_names
46+
#include "config_t.h" // configuration
47+
#include "odin_util.h" // get_directory
48+
#include "odin_error.h" // error_message
49+
#include "hard_blocks.h" // hard_block_names
5050

5151
#ifdef ODIN_USE_YOSYS
5252
# include "kernel/yosys.h" // Yosys
@@ -164,14 +164,11 @@ void YYosys::load_target_dsp_blocks() {
164164
vw._create_file(configuration.dsp_verilog.c_str());
165165

166166
t_model* hb = Arch.models;
167-
while(hb) {
167+
while (hb) {
168168
// declare hardblocks in a verilog file
169-
if (strcmp(hb->name, SINGLE_PORT_RAM_string) &&
170-
strcmp(hb->name, DUAL_PORT_RAM_string) &&
171-
strcmp(hb->name, "multiply") &&
172-
strcmp(hb->name, "adder"))
169+
if (strcmp(hb->name, SINGLE_PORT_RAM_string) && strcmp(hb->name, DUAL_PORT_RAM_string) && strcmp(hb->name, "multiply") && strcmp(hb->name, "adder"))
173170
vw.declare_blackbox(hb->name);
174-
171+
175172
hb = hb->next;
176173
}
177174

ODIN_II/SRC/include/Verilog.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@ class Verilog {
120120
void _write(const netlist_t* netlist);
121121
void _create_file(const char* file_name, const file_type_e file_type = _VERILOG);
122122

123-
124-
125123
/**
126124
*-------------------------------------------------------------------------------------------
127125
* (function: declare_blackbox)

0 commit comments

Comments
 (0)