Skip to content

Commit d07728c

Browse files
authored
Merge pull request #1 from verilog-to-routing/master
Update from trunk
2 parents 876e0ca + 76b67f9 commit d07728c

File tree

396 files changed

+27293
-5632
lines changed

Some content is hidden

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

396 files changed

+27293
-5632
lines changed

.travis/script.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,9 @@ start_section "vtr.test.4" "${GREEN}Testing..${NC} ${CYAN}odin_reg_micro${NC}"
5050
end_section "vtr.test.4"
5151

5252
$SPACER
53+
54+
start_section "vtr.test.5" "${GREEN}Testing..${NC} ${CYAN}odin_reg_operators${NC}"
55+
./run_reg_test.pl odin_reg_operators
56+
end_section "vtr.test.5"
57+
58+
$SPACER

CMakeLists.txt

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ option(VTR_ENABLE_COVERAGE "Enable code coverage tracking (gcov)" OFF)
2323
option(VTR_ENABLE_DEBUG_LOGGING "Enable debug logging" OFF)
2424

2525
option(WITH_BLIFEXPLORER "Enable build with blifexplorer" OFF)
26+
option(WITH_LIBRTLNUMBER "Enable build with librtlnumber" OFF)
27+
option(WITH_OLD_ABC "Enable build with old abc" OFF)
28+
option(ODIN_DEBUG "Enable building oding with extra debug flags" OFF)
2629

2730
set(VTR_VERSION_MAJOR 8)
2831
set(VTR_VERSION_MINOR 0)
@@ -92,7 +95,9 @@ else()
9295
"-Wredundant-decls" #Warn if there are overlapping declarations
9396
"-Wswitch-default" #Warn if a switch has no default
9497
"-Wundef" #Warn if #if() preprocessor refers to an undefined directive
98+
"-Wunused" #Warn about unused variables/parameters
9599
"-Wunused-variable" #Warn about variables that are not used
100+
"-Wunused-parameter" #Warn about function parameters which are unused
96101
"-Wdisabled-optimization" #Warn when optimizations are skipped (usually due to large/complex code)
97102
"-Wnoexcept" #Warn when functions should be noexcept (i.e. compiler know it doesn't throw)
98103
"-Woverloaded-virtual" #Warn when a function declaration overrides a virtual method
@@ -101,7 +106,14 @@ else()
101106
"-Wduplicated-cond" #Warn about identical conditions in if-else chains
102107
"-Wduplicated-branches" #Warn when different branches of an if-else chain are equivalent
103108
"-Wnull-dereference" #Warn about null pointer dereference execution paths
109+
"-Wuninitialized" #Warn about unitialized values
110+
"-Winit-self" #Warn about self-initialization
111+
"-Wcatch-value=3" #Warn when catch statements don't catch by reference
112+
"-Wextra-semi" #Warn about redudnant semicolons
104113
#GCC-like optional
114+
#"-Wsuggest-final-types" #Suggest where 'final' would help if specified on a type methods
115+
#"-Wsuggest-final-methods" #Suggest where 'final' would help if specified on methods
116+
#"-Wsuggest-override" #Suggest where 'override' should be specified
105117
#"-Wold-style-cast" #Warn about using c-style casts
106118
#"-Wconversion" #Warn when type conversions may change value
107119
#"-Wsign-conversion" #Warn if a conversion may change the sign
@@ -113,6 +125,7 @@ else()
113125
#"-Wsign-promo" #Warn when overload resolution converts an unsigned type to signed when an unsigned overload exists
114126
#"-Wdouble-promotion" #Warn when float is implicitly propted to double
115127
#"-Wuseless-cast" #Warn about casts to the same type
128+
#"-Wzero-as-null-pointer-constant" #Warn about using '0' instead of nullptr
116129
)
117130
endif()
118131

