2021-03-12 19:25:41 +08:00
|
|
|
function(create_rapidwright_device_db)
|
2021-03-13 02:02:00 +08:00
|
|
|
# ~~~
|
|
|
|
# create_rapidwright_device_db(
|
|
|
|
# device <common device>
|
|
|
|
# part <part>
|
|
|
|
# )
|
|
|
|
# ~~~
|
|
|
|
#
|
|
|
|
# Generates a device database from RapidWright
|
|
|
|
#
|
|
|
|
# Targets generated:
|
|
|
|
# - rapidwright-<device>-device
|
|
|
|
|
2021-03-12 19:25:41 +08:00
|
|
|
set(options)
|
2021-03-12 23:37:00 +08:00
|
|
|
set(oneValueArgs device part)
|
2021-03-12 19:25:41 +08:00
|
|
|
set(multiValueArgs)
|
|
|
|
|
|
|
|
cmake_parse_arguments(
|
|
|
|
create_rapidwright_device_db
|
|
|
|
"${options}"
|
|
|
|
"${oneValueArgs}"
|
|
|
|
"${multiValueArgs}"
|
|
|
|
${ARGN}
|
|
|
|
)
|
|
|
|
|
2021-03-12 23:37:00 +08:00
|
|
|
set(device ${create_rapidwright_device_db_device})
|
2021-03-12 19:25:41 +08:00
|
|
|
set(part ${create_rapidwright_device_db_part})
|
|
|
|
set(rapidwright_device_db ${CMAKE_CURRENT_BINARY_DIR}/${part}.device)
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${rapidwright_device_db}
|
|
|
|
COMMAND
|
|
|
|
RAPIDWRIGHT_PATH=${RAPIDWRIGHT_PATH}
|
2021-03-13 02:02:00 +08:00
|
|
|
${INVOKE_RAPIDWRIGHT}
|
2021-03-12 19:25:41 +08:00
|
|
|
com.xilinx.rapidwright.interchange.DeviceResourcesExample
|
|
|
|
${part}
|
|
|
|
DEPENDS
|
2021-03-13 02:02:00 +08:00
|
|
|
${INVOKE_RAPIDWRIGHT}
|
2021-03-12 19:25:41 +08:00
|
|
|
)
|
|
|
|
|
2021-03-12 23:37:00 +08:00
|
|
|
add_custom_target(rapidwright-${device}-device DEPENDS ${rapidwright_device_db})
|
|
|
|
set_property(TARGET rapidwright-${device}-device PROPERTY LOCATION ${rapidwright_device_db})
|
2021-03-12 19:25:41 +08:00
|
|
|
endfunction()
|
|
|
|
|
2021-03-12 23:37:00 +08:00
|
|
|
function(create_patched_device_db)
|
2021-03-13 02:02:00 +08:00
|
|
|
# ~~~
|
|
|
|
# create_patched_device_db(
|
|
|
|
# device <common device>
|
|
|
|
# patch_name <patch_name>
|
|
|
|
# patch_path <patch_path>
|
|
|
|
# patch_format <patch_format>
|
|
|
|
# patch_data <patch_data>
|
|
|
|
# input_device <input_device target>
|
|
|
|
# )
|
|
|
|
# ~~~
|
|
|
|
#
|
|
|
|
# Generates a patched device database starting from an input device
|
|
|
|
#
|
|
|
|
# Targets generated:
|
|
|
|
# - <patch_name>-<device>-device
|
|
|
|
|
2021-03-12 19:25:41 +08:00
|
|
|
set(options)
|
2021-03-13 02:02:00 +08:00
|
|
|
set(oneValueArgs device patch_name patch_path patch_format patch_data input_device)
|
2021-03-12 19:25:41 +08:00
|
|
|
set(multiValueArgs)
|
|
|
|
|
|
|
|
cmake_parse_arguments(
|
2021-03-12 23:37:00 +08:00
|
|
|
create_patched_device_db
|
2021-03-12 19:25:41 +08:00
|
|
|
"${options}"
|
|
|
|
"${oneValueArgs}"
|
|
|
|
"${multiValueArgs}"
|
|
|
|
${ARGN}
|
|
|
|
)
|
|
|
|
|
2021-03-12 23:37:00 +08:00
|
|
|
set(device ${create_patched_device_db_device})
|
2021-03-13 02:02:00 +08:00
|
|
|
set(patch_name ${create_patched_device_db_patch_name})
|
|
|
|
set(patch_path ${create_patched_device_db_patch_path})
|
|
|
|
set(patch_format ${create_patched_device_db_patch_format})
|
|
|
|
set(patch_data ${create_patched_device_db_patch_data})
|
|
|
|
set(input_device ${create_patched_device_db_input_device})
|
|
|
|
|
|
|
|
get_property(input_device_loc TARGET ${input_device} PROPERTY LOCATION)
|
|
|
|
set(output_device_file ${CMAKE_CURRENT_BINARY_DIR}/${device}_${patch_name}.device)
|
2021-03-12 19:25:41 +08:00
|
|
|
add_custom_command(
|
2021-03-13 02:02:00 +08:00
|
|
|
OUTPUT ${output_device_file}
|
2021-03-12 19:25:41 +08:00
|
|
|
COMMAND
|
2021-03-12 23:37:00 +08:00
|
|
|
${PYTHON_EXECUTABLE} -mfpga_interchange.patch
|
2021-03-12 19:25:41 +08:00
|
|
|
--schema_dir ${INTERCHANGE_SCHEMA_PATH}
|
|
|
|
--schema device
|
2021-03-13 02:02:00 +08:00
|
|
|
--patch_path ${patch_path}
|
|
|
|
--patch_format ${patch_format}
|
|
|
|
${input_device_loc}
|
|
|
|
${patch_data}
|
|
|
|
${output_device_file}
|
2021-03-12 19:25:41 +08:00
|
|
|
DEPENDS
|
2021-03-13 02:02:00 +08:00
|
|
|
${input_device}
|
|
|
|
${input_device_loc}
|
2021-03-12 19:25:41 +08:00
|
|
|
)
|
|
|
|
|
2021-03-13 02:02:00 +08:00
|
|
|
add_custom_target(${patch_name}-${device}-device DEPENDS ${output_device_file})
|
|
|
|
set_property(TARGET ${patch_name}-${device}-device PROPERTY LOCATION ${output_device_file})
|
2021-03-12 23:37:00 +08:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(generate_chipdb)
|
2021-03-13 02:02:00 +08:00
|
|
|
# ~~~
|
|
|
|
# create_patched_device_db(
|
|
|
|
# device <common device>
|
|
|
|
# part <part>
|
|
|
|
# )
|
|
|
|
# ~~~
|
|
|
|
#
|
|
|
|
# Generates a chipdb BBA file, starting from a RapidWright device database which is then patched.
|
|
|
|
# Patches applied:
|
|
|
|
# - constraints patch
|
|
|
|
# - luts patch
|
|
|
|
#
|
|
|
|
# The chipdb file is moved to the <nextpnr-root>/build/fpga_interchange/chipdb/ directory
|
|
|
|
#
|
|
|
|
# Targets generated:
|
|
|
|
# - chipdb-<device>-bba
|
|
|
|
|
2021-03-12 23:37:00 +08:00
|
|
|
set(options)
|
2021-03-13 02:02:00 +08:00
|
|
|
set(oneValueArgs device part bel_bucket_seeds)
|
2021-03-12 23:37:00 +08:00
|
|
|
set(multiValueArgs)
|
|
|
|
|
|
|
|
cmake_parse_arguments(
|
|
|
|
generate_chipdb
|
|
|
|
"${options}"
|
|
|
|
"${oneValueArgs}"
|
|
|
|
"${multiValueArgs}"
|
|
|
|
${ARGN}
|
|
|
|
)
|
|
|
|
|
|
|
|
set(device ${generate_chipdb_device})
|
|
|
|
set(part ${generate_chipdb_part})
|
2021-03-13 02:02:00 +08:00
|
|
|
set(bel_bucket_seeds ${generate_chipdb_bel_bucket_seeds})
|
2021-03-12 23:37:00 +08:00
|
|
|
|
|
|
|
create_rapidwright_device_db(
|
|
|
|
device ${device}
|
|
|
|
part ${part}
|
|
|
|
)
|
2021-03-12 19:25:41 +08:00
|
|
|
|
2021-03-13 02:02:00 +08:00
|
|
|
# Generate constraints patch
|
|
|
|
create_patched_device_db(
|
|
|
|
device ${device}
|
|
|
|
patch_name constraints
|
|
|
|
patch_path constraints
|
|
|
|
patch_format yaml
|
|
|
|
patch_data ${PYTHON_INTERCHANGE_PATH}/test_data/series7_constraints.yaml
|
|
|
|
input_device rapidwright-${device}-device
|
|
|
|
)
|
|
|
|
|
|
|
|
# Generate lut constraints patch
|
|
|
|
create_patched_device_db(
|
|
|
|
device ${device}
|
|
|
|
patch_name constraints-luts
|
|
|
|
patch_path lutDefinitions
|
|
|
|
patch_format yaml
|
|
|
|
patch_data ${PYTHON_INTERCHANGE_PATH}/test_data/series7_luts.yaml
|
|
|
|
input_device constraints-${device}-device
|
|
|
|
)
|
|
|
|
|
|
|
|
get_property(constraints_luts_device_loc TARGET constraints-luts-${device}-device PROPERTY LOCATION)
|
2021-03-12 23:37:00 +08:00
|
|
|
set(chipdb_bba ${chipdb_dir}/chipdb-${device}.bba)
|
2021-03-12 19:25:41 +08:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${chipdb_bba}
|
|
|
|
COMMAND
|
2021-03-12 23:37:00 +08:00
|
|
|
${PYTHON_EXECUTABLE} -mfpga_interchange.nextpnr_emit
|
2021-03-12 19:25:41 +08:00
|
|
|
--schema_dir ${INTERCHANGE_SCHEMA_PATH}
|
2021-03-12 23:37:00 +08:00
|
|
|
--output_dir ${CMAKE_CURRENT_BINARY_DIR}
|
2021-03-13 02:02:00 +08:00
|
|
|
--bel_bucket_seeds ${bel_bucket_seeds}
|
|
|
|
--device ${constraints_luts_device_loc}
|
2021-03-12 19:25:41 +08:00
|
|
|
COMMAND
|
2021-03-12 23:37:00 +08:00
|
|
|
mv ${CMAKE_CURRENT_BINARY_DIR}/chipdb.bba ${chipdb_bba}
|
2021-03-12 19:25:41 +08:00
|
|
|
DEPENDS
|
2021-03-12 23:37:00 +08:00
|
|
|
constraints-luts-${device}-device
|
2021-03-13 02:02:00 +08:00
|
|
|
${constraints_luts_device_loc}
|
2021-03-12 19:25:41 +08:00
|
|
|
)
|
|
|
|
|
2021-03-12 23:37:00 +08:00
|
|
|
add_custom_target(chipdb-${device}-bba DEPENDS ${chipdb_bba})
|
|
|
|
add_dependencies(chipdb-${family}-bbas chipdb-${device}-bba)
|
2021-03-12 19:25:41 +08:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
set(chipdb_dir ${CMAKE_CURRENT_BINARY_DIR}/${family}/chipdb)
|
|
|
|
file(MAKE_DIRECTORY ${chipdb_dir})
|
|
|
|
|
|
|
|
add_custom_target(chipdb-${family}-bbas)
|
|
|
|
|
|
|
|
add_subdirectory(${family}/examples/devices)
|