Skip to content

Commit 8d89fa8

Browse files
authored
Merge pull request #1340 from verilog-to-routing/import_vqm2blif
Import vqm2blif into VTR
2 parents bb51a8b + 46263a7 commit 8d89fa8

29 files changed

+11410
-0
lines changed

libs/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ add_subdirectory(libarchfpga)
1010
add_subdirectory(libvtrutil)
1111
add_subdirectory(liblog)
1212
add_subdirectory(libpugiutil)
13+
add_subdirectory(libvqm)
1314
if(${WITH_ODIN})
1415
add_subdirectory(librtlnumber)
1516
endif()

libs/libvqm/CMakeLists.txt

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
cmake_minimum_required(VERSION 2.8.12)
2+
project("libvqm")
3+
4+
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
5+
#Only set compiler settings if we are not a sub-project
6+
set(WARN_FLAGS "-Wall -Wextra -Wpedantic -Wcast-qual -Wcast-align -Wshadow -Wformat=2 -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wredundant-decls -Wswitch-default -Wundef -Wunused-variable -Wdisabled-optimization -Wnoexcept -Woverloaded-virtual -Wctor-dtor-privacy -Wnon-virtual-dtor")
7+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11 ${WARN_FLAGS}")
8+
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=leak -fsanitize=undefined")
9+
set(FLEX_BISON_WARN_SUPPRESS_FLAGS "-Wno-switch-default -Wno-unused-parameter -Wno-missing-declarations")
10+
endif()
11+
12+
#Flex and Bison are used to generate the parser
13+
find_package(BISON REQUIRED 3.0)
14+
find_package(FLEX REQUIRED)
15+
16+
file(GLOB_RECURSE LIB_SOURCES *.c *.cpp)
17+
file(GLOB_RECURSE LIB_HEADERS *.h)
18+
files_to_dirs(LIB_HEADERS LIB_INCLUDE_DIRS)
19+
20+
#Find the flex and bison input files
21+
file(GLOB_RECURSE LEXER_SOURCES *.l)
22+
file(GLOB_RECURSE PARSER_SOURCES *.y)
23+
24+
#Make the flex and bison targets
25+
flex_target(VqmLexer ${LEXER_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/vqm_lexer.gen.c
26+
COMPILE_FLAGS --header-file=${CMAKE_CURRENT_BINARY_DIR}/vqm_lexer.gen.h)
27+
bison_target(VqmParser ${PARSER_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/vqm_parser.gen.c)
28+
add_flex_bison_dependency(VqmLexer VqmParser)
29+
30+
31+
#Treat .c as CXX
32+
set_source_files_properties(${LIB_SOURCES} ${FLEX_VqmLexer_OUTPUTS} ${BISON_VqmParser_OUTPUT_SOURCE} PROPERTIES LANGUAGE CXX)
33+
34+
#Suppress warnings in Flex/Bison generated files
35+
if(FLEX_BISON_WARN_SUPPRESS_FLAGS)
36+
set_source_files_properties(${FLEX_VqmLexer_OUTPUTS} ${BISON_VqmParser_OUTPUT_SOURCE}
37+
PROPERTIES COMPILE_FLAGS ${FLEX_BISON_WARN_SUPPRESS_FLAGS})
38+
endif()
39+
40+
#Create the library
41+
add_library(libvqm STATIC
42+
${LIB_HEADERS}
43+
${LIB_SOURCES}
44+
${FLEX_VqmLexer_OUTPUTS}
45+
${BISON_VqmParser_OUTPUT_SOURCE})
46+
target_include_directories(libvqm PUBLIC ${LIB_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR})
47+
set_target_properties(libvqm PROPERTIES PREFIX "") #Avoid extra 'lib' prefix
48+
49+
target_link_libraries(libvqm
50+
libvtrutil)

libs/libvqm/Makefile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
CC = g++
2+
AR = ar
3+
4+
WARN_FLAGS = -Wall
5+
6+
DEBUG_FLAGS = -g
7+
OPT_FLAGS = $(OPTIMIZATION_LEVEL_FOR_RELEASE_BUILD)
8+
INC_FLAGS = -I./
9+
LIB_FLAGS = rcs
10+
11+
FLAGS = $(WARN_FLAGS) $(INC_FLAGS) -Wno-write-strings
12+
13+
ifneq (,$(findstring release, $(BUILD_TYPE)))
14+
FLAGS := $(FLAGS) $(OPT_FLAGS)
15+
else # DEBUG build
16+
FLAGS := $(FLAGS) $(DEBUG_FLAGS)
17+
endif
18+
19+
SRC = vqm_common.c vqm_dll.cpp
20+
GEN = vqm_parser.tab.c lex.yy.c vqm_parser.tab.h
21+
H = vqm_common.h vqm_dll.h
22+
23+
PARSER1 = $(if $(strip $(shell which flex)), flex, \
24+
$(error flex not found. VQM2BLIF requires flex to compile.))
25+
PARSER2 = $(if $(strip $(shell which bison)), bison, \
26+
$(error bison not found. VQM2BLIF requires bison to compile.))
27+
28+
all: libvqm.a
29+
30+
libvqm.a: $(SRC) vqm_parser.l vqm_parser.y $(H)
31+
$(PARSER1) vqm_parser.l
32+
$(PARSER2) -d vqm_parser.y
33+
$(CC) $(FLAGS) -c *.c *.cpp
34+
$(AR) $(LIB_FLAGS) $@ *.o
35+
36+
clean:
37+
rm -f *.o *.a $(GEN)
38+

0 commit comments

Comments
 (0)