@@ -155,6 +168,7 @@ if(VTR_ENABLE_SANITIZE)
155168
# -fuse-ld=gold force the gold linker to be used (required for sanitizers, but not enabled by default on some systems)
156169
set(SANITIZE_FLAGS "-g -fsanitize=address -fsanitize=leak -fsanitize=undefined -fuse-ld=gold")
157170
message(STATUS "SANTIIZE_FLAGS: ${SANITIZE_FLAGS}")
171+
link_libraries("-static-libasan") #Fixes 'ASan runtime does not come first in initial library list'
158172
endif()
159173

160174
#
@@ -191,10 +205,23 @@ if(VTR_ENABLE_DEBUG_LOGGING)
191205
message(STATUS "Logging Flags: ${LOGGING_FLAGS}")
192206
endif()
193207

208+
if (CMAKE_MAKE_PROGRAM EQUAL "ninja" )
209+
#Only for coloured output for ninja, it may be desired
210+
#to not force colours with other make programs (e.g. if
211+
#being parsed by an IDE).
212+
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
213+
set(COLORED_COMPILE "-fdiagnostics-color=always")
214+
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
215+
set(COLORED_COMPILE "-fcolor-diagnostics")
216+
else()
217+
set(COLORED_COMPILE "")
218+
endif ()
219+
endif()
220+
194221
#
195222
# Set final flags
196223
#
197-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARN_FLAGS} ${SANITIZE_FLAGS} ${PROFILING_FLAGS} ${COVERAGE_FLAGS} ${LOGGING_FLAGS}")
224+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARN_FLAGS} ${SANITIZE_FLAGS} ${PROFILING_FLAGS} ${COVERAGE_FLAGS} ${LOGGING_FLAGS} ${COLORED_COMPILE}")
198225
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
199226

200227

@@ -231,9 +258,13 @@ add_subdirectory(vpr)
231258
add_subdirectory(abc)
232259
add_subdirectory(ODIN_II)
233260
add_subdirectory(ace2)
261+
add_subdirectory(utils)
234262
if(WITH_BLIFEXPLORER)
235263
add_subdirectory(blifexplorer)
236264
endif()
265+
if(WITH_OLD_ABC)
266+
add_subdirectory(abc_with_bb_support)
267+
endif()
237268

238269
#Add extra compilation flags to suppress warnings from some libraries/tools
239270
# Note that target_compile_options() *appends* to the current compilation options of
@@ -245,10 +276,20 @@ if(CXX_COMPILER_SUPPORTS_-w)
245276
target_compile_options(libabc PRIVATE "-w")
246277
target_compile_options(abc PRIVATE "-w")
247278
endif()
279+
if(CXX_COMPILER_SUPPORTS_-w)
280+
if(WITH_OLD_ABC)
281+
target_compile_options(liboldabc PRIVATE "-w")
282+
target_compile_options(oldabc PRIVATE "-w")
283+
endif()
284+
endif()
248285

249286
#Some ABC headers generate warnings, treat them as system headers to suppress warnings
250287
get_property(ABC_INCLUDE_DIRS TARGET libabc PROPERTY INCLUDE_DIRECTORIES)
251288
target_include_directories(libabc SYSTEM INTERFACE ${ABC_INCLUDE_DIRS})
289+
if(WITH_OLD_ABC)
290+
get_property(OLD_ABC_INCLUDE_DIRS TARGET liboldabc PROPERTY INCLUDE_DIRECTORIES)
291+
target_include_directories(liboldabc SYSTEM INTERFACE ${OLD_ABC_INCLUDE_DIRS})
292+
endif()
252293

