aboutsummaryrefslogtreecommitdiffstats
path: root/fpga_interchange/examples
diff options
context:
space:
mode:
authorAlessandro Comodi <acomodi@antmicro.com>2021-03-12 13:53:09 +0100
committerAlessandro Comodi <acomodi@antmicro.com>2021-03-16 15:39:01 +0100
commit77ffdd7fd4e90e0da43e81b1f5e021b08ee64a9f (patch)
tree143ce61b476d33d2b0ddd63d5beb872f5d077949 /fpga_interchange/examples
parent6a08b0d733e928e5e7c180dee21829f7db2d9ccf (diff)
downloadnextpnr-77ffdd7fd4e90e0da43e81b1f5e021b08ee64a9f.tar.gz
nextpnr-77ffdd7fd4e90e0da43e81b1f5e021b08ee64a9f.tar.bz2
nextpnr-77ffdd7fd4e90e0da43e81b1f5e021b08ee64a9f.zip
fpga_interchange: tests: add cmake functions
Also move all tests in a tests directory Signed-off-by: Alessandro Comodi <acomodi@antmicro.com>
Diffstat (limited to 'fpga_interchange/examples')
-rw-r--r--fpga_interchange/examples/const_wire/Makefile8
-rw-r--r--fpga_interchange/examples/counter/Makefile8
-rw-r--r--fpga_interchange/examples/ff/Makefile8
-rw-r--r--fpga_interchange/examples/lut/Makefile8
-rw-r--r--fpga_interchange/examples/tests.cmake115
-rw-r--r--fpga_interchange/examples/tests/CMakeLists.txt5
-rw-r--r--fpga_interchange/examples/tests/const_wire/CMakeLists.txt17
-rw-r--r--fpga_interchange/examples/tests/const_wire/run.tcl (renamed from fpga_interchange/examples/wire/run.tcl)4
-rw-r--r--fpga_interchange/examples/tests/const_wire/wire.v (renamed from fpga_interchange/examples/const_wire/wire.v)0
-rw-r--r--fpga_interchange/examples/tests/const_wire/wire.xdc (renamed from fpga_interchange/examples/const_wire/wire.xdc)0
-rw-r--r--fpga_interchange/examples/tests/counter/CMakeLists.txt17
-rw-r--r--fpga_interchange/examples/tests/counter/counter.v (renamed from fpga_interchange/examples/counter/counter.v)0
-rw-r--r--fpga_interchange/examples/tests/counter/counter.xdc (renamed from fpga_interchange/examples/counter/counter.xdc)0
-rw-r--r--fpga_interchange/examples/tests/counter/run.tcl (renamed from fpga_interchange/examples/counter/run.tcl)4
-rw-r--r--fpga_interchange/examples/tests/ff/CMakeLists.txt17
-rw-r--r--fpga_interchange/examples/tests/ff/ff.v (renamed from fpga_interchange/examples/ff/ff.v)0
-rw-r--r--fpga_interchange/examples/tests/ff/ff.xdc (renamed from fpga_interchange/examples/ff/ff.xdc)0
-rw-r--r--fpga_interchange/examples/tests/ff/run.tcl (renamed from fpga_interchange/examples/const_wire/run.tcl)4
-rw-r--r--fpga_interchange/examples/tests/lut/CMakeLists.txt17
-rw-r--r--fpga_interchange/examples/tests/lut/lut.v (renamed from fpga_interchange/examples/lut/lut.v)0
-rw-r--r--fpga_interchange/examples/tests/lut/lut.xdc (renamed from fpga_interchange/examples/lut/lut.xdc)0
-rw-r--r--fpga_interchange/examples/tests/lut/run.tcl (renamed from fpga_interchange/examples/ff/run.tcl)4
-rw-r--r--fpga_interchange/examples/tests/wire/CMakeLists.txt17
-rw-r--r--fpga_interchange/examples/tests/wire/run.tcl (renamed from fpga_interchange/examples/lut/run.tcl)4
-rw-r--r--fpga_interchange/examples/tests/wire/wire.v (renamed from fpga_interchange/examples/wire/wire.v)0
-rw-r--r--fpga_interchange/examples/tests/wire/wire.xdc (renamed from fpga_interchange/examples/wire/wire.xdc)0
-rw-r--r--fpga_interchange/examples/wire/Makefile8
27 files changed, 215 insertions, 50 deletions
diff --git a/fpga_interchange/examples/const_wire/Makefile b/fpga_interchange/examples/const_wire/Makefile
deleted file mode 100644
index 49194f53..00000000
--- a/fpga_interchange/examples/const_wire/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-DESIGN := wire
-DESIGN_TOP := top
-PACKAGE := csg324
-
-include ../template.mk
-
-build/wire.json: wire.v | build
- yosys -c run.tcl
diff --git a/fpga_interchange/examples/counter/Makefile b/fpga_interchange/examples/counter/Makefile
deleted file mode 100644
index 27d20cdf..00000000
--- a/fpga_interchange/examples/counter/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-DESIGN := counter
-DESIGN_TOP := top
-PACKAGE := cpg236
-
-include ../template.mk
-
-build/counter.json: counter.v | build
- yosys -c run.tcl
diff --git a/fpga_interchange/examples/ff/Makefile b/fpga_interchange/examples/ff/Makefile
deleted file mode 100644
index c6118ff7..00000000
--- a/fpga_interchange/examples/ff/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-DESIGN := ff
-DESIGN_TOP := top
-PACKAGE := csg324
-
-include ../template.mk
-
-build/ff.json: ff.v | build
- yosys -c run.tcl
diff --git a/fpga_interchange/examples/lut/Makefile b/fpga_interchange/examples/lut/Makefile
deleted file mode 100644
index 54fc8994..00000000
--- a/fpga_interchange/examples/lut/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-DESIGN := lut
-DESIGN_TOP := top
-PACKAGE := csg324
-
-include ../template.mk
-
-build/lut.json: lut.v | build
- yosys -c run.tcl
diff --git a/fpga_interchange/examples/tests.cmake b/fpga_interchange/examples/tests.cmake
new file mode 100644
index 00000000..a550fb8f
--- /dev/null
+++ b/fpga_interchange/examples/tests.cmake
@@ -0,0 +1,115 @@
+function(add_interchange_test)
+ # ~~~
+ # add_interchange_test(
+ # name <name>
+ # part <part>
+ # part <package>
+ # tcl <tcl>
+ # xdc <xdc>
+ # top <top name>
+ # sources <sources list>
+ # )
+ # ~~~
+
+ set(options)
+ set(oneValueArgs name part package tcl xdc top)
+ set(multiValueArgs sources)
+
+ cmake_parse_arguments(
+ add_interchange_test
+ "${options}"
+ "${oneValueArgs}"
+ "${multiValueArgs}"
+ ${ARGN}
+ )
+
+ set(name ${add_interchange_test_name})
+ set(part ${add_interchange_test_part})
+ set(package ${add_interchange_test_package})
+ 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(sources)
+ foreach(source ${add_interchange_test_sources})
+ list(APPEND sources ${CMAKE_CURRENT_SOURCE_DIR}/${source})
+ endforeach()
+
+ if (NOT DEFINED top)
+ # Setting default top value
+ set(top "top")
+ endif()
+
+ # Synthesis
+ set(synth_json ${CMAKE_CURRENT_BINARY_DIR}/${name}.json)
+ add_custom_command(
+ OUTPUT ${synth_json}
+ COMMAND
+ SOURCES=${sources}
+ OUT_JSON=${synth_json}
+ yosys -c ${tcl}
+ DEPENDS ${sources}
+ )
+
+ add_custom_target(test-${family}-${name}-json DEPENDS ${synth_json})
+
+ # Logical Netlist
+ set(device_target constraints-luts-${part}-device)
+ get_property(device_loc TARGET constraints-luts-${part}-device PROPERTY LOCATION)
+
+ set(netlist ${CMAKE_CURRENT_BINARY_DIR}/${name}.netlist)
+ add_custom_command(
+ OUTPUT ${netlist}
+ COMMAND
+ python3 -mfpga_interchange.yosys_json
+ --schema_dir ${INTERCHANGE_SCHEMA_PATH}
+ --device ${device_loc}
+ --top ${top}
+ ${synth_json}
+ ${netlist}
+ DEPENDS
+ ${synth_json}
+ ${device_target}
+ )
+
+ add_custom_target(test-${family}-${name}-netlist DEPENDS ${netlist})
+
+ set(chipdb_target chipdb-${part}-bba)
+
+ # Physical Netlist
+ set(phys ${CMAKE_CURRENT_BINARY_DIR}/${name}.phys)
+ add_custom_command(
+ OUTPUT ${phys}
+ COMMAND
+ nextpnr-fpga_interchange
+ --chipdb ${chipdb_dir}/chipdb-${part}.bba
+ --xdc ${xdc}
+ --netlist ${netlist}
+ --phys ${phys}
+ --package ${package}
+ DEPENDS
+ ${netlist}
+ ${chipdb_target}
+ )
+
+ add_custom_target(test-${family}-${name}-phys DEPENDS ${phys})
+
+ set(dcp ${CMAKE_CURRENT_BINARY_DIR}/${name}.dcp)
+ add_custom_command(
+ OUTPUT ${dcp}
+ COMMAND
+ RAPIDWRIGHT_PATH=${RAPIDWRIGHT_PATH}
+ ${RAPIDWRIGHT_PATH}/scripts/invoke_rapidwright.sh
+ com.xilinx.rapidwright.interchange.PhysicalNetlistToDcp
+ ${netlist} ${phys} ${xdc} ${dcp}
+ DEPENDS
+ ${phys}
+ ${netlist}
+ )
+
+ add_custom_target(test-${family}-${name}-dcp DEPENDS ${dcp})
+ add_dependencies(all-${family}-tests test-${family}-${name}-dcp)
+endfunction()
+
+add_custom_target(all-${family}-tests)
+add_subdirectory(${family}/examples/tests)
diff --git a/fpga_interchange/examples/tests/CMakeLists.txt b/fpga_interchange/examples/tests/CMakeLists.txt
new file mode 100644
index 00000000..49b5b587
--- /dev/null
+++ b/fpga_interchange/examples/tests/CMakeLists.txt
@@ -0,0 +1,5 @@
+add_subdirectory(wire)
+add_subdirectory(const_wire)
+add_subdirectory(counter)
+add_subdirectory(ff)
+add_subdirectory(lut)
diff --git a/fpga_interchange/examples/tests/const_wire/CMakeLists.txt b/fpga_interchange/examples/tests/const_wire/CMakeLists.txt
new file mode 100644
index 00000000..163f4a97
--- /dev/null
+++ b/fpga_interchange/examples/tests/const_wire/CMakeLists.txt
@@ -0,0 +1,17 @@
+add_interchange_test(
+ name const_wire_basys3
+ part xc7a35tcpg236-1
+ package cpg236
+ tcl run.tcl
+ xdc wire.xdc
+ sources wire.v
+)
+
+add_interchange_test(
+ name const_wire_arty
+ part xc7a35tcsg324-1
+ package csg324
+ tcl run.tcl
+ xdc wire.xdc
+ sources wire.v
+)
diff --git a/fpga_interchange/examples/wire/run.tcl b/fpga_interchange/examples/tests/const_wire/run.tcl
index 9127be20..b8d0df72 100644
--- a/fpga_interchange/examples/wire/run.tcl
+++ b/fpga_interchange/examples/tests/const_wire/run.tcl
@@ -1,6 +1,6 @@
yosys -import
-read_verilog wire.v
+read_verilog $::env(SOURCES)
synth_xilinx -nolutram -nowidelut -nosrl -nocarry -nodsp
@@ -11,4 +11,4 @@ opt_clean
setundef -zero -params
-write_json build/wire.json
+write_json $::env(OUT_JSON)
diff --git a/fpga_interchange/examples/const_wire/wire.v b/fpga_interchange/examples/tests/const_wire/wire.v
index 5b1ab692..5b1ab692 100644
--- a/fpga_interchange/examples/const_wire/wire.v
+++ b/fpga_interchange/examples/tests/const_wire/wire.v
diff --git a/fpga_interchange/examples/const_wire/wire.xdc b/fpga_interchange/examples/tests/const_wire/wire.xdc
index 0d96fc45..0d96fc45 100644
--- a/fpga_interchange/examples/const_wire/wire.xdc
+++ b/fpga_interchange/examples/tests/const_wire/wire.xdc
diff --git a/fpga_interchange/examples/tests/counter/CMakeLists.txt b/fpga_interchange/examples/tests/counter/CMakeLists.txt
new file mode 100644
index 00000000..e105a86a
--- /dev/null
+++ b/fpga_interchange/examples/tests/counter/CMakeLists.txt
@@ -0,0 +1,17 @@
+add_interchange_test(
+ name counter_basys3
+ part xc7a35tcpg236-1
+ package cpg236
+ tcl run.tcl
+ xdc counter.xdc
+ sources counter.v
+)
+
+add_interchange_test(
+ name counter_arty
+ part xc7a35tcsg324-1
+ package csg324
+ tcl run.tcl
+ xdc counter.xdc
+ sources counter.v
+)
diff --git a/fpga_interchange/examples/counter/counter.v b/fpga_interchange/examples/tests/counter/counter.v
index 00f52a20..00f52a20 100644
--- a/fpga_interchange/examples/counter/counter.v
+++ b/fpga_interchange/examples/tests/counter/counter.v
diff --git a/fpga_interchange/examples/counter/counter.xdc b/fpga_interchange/examples/tests/counter/counter.xdc
index 7cbe67f6..7cbe67f6 100644
--- a/fpga_interchange/examples/counter/counter.xdc
+++ b/fpga_interchange/examples/tests/counter/counter.xdc
diff --git a/fpga_interchange/examples/counter/run.tcl b/fpga_interchange/examples/tests/counter/run.tcl
index 245aab04..7cd9f10f 100644
--- a/fpga_interchange/examples/counter/run.tcl
+++ b/fpga_interchange/examples/tests/counter/run.tcl
@@ -1,6 +1,6 @@
yosys -import
-read_verilog counter.v
+read_verilog $::env(SOURCES)
synth_xilinx -nolutram -nowidelut -nosrl -nocarry -nodsp
techmap -map ../remap.v
@@ -12,4 +12,4 @@ opt_clean
setundef -zero -params
-write_json build/counter.json
+write_json $::env(OUT_JSON)
diff --git a/fpga_interchange/examples/tests/ff/CMakeLists.txt b/fpga_interchange/examples/tests/ff/CMakeLists.txt
new file mode 100644
index 00000000..66074c64
--- /dev/null
+++ b/fpga_interchange/examples/tests/ff/CMakeLists.txt
@@ -0,0 +1,17 @@
+add_interchange_test(
+ name ff_basys3
+ part xc7a35tcpg236-1
+ package cpg236
+ tcl run.tcl
+ xdc ff.xdc
+ sources ff.v
+)
+
+add_interchange_test(
+ name ff_arty
+ part xc7a35tcsg324-1
+ package csg324
+ tcl run.tcl
+ xdc ff.xdc
+ sources ff.v
+)
diff --git a/fpga_interchange/examples/ff/ff.v b/fpga_interchange/examples/tests/ff/ff.v
index 1c271042..1c271042 100644
--- a/fpga_interchange/examples/ff/ff.v
+++ b/fpga_interchange/examples/tests/ff/ff.v
diff --git a/fpga_interchange/examples/ff/ff.xdc b/fpga_interchange/examples/tests/ff/ff.xdc
index 3c132f1d..3c132f1d 100644
--- a/fpga_interchange/examples/ff/ff.xdc
+++ b/fpga_interchange/examples/tests/ff/ff.xdc
diff --git a/fpga_interchange/examples/const_wire/run.tcl b/fpga_interchange/examples/tests/ff/run.tcl
index 9127be20..b8d0df72 100644
--- a/fpga_interchange/examples/const_wire/run.tcl
+++ b/fpga_interchange/examples/tests/ff/run.tcl
@@ -1,6 +1,6 @@
yosys -import
-read_verilog wire.v
+read_verilog $::env(SOURCES)
synth_xilinx -nolutram -nowidelut -nosrl -nocarry -nodsp
@@ -11,4 +11,4 @@ opt_clean
setundef -zero -params
-write_json build/wire.json
+write_json $::env(OUT_JSON)
diff --git a/fpga_interchange/examples/tests/lut/CMakeLists.txt b/fpga_interchange/examples/tests/lut/CMakeLists.txt
new file mode 100644
index 00000000..4ec74b3d
--- /dev/null
+++ b/fpga_interchange/examples/tests/lut/CMakeLists.txt
@@ -0,0 +1,17 @@
+add_interchange_test(
+ name lut_basys3
+ part xc7a35tcpg236-1
+ package cpg236
+ tcl run.tcl
+ xdc lut.xdc
+ sources lut.v
+)
+
+add_interchange_test(
+ name lut_arty
+ part xc7a35tcsg324-1
+ package csg324
+ tcl run.tcl
+ xdc lut.xdc
+ sources lut.v
+)
diff --git a/fpga_interchange/examples/lut/lut.v b/fpga_interchange/examples/tests/lut/lut.v
index ca18e665..ca18e665 100644
--- a/fpga_interchange/examples/lut/lut.v
+++ b/fpga_interchange/examples/tests/lut/lut.v
diff --git a/fpga_interchange/examples/lut/lut.xdc b/fpga_interchange/examples/tests/lut/lut.xdc
index 4f390f25..4f390f25 100644
--- a/fpga_interchange/examples/lut/lut.xdc
+++ b/fpga_interchange/examples/tests/lut/lut.xdc
diff --git a/fpga_interchange/examples/ff/run.tcl b/fpga_interchange/examples/tests/lut/run.tcl
index 726d86eb..b8d0df72 100644
--- a/fpga_interchange/examples/ff/run.tcl
+++ b/fpga_interchange/examples/tests/lut/run.tcl
@@ -1,6 +1,6 @@
yosys -import
-read_verilog ff.v
+read_verilog $::env(SOURCES)
synth_xilinx -nolutram -nowidelut -nosrl -nocarry -nodsp
@@ -11,4 +11,4 @@ opt_clean
setundef -zero -params
-write_json build/ff.json
+write_json $::env(OUT_JSON)
diff --git a/fpga_interchange/examples/tests/wire/CMakeLists.txt b/fpga_interchange/examples/tests/wire/CMakeLists.txt
new file mode 100644
index 00000000..7736877f
--- /dev/null
+++ b/fpga_interchange/examples/tests/wire/CMakeLists.txt
@@ -0,0 +1,17 @@
+add_interchange_test(
+ name wire_basys3
+ part xc7a35tcpg236-1
+ package cpg236
+ tcl run.tcl
+ xdc wire.xdc
+ sources wire.v
+)
+
+add_interchange_test(
+ name wire_arty
+ part xc7a35tcsg324-1
+ package csg324
+ tcl run.tcl
+ xdc wire.xdc
+ sources wire.v
+)
diff --git a/fpga_interchange/examples/lut/run.tcl b/fpga_interchange/examples/tests/wire/run.tcl
index 1edd8bb7..b8d0df72 100644
--- a/fpga_interchange/examples/lut/run.tcl
+++ b/fpga_interchange/examples/tests/wire/run.tcl
@@ -1,6 +1,6 @@
yosys -import
-read_verilog lut.v
+read_verilog $::env(SOURCES)
synth_xilinx -nolutram -nowidelut -nosrl -nocarry -nodsp
@@ -11,4 +11,4 @@ opt_clean
setundef -zero -params
-write_json build/lut.json
+write_json $::env(OUT_JSON)
diff --git a/fpga_interchange/examples/wire/wire.v b/fpga_interchange/examples/tests/wire/wire.v
index 429d05ff..429d05ff 100644
--- a/fpga_interchange/examples/wire/wire.v
+++ b/fpga_interchange/examples/tests/wire/wire.v
diff --git a/fpga_interchange/examples/wire/wire.xdc b/fpga_interchange/examples/tests/wire/wire.xdc
index c923f0fc..c923f0fc 100644
--- a/fpga_interchange/examples/wire/wire.xdc
+++ b/fpga_interchange/examples/tests/wire/wire.xdc
diff --git a/fpga_interchange/examples/wire/Makefile b/fpga_interchange/examples/wire/Makefile
deleted file mode 100644
index 49194f53..00000000
--- a/fpga_interchange/examples/wire/Makefile
+++ /dev/null
@@ -1,8 +0,0 @@
-DESIGN := wire
-DESIGN_TOP := top
-PACKAGE := csg324
-
-include ../template.mk
-
-build/wire.json: wire.v | build
- yosys -c run.tcl