Skip to content

Commit 64d6389

Browse files
committed
Merge remote-tracking branch 'upstream/master' into diagonals
2 parents a5e8bde + 21c26bb commit 64d6389

File tree

286 files changed

+21573
-8468
lines changed

Some content is hidden

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

286 files changed

+21573
-8468
lines changed

.github/scripts/hostsetup.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ apt install -y \
3030
build-essential \
3131
capnproto \
3232
clang \
33-
cmake \
3433
ctags \
3534
curl \
3635
doxygen \
@@ -65,12 +64,23 @@ apt install -y \
6564
valgrind \
6665
zip \
6766
qt5-default \
67+
uuid-dev \
68+
default-jdk \
6869
g++-9 \
6970
gcc-9 \
7071
wget
7172
# Don't include libtbb-dev since it may increase memory usage
7273
#libtbb-dev \
7374

75+
# installing the latest version of cmake
76+
apt install -y apt-transport-https ca-certificates gnupg
77+
wget -qO - https://apt.kitware.com/keys/kitware-archive-latest.asc |apt-key add -
78+
79+
apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main'
80+
apt update
81+
apt install -y cmake
82+
83+
7484
export PATH="$PATH:/home/kbuilder/.local/bin"
7585

7686
export CC=gcc-9

.github/scripts/install_dependencies.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ sudo apt install -y \
3939
valgrind \
4040
zip \
4141
qt5-default \
42+
uuid-dev \
43+
default-jdk \
4244
clang-format-7 \
4345
g++-7 \
4446
gcc-7 \

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ jobs:
3232
- {test: "vtr_reg_nightly_test4", cores: "16", options: "", cmake: "" }
3333
- {test: "vtr_reg_strong", cores: "16", options: "", cmake: "-DVTR_ASSERT_LEVEL=3" }
3434
- {test: "vtr_reg_strong", cores: "16", options: "-skip_qor", cmake: "-DVTR_ASSERT_LEVEL=3 -DVTR_ENABLE_SANITIZE=ON"}
35-
- {test: "vtr_reg_yosys", cores: "16", options: "", cmake: "-DWITH_YOSYS=ON" }
36-
- {test: "vtr_reg_yosys_odin", cores: "16", options: "", cmake: "-DODIN_USE_YOSYS=ON" }
35+
- {test: "vtr_reg_yosys", cores: "16", options: "", cmake: "-DWITH_YOSYS=ON -DYOSYS_SV_UHDM_PLUGIN=ON" }
36+
- {test: "vtr_reg_yosys_odin", cores: "16", options: "", cmake: "-DODIN_USE_YOSYS=ON -DYOSYS_SV_UHDM_PLUGIN=ON"}
3737
- {test: "odin_tech_strong", cores: "16", options: "", cmake: "-DODIN_USE_YOSYS=ON" }
3838
- {test: "odin_reg_strong", cores: "16", options: "", cmake: "" }
3939

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ bin/
1212
CMakeCache.txt
1313
CMakeFiles
1414
build
15+
Yosys
1516

1617
#
1718
#VTR Flow/Tasks
@@ -105,6 +106,11 @@ ODIN_II/usefull_tools/**/track_completed
105106
#
106107
Yosys
107108

109+
#
110+
#ArchFPGA exec dir
111+
#
112+
ArchFPGA
113+
108114
#
109115
#Python
110116
#

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ option(ODIN_SANITIZE "Enable building odin with sanitize flags" OFF)
5555
# Allow the user to enable building Yosys
5656
option(WITH_YOSYS "Enable building Yosys" OFF)
5757
option(ODIN_USE_YOSYS "Enable building Yosys" OFF)
58+
option(YOSYS_SV_UHDM_PLUGIN "Enable building and installing Yosys SystemVerilog and UHDM plugins" OFF)
5859

5960
set(VTR_VERSION_MAJOR 8)
6061
set(VTR_VERSION_MINOR 1)
@@ -398,6 +399,14 @@ elseif(${WITH_ODIN})
398399
endif()
399400
endif()
400401

