Skip to content

Commit 8980e46

Browse files
authored
Merge pull request #495 from antmicro/master+wip-analysis
"post-synthesis" netlist writing fix
2 parents 7d6424b + e190bf5 commit 8980e46

File tree

38 files changed

+721
-529
lines changed

38 files changed

+721
-529
lines changed

.github/kokoro/continuous/strong_sanitized.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
build_file: "vtr-verilog-to-routing/.github/kokoro/run-vtr.sh"
44

5-
# 1 hour
6-
timeout_mins: 60
5+
# 2 hour
6+
timeout_mins: 120
77

88
action {
99
define_artifacts {

.github/kokoro/presubmit/strong_sanitized.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
build_file: "vtr-verilog-to-routing/.github/kokoro/run-vtr.sh"
44

5-
# 1 hour
6-
timeout_mins: 60
5+
# 2 hour
6+
timeout_mins: 120
77

88
action {
99
define_artifacts {

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ jobs:
142142
script:
143143
- ./.github/travis/build.sh
144144
#We skip QoR since we are only checking for errors in sanitizer runs
145-
- travis_wait 30 ./run_reg_test.pl vtr_reg_basic -show_failures -skip_qor -j2
145+
- travis_wait 50 ./run_reg_test.pl vtr_reg_basic -show_failures -skip_qor -j2
146146
#Currently strong regression with sanitizers is disabled as it exceeds the maximum travis job run-time
147147
#- stage: Test
148148
#name: "Sanitized Strong Regression Tests"

BUILDING.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,24 @@ apt-get install \
9494
ctags
9595
```
9696

97+
#### Using Nix ####
98+
99+
Although the recommended platform is Debian or Ubuntu, Nix can be used to build VTR on other platforms, such as MacOS.
100+
101+
If you don't have [Nix](https://nixos.org/nix/), you can [get it](https://nixos.org/nix/download.html) with:
102+
103+
```shell
104+
$ curl -L https://nixos.org/nix/install | sh
105+
```
106+
107+
These commands will set up dependencies for Linux and MacOS and build VTR:
108+
109+
```shell
110+
#In the VTR root
111+
$ nix-shell dev/nix/shell.nix
112+
$ make
113+
```
114+
97115
### Building using the Makefile wrapper ###
98116
Run `make` from the root of the VTR source tree
99117

ODIN_II/SRC/include/Hashtable.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#include <stdlib.h>
2727
#include <stdint.h>
28+
#include <string>
2829
#include <unordered_map>
2930
#include <string>
3031

ODIN_II/SRC/include/odin_error.h

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,32 +28,25 @@ extern const char* odin_error_STR[];
2828
extern std::vector<std::pair<std::string, int>> include_file_names;
2929
extern int delayed_errors;
3030
// causes an interrupt in GDB
31-
static inline void _verbose_assert(bool condition, const char* condition_str, const char* odin_file_name, long odin_line_number, const char* odin_function_name) {
32-
fflush(stdout);
33-
if (!condition) {
34-
fprintf(stderr, "Assertion failed(%s)@[%s]%s::%ld \n", condition_str, odin_file_name, odin_function_name, odin_line_number);
35-
fflush(stderr);
36-
std::abort();
37-
}
38-
}
31+
void _verbose_assert(bool condition, const char* condition_str, const char* odin_file_name, long odin_line_number, const char* odin_function_name);
3932

4033
#define oassert(condition) _verbose_assert(condition, #condition, __FILE__, __LINE__, __func__)
4134

4235
void _log_message(odin_error error_type, long column, long line_number, long file, bool soft_error, const char* function_file_name, long function_line, const char* function_name, const char* message, ...);
4336

4437
#define error_message(error_type, line_number, file, message, ...) \
45-
_log_message(error_type, -1, line_number, file, true, __FILE__, __LINE__, __func__, message, __VA_ARGS__)
38+
_log_message(error_type, -1, line_number, file, true, __FILE__, __LINE__, __PRETTY_FUNCTION__, message, __VA_ARGS__)
4639

4740
#define warning_message(error_type, line_number, file, message, ...) \
48-
_log_message(error_type, -1, line_number, file, false, __FILE__, __LINE__, __func__, message, __VA_ARGS__)
41+
_log_message(error_type, -1, line_number, file, false, __FILE__, __LINE__, __PRETTY_FUNCTION__, message, __VA_ARGS__)
4942

5043
#define possible_error_message(error_type, line_number, file, message, ...) \
51-
_log_message(error_type, -1, line_number, file, !global_args.permissive.value(), __FILE__, __LINE__, __func__, message, __VA_ARGS__)
44+
_log_message(error_type, -1, line_number, file, !global_args.permissive.value(), __FILE__, __LINE__, __PRETTY_FUNCTION__, message, __VA_ARGS__)
5245

53-
#define delayed_error_message(error_type, column, line_number, file, message, ...) \
54-
{ \
55-
_log_message(error_type, column, line_number, file, false, __FILE__, __LINE__, __func__, message, __VA_ARGS__); \
56-
delayed_errors += 1; \
46+
#define delayed_error_message(error_type, column, line_number, file, message, ...) \
47+
{ \
48+
_log_message(error_type, column, line_number, file, false, __FILE__, __LINE__, __PRETTY_FUNCTION__, message, __VA_ARGS__); \
49+
delayed_errors += 1; \
5750
}
5851

5952
void verify_delayed_error(odin_error error_type);

ODIN_II/SRC/odin_error.cpp

Lines changed: 67 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void verify_delayed_error(odin_error error_type) {
2828
}
2929
}
3030

31-
static std::string make_marker_from_str(std::string str, int column) {
31+
static std::string make_marker_from_str(std::string str, unsigned long column) {
3232
str.erase(column);
3333
for (size_t i = 0; i < str.size(); i++) {
3434
if (str[i] != ' ' && str[i] != '\t') {
@@ -40,36 +40,54 @@ static std::string make_marker_from_str(std::string str, int column) {
4040
return str;
4141
}
4242

43-
static void print_culprit_line(long column, long line_number, long file) {
43+
static std::string get_culprit_line(long line_number, const char* file) {
4444
std::string culprit_line = "";
45-
46-
if (file >= 0 && (size_t)file < include_file_names.size()
47-
&& line_number >= 0) {
48-
FILE* input_file = fopen(include_file_names[file].first.c_str(), "r");
49-
if (input_file) {
50-
bool copy_characters = false;
51-
int current_line_number = 0;
52-
53-
for (;;) {
54-
int c = fgetc(input_file);
55-
if (EOF == c) {
56-
break;
57-
} else if ('\n' == c) {
58-
++current_line_number;
59-
if (line_number == current_line_number) {
60-
copy_characters = true;
61-
} else if (copy_characters) {
62-
break;
63-
}
45+
FILE* input_file = fopen(file, "r");
46+
if (input_file) {
47+
bool copy_characters = false;
48+
int current_line_number = 0;
49+
50+
for (;;) {
51+
int c = fgetc(input_file);
52+
if (EOF == c) {
53+
break;
54+
} else if ('\n' == c) {
55+
++current_line_number;
56+
if (line_number == current_line_number) {
57+
copy_characters = true;
6458
} else if (copy_characters) {
65-
culprit_line.push_back(c);
59+
break;
6660
}
61+
} else if (copy_characters) {
62+
culprit_line.push_back(c);
6763
}
68-
fclose(input_file);
6964
}
70-
fprintf(stderr, "%s\n", culprit_line.c_str());
65+
fclose(input_file);
66+
}
67+
return culprit_line;
68+
}
69+
70+
static void print_culprit_line(long column, long line_number, const char* file) {
71+
std::string culprit_line = get_culprit_line(line_number, file);
72+
if (!culprit_line.empty()) {
73+
int num_printed;
74+
fprintf(stderr, "%ld: %n%s\n", line_number + 1, &num_printed, culprit_line.c_str());
7175
if (column >= 0) {
72-
fprintf(stderr, "%s\n", make_marker_from_str(culprit_line, column).c_str());
76+
fprintf(stderr, "%s\n", make_marker_from_str(culprit_line, num_printed + column).c_str());
77+
}
78+
}
79+
}
80+
81+
static void print_culprit_line_with_context(long target_line, const char* file, long num_context_lines) {
82+
for (long curr_line = std::max(target_line - num_context_lines, 0l); curr_line <= target_line + num_context_lines; curr_line++) {
83+
std::string culprit_line = get_culprit_line(curr_line, file);
84+
if (!culprit_line.empty()) {
85+
int num_printed;
86+
fprintf(stderr, "%ld: %n%s\n", curr_line + 1, &num_printed, culprit_line.c_str());
87+
if (curr_line == target_line) {
88+
const unsigned long first_char_pos = culprit_line.find_first_not_of(" \t");
89+
fprintf(stderr, "%s\n", make_marker_from_str(culprit_line, num_printed + first_char_pos).c_str());
90+
}
7391
}
7492
}
7593
}
@@ -94,7 +112,7 @@ void _log_message(odin_error error_type, long column, long line_number, long fil
94112
file_name = file_name.substr(slash_location + 1);
95113
}
96114

97-
fprintf(stderr, " %s::%ld", file_name.c_str(), line_number + 1);
115+
fprintf(stderr, " %s:%ld", file_name.c_str(), line_number + 1);
98116
}
99117

100118
if (message != NULL) {
@@ -107,8 +125,29 @@ void _log_message(odin_error error_type, long column, long line_number, long fil
107125
fprintf(stderr, "\n");
108126
}
109127

110-
print_culprit_line(column, line_number, file);
128+
if (file >= 0 && (size_t)file < include_file_names.size()
129+
&& line_number >= 0) {
130+
print_culprit_line(column, line_number, include_file_names[file].first.c_str());
131+
}
111132

112133
fflush(stderr);
113-
_verbose_assert(!fatal_error, "", function_file_name, function_line, function_name);
134+
_verbose_assert(!fatal_error, NULL, function_file_name, function_line, function_name);
135+
}
136+
137+
void _verbose_assert(bool condition, const char* condition_str, const char* odin_file_name, long odin_line_number, const char* odin_function_name) {
138+
fflush(stdout);
139+
if (!condition) {
140+
fprintf(stderr, "%s:%ld: %s: ", odin_file_name, odin_line_number, odin_function_name);
141+
if (condition_str) {
142+
// We are an assertion, print the condition that failed and which line it occurred on
143+
fprintf(stderr, "Assertion %s failed\n", condition_str);
144+
// odin_line_number-1 since __LINE__ starts from 1
145+
print_culprit_line_with_context(odin_line_number - 1, odin_file_name, 2);
146+
} else {
147+
// We are a parsing error, dont print the culprit line
148+
fprintf(stderr, "Fatal error\n");
149+
}
150+
fflush(stderr);
151+
std::abort();
152+
}
114153
}

ODIN_II/SRC/odin_ii.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ netlist_t* start_odin_ii(int argc, char** argv) {
250250

251251
/* read the FPGA architecture file */
252252
if (global_args.arch_file.provenance() == argparse::Provenance::SPECIFIED) {
253-
printf("Architecture: %s\n", basename(global_args.arch_file.value().c_str()));
253+
printf("Architecture: %s\n", vtr::basename(global_args.arch_file.value()).c_str());
254254
fflush(stdout);
255255

256256
printf("Reading FPGA Architecture file\n");
@@ -267,7 +267,7 @@ netlist_t* start_odin_ii(int argc, char** argv) {
267267
/* do High level Synthesis */
268268
if (!configuration.list_of_file_names.empty() && configuration.is_verilog_input) {
269269
for (std::string v_file : global_args.verilog_files.value()) {
270-
printf("Verilog: %s\n", basename(v_file.c_str()));
270+
printf("Verilog: %s\n", vtr::basename(v_file).c_str());
271271
}
272272
fflush(stdout);
273273

@@ -294,7 +294,7 @@ netlist_t* start_odin_ii(int argc, char** argv) {
294294
configuration.list_of_file_names = {global_args.output_file};
295295
current_parse_file = 0;
296296
} else {
297-
printf("Blif: %s\n", basename(global_args.blif_file.value().c_str()));
297+
printf("Blif: %s\n", vtr::basename(global_args.blif_file.value()).c_str());
298298
fflush(stdout);
299299
}
300300

ODIN_II/SRC/parse_making_ast.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "hard_blocks.h"
3939
#include "vtr_util.h"
4040
#include "vtr_memory.h"
41+
#include "vtr_path.h"
4142

4243
#include "scope_util.h"
4344

ODIN_II/regression_test/benchmark/task/full/synthesis_result.json

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -483,24 +483,24 @@
483483
"exit": 0,
484484
"errors": [],
485485
"warnings": [
486-
"PARSE_TO_AST LU8PEEng.v::138 NWIDTH is redefined, overwritting its value",
487-
"PARSE_TO_AST LU8PEEng.v::139 BLOCKWIDTH is redefined, overwritting its value",
488-
"PARSE_TO_AST LU8PEEng.v::140 DDRSIZEWIDTH is redefined, overwritting its value",
489-
"PARSE_TO_AST LU8PEEng.v::141 RAMSIZEWIDTH is redefined, overwritting its value",
490-
"PARSE_TO_AST LU8PEEng.v::677 BLOCKWIDTH is redefined, overwritting its value",
491-
"PARSE_TO_AST LU8PEEng.v::678 RAMWIDTH is redefined, overwritting its value",
492-
"PARSE_TO_AST LU8PEEng.v::679 RAMNUMBYTES is redefined, overwritting its value",
493-
"PARSE_TO_AST LU8PEEng.v::680 RAMSIZEWIDTH is redefined, overwritting its value",
494-
"PARSE_TO_AST LU8PEEng.v::686 TOPWIDTH is redefined, overwritting its value",
495-
"PARSE_TO_AST LU8PEEng.v::2448 wFIFOINPUTWIDTH is redefined, overwritting its value",
496-
"PARSE_TO_AST LU8PEEng.v::2456 aFIFOWIDTH is redefined, overwritting its value",
497-
"PARSE_TO_AST LU8PEEng.v::2462 BURSTLEN is redefined, overwritting its value",
498-
"PARSE_TO_AST LU8PEEng.v::2466 MEMCONWIDTH is redefined, overwritting its value",
499-
"PARSE_TO_AST LU8PEEng.v::2467 MEMCONNUMBYTES is redefined, overwritting its value",
500-
"PARSE_TO_AST LU8PEEng.v::2468 DDRSIZEWIDTH is redefined, overwritting its value",
501-
"PARSE_TO_AST LU8PEEng.v::2471 RAMWIDTH is redefined, overwritting its value",
502-
"PARSE_TO_AST LU8PEEng.v::2472 RAMNUMBYTES is redefined, overwritting its value",
503-
"PARSE_TO_AST LU8PEEng.v::2473 RAMSIZEWIDTH is redefined, overwritting its value"
486+
"PARSE_TO_AST LU8PEEng.v:138 NWIDTH is redefined, overwritting its value",
487+
"PARSE_TO_AST LU8PEEng.v:139 BLOCKWIDTH is redefined, overwritting its value",
488+
"PARSE_TO_AST LU8PEEng.v:140 DDRSIZEWIDTH is redefined, overwritting its value",
489+
"PARSE_TO_AST LU8PEEng.v:141 RAMSIZEWIDTH is redefined, overwritting its value",
490+
"PARSE_TO_AST LU8PEEng.v:677 BLOCKWIDTH is redefined, overwritting its value",
491+
"PARSE_TO_AST LU8PEEng.v:678 RAMWIDTH is redefined, overwritting its value",
492+
"PARSE_TO_AST LU8PEEng.v:679 RAMNUMBYTES is redefined, overwritting its value",
493+
"PARSE_TO_AST LU8PEEng.v:680 RAMSIZEWIDTH is redefined, overwritting its value",
494+
"PARSE_TO_AST LU8PEEng.v:686 TOPWIDTH is redefined, overwritting its value",
495+
"PARSE_TO_AST LU8PEEng.v:2448 wFIFOINPUTWIDTH is redefined, overwritting its value",
496+
"PARSE_TO_AST LU8PEEng.v:2456 aFIFOWIDTH is redefined, overwritting its value",
497+
"PARSE_TO_AST LU8PEEng.v:2462 BURSTLEN is redefined, overwritting its value",
498+
"PARSE_TO_AST LU8PEEng.v:2466 MEMCONWIDTH is redefined, overwritting its value",
499+
"PARSE_TO_AST LU8PEEng.v:2467 MEMCONNUMBYTES is redefined, overwritting its value",
500+
"PARSE_TO_AST LU8PEEng.v:2468 DDRSIZEWIDTH is redefined, overwritting its value",
501+
"PARSE_TO_AST LU8PEEng.v:2471 RAMWIDTH is redefined, overwritting its value",
502+
"PARSE_TO_AST LU8PEEng.v:2472 RAMNUMBYTES is redefined, overwritting its value",
503+
"PARSE_TO_AST LU8PEEng.v:2473 RAMSIZEWIDTH is redefined, overwritting its value"
504504
],
505505
"max_rss(MiB)": 214.7,
506506
"exec_time(ms)": 2846.7,
@@ -527,9 +527,9 @@
527527
"exit": 0,
528528
"errors": [],
529529
"warnings": [
530-
"NETLIST matmul.v::21 Could not resolve initial assignment to a constant value, skipping",
531-
"NETLIST matmul.v::42 indexing into memory with matrix_multiplication has larger input than memory. Unused pins:",
532-
"NETLIST matmul.v::46 indexing into memory with matrix_multiplication has larger input than memory. Unused pins:"
530+
"NETLIST matmul.v:21 Could not resolve initial assignment to a constant value, skipping",
531+
"NETLIST matmul.v:42 indexing into memory with matrix_multiplication has larger input than memory. Unused pins:",
532+
"NETLIST matmul.v:46 indexing into memory with matrix_multiplication has larger input than memory. Unused pins:"
533533
],
534534
"max_rss(MiB)": 6.3,
535535
"exec_time(ms)": 5.8,

0 commit comments

Comments
 (0)