Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

interchange: add FASM generation target and clean-up tests #678

Merged
merged 2 commits into from
Apr 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/interchange_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ jobs:
env:
RAPIDWRIGHT_PATH: ${{ github.workspace }}/RapidWright
PYTHON_INTERCHANGE_PATH: ${{ github.workspace }}/python-fpga-interchange
PYTHON_INTERCHANGE_TAG: v0.0.7
PYTHON_INTERCHANGE_TAG: v0.0.9
PRJOXIDE_REVISION: a85135648c3ef2f7b3fd53ae2187ef6460e34b16
DEVICE: ${{ matrix.device }}
run: |
Expand Down
7 changes: 6 additions & 1 deletion fpga_interchange/examples/boards.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ function(add_board)
# ~~~
# add_board(
# name <board name>
# device_family <device family>
# device <common device>
# package <package>
# )
Expand All @@ -12,6 +13,8 @@ function(add_board)
#
# Arguments:
# - name: name of the board. E.g. arty
# - device_family: the name of the family this device belongs to.
# E.g. the xc7a35t device belongs to the xc7 family
# - device: common device name of a set of parts. E.g. xc7a35tcsg324-1 and xc7a35tcpg236-1
# share the same xc7a35t device prefix
# - package: one of the packages available for a given device. E.g. cpg236
Expand All @@ -20,7 +23,7 @@ function(add_board)
# - board-<name>

set(options)
set(oneValueArgs name device package)
set(oneValueArgs name device_family device package)
set(multiValueArgs)

cmake_parse_arguments(
Expand All @@ -32,13 +35,15 @@ function(add_board)
)

set(name ${add_board_name})
set(device_family ${add_board_device_family})
set(device ${add_board_device})
set(package ${add_board_package})

add_custom_target(board-${name} DEPENDS device-${device})
set_target_properties(
board-${name}
PROPERTIES
DEVICE_FAMILY ${device_family}
DEVICE ${device}
PACKAGE ${package}
)
Expand Down
5 changes: 5 additions & 0 deletions fpga_interchange/examples/boards/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
add_board(
name arty35t
device_family xc7
device xc7a35t
package csg324
)

add_board(
name arty100t
device_family xc7
device xc7a100t
package csg324
)

add_board(
name nexys_video
device_family xc7
device xc7a200t
package sbg484
)

add_board(
name basys3
device_family xc7
device xc7a35t
package cpg236
)

add_board(
name zybo
device_family xc7
device xc7z010
package clg400
)
63 changes: 56 additions & 7 deletions fpga_interchange/examples/tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ function(add_interchange_test)
# sources <sources list>
# [top <top name>]
# [techmap <techmap file>]
# [output_fasm]
# [device_family <device family>]
# )
#
# Generates targets to run desired tests
Expand All @@ -18,6 +20,8 @@ function(add_interchange_test)
# - name: test name. This must be unique and no other tests with the same
# name should exist
# - family: nextpnr architecture family (e.g. fpga_interchange)
# - device_family: common device name of a set of parts. E.g. xc7a35tcsg324-1 and xc7a35tcpg236-1
# share the same xc7a35t device prefix
# - device: common device name of a set of parts. E.g. xc7a35tcsg324-1 and xc7a35tcpg236-1
# share the same xc7a35t device prefix
# - package: package among the ones available for the device
Expand All @@ -27,15 +31,18 @@ function(add_interchange_test)
# - top (optional): name of the top level module.
# If not provided, "top" is assigned as top level module
# - techmap (optional): techmap file used during synthesis
# - output_fasm (optional): generates a fasm output
# - device_family (optional): this information is used during FASM generation, therfore it is
# required only if the `output_fasm` option is enabled
#
# Targets generated:
# - test-fpga_interchange-<name>-json : synthesis output
# - test-fpga_interchange-<name>-netlist : interchange logical netlist
# - test-fpga_interchange-<name>-phys : interchange physical netlist
# - test-fpga_interchange-<name>-dcp : design checkpoint with RapidWright

set(options skip_dcp)
set(oneValueArgs name family device package tcl xdc top techmap)
set(options skip_dcp output_fasm)
set(oneValueArgs name family device package tcl xdc top techmap device_family)
set(multiValueArgs sources)