402+
# handle cmake params to compile Yosys SystemVerilog/UHDM plugins
403+
if(${YOSYS_SV_UHDM_PLUGIN})
404+
# avoid compiling plugins in case the Yosys frontend is not active
405+
if(NOT ${WITH_YOSYS} AND NOT ${ODIN_USE_YOSYS})
406+
message(SEND_ERROR "Utilizing SystemVerilog/UHDM plugins requires activating Yosys frontend. Please set either WITH_YOSYS or ODIN_USE_YOSYS on.")
407+
endif()
408+
endif()
409+
401410
#Add extra compilation flags to suppress warnings from some libraries/tools
402411
# Note that target_compile_options() *appends* to the current compilation options of
403412
# the specified target

ODIN_II/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ if(ODIN_DEBUG)
77
message("*** Compiling with Odin debug flags")
88

99
set(ODIN_EXTRA_FLAGS
10-
"-g"
11-
"-ggdb"
10+
"-g3"
11+
"-ggdb3"
1212
"-O0"
1313
${ODIN_EXTRA_FLAGS}
1414
)
@@ -136,6 +136,9 @@ endif()
136136
if(${ODIN_USE_YOSYS})
137137
add_definitions("-DODIN_USE_YOSYS=ON")
138138
add_definitions("-D_YOSYS_")
139+
if(${YOSYS_SV_UHDM_PLUGIN})
140+
add_definitions("-DYOSYS_SV_UHDM_PLUGIN=ON")
141+
endif()
139142
endif()
140143

141144
add_definitions(-DUSING_BISON -DYYERROR_VERBOSE)

