fpga_interchange: address review comments

Signed-off-by: Alessandro Comodi <acomodi@antmicro.com>
This commit is contained in:
Alessandro Comodi 2021-03-16 21:49:06 +01:00
parent f9e9fadbc8
commit c1e668f823
10 changed files with 96 additions and 20 deletions

View File

@ -22,6 +22,8 @@ jobs:
- name: Execute build script - name: Execute build script
run: stdbuf -i0 -o0 -e0 ./.github/ci/build_interchange.sh run: stdbuf -i0 -o0 -e0 ./.github/ci/build_interchange.sh
- name: Execute test script - name: Run tests
run: | run: |
cd build && make all-fpga_interchange-tests -j`nproc` cd build
make all-fpga_interchange-archcheck-tests -j`nproc`
make all-fpga_interchange-tests -j`nproc`

View File

@ -123,6 +123,7 @@ function(generate_xc7_device_db)
# generate_xc7_device_db( # generate_xc7_device_db(
# device <common device> # device <common device>
# part <part> # part <part>
# device_target <variable name for device target>
# ) # )
# ~~~ # ~~~
# #
@ -134,7 +135,7 @@ function(generate_xc7_device_db)
# The final device target is output in the device_target variable to use in the parent scope # The final device target is output in the device_target variable to use in the parent scope
set(options) set(options)
set(oneValueArgs device part) set(oneValueArgs device part device_target)
set(multiValueArgs) set(multiValueArgs)
cmake_parse_arguments( cmake_parse_arguments(
@ -147,6 +148,7 @@ function(generate_xc7_device_db)
set(device ${create_rapidwright_device_db_device}) set(device ${create_rapidwright_device_db_device})
set(part ${create_rapidwright_device_db_part}) set(part ${create_rapidwright_device_db_part})
set(device_target ${create_rapidwright_device_db_device_target})
create_rapidwright_device_db( create_rapidwright_device_db(
device ${device} device ${device}
@ -176,12 +178,15 @@ function(generate_xc7_device_db)
output_target constraints_luts_device output_target constraints_luts_device
) )
set(device_target ${constraints_luts_device} PARENT_SCOPE) if(DEFINED device_target)
set(${device_target} ${constraints_luts_device} PARENT_SCOPE)
endif()
endfunction() endfunction()
function(generate_chipdb) function(generate_chipdb)
# ~~~ # ~~~
# generate_chipdb( # generate_chipdb(
# family <family>
# device <common device> # device <common device>
# part <part> # part <part>
# device_target <device target> # device_target <device target>
@ -198,10 +203,15 @@ function(generate_chipdb)
# The package argument is only used to run the architecture check target. # The package argument is only used to run the architecture check target.
# #
# Targets generated: # Targets generated:
# - chipdb-<device>-bba # - chipdb-${device}-bba
# - chipdb-${device}-bin
# - device-${device}
#
# The device-${device} target contains properties to get the interchange device as well
# as the binary chipdb
set(options) set(options)
set(oneValueArgs device part device_target bel_bucket_seeds package) set(oneValueArgs family device part device_target bel_bucket_seeds package)
set(multiValueArgs) set(multiValueArgs)
cmake_parse_arguments( cmake_parse_arguments(
@ -212,6 +222,7 @@ function(generate_chipdb)
${ARGN} ${ARGN}
) )
set(family ${generate_chipdb_family})
set(device ${generate_chipdb_device}) set(device ${generate_chipdb_device})
set(part ${generate_chipdb_part}) set(part ${generate_chipdb_part})
set(device_target ${generate_chipdb_device_target}) set(device_target ${generate_chipdb_device_target})
@ -219,7 +230,7 @@ function(generate_chipdb)
set(package ${generate_chipdb_package}) set(package ${generate_chipdb_package})
get_target_property(device_loc ${device_target} LOCATION) get_target_property(device_loc ${device_target} LOCATION)
set(chipdb_bba ${CMAKE_CURRENT_BINARY_DIR}/chipdb-${device}.bba) set(chipdb_bba ${CMAKE_CURRENT_BINARY_DIR}/chipdb.bba)
add_custom_command( add_custom_command(
OUTPUT ${chipdb_bba} OUTPUT ${chipdb_bba}
COMMAND COMMAND
@ -228,8 +239,6 @@ function(generate_chipdb)
--output_dir ${CMAKE_CURRENT_BINARY_DIR} --output_dir ${CMAKE_CURRENT_BINARY_DIR}
--bel_bucket_seeds ${bel_bucket_seeds} --bel_bucket_seeds ${bel_bucket_seeds}
--device ${device_loc} --device ${device_loc}
COMMAND
mv ${CMAKE_CURRENT_BINARY_DIR}/chipdb.bba ${chipdb_bba}
DEPENDS DEPENDS
${bel_bucket_seeds} ${bel_bucket_seeds}
${device_target} ${device_target}
@ -251,6 +260,17 @@ function(generate_chipdb)
add_custom_target(chipdb-${device}-bin DEPENDS ${chipdb_bin}) add_custom_target(chipdb-${device}-bin DEPENDS ${chipdb_bin})
# Setting device target properties
add_custom_target(device-${device})
set_target_properties(
device-${device}
PROPERTIES
DEVICE_LOC ${device_loc}
DEVICE_TARGET ${device_target}
CHIPDB_BIN_LOC ${chipdb_bin}
CHIPDB_BIN_TARGET chipdb-${device}-bin
)
# Generate architecture check target # Generate architecture check target
set(test_data_source ${CMAKE_CURRENT_SOURCE_DIR}/test_data.yaml) set(test_data_source ${CMAKE_CURRENT_SOURCE_DIR}/test_data.yaml)
set(test_data_binary ${CMAKE_CURRENT_BINARY_DIR}/test_data.yaml) set(test_data_binary ${CMAKE_CURRENT_BINARY_DIR}/test_data.yaml)
@ -273,6 +293,7 @@ function(generate_chipdb)
--test --test
DEPENDS DEPENDS
${chipdb_bin} ${chipdb_bin}
chipdb-${device}-bin
) )
add_custom_target( add_custom_target(
@ -281,10 +302,13 @@ function(generate_chipdb)
nextpnr-fpga_interchange nextpnr-fpga_interchange
--chipdb ${chipdb_bin} --chipdb ${chipdb_bin}
--package ${package} --package ${package}
--run ${root_dir}/python/check_arch_api.py --run ${PROJECT_SOURCE_DIR}/python/check_arch_api.py
DEPENDS DEPENDS
${chipdb_bin} ${chipdb_bin}
chipdb-${device}-bin
${test_data_binary} ${test_data_binary}
) )
add_dependencies(all-${family}-archcheck-tests chipdb-${device}-bin-check-test-data chipdb-${device}-bin-check)
endfunction() endfunction()

View File

@ -1,12 +1,14 @@
generate_xc7_device_db( generate_xc7_device_db(
device xc7a35t device xc7a35t
part xc7a35tcsg324-1 part xc7a35tcsg324-1
device_target target
) )
generate_chipdb( generate_chipdb(
family ${family}
device xc7a35t device xc7a35t
part xc7a35tcsg324-1 part xc7a35tcsg324-1
device_target ${device_target} device_target ${target}
bel_bucket_seeds ${PYTHON_INTERCHANGE_PATH}/test_data/series7_bel_buckets.yaml bel_bucket_seeds ${PYTHON_INTERCHANGE_PATH}/test_data/series7_bel_buckets.yaml
package csg324 package csg324
) )

View File

@ -2,6 +2,7 @@ function(add_interchange_test)
# ~~~ # ~~~
# add_interchange_test( # add_interchange_test(
# name <name> # name <name>
# family <family>
# device <common device> # device <common device>
# package <package> # package <package>
# tcl <tcl> # tcl <tcl>
@ -20,7 +21,7 @@ function(add_interchange_test)
# - test-fpga_interchange-<name>-dcp : design checkpoint with RapidWright # - test-fpga_interchange-<name>-dcp : design checkpoint with RapidWright
set(options) set(options)
set(oneValueArgs name device package tcl xdc top techmap) set(oneValueArgs name family device package tcl xdc top techmap)
set(multiValueArgs sources) set(multiValueArgs sources)
cmake_parse_arguments( cmake_parse_arguments(
@ -32,6 +33,7 @@ function(add_interchange_test)
) )
set(name ${add_interchange_test_name}) set(name ${add_interchange_test_name})
set(family ${add_interchange_test_family})
set(device ${add_interchange_test_device}) set(device ${add_interchange_test_device})
set(package ${add_interchange_test_package}) set(package ${add_interchange_test_package})
set(top ${add_interchange_test_top}) set(top ${add_interchange_test_top})
@ -64,8 +66,8 @@ function(add_interchange_test)
add_custom_target(test-${family}-${name}-json DEPENDS ${synth_json}) add_custom_target(test-${family}-${name}-json DEPENDS ${synth_json})
# Logical Netlist # Logical Netlist
set(device_target constraints-luts-${device}-device) get_property(device_target TARGET device-${device} PROPERTY DEVICE_TARGET)
get_property(device_loc TARGET constraints-luts-${device}-device PROPERTY LOCATION) get_property(device_loc TARGET device-${device} PROPERTY DEVICE_LOC)
set(netlist ${CMAKE_CURRENT_BINARY_DIR}/${name}.netlist) set(netlist ${CMAKE_CURRENT_BINARY_DIR}/${name}.netlist)
add_custom_command( add_custom_command(
@ -85,27 +87,64 @@ function(add_interchange_test)
add_custom_target(test-${family}-${name}-netlist DEPENDS ${netlist}) add_custom_target(test-${family}-${name}-netlist DEPENDS ${netlist})
set(chipdb_target chipdb-${device}-bin) # Logical Netlist YAML
set(netlist_yaml ${CMAKE_CURRENT_BINARY_DIR}/${name}.netlist.yaml)
add_custom_command(
OUTPUT ${netlist_yaml}
COMMAND
${PYTHON_EXECUTABLE} -mfpga_interchange.convert
--schema_dir ${INTERCHANGE_SCHEMA_PATH}
--schema logical
--input_format capnp
--output_format yaml
${netlist}
${netlist_yaml}
DEPENDS
${netlist}
)
add_custom_target(test-${family}-${name}-netlist-yaml DEPENDS ${netlist_yaml})
# Physical Netlist # Physical Netlist
get_property(chipdb_bin_target TARGET device-${device} PROPERTY CHIPDB_BIN_TARGET)
get_property(chipdb_bin_loc TARGET device-${device} PROPERTY CHIPDB_BIN_LOC)
set(phys ${CMAKE_CURRENT_BINARY_DIR}/${name}.phys) set(phys ${CMAKE_CURRENT_BINARY_DIR}/${name}.phys)
add_custom_command( add_custom_command(
OUTPUT ${phys} OUTPUT ${phys}
COMMAND COMMAND
nextpnr-fpga_interchange nextpnr-fpga_interchange
--chipdb ${chipdb_dir}/chipdb-${device}.bin --chipdb ${chipdb_bin_loc}
--xdc ${xdc} --xdc ${xdc}
--netlist ${netlist} --netlist ${netlist}
--phys ${phys} --phys ${phys}
--package ${package} --package ${package}
DEPENDS DEPENDS
${netlist} ${netlist}
${chipdb_target} ${chipdb_bin_target}
${chipdb_dir}/chipdb-${device}.bin ${chipdb_bin_loc}
) )
add_custom_target(test-${family}-${name}-phys DEPENDS ${phys}) add_custom_target(test-${family}-${name}-phys DEPENDS ${phys})
# Physical Netlist YAML
set(phys_yaml ${CMAKE_CURRENT_BINARY_DIR}/${name}.phys.yaml)
add_custom_command(
OUTPUT ${phys_yaml}
COMMAND
${PYTHON_EXECUTABLE} -mfpga_interchange.convert
--schema_dir ${INTERCHANGE_SCHEMA_PATH}
--schema physical
--input_format capnp
--output_format yaml
${phys}
${phys_yaml}
DEPENDS
${phys}
)
add_custom_target(test-${family}-${name}-phys-yaml DEPENDS ${phys_yaml})
set(dcp ${CMAKE_CURRENT_BINARY_DIR}/${name}.dcp) set(dcp ${CMAKE_CURRENT_BINARY_DIR}/${name}.dcp)
add_custom_command( add_custom_command(
OUTPUT ${dcp} OUTPUT ${dcp}

View File

@ -1,5 +1,6 @@
add_interchange_test( add_interchange_test(
name const_wire_basys3 name const_wire_basys3
family ${family}
device xc7a35t device xc7a35t
package cpg236 package cpg236
tcl run.tcl tcl run.tcl
@ -9,6 +10,7 @@ add_interchange_test(
add_interchange_test( add_interchange_test(
name const_wire_arty name const_wire_arty
family ${family}
device xc7a35t device xc7a35t
package csg324 package csg324
tcl run.tcl tcl run.tcl

View File

@ -1,5 +1,6 @@
add_interchange_test( add_interchange_test(
name counter_basys3 name counter_basys3
family ${family}
device xc7a35t device xc7a35t
package cpg236 package cpg236
tcl run.tcl tcl run.tcl
@ -10,6 +11,7 @@ add_interchange_test(
add_interchange_test( add_interchange_test(
name counter_arty name counter_arty
family ${family}
device xc7a35t device xc7a35t
package csg324 package csg324
tcl run.tcl tcl run.tcl

View File

@ -1,5 +1,6 @@
add_interchange_test( add_interchange_test(
name ff_basys3 name ff_basys3
family ${family}
device xc7a35t device xc7a35t
package cpg236 package cpg236
tcl run.tcl tcl run.tcl
@ -9,6 +10,7 @@ add_interchange_test(
add_interchange_test( add_interchange_test(
name ff_arty name ff_arty
family ${family}
device xc7a35t device xc7a35t
package csg324 package csg324
tcl run.tcl tcl run.tcl

View File

@ -1,5 +1,6 @@
add_interchange_test( add_interchange_test(
name lut_basys3 name lut_basys3
family ${family}
device xc7a35t device xc7a35t
package cpg236 package cpg236
tcl run.tcl tcl run.tcl
@ -9,6 +10,7 @@ add_interchange_test(
add_interchange_test( add_interchange_test(
name lut_arty name lut_arty
family ${family}
device xc7a35t device xc7a35t
package csg324 package csg324
tcl run.tcl tcl run.tcl

View File

@ -1,5 +1,6 @@
add_interchange_test( add_interchange_test(
name wire_basys3 name wire_basys3
family ${family}
device xc7a35t device xc7a35t
package cpg236 package cpg236
tcl run.tcl tcl run.tcl
@ -9,6 +10,7 @@ add_interchange_test(
add_interchange_test( add_interchange_test(
name wire_arty name wire_arty
family ${family}
device xc7a35t device xc7a35t
package csg324 package csg324
tcl run.tcl tcl run.tcl

View File

@ -19,9 +19,8 @@ include(${family}/examples/tests.cmake)
set(chipdb_dir ${CMAKE_CURRENT_BINARY_DIR}/${family}/chipdb) set(chipdb_dir ${CMAKE_CURRENT_BINARY_DIR}/${family}/chipdb)
file(MAKE_DIRECTORY ${chipdb_dir}) file(MAKE_DIRECTORY ${chipdb_dir})
set(root_dir ${CMAKE_CURRENT_SOURCE_DIR})
add_custom_target(all-${family}-tests) add_custom_target(all-${family}-tests)
add_custom_target(all-${family}-archcheck-tests)
add_subdirectory(${family}/examples/devices) add_subdirectory(${family}/examples/devices)
add_subdirectory(${family}/examples/tests) add_subdirectory(${family}/examples/tests)