Skip to content

Commit aad4b5a

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

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() = default;
4444

@@ -53,9 +53,7 @@ inline void Verilog::Writer::_create_file(const char* file_name, const file_type
5353
this->output_file = create_verilog(file_name);
5454
}
5555

56-
5756
void Verilog::Writer::_write(const netlist_t* netlist) {
58-
5957
// to write the top module and netlist components
6058
if (netlist) {
6159
/* [TODO] */
@@ -64,9 +62,9 @@ void Verilog::Writer::_write(const netlist_t* netlist) {
6462
// print out the rest od models, including DSPs in the target architecture
6563
t_model* model = Arch.models;
6664

67-
while(model) {
65+
while (model) {
6866
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) {
7068
fprintf(this->output_file, "%s", (char*)this->models_declaration->data[sc_spot]);
7169
fflush(this->output_file);
7270
}
@@ -97,7 +95,6 @@ FILE* Verilog::Writer::create_verilog(const char* file_name) {
9795
return (out);
9896
}
9997

100-
10198
/**
10299
*-------------------------------------------------------------------------------------------
103100
* (function: declare_blackbox)
@@ -119,13 +116,13 @@ long Verilog::Writer::declare_blackbox(const char* bb_name) {
119116

120117
t_model* bb = find_hard_block(bb_name);
121118
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);
124121
}
125122

126123
std::stringstream bb_declaration;
127124

128-
// need to specify "(* blackbox *)" tag if Yosys
125+
// need to specify "(* blackbox *)" tag if Yosys
129126
// is going to elaborate the Verilog file
130127
if (elaborator_e::_YOSYS) {
131128
bb_declaration << BLACKBOX_ATTR << NEWLINE;
@@ -138,8 +135,8 @@ long Verilog::Writer::declare_blackbox(const char* bb_name) {
138135
bb_declaration << END_MODULE << NEWLINE << std::endl;
139136

140137
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());
143140
return (sc_spot);
144141
}
145142

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

166163
std::stringstream input_stream;
167164
t_model_ports* input_port = model->inputs;
168-
while(input_port) {
165+
while (input_port) {
169166
input_stream << TAB
170167
<< 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
174171
<< TAB << input_port->name
175172
<< COMMA << std::endl;
176173

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

181178
std::stringstream output_stream;
182179
t_model_ports* output_port = model->outputs;
183-
while(output_port) {
184-
output_stream << TAB
180+
while (output_port) {
181+
output_stream << TAB
185182
<< 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
189186
<< TAB << output_port->name
190187
<< COMMA << std::endl;
191188

@@ -196,17 +193,17 @@ std::string Verilog::Writer::declare_ports(t_model* model) {
196193
std::string input_str = input_stream.str();
197194
std::string output_str = output_stream.str();
198195

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

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);
210207
}
211208

212209
// 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)