ODIN_II/SRC/BLIFReader.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -348,18 +348,18 @@ void BLIF::Reader::create_hard_block_nodes(hard_block_models* models) {
348348
/* check for coarse-grain configuration */
349349
if (configuration.coarsen) {
350350
if (yosys_subckt_strmap.find(subcircuit_name) != yosys_subckt_strmap.end())
351-
new_node->type = yosys_subckt_strmap[subcircuit_name];
351+
new_node->type = yosys_subckt_strmap.at(subcircuit_name);
352352

353353
if (new_node->type == NO_OP && yosys_subckt_strmap.find(subcircuit_stripped_name) != yosys_subckt_strmap.end())
354-
new_node->type = yosys_subckt_strmap[subcircuit_stripped_name];
354+
new_node->type = yosys_subckt_strmap.at(subcircuit_stripped_name);
355355

356356
if (new_node->type == NO_OP) {
357357
/* in case of weird names, need to add memories manually */
358358
int sc_spot = -1;
359359
char* yosys_subckt_str = NULL;
360360
if ((yosys_subckt_str = retrieve_node_type_from_subckt_name(subcircuit_stripped_name)) != NULL) {
361361
/* specify node type */
362-
new_node->type = yosys_subckt_strmap[yosys_subckt_str];
362+
new_node->type = yosys_subckt_strmap.at(yosys_subckt_str);
363363
} else if ((sc_spot = sc_lookup_string(hard_block_names, subcircuit_stripped_name)) != -1) {
364364
/* specify node type */
365365
new_node->type = HARD_IP;
@@ -387,11 +387,14 @@ void BLIF::Reader::create_hard_block_nodes(hard_block_models* models) {
387387
: operation_list_END;
388388
}
389389
} else {
390-
new_node->type = odin_subckt_strmap[subcircuit_name];
390+
if (odin_subckt_strmap.find(subcircuit_name) != odin_subckt_strmap.end())
391+
new_node->type = odin_subckt_strmap.at(subcircuit_name);
391392

392393
/* check for subcircuit prefix prefix */
393-
if (subcircuit_stripped_name && new_node->type == NO_OP)
394-
new_node->type = odin_subckt_strmap[subcircuit_stripped_name];
394+
if (subcircuit_stripped_name
395+
&& new_node->type == NO_OP
396+
&& odin_subckt_strmap.find(subcircuit_stripped_name) != odin_subckt_strmap.end())
397+
new_node->type = odin_subckt_strmap.at(subcircuit_stripped_name);
395398

396399
if (new_node->type == NO_OP)
397400
new_node->type = MEMORY;
@@ -2176,7 +2179,7 @@ void BLIF::Reader::hard_block_sensitivities(const char* subckt_name, nnode_t* ne
21762179
char* buffer = NULL;
21772180
attr_t* attributes = new_node->attributes;
21782181
operation_list op = (yosys_subckt_strmap.find(subckt_name) != yosys_subckt_strmap.end())
2179-
? yosys_subckt_strmap[subckt_name]
2182+
? yosys_subckt_strmap.at(subckt_name)
21802183
: NO_OP;
21812184

21822185
if (need_params(op)) {

ODIN_II/SRC/GenericReader.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ inline void* GenericReader::_read() {
4545
void* netlist = NULL;
4646

4747
switch (configuration.input_file_type) {
48-
case (file_type_e::_VERILOG): {
48+
case (file_type_e::_VERILOG): // fallthrough
49+
case (file_type_e::_VERILOG_HEADER): {
4950
netlist = this->read_verilog();
5051
break;
5152
}

ODIN_II/SRC/YYosys.cpp

Lines changed: 58 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,6 @@
5151
#ifdef ODIN_USE_YOSYS
5252
# include "kernel/yosys.h" // Yosys
5353
USING_YOSYS_NAMESPACE
54-
# define YOSYS_ELABORATION_ERROR \
55-
"\n\tERROR: Yosys failed to perform elaboration, " \
56-
"Please look at the log file for the failure cause or pass \'--show_yosys_log\' to Odin-II to see the logs.\n"
57-
# define YOSYS_FORK_ERROR \
58-
"\n\tERROR: Yosys child process failed to be created\n"
59-
#else
60-
# define YOSYS_INSTALLATION_ERROR \
61-
"ERROR: It seems Yosys is not installed in the VTR repository." \
62-
" Please compile the VTR with (" ODIN_USE_YOSYS_STR ") flag.\n"
6354
#endif
6455

6556
/**
@@ -137,11 +128,31 @@ void YYosys::perform_elaboration() {
137128
/* wait for the Yosys child process */
138129
auto yosys_status = -1; // the status of the Yosys fork
139130
waitpid(0, &yosys_status, 0);
140-
int yosys_exit_status = WEXITSTATUS(yosys_status);
141-
142-
if (yosys_exit_status != 0) {
143-
error_message(PARSER, unknown_location, "%s", YOSYS_ELABORATION_ERROR);
131+
/* check if Yosys exited abnormally */
132+
if (!WIFEXITED(yosys_status)) {
133+
if (WIFSIGNALED(yosys_status)) {
134+
error_message(PARSER, unknown_location,
135+
"Yosys exited with signal %d - %s",
136+
WTERMSIG(yosys_status),
137+
YOSYS_ELABORATION_ERROR);
138+
} else if (WIFSTOPPED(yosys_status)) {
139+
error_message(PARSER, unknown_location,
140+
"Yosys stopped with signal %d - %s",
141+
WSTOPSIG(yosys_status),
142+
YOSYS_ELABORATION_ERROR);
143+
} else {
144+
error_message(PARSER, unknown_location, "%s",
145+
"Something strange just happened with Yosys child process.\n");
146+
}
147+
} else {
148+
auto yosys_exit_status = WEXITSTATUS(yosys_status);
149+
if (yosys_exit_status != 0)
150+
error_message(PARSER, unknown_location,
151+
"Yosys exited with status %d - %s",
152+
yosys_exit_status,
153+
YOSYS_ELABORATION_ERROR);
144154
}
155+
145156
/* Yosys successfully generated coarse-grain BLIF file */
146157
this->re_initialize_odin_globals();
147158
}
@@ -197,6 +208,11 @@ void YYosys::init_yosys() {
197208
yosys_setup();
198209
yosys_banner();
199210

211+
# ifdef YOSYS_SV_UHDM_PLUGIN
212+
/* Load SystemVerilog/UHDM plugins in the Yosys frontend */
213+
run_pass(std::string("plugin -i systemverilog"));
214+
# endif
215+
200216
/* Read VTR baseline library first */
201217
run_pass(std::string("read_verilog -nomem2reg " + this->vtr_primitives_file));
202218
run_pass(std::string("setattr -mod -set keep_hierarchy 1 " + std::string(SINGLE_PORT_RAM_string)));
@@ -249,9 +265,34 @@ void YYosys::execute() {
249265
} else {
250266
// Read the hardware decription Verilog circuits
251267
// FOR loop enables include feature for Yosys+Odin (multiple Verilog input files)
252-
for (auto verilog_circuit : this->verilog_circuits)
253-
run_pass(std::string("read_verilog -sv -nolatches " + verilog_circuit));
254-
268+
std::string aggregated_circuits;
269+
for (auto circuit : this->verilog_circuits)
270+
aggregated_circuits += circuit + " ";
271+
// Read Verilog/SystemVerilog/UHDM files based on their type, considering the SystemVerilog/UHDM plugins
272+
# ifdef YOSYS_SV_UHDM_PLUGIN
273+
/* Load SystemVerilog/UHDM plugins in the Yosys frontend */
274+
switch (configuration.input_file_type) {
275+
case (file_type_e::_VERILOG): // fallthrough
276+
case (file_type_e::_VERILOG_HEADER): {
277+
run_pass(std::string("read_verilog -sv -nolatches " + aggregated_circuits));
278+
break;
279+
}
280+
case (file_type_e::_SYSTEM_VERILOG): {
281+
run_pass(std::string("read_systemverilog -debug " + aggregated_circuits));
282+
break;
283+
}
284+
case (file_type_e::_UHDM): {
285+
run_pass(std::string("read_uhdm -debug " + aggregated_circuits));
286+
break;
287+
}
288+
default: {
289+
error_message(UTIL, unknown_location,
290+
"Invalid file type (%s) for Yosys+Odin-II synthesizer.", file_extension_strmap[configuration.input_file_type]);
291+
}
292+
}
293+
# else
294+
run_pass(std::string("read_verilog -sv -nolatches " + aggregated_circuits));
295+
# endif
255296
// Check whether cells match libraries and find top module
256297
if (global_args.top_level_module_name.provenance() == argparse::Provenance::SPECIFIED) {
257298
run_pass(std::string("hierarchy -check -top " + global_args.top_level_module_name.value() + " -purge_lib"));
@@ -298,7 +339,7 @@ void YYosys::execute() {
298339
run_pass(std::string("pmuxtree"));
299340
// To possibly reduce word sizes by Yosys
300341
run_pass(std::string("wreduce"));
301-
// "-undirven" to ensure there is no wire without drive
342+
// "-undriven" to ensure there is no wire without drive
302343
// -noff #potential option to remove all sdffXX and etc. Only dff will remain
303344
// "opt_muxtree" removes dead branches, "opt_expr" performs const folding and
304345
// removes "undef" from mux inputs and replace muxes with buffers and inverters

ODIN_II/SRC/adders.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,7 +1064,7 @@ void remove_list_node(t_linked_vptr* pre, t_linked_vptr* next) {
10641064
pre->next = next->next;
10651065
else
10661066
pre->next = NULL;
1067-
vtr::free(next);
1067+
delete next;
10681068
}
10691069

10701070
/*---------------------------------------------------------------------------
@@ -1434,4 +1434,4 @@ nnode_t* check_missing_ports(nnode_t* node, uintptr_t traverse_mark_number, netl
14341434
}
14351435

14361436
return new_node;
1437-
}
1437+
}

ODIN_II/SRC/enum_str.cpp

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ const char* ieee_std_STR[] = {
77
"1364-2005",
88
};
99

10-
const char* file_extension_supported_STR[] = {
11-
".v",
12-
".vh",
13-
};
14-
1510
const char* edge_type_e_STR[] = {
1611
"UNDEFINED_SENSITIVITY",
1712
"FALLING_EDGE_SENSITIVITY",
@@ -213,16 +208,28 @@ const char* ids_STR[] = {
213208
"ids_END"};
214209

215210
/* supported input/output file extensions */
216-
strmap<file_type_e> file_type_strmap({{"ilang", file_type_e::_ILANG},
217-
{"verilog", file_type_e::_VERILOG},
218-
{"verilog_header", file_type_e::_VERILOG_HEADER},
219-
{"blif", file_type_e::_BLIF},
220-
{"eblif", file_type_e::_EBLIF},
221-
{"undef", file_type_e::_UNDEFINED}});
211+
extern const strbimap<file_type_e> file_extension_strmap({{".ilang", file_type_e::_ILANG},
212+
{".v", file_type_e::_VERILOG},
213+
{".vh", file_type_e::_VERILOG_HEADER},
214+
{".sv", file_type_e::_SYSTEM_VERILOG},
215+
{".svh", file_type_e::_SYSTEM_VERILOG_HEADER},
216+
{".uhdm", file_type_e::_UHDM},
217+
{".blif", file_type_e::_BLIF},
218+
{".eblif", file_type_e::_EBLIF}});
219+
220+
/* supported input/output file types */
221+
extern const strbimap<file_type_e> file_type_strmap({{"ilang", file_type_e::_ILANG},
222+
{"verilog", file_type_e::_VERILOG},
223+
{"verilog_header", file_type_e::_VERILOG_HEADER},
224+
{"systemverilog", file_type_e::_SYSTEM_VERILOG},
225+
{"systemverilog_header", file_type_e::_SYSTEM_VERILOG_HEADER},
226+
{"uhdm", file_type_e::_UHDM},
227+
{"blif", file_type_e::_BLIF},
228+
{"eblif", file_type_e::_EBLIF}});
222229

223230
/* available elaborators for Odin-II techmap */
224-
strmap<elaborator_e> elaborator_strmap({{"odin", elaborator_e::_ODIN},
225-
{"yosys", elaborator_e::_YOSYS}});
231+
extern const strmap<elaborator_e> elaborator_strmap({{"odin", elaborator_e::_ODIN},
232+
{"yosys", elaborator_e::_YOSYS}});
226233

227234
/**
228235
* global hashmap of odin subckt types
@@ -232,10 +239,10 @@ strmap<elaborator_e> elaborator_strmap({{"odin", elaborator_e::_ODIN},
232239
* FIRST_ELEMENT: model name showing in a blif file
233240
* SECOND_ELEMENT: corresponding Odin-II cell type
234241
*/
235-
strmap<operation_list> odin_subckt_strmap({{"multiply", MULTIPLY},
236-
{"mult_", MULTIPLY},
237-
{"adder", ADD},
238-
{"sub", MINUS}});
242+
extern const strmap<operation_list> odin_subckt_strmap({{"multiply", MULTIPLY},
243+
{"mult_", MULTIPLY},
244+
{"adder", ADD},
245+
{"sub", MINUS}});
239246

240247
/**
241248
* global hashmap of yosys subckt types
@@ -254,7 +261,7 @@ strmap<operation_list> odin_subckt_strmap({{"multiply", MULTIPLY},
254261
* in the BLIF Elaboration phase to make the new node compatible
255262
* with the Odin-II partial mapper.
256263
*/
257-
strmap<operation_list> yosys_subckt_strmap({
264+
extern const strmap<operation_list> yosys_subckt_strmap({
258265
{"$_ANDNOT_", operation_list_END},
259266
{"$_AND_", operation_list_END}, // (A, B, Y)
260267
{"$_AOI3_", operation_list_END}, // (A, B, C, Y)

ODIN_II/SRC/include/GenericIO.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class GenericIO {
5050
virtual void _write(const netlist_t* netlist);
5151

5252
/* to create the output file */
53-
virtual void _create_file(const char* file_name, const file_type_e file_type = _UNDEFINED);
53+
virtual void _create_file(const char* file_name, const file_type_e file_type = file_type_e_END);
5454
};
5555

5656
#endif // __GENERIC_IO_H__

ODIN_II/SRC/include/GenericWriter.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class GenericWriter : public GenericIO {
6262
*/
6363

6464
/* to create the output file */
65-
void _create_file(const char* file_name, const file_type_e file_type = _UNDEFINED);
65+
void _create_file(const char* file_name, const file_type_e file_type = file_type_e_END);
6666

6767
protected:
6868
FILE* output_file;

0 commit comments

Comments
 (0)