Skip to content

Commit b6f36ec

Browse files
authored
Merge pull request #3 from verilog-to-routing/master
Pull from upstream
2 parents 3eddd97 + b00ffbb commit b6f36ec

File tree

644 files changed

+274894
-16976
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

644 files changed

+274894
-16976
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ vgcore*
6666
*.place
6767
*.route
6868
*.out
69+
*.bin
70+
71+
#
72+
# FASM result files
73+
#
74+
*.fasm
6975

7076
#
7177
#Odin test outputs

.readthedocs.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ version: 2
77

88
# Build documentation in the docs/ directory with Sphinx
99
sphinx:
10-
builder: htmldir
10+
builder: dirhtml
1111
configuration: doc/src/conf.py
1212

1313
# Optionally build your docs in additional formats such as PDF and ePub
1414
formats: all
1515

1616
# Optionally set the version of Python and requirements required to build your docs
1717
python:
18-
version: 2
18+
version: 3.7
1919
install:
2020
- requirements: doc/requirements.txt

ODIN_II/CMakeLists.txt

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ if(ODIN_COVERAGE)
6464
)
6565

6666
set(ODIN_EXTRA_LINK_FLAGS
67-
"-lgcov --coverage"
67+
"-lgcov"
68+
"--coverage"
69+
${ODIN_EXTRA_LINK_FLAGS}
6870
)
6971

7072
endif()
@@ -74,13 +76,23 @@ if(ODIN_SANITIZE)
7476
message("*** Compiling with Odin Coverage flags")
7577

7678
set(ODIN_EXTRA_FLAGS
77-
"-g"
79+
"-O1"
80+
"-fno-omit-frame-pointer"
7881
"-fsanitize=address"
82+
"-fsanitize=leak"
83+
"-fsanitize=undefined"
84+
"-fuse-ld=gold"
7985
${ODIN_EXTRA_FLAGS}
8086
)
8187

8288
set(ODIN_EXTRA_LINK_FLAGS
89+
"-O1"
90+
"-fno-omit-frame-pointer"
8391
"-fsanitize=address"
92+
"-fsanitize=leak"
93+
"-fsanitize=undefined"
94+
"-fuse-ld=gold"
95+
${ODIN_EXTRA_LINK_FLAGS}
8496
)
8597

8698
endif()
@@ -169,10 +181,10 @@ foreach(ODIN_FLAG ${ODIN_EXTRA_FLAGS})
169181
endforeach()
170182

171183
#add extra link flags for odin
172-
if(ODIN_EXTRA_LINK_FLAGS)
173-
set_target_properties(libodin_ii PROPERTIES LINK_FLAGS ${ODIN_EXTRA_LINK_FLAGS})
174-
set_target_properties(odin_II PROPERTIES LINK_FLAGS ${ODIN_EXTRA_LINK_FLAGS})
175-
endif()
184+
foreach(ODIN_LINK_FLAG ${ODIN_EXTRA_LINK_FLAGS})
185+
target_link_libraries(libodin_ii ${ODIN_LINK_FLAG})
186+
target_link_libraries(odin_II ${ODIN_LINK_FLAG})
187+
endforeach()
176188

177189
#Supress IPO link warnings if IPO is enabled
178190
get_target_property(ODIN_USES_IPO odin_II INTERPROCEDURAL_OPTIMIZATION)

ODIN_II/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Odin_II
2+
=======
3+
4+
Odin II is used for logic synthesis and elaboration, converting a subset of the Verilog Hardware Description Language (HDL) into a BLIF netlist.
5+
6+
-----------------
7+
8+
* **[Quick Start](../doc/src/odin/quickstart.md)**
9+
* **[User Guide](../doc/src/odin/user_guide.md)**
10+
* **[Verilog Support](../doc/src/odin/verilog_support.md)**
11+
* **Developper guide**
12+
* [Contributing](../doc/src/odin/dev_guide/contributing)
13+
* [Regression Tests](../doc/src/odin/dev_guide/regression_test)
14+
* [Regression Tool](../doc/src/odin/dev_guide/verify_script)
15+
* [Validating Tests](../doc/src/odin/dev_guide/testing)

ODIN_II/README.rst

Lines changed: 0 additions & 1 deletion
This file was deleted.