253294
#PugiXml has some deliberate switch fallthrough cases (as indicated by comments), but they
254295
#are tagged as warnings with g++-7 (the comments don't match g++-7's suppression regexes).
@@ -306,11 +347,25 @@ set_target_properties(libtatum
306347
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/libs/EXTERNAL/libtatum"
307348
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/libs/EXTERNAL/libtatum"
308349
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/libs/EXTERNAL/libtatum")
350+
if(WITH_LIBRTLNUMBER)
351+
set_target_properties(librtlnumber rtl_number
352+
PROPERTIES
353+
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/libs/librtlnumber"
354+
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/libs/librtlnumber"
355+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/libs/librtlnumber")
356+
endif()
309357
set_target_properties(libabc abc
310358
PROPERTIES
311359
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/abc"
312360
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/abc"
313361
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/abc")
362+
if(WITH_OLD_ABC)
363+
set_target_properties(liboldabc oldabc
364+
PROPERTIES
365+
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/abc_with_bb_support"
366+
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/abc_with_bb_support"
367+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/abc_with_bb_support")
368+
endif()
314369
set_target_properties(libvpr vpr
315370
PROPERTIES
316371
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/vpr"

Makefile

Lines changed: 71 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#This is a simple wrapper hiding cmake from non-expert end users.
1+
#This is a simple wrapper which hides cmake (for convenience, and from non-expert end users).
22
#
33
# It supports the targets:
44
# 'make' - builds everything (all libaries/executables)
@@ -13,21 +13,28 @@
1313

1414
#Default build type
1515
# Possible values:
16-
# release
17-
# debug
16+
# release_pgo #Perform a 2-stage build with profile-guided compiler optimization
17+
# release #Build with compiler optimization
18+
# debug #Build with debug info and no compiler optimization
1819
BUILD_TYPE ?= release
1920

21+
#Convert to lower case for consistency
22+
BUILD_TYPE := $(shell echo $(BUILD_TYPE) | tr '[:upper:]' '[:lower:]')
23+
24+
#Trim any _pgo in the build type name (since it would not match any of
25+
#CMake's standard build types)
26+
CMAKE_BUILD_TYPE := $(shell echo $(BUILD_TYPE) | sed 's/_\?pgo//')
27+
2028
#Allows users to pass parameters to cmake
2129
# e.g. make CMAKE_PARAMS="-DVTR_ENABLE_SANITIZE=true"
22-
override CMAKE_PARAMS := -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) -G 'Unix Makefiles' ${CMAKE_PARAMS}
30+
override CMAKE_PARAMS := -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE) -G 'Unix Makefiles' ${CMAKE_PARAMS}
2331

2432

2533
# -s : Suppresss makefile output (e.g. entering/leaving directories)
2634
# --output-sync target : For parallel compilation ensure output for each target is synchronized (make version >= 4.0)
2735
MAKEFLAGS := -s
2836

29-
BUILD_DIR=./build
30-
GENERATED_MAKEFILE := $(BUILD_DIR)/Makefile
37+
BUILD_DIR ?= build
3138

3239
#Check for the cmake exectuable
3340
CMAKE := $(shell command -v cmake 2> /dev/null)
@@ -38,31 +45,75 @@ export CTEST_OUTPUT_ON_FAILURE=TRUE
3845
#All targets in this make file are always out of date.
3946
# This ensures that any make target requests are forwarded to
4047
# the generated makefile
41-
.PHONY: all distclean $(GENERATED_MAKEFILE) $(MAKECMDGOALS)
48+
.PHONY: all distclean $(MAKECMDGOALS)
4249

43-
#Build everything
44-
all: $(GENERATED_MAKEFILE)
45-
@+$(MAKE) -C $(BUILD_DIR)
50+
#For an 'all' build with BUILD_TYPE containing 'pgo' this will perform a 2-stage compilation
51+
#with profile guided optimization.
52+
#For a BUILD_TYPE without 'pgo', a single stage (non-pgo) compilation is performed.
53+
54+
#Forward any targets that are not named 'distclean' or 'clean' to the generated Makefile
55+
ifneq ($(MAKECMDGOALS),distclean)
56+
ifneq ($(MAKECMDGOALS),clean)
57+
all $(MAKECMDGOALS):
58+
ifeq ($(CMAKE),)
59+
$(error Required 'cmake' executable not found. On debian/ubuntu try 'sudo apt-get install cmake' to install)
60+
endif
61+
@ mkdir -p $(BUILD_DIR)
62+
ifneq (,$(findstring pgo,$(BUILD_TYPE)))
63+
#
64+
#Profile Guided Optimization Build
65+
#
66+
@echo "Performing Profile Guided Optimization (PGO) build..."
67+
#
68+
#1st-stage build for profile generation
69+
#
70+
echo "cd $(BUILD_DIR) && $(CMAKE) $(CMAKE_PARAMS) -DVPR_PGO_CONFIG=prof_gen .. "
71+
cd $(BUILD_DIR) && $(CMAKE) $(CMAKE_PARAMS) -DVPR_PGO_CONFIG=prof_gen ..
72+
@+$(MAKE) -C $(BUILD_DIR) $(MAKECMDGOALS)
73+
#
74+
#Run benchmarks to generate profiling data
75+
#
76+
echo "Generating profile data for PGO (may take several minutes)"
77+
#Need titan benchmarks for pgo_profile task
78+
@+$(MAKE) -C $(BUILD_DIR) get_titan_benchmarks
79+
#Note profiling must be done serially to avoid corrupting the generated profiles
80+
./run_reg_test.pl pgo_profile
81+
#
82+
#Configure 2nd-stage build to use profiling data to guide compiler optimization
83+
#
84+
echo "cd $(BUILD_DIR) && $(CMAKE) $(CMAKE_PARAMS) -DVPR_PGO_CONFIG=prof_use .. "
85+
cd $(BUILD_DIR) && $(CMAKE) $(CMAKE_PARAMS) -DVPR_PGO_CONFIG=prof_use ..
86+
else #BUILD_TYPE not containing 'pgo'
87+
#
88+
#Configure for standard build
89+
#
90+
@echo "Performing standard build..."
91+
echo "cd $(BUILD_DIR) && $(CMAKE) $(CMAKE_PARAMS) .. "
92+
cd $(BUILD_DIR) && $(CMAKE) $(CMAKE_PARAMS) ..
93+
endif #BUILD_TYPE
94+
#
95+
#Final build
96+
#
97+
@echo "Building target(s): $(MAKECMDGOALS)"
98+
@+$(MAKE) -C $(BUILD_DIR) $(MAKECMDGOALS)
99+
endif #clean
100+
endif #distclean
46101

47102
#Call the generated Makefile's clean, and then remove all cmake generated files
48-
distclean: $(GENERATED_MAKEFILE)
49-
@ echo "Cleaning build..."
50-
@+$(MAKE) -C $(BUILD_DIR) clean
103+
distclean: clean
51104
@ echo "Removing build system files.."
52105
@ rm -rf $(BUILD_DIR)
53106
@ rm -rf CMakeFiles CMakeCache.txt #In case 'cmake .' was run in the source directory
54107

55-
#Call cmake to generate the main Makefile
56-
$(GENERATED_MAKEFILE):
108+
clean:
57109
ifeq ($(CMAKE),)
58110
$(error Required 'cmake' executable not found. On debian/ubuntu try 'sudo apt-get install cmake' to install)
59111
endif
112+
@ echo "Cleaning files.."
113+
#We run cmake so we can use the generated Makefile to clean any executables
114+
#generated outside the build directory
60115
@ mkdir -p $(BUILD_DIR)
61116
echo "cd $(BUILD_DIR) && $(CMAKE) $(CMAKE_PARAMS) .. "
62117
cd $(BUILD_DIR) && $(CMAKE) $(CMAKE_PARAMS) ..
118+
@+$(MAKE) -C $(BUILD_DIR) clean
63119

64-
#Forward any targets that are not named 'distclean' to the generated Makefile
65-
ifneq ($(MAKECMDGOALS),distclean)
66-
$(MAKECMDGOALS): $(GENERATED_MAKEFILE)
67-
@+$(MAKE) -C $(BUILD_DIR) $(MAKECMDGOALS)
68-
endif

ODIN_II/CMakeLists.txt

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,51 @@ cmake_minimum_required(VERSION 2.8.12)
22

33
project("ODIN_II")
44

5+
#base extra flags for odin
6+
set(ODIN_EXTRA_FLAGS
7+
"" # nothing for now
8+
)
9+
10+
if(ODIN_DEBUG)
11+
12+
message("*** Compiling with Odin debug flags")
13+
14+
set(ODIN_REF_FLAGS
15+
"-Wchkp" # Warn about memory access errors found by Pointer Bounds Checker
16+
"-Wreturn-local-addr" # Warn about returning a pointer/reference to a local or temporary variable.
17+
"-Wnonnull" # Warn about NULL being passed to argument slots marked as requiring non-NULL
18+
)
19+
20+
set(ODIN_SIGN_FLAGS
21+
"-Wsign-compare" # Warn about signed-unsigned comparisons
22+
"-Wsign-conversion" # Warn about signedness conversion
23+
"-Wsign-promo" # Warn when overload promotes from unsigned to signed
24+
"-Wconversion" # Warn for implicit type conversions that may change a value
25+
)
26+
27+
set(ODIN_LIMITS_FLAGS
28+
"-Wshift-count-overflow" # Warn if shift count >= width of type
29+
"-Wshift-count-negative" # Warn if shift count is negative
30+
"-Wstrict-overflow" # Warn about optimizations that assume that signed overflow is undefined
31+
"-Wtype-limits" # Warn if a comparison is always true or always false due to the limited range of the data type
32+
)
33+
34+
set(ODIN_EXTRA_FLAGS
35+
"-g"
36+
"-ggdb"
37+
"-O0"
38+
""
39+
${ODIN_EXTRA_FLAGS}
40+
##############
41+
# comment out the flag set you do not wish to see added below
42+
#
43+
${ODIN_REF_FLAGS}
44+
${ODIN_SIGN_FLAGS}
45+
${ODIN_LIMITS_FLAGS}
46+
)
47+
48+
endif()
49+
550
#Flex and Bison are used to generate the parser
651
find_package(BISON REQUIRED)
752
find_package(FLEX REQUIRED)
@@ -48,17 +93,47 @@ add_library(libodin_ii STATIC
4893
target_include_directories(libodin_ii PUBLIC ${LIB_INCLUDE_DIRS})
4994
set_target_properties(libodin_ii PROPERTIES PREFIX "") #Avoid extra 'lib' prefix
5095

96+
#################################
97+
# INCLUDE EXTRA ODIN FLAGS IS EXECUTED HERE
98+
#
99+
# include the flags one at a time in case some are not supported and report the error
100+
#
101+
102+
foreach(ODIN_FLAG ${ODIN_EXTRA_FLAGS})
51103

104+
CHECK_CXX_COMPILER_FLAG(${ODIN_FLAG} FLAG_TEST)
105+
106+
if(FLAG_TEST)
107+
message("-- Performing Test CXX_SUPPORT_FLAG${ODIN_FLAG} - Success")
108+
target_compile_options(libodin_ii PRIVATE ${ODIN_FLAG})
109+
else()
110+
message("-- Performing Test CXX_SUPPORT_FLAG${ODIN_FLAG} - Failure")
111+
endif()
112+
113+
endforeach()
114+
115+
if(WITH_LIBRTLNUMBER)
116+
target_link_libraries(libodin_ii
117+
libvtrutil
118+
librtlnumber
119+
libarchfpga
120+
libabc
121+
libargparse
122+
${CMAKE_DL_LIBS})
123+
else()
52124
target_link_libraries(libodin_ii
53125
libvtrutil
54126
libarchfpga
55127
libabc
56128
libargparse
57129
${CMAKE_DL_LIBS})
130+
endif()
58131

59132
#Create the executable
60133
add_executable(odin_II ${EXEC_SOURCES})
134+
61135
target_link_libraries(odin_II
62136
libodin_ii)
63137

138+
64139
install(TARGETS odin_II libodin_ii DESTINATION bin)

0 commit comments

Comments
 (0)