cmake_parse_arguments(
Expand All @@ -51,10 +58,12 @@ function(add_interchange_test)
set(device ${add_interchange_test_device})
set(package ${add_interchange_test_package})
set(skip_dcp ${add_interchange_test_skip_dcp})
set(output_fasm ${add_interchange_test_output_fasm})
set(top ${add_interchange_test_top})
set(tcl ${CMAKE_CURRENT_SOURCE_DIR}/${add_interchange_test_tcl})
set(xdc ${CMAKE_CURRENT_SOURCE_DIR}/${add_interchange_test_xdc})
set(techmap ${CMAKE_CURRENT_SOURCE_DIR}/${add_interchange_test_techmap})
set(device_family ${add_interchange_test_device_family})

set(sources)
foreach(source ${add_interchange_test_sources})
Expand Down Expand Up @@ -247,9 +256,9 @@ function(add_interchange_test)

add_custom_target(test-${family}-${name}-phys-yaml DEPENDS ${phys_yaml})

set(last_target "")
if(skip_dcp)
add_dependencies(all-${family}-tests test-${family}-${name}-phys-yaml)
add_dependencies(all-${device}-tests test-${family}-${name}-phys-yaml)
set(last_target test-${family}-${name}-phys)
else()
set(dcp ${CMAKE_CURRENT_BINARY_DIR}/${name}.dcp)
add_custom_command(
Expand All @@ -266,8 +275,38 @@ function(add_interchange_test)
)

add_custom_target(test-${family}-${name}-dcp DEPENDS ${dcp})
add_dependencies(all-${family}-tests test-${family}-${name}-dcp)
add_dependencies(all-${device}-tests test-${family}-${name}-dcp)
set(last_target test-${family}-${name}-dcp)
endif()

add_dependencies(all-${device}-tests ${last_target})
add_dependencies(all-${family}-tests ${last_target})

if(output_fasm)
if(NOT DEFINED device_family)
message(FATAL_ERROR "If FASM output is enabled, the device family must be provided as well!")
endif()

# Output FASM target
set(fasm ${CMAKE_CURRENT_BINARY_DIR}/${name}.fasm)
add_custom_command(
OUTPUT ${fasm}
COMMAND
${PYTHON_EXECUTABLE} -mfpga_interchange.fasm_generator
--schema_dir ${INTERCHANGE_SCHEMA_PATH}
--family ${device_family}
${device_loc}
${netlist}
${phys}
${fasm}
DEPENDS
${device_target}
${netlist}
${phys}
)

add_custom_target(test-${family}-${name}-fasm DEPENDS ${fasm} ${last_target})
add_dependencies(all-${device}-tests test-${family}-${name}-fasm)
add_dependencies(all-${family}-tests test-${family}-${name}-fasm)
endif()
endfunction()

Expand Down Expand Up @@ -301,7 +340,7 @@ function(add_interchange_group_test)
# Note: it is assumed that there exists an XDC file for each board, with the following naming
# convention: <board>.xdc

set(options)
set(options output_fasm)
set(oneValueArgs name family tcl top techmap)
set(multiValueArgs sources board_list)

Expand All @@ -319,26 +358,36 @@ function(add_interchange_group_test)
set(tcl ${add_interchange_group_test_tcl})
set(techmap ${add_interchange_group_test_techmap})
set(sources ${add_interchange_group_test_sources})
set(output_fasm ${add_interchange_group_test_output_fasm})

set(output_fasm_arg "")
if(output_fasm)
set(output_fasm_arg "output_fasm")
endif()


if (NOT DEFINED top)
# Setting default top value
set(top "top")
endif()

foreach(board ${add_interchange_group_test_board_list})
get_property(device_family TARGET board-${board} PROPERTY DEVICE_FAMILY)
get_property(device TARGET board-${board} PROPERTY DEVICE)
get_property(package TARGET board-${board} PROPERTY PACKAGE)

add_interchange_test(
name ${name}_${board}
family ${family}
device ${device}
device_family ${device_family}
package ${package}
tcl ${tcl}
xdc ${board}.xdc
sources ${sources}
top ${top}
techmap ${techmap}
${output_fasm_arg}
)
endforeach()
endfunction()
18 changes: 3 additions & 15 deletions fpga_interchange/examples/tests/const_wire/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
add_interchange_test(
name const_wire_basys3
add_interchange_group_test(
name const_wire
family ${family}
device xc7a35t
package cpg236
board_list basys3 arty35t arty100t
tcl run.tcl
xdc wire_basys3.xdc
sources wire.v
)

add_interchange_test(
name const_wire_arty
family ${family}
device xc7a35t
package csg324
tcl run.tcl
xdc wire_arty.xdc
sources wire.v
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set_property PACKAGE_PIN N15 [get_ports o]
set_property PACKAGE_PIN N16 [get_ports o2]
set_property PACKAGE_PIN P17 [get_ports o3]
set_property PACKAGE_PIN R17 [get_ports o4]
set_property PACKAGE_PIN H5 [get_ports o]
set_property PACKAGE_PIN J5 [get_ports o2]
set_property PACKAGE_PIN T9 [get_ports o3]
set_property PACKAGE_PIN T10 [get_ports o4]

set_property IOSTANDARD LVCMOS33 [get_ports o]
set_property IOSTANDARD LVCMOS33 [get_ports o2]
Expand Down
9 changes: 9 additions & 0 deletions fpga_interchange/examples/tests/const_wire/arty35t.xdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set_property PACKAGE_PIN H5 [get_ports o]
set_property PACKAGE_PIN J5 [get_ports o2]
set_property PACKAGE_PIN T9 [get_ports o3]
set_property PACKAGE_PIN T10 [get_ports o4]

set_property IOSTANDARD LVCMOS33 [get_ports o]
set_property IOSTANDARD LVCMOS33 [get_ports o2]
set_property IOSTANDARD LVCMOS33 [get_ports o3]
set_property IOSTANDARD LVCMOS33 [get_ports o4]
3 changes: 2 additions & 1 deletion fpga_interchange/examples/tests/counter/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
add_interchange_group_test(
name counter
family ${family}
board_list basys3 arty35t arty100t
board_list basys3 arty35t arty100t zybo
tcl run.tcl
sources counter.v
techmap ../../remap.v
output_fasm
)
14 changes: 14 additions & 0 deletions fpga_interchange/examples/tests/counter/zybo.xdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# zybo board
set_property PACKAGE_PIN K17 [get_ports clk]
set_property PACKAGE_PIN K18 [get_ports rst]
set_property PACKAGE_PIN M14 [get_ports io_led[4]]
set_property PACKAGE_PIN M15 [get_ports io_led[5]]
set_property PACKAGE_PIN G14 [get_ports io_led[6]]
set_property PACKAGE_PIN D18 [get_ports io_led[7]]

set_property IOSTANDARD LVCMOS33 [get_ports clk]
set_property IOSTANDARD LVCMOS33 [get_ports rst]
set_property IOSTANDARD LVCMOS33 [get_ports io_led[4]]
set_property IOSTANDARD LVCMOS33 [get_ports io_led[5]]
set_property IOSTANDARD LVCMOS33 [get_ports io_led[6]]
set_property IOSTANDARD LVCMOS33 [get_ports io_led[7]]
19 changes: 4 additions & 15 deletions fpga_interchange/examples/tests/ff/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
add_interchange_test(
name ff_basys3
add_interchange_group_test(
name ff
family ${family}
device xc7a35t
package cpg236
board_list basys3 arty35t arty100t
tcl run.tcl
xdc ff_basys3.xdc
sources ff.v
)

add_interchange_test(
name ff_arty
family ${family}
device xc7a35t
package csg324
tcl run.tcl
xdc ff_arty.xdc
sources ff.v
output_fasm
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set_property PACKAGE_PIN P17 [get_ports clk]
set_property PACKAGE_PIN N15 [get_ports d]
set_property PACKAGE_PIN N16 [get_ports r]
set_property PACKAGE_PIN M17 [get_ports q]
set_property PACKAGE_PIN E3 [get_ports clk]
set_property PACKAGE_PIN A8 [get_ports d]
set_property PACKAGE_PIN D9 [get_ports r]
set_property PACKAGE_PIN H5 [get_ports q]

set_property IOSTANDARD LVCMOS33 [get_ports clk]
set_property IOSTANDARD LVCMOS33 [get_ports d]
Expand Down
9 changes: 9 additions & 0 deletions fpga_interchange/examples/tests/ff/arty35t.xdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set_property PACKAGE_PIN E3 [get_ports clk]
set_property PACKAGE_PIN A8 [get_ports d]
set_property PACKAGE_PIN D9 [get_ports r]
set_property PACKAGE_PIN H5 [get_ports q]

set_property IOSTANDARD LVCMOS33 [get_ports clk]
set_property IOSTANDARD LVCMOS33 [get_ports d]
set_property IOSTANDARD LVCMOS33 [get_ports r]
set_property IOSTANDARD LVCMOS33 [get_ports q]
19 changes: 4 additions & 15 deletions fpga_interchange/examples/tests/lut/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
add_interchange_test(
name lut_basys3
add_interchange_group_test(
name lut
family ${family}
device xc7a35t
package cpg236
board_list basys3 arty35t arty100t
tcl run.tcl
xdc lut_basys3.xdc
sources lut.v
)

add_interchange_test(
name lut_arty
family ${family}
device xc7a35t
package csg324
tcl run.tcl
xdc lut_arty.xdc
sources lut.v
output_fasm
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set_property PACKAGE_PIN N16 [get_ports i0]
set_property PACKAGE_PIN N15 [get_ports i1]
set_property PACKAGE_PIN M17 [get_ports o]
set_property PACKAGE_PIN A8 [get_ports i0]
set_property PACKAGE_PIN C11 [get_ports i1]
set_property PACKAGE_PIN H5 [get_ports o]

set_property IOSTANDARD LVCMOS33 [get_ports i0]
set_property IOSTANDARD LVCMOS33 [get_ports i1]
Expand Down
7 changes: 7 additions & 0 deletions fpga_interchange/examples/tests/lut/arty35t.xdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
set_property PACKAGE_PIN A8 [get_ports i0]
set_property PACKAGE_PIN C11 [get_ports i1]
set_property PACKAGE_PIN H5 [get_ports o]

set_property IOSTANDARD LVCMOS33 [get_ports i0]
set_property IOSTANDARD LVCMOS33 [get_ports i1]
set_property IOSTANDARD LVCMOS33 [get_ports o]