ODIN_II/SRC/adders.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ void split_adder(nnode_t* nodeo, int a, int b, int sizea, int sizeb, int cin, in
675675
// don't add a dummy adder in the beginning of the chain if the first cin will be connected to a global gnd
676676
if ((flag == 0 || count > 1) && !configuration.adder_cin_global) {
677677
//connect the a[0] and b[0] of first adder node to ground
678-
connect_nodes(netlist->gnd_node, 0, node[0], 0);
678+
connect_nodes(netlist->vcc_node, 0, node[0], 0);
679679
connect_nodes(netlist->gnd_node, 0, node[0], sizea);
680680
//hang the first sumout
681681
node[0]->output_pins[1] = allocate_npin();

ODIN_II/SRC/ast_elaborate.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,10 +1106,10 @@ ast_node_t* build_hierarchy(ast_node_t* node, ast_node_t* parent, int index, sc_
11061106
break;
11071107
}
11081108
}
1109+
}
11091110

1110-
if (child_skip_list) {
1111-
child_skip_list = (short*)vtr::free(child_skip_list);
1112-
}
1111+
if (child_skip_list) {
1112+
child_skip_list = (short*)vtr::free(child_skip_list);
11131113
}
11141114

11151115
return node;

ODIN_II/SRC/ast_util.cpp

Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,12 +1322,12 @@ void assert_constant_positionnal_args(ast_node_t* node, long arg_count) {
13221322
"%s node expects arguments\n", ast_node_name_based_on_ids(node));
13231323
} else if (node->num_children < arg_count) {
13241324
error_message(AST, node->line_number, node->file_number,
1325-
"%s node expects %d positional arguments\n", ast_node_name_based_on_ids(node), arg_count);
1325+
"%s node expects %ld positional arguments\n", ast_node_name_based_on_ids(node), arg_count);
13261326
} else {
13271327
for (long i = 0; i < arg_count; i += 1) {
13281328
if (!node_is_constant(node->children[i])) {
13291329
error_message(AST, node->line_number, node->file_number,
1330-
"%s node expects a constant at positional arguments [%d]\n", ast_node_name_based_on_ids(node), i);
1330+
"%s node expects a constant at positional arguments [%ld]\n", ast_node_name_based_on_ids(node), i);
13311331
}
13321332
}
13331333
}
@@ -1338,39 +1338,52 @@ void assert_constant_positionnal_args(ast_node_t* node, long arg_count) {
13381338
* a simple printf would not be able to do this since escaped characters are compile time
13391339
*/
13401340
void c_simple_print(std::string str) {
1341+
size_t str_size = str.size();
13411342
size_t start = 0;
13421343
while (start != std::string::npos) {
13431344
size_t format_char_index = str.find_first_of('\\', start);
13441345
size_t next_char = format_char_index;
1345-
printf("%s", str.substr(start, format_char_index).c_str());
1346+
if (start != format_char_index) {
1347+
printf("%s", str.substr(start, format_char_index).c_str());
1348+
}
13461349
// print the string
13471350
if (format_char_index != std::string::npos) {
1348-
// try and see if its an octal number
1349-
char buffer[4] = {
1350-
str[format_char_index + 1],
1351-
str[format_char_index + 2],
1352-
str[format_char_index + 3],
1353-
0};
1354-
next_char = format_char_index + 4;
1355-
char* endptr = NULL;
1356-
char octal_value = (char)strtoul(buffer, &endptr, 8);
1357-
if (endptr == &buffer[3]) {
1358-
// if it is an octal number print the octal char
1359-
printf("%c", octal_value);
1360-
} else {
1361-
next_char = format_char_index + 2;
1362-
switch (str[format_char_index + 1]) {
1363-
case 'n':
1364-
printf("\n");
1365-
break;
1366-
case 't':
1367-
printf("\t");
1368-
break;
1369-
default:
1351+
next_char = format_char_index + 2;
1352+
switch (str[format_char_index + 1]) {
1353+
case 'n':
1354+
printf("\n");
1355+
break;
1356+
case 't':
1357+
printf("\t");
1358+
break;
1359+
default:
1360+
// can only be octal if there is 3+ chars following
1361+
if ((str_size - 3) >= format_char_index) {
1362+
// try and see if its an octal number
1363+
char buffer[4] = {
1364+
str[format_char_index + 1],
1365+
str[format_char_index + 2],
1366+
str[format_char_index + 3],
1367+
0};
1368+
next_char = format_char_index + 4;
1369+
char* endptr = NULL;
1370+
char octal_value = (char)strtoul(buffer, &endptr, 8);
1371+
if (endptr == &buffer[3]) {
1372+
// if it is an octal number print the octal char
1373+
printf("%c", octal_value);
1374+
} else {
1375+
// otherwise just print the character
1376+
next_char = format_char_index + 2;
1377+
printf("%c", str[format_char_index + 1]);
1378+
break;
1379+
}
1380+
1381+
} else {
13701382
// otherwise just print the character
1383+
next_char = format_char_index + 2;
13711384
printf("%c", str[format_char_index + 1]);
13721385
break;
1373-
}
1386+
}
13741387
}
13751388
}
13761389
start = next_char;
@@ -1401,7 +1414,7 @@ void c_display(ast_node_t* node) {
14011414
printf("%%");
14021415
} else if (!argv_nodes || argc_node >= argv_nodes->num_children || argv_nodes->children[argc_node] == NULL) {
14031416
error_message(AST, node->children[0]->line_number, node->children[0]->file_number,
1404-
"specifier character [%d] has no argument associated with it", argc_node);
1417+
"specifier character [%ld] has no argument associated with it", argc_node);
14051418
} else {
14061419
ast_node_t* argv = argv_nodes->children[argc_node];
14071420
switch (tolower(format_input[1])) {
@@ -1414,7 +1427,7 @@ void c_display(ast_node_t* node) {
14141427
case 'b': {
14151428
if (!node_is_constant(argv)) {
14161429
error_message(AST, argv->line_number, argv->file_number,
1417-
"specifier character [%d] is not associated with a constant, node is %s",
1430+
"specifier character [%ld] is not associated with a constant, node is %s",
14181431
argc_node, ast_node_name_based_on_ids(argv));
14191432
}
14201433
printf("%s", argv->types.vnumber->to_vstring(format_input[1]).c_str());
@@ -1440,7 +1453,7 @@ void c_display(ast_node_t* node) {
14401453
case 't': {
14411454
if (!node_is_constant(argv)) {
14421455
error_message(AST, argv->line_number, argv->file_number,
1443-
"specifier character [%d] is not associated with a constant, node is %s",
1456+
"specifier character [%ld] is not associated with a constant, node is %s",
14441457
argc_node, ast_node_name_based_on_ids(argv));
14451458
}
14461459
// TODO: for now we just print as is

ODIN_II/SRC/include/odin_util.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const char* ast_node_name_based_on_ids(ast_node_t* node);
2222
char* make_signal_name(char* signal_name, int bit);
2323
char* make_full_ref_name(const char* previous, const char* module_name, const char* module_instance_name, const char* signal_name, long bit);
2424
char* make_full_name_w_o_array_ref(const char* previous, const char* module_name, const char* module_instance_name);
25+
bool output_vector_headers_equal(char* buffer1, char* buffer2);
2526

2627
char* twos_complement(char* str);
2728
int is_string_of_radix(char* string, int radix);

ODIN_II/SRC/odin_ii.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,6 @@ netlist_t* start_odin_ii(int argc, char** argv) {
212212
zero_string = vtr::strdup(ZERO_GND_ZERO);
213213
pad_string = vtr::strdup(ZERO_PAD_ZERO);
214214

215-
printf("--------------------------------------------------------------------\n");
216-
printf("Welcome to ODIN II version 0.1 - the better High level synthesis tools++ targetting FPGAs (mainly VPR)\n");
217-
printf("Email: [email protected] and [email protected] for support issues\n\n");
218215
} catch (vtr::VtrError& vtr_error) {
219216
printf("Odin failed to initialize %s with exit code%d\n", vtr_error.what(), ERROR_INITIALIZATION);
220217
exit(ERROR_INITIALIZATION);

ODIN_II/SRC/odin_util.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,57 @@ void trim_string(char* string, const char* chars) {
909909
}
910910
}
911911

912+
/*
913+
* Tokenizes a string and returns an array where each element is a
914+
* token and a pointer (that needs to be passed through) with the
915+
* size of the array
916+
*/
917+
static char** string_to_token_array(char* string, int* size) {
918+
char** arr = NULL;
919+
920+
char* token = strtok(string, " \n\t");
921+
int i = 0;
922+
923+
while (token != NULL) {
924+
arr = (char**)vtr::realloc(arr, sizeof(char*) * (i + 1));
925+
arr[i] = token;
926+
token = strtok(NULL, " \n\t");
927+
i++;
928+
}
929+
*size = (i);
930+
return arr;
931+
}
932+
933+
/*
934+
* Will seperate the headers from the inputs and compare them
935+
* Will return value of 1 if they match and 0 if
936+
* they don't match. Possible error if the vector headers match
937+
* but are in different order
938+
*/
939+
bool output_vector_headers_equal(char* buffer1, char* buffer2) {
940+
int size1 = 0;
941+
int size2 = 0;
942+
char* buffer1_copy = strdup(buffer1);
943+
char* buffer2_copy = strdup(buffer2);
944+
945+
char** header1 = string_to_token_array(buffer1_copy, &size1);
946+
char** header2 = string_to_token_array(buffer2_copy, &size2);
947+
948+
int i = 0;
949+
bool header_matches;
950+
951+
header_matches = (size1 == size2);
952+
for (i = 0; header_matches && i < (size1 - 1); i++) {
953+
header_matches = (0 == strcmp(header1[i], header2[i]));
954+
}
955+
956+
vtr::free(header1);
957+
vtr::free(header2);
958+
vtr::free(buffer1_copy);
959+
vtr::free(buffer2_copy);
960+
return (header_matches);
961+
}
962+
912963
/**
913964
* verifies only one condition evaluates to true
914965
*/

ODIN_II/SRC/simulate_blif.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2727,7 +2727,7 @@ static int verify_output_vectors(const char* output_vector_file, int num_vectors
27272727
break;
27282728
}
27292729
// The headers differ.
2730-
else if ((cycle == -1) && strcmp(buffer1, buffer2)) {
2730+
else if ((cycle == -1) && !output_vector_headers_equal(buffer1, buffer2)) {
27312731
error = true;
27322732
warning_message(SIMULATION, 0, -1,
27332733
"Vector headers do not match: \n"

ODIN_II/SRC/verilog_bison.y

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ int yywrap(){ return 1;}
4242
int yylex(void);
4343

4444
%}
45+
/* give detailed errors */
46+
%define parse.error verbose
4547

4648
%locations
4749

ODIN_II/exec_wrapper.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,20 +167,26 @@ function display() {
167167
LEAK_MESSAGE=""
168168

169169
# check for valgrind leaks
170-
LEAK_COUNT="$(cat ${LOG_FILE} | grep 'ERROR SUMMARY:' | awk '{print $4}' | grep -E '^\-?[0-9]+$')"
170+
VALGRIND_LEAK_COUNT="$(cat ${LOG_FILE} | grep 'ERROR SUMMARY:' | awk '{print $4}' | grep -E '^\-?[0-9]+$')"
171+
# check for LSAN leaks
172+
LSAN_LEAK_COUNT="$(cat ${LOG_FILE} | grep 'SUMMARY: AddressSanitizer:' | awk '{print $7}' | grep -E '^\-?[0-9]+$')"
173+
174+
LEAK_COUNT=$(( VALGRIND_LEAK_COUNT + LSAN_LEAK_COUNT ))
175+
171176
case "_${LEAK_COUNT}" in
172177
_|_0) LEAK_MESSAGE=""
173178
;;_1) LEAK_MESSAGE="[${LEAK_COUNT}]Leak "
174179
;;*) LEAK_MESSAGE="[${LEAK_COUNT}]Leaks "
175180
esac
176181

177182
# check for uncaught errors
178-
179183
ERROR_CATCH="$(cat "${LOG_FILE}" | grep 'Odin exited with code: ' | awk '{print $5}' | grep -E '^\-?[0-9]+$')"
180184
[ "_${ERROR_CATCH}" != "_" ] && EXIT_CODE="${ERROR_CATCH}"
181185

182186
EXIT_ERROR_TYPE=$( print_exit_type "${EXIT_CODE}" )
183187

188+
MISMATCH_CHECK="$(cat "${LOG_FILE}" | grep "Error::OUTPUT_BLIF Vector files differ.")"
189+
[ "_${MISMATCH_CHECK}" != "_" ] && EXIT_ERROR_TYPE="MISMATCH"
184190

185191
if [ "_${EXIT_CODE}" == "_0" ] && [ "_${LEAK_MESSAGE}" == "_" ]
186192
then

ODIN_II/main.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,32 @@
11
#include "odin_ii.h"
22
#include "odin_types.h"
33
#include "vtr_time.h"
4+
#include "vtr_version.h"
45

56
int main(int argc, char** argv) {
67
vtr::ScopedFinishTimer t("Odin II");
8+
9+
printf(
10+
"=======================================================================\n"
11+
" Odin II - Verilog synthesis tools targetting VPR FPGAs\n"
12+
"-----------------------------------------------------------------------\n"
13+
"\tVersion: %s\n"
14+
"\tRevision: %s\n"
15+
"\tCompiled: %s\n"
16+
"\tCompiler: %s\n"
17+
"\tBuild Info: %s\n"
18+
"\n"
19+
"University of New Brunswick\n"
20+
"For documentation:\n"
21+
" https://docs.verilogtorouting.org/en/latest/odin\n"
22+
"For question:\n"
23+
24+
"\n"
25+
"This is free open source code under MIT license.\n"
26+
"=======================================================================\n"
27+
"\n",
28+
vtr::VERSION, vtr::VCS_REVISION, vtr::BUILD_TIMESTAMP, vtr::COMPILER, vtr::BUILD_INFO);
29+
730
netlist_t* odin_netlist = start_odin_ii(argc, argv);
831
terminate_odin_ii(odin_netlist);
932
return 0;

0 commit comments

Comments
 (0)