Skip to content

Commit e1ce15c

Browse files
committed
libs: capnp: add interchange schema compilation
Signed-off-by: Alessandro Comodi <[email protected]>
1 parent fd81de5 commit e1ce15c

File tree

4 files changed

+67
-7
lines changed

4 files changed

+67
-7
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ option(VTR_ENABLE_CAPNPROTO "Enable capnproto binary serialization support in VP
4040
#Allow the user to enable/disable VPR analytic placement
4141
#VPR option --enable_analytic_placer is also required for Analytic Placement
4242
option(VPR_ANALYTIC_PLACE "Enable analytic placement in VPR." ON)
43+
option(VPR_ENABLE_INTERCHANGE "Enable FPGA interchange." ON)
4344

4445
option(WITH_BLIFEXPLORER "Enable build with blifexplorer" OFF)
4546

@@ -366,7 +367,6 @@ if (VPR_USE_EZGL STREQUAL "auto")
366367
endif()
367368
endif()
368369

369-
370370
#Add the various sub-projects
371371
if(${WITH_ABC})
372372
add_subdirectory(abc)

libs/EXTERNAL/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ add_subdirectory(libsdcparse)
88
add_subdirectory(libblifparse)
99
add_subdirectory(libtatum)
1010

11-
#VPR_USE_EZGL is initialized in the root CMakeLists.
11+
#VPR_USE_EZGL is initialized in the root CMakeLists.
1212
#compile libezgl only if the user asks for or has its dependencies installed.
1313
if(VPR_USE_EZGL STREQUAL "on")
1414
add_subdirectory(libezgl)

libs/libarchfpga/CMakeLists.txt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,23 @@ list(REMOVE_ITEM LIB_SOURCES ${EXEC_SOURCES})
1212

1313
#Create the library
1414
add_library(libarchfpga STATIC
15-
${LIB_HEADERS}
16-
${LIB_SOURCES})
15+
${LIB_HEADERS}
16+
${LIB_SOURCES}
17+
)
18+
1719
target_include_directories(libarchfpga PUBLIC ${LIB_INCLUDE_DIRS})
20+
1821
set_target_properties(libarchfpga PROPERTIES PREFIX "") #Avoid extra 'lib' prefix
1922

2023
#Specify link-time dependancies
2124
target_link_libraries(libarchfpga
2225
libvtrutil
2326
libpugixml
24-
libpugiutil)
27+
libpugiutil
28+
libvtrcapnproto
29+
)
30+
31+
target_compile_definitions(libarchfpga PUBLIC ${INTERCHANGE_SCHEMA_HEADERS})
2532

2633
#Create the test executable
2734
add_executable(read_arch ${EXEC_SOURCES})

libs/libvtrcapnproto/CMakeLists.txt

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,73 @@ set(CAPNP_DEFS
2525
gen/rr_graph_uxsdcxx.capnp
2626
map_lookahead.capnp
2727
extended_map_lookahead.capnp
28-
)
28+
)
29+
2930
capnp_generate_cpp(CAPNP_SRCS CAPNP_HDRS
3031
${CAPNP_DEFS}
32+
)
33+
34+
if (VPR_ENABLE_INTERCHANGE)
35+
set(IC_DIR ${CMAKE_SOURCE_DIR}/libs/EXTERNAL/libinterchange/interchange)
36+
set(CAPNPC_SRC_PREFIX ${IC_DIR})
37+
38+
find_program(WGET wget REQUIRED)
39+
40+
# Add Java schema
41+
set(JAVA_SCHEMA ${CMAKE_CURRENT_BINARY_DIR}/schema/capnp/java.capnp)
42+
add_custom_command(
43+
OUTPUT ${JAVA_SCHEMA}
44+
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/schema/capnp/
45+
COMMAND ${WGET}
46+
https://raw.githubusercontent.com/capnproto/capnproto-java/master/compiler/src/main/schema/capnp/java.capnp
47+
-O ${JAVA_SCHEMA}
48+
)
49+
50+
add_custom_target(
51+
get_java_capnp_schema
52+
DEPENDS ${JAVA_SCHEMA}
53+
)
54+
55+
set(CAPNPC_IMPORT_DIRS)
56+
list(APPEND CAPNPC_IMPORT_DIRS ${CMAKE_CURRENT_BINARY_DIR}/schema)
57+
58+
set(IC_PROTOS
59+
LogicalNetlist.capnp
60+
PhysicalNetlist.capnp
61+
DeviceResources.capnp
62+
References.capnp
3163
)
64+
set(IC_SRCS)
65+
set(IC_HDRS)
66+
foreach(PROTO ${IC_PROTOS})
67+
capnp_generate_cpp(
68+
IC_SRC
69+
IC_HDR
70+
${IC_DIR}/${PROTO}
71+
)
72+
list(APPEND IC_SRCS ${IC_SRC})
73+
list(APPEND IC_HDRS ${IC_HDR})
74+
list(APPEND CAPNP_DEFS ${IC_DIR}/${PROTO})
75+
endforeach()
76+
endif()
3277

3378
install(FILES ${CAPNP_DEFS} DESTINATION ${CMAKE_INSTALL_DATADIR}/vtr)
3479

3580
add_library(libvtrcapnproto STATIC
3681
${CAPNP_SRCS}
82+
${IC_SRCS}
3783
mmap_file.h
3884
mmap_file.cpp
3985
serdes_utils.h
4086
serdes_utils.cpp
4187
)
88+
89+
if (VPR_ENABLE_INTERCHANGE)
90+
add_dependencies(libvtrcapnproto
91+
get_java_capnp_schema
92+
)
93+
endif()
94+
4295
target_include_directories(libvtrcapnproto PUBLIC
4396
${CMAKE_CURRENT_SOURCE_DIR}
4497
${CMAKE_CURRENT_BINARY_DIR}
@@ -47,4 +100,4 @@ target_include_directories(libvtrcapnproto PUBLIC
47100
target_link_libraries(libvtrcapnproto
48101
libvtrutil
49102
CapnProto::capnp
50-
)
103+
)

0 commit comments

Comments
 (0)