Skip to content

Commit e8feae4

Browse files
ThVergolofk
authored andcommitted
tests: add tests for untested flows and flow-API tools
Add tests using the golden-file harness for the previously untested flow-API tools ghdl, sv2v, vpr, icetime and sandpipersaas, and for the previously untested flows icestorm, vivado, vpr, gowin and efinity. The flow test fixture gains a paramtypes argument (defaulting to the previous behaviour) since the gowin flow rejects vlogparam/vlogdefine parameters. The f4pga flow is left untested since its configure_flow still returns the legacy list-of-tuples flow description, which the current Edaflow base class cannot consume.
1 parent 6c1afd6 commit e8feae4

38 files changed

Lines changed: 1059 additions & 1 deletion

tests/edalize_flow_common.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,15 @@ def _flow_fixture(
4949
toplevel="top_module",
5050
ref_subdir="",
5151
config_files=[],
52+
paramtypes=["plusarg", "vlogdefine", "vlogparam"],
5253
):
5354

54-
edam = get_edam(flow_options=flow_options, files=files, toplevel=toplevel)
55+
edam = get_edam(
56+
flow_options=flow_options,
57+
files=files,
58+
toplevel=toplevel,
59+
paramtypes=paramtypes,
60+
)
5561
ff = FlowFixture(flow_name, edam, tmp_path, ref_subdir)
5662

5763
# ff.flow.work_root = tmp_path

tests/flows/efinity/Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#Auto generated by Edalize
2+
3+
all: post_build
4+
5+
pre_build:
6+
7+
outflow/design.bit: sdc_file sv_file.sv vlog_file.v vlog_with_define.v vlog05_file.v vlog_incfile vhdl_file.vhd vhdl_lfile vhdl2008_file another_sv_file.sv | pre_build
8+
$(EDALIZE_LAUNCHER) env EFXPT_HOME=path/to/efinity/intallation/pt EFXPGM_HOME=path/to/efinity/intallation/pgm path/to/efinity/intallation/bin/python3 path/to/efinity/intallation/scripts/efx_run.py --prj design.xml --flow compile
9+
10+
post_build: outflow/design.bit
11+
12+
pre_run:
13+
14+
run: pre_run
15+
16+
post_run: run

tests/flows/efinity/design.xml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<efx:project name="design" description="" last_change_date="" location="" sw_version="" xmlns:efx="http://www.efinixinc.com/enf_proj" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.efinixinc.com/enf_proj enf_proj.xsd">
3+
<efx:device_info>
4+
<efx:family name="Trion"/><efx:device name="T8F81"/><efx:timing_model name="C2"/> </efx:device_info>
5+
<efx:design_info def_veri_version="verilog_2k" def_vhdl_version="vhdl_2008">
6+
<efx:top_module name="top_module"/> <efx:design_file name="sv_file.sv" version="sv_09"/>
7+
<efx:design_file name="vlog_file.v" version=""/>
8+
<efx:design_file name="vlog_with_define.v" version=""/>
9+
<efx:design_file name="vlog05_file.v" version=""/>
10+
<efx:design_file name="vlog_incfile" version=""/>
11+
<efx:design_file name="vhdl_file.vhd" version=""/>
12+
<efx:design_file name="vhdl_lfile" version=""/>
13+
<efx:design_file name="vhdl2008_file" version=""/>
14+
<efx:design_file name="another_sv_file.sv" version="sv_09"/>
15+
<efx:top_vhdl_arch name=""/>
16+
</efx:design_info>
17+
<efx:package_info>
18+
<efx:package name=""/>
19+
</efx:package_info>
20+
<efx:constraint_info>
21+
<efx:sdc_file name="sdc_file" />
22+
</efx:constraint_info>
23+
<efx:sim_info/>
24+
<efx:misc_info/>
25+
<efx:ip_info/>
26+
<efx:synthesis tool_name="efx_map">
27+
<efx:param name="work_dir" value="work_syn" value_type="e_string"/>
28+
<efx:param name="write_efx_verilog" value="on" value_type="e_bool"/>
29+
<efx:param name="seq_opt" value="0" value_type="e_option"/>
30+
<efx:dynparam name="vlogparam_bool" value="True"/>
31+
<efx:dynparam name="vlogparam_int" value="42"/>
32+
<efx:dynparam name="vlogparam_str" value="hello"/>
33+
<efx:defmacro name="vlogdefine_bool" value="True"/>
34+
<efx:defmacro name="vlogdefine_int" value="42"/>
35+
<efx:defmacro name="vlogdefine_str" value="hello"/>
36+
</efx:synthesis>
37+
<efx:place_and_route tool_name="efx_pnr">
38+
<efx:param name="work_dir" value="work_pnr" value_type="e_string" />
39+
<efx:param name="verbose" value="off" value_type="e_bool" />
40+
<efx:param name="load_delaym" value="on" value_type="e_bool"/>
41+
</efx:place_and_route>
42+
<efx:bitstream_generation tool_name="efx_pgm">
43+
<efx:param name="mode" value="active" value_type="e_string"/>
44+
<efx:param name="width" value="1" value_type="e_string"/>
45+
<!-- on, off, smart -->
46+
<efx:param name="enable_roms" value="smart" value_type="e_option"/>
47+
<efx:param name="spi_low_power_mode" value="on" value_type="e_bool"/>
48+
<efx:param name="io_weak_pullup" value="on" value_type="e_bool"/>
49+
<efx:param name="oscillator_clock_divider" value="DIV8" value_type="e_option"/>
50+
<!-- on, off -->
51+
<efx:param name="bitstream_compression" value="on" value_type="e_bool"/>
52+
<!-- on, off -->
53+
<efx:param name="enable_external_master_clock" value="off" value_type="e_bool"/>
54+
<!-- posedge, negedge -->
55+
<efx:param name="active_capture_clk_edge" value="posedge" value_type="e_option"/>
56+
<efx:param name="jtag_usercode" value="0xFFFFFFFF" value_type="e_string"/>
57+
<!-- on, off -->
58+
<efx:param name="release_tri_then_reset" value="on" value_type="e_bool"/>
59+
</efx:bitstream_generation>
60+
<efx:debugger>
61+
<efx:param name="work_dir" value="work_dbg" value_type="e_string" />
62+
<efx:param name="auto_instantiation" value="off" value_type="e_bool" />
63+
<efx:param name="profile" value="NONE" value_type="e_string" />
64+
</efx:debugger>
65+
<efx:security>
66+
<!-- on, off -->
67+
<efx:param name="randomize_iv_value" value="on" value_type="e_bool"/>
68+
<efx:param name="iv_value" value="" value_type="e_string"/>
69+
</efx:security>
70+
</efx:project>

tests/flows/gowin/Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#Auto generated by Edalize
2+
3+
all: post_build
4+
5+
pre_build:
6+
7+
pnr/design.fs: sdc_file sv_file.sv tcl_file.tcl vlog_file.v vlog_with_define.v vlog_incfile vhdl_file.vhd vhdl_lfile another_sv_file.sv | pre_build
8+
$(EDALIZE_LAUNCHER) gw_sh edalize_gowin_template.tcl
9+
10+
post_build: pnr/design.fs
11+
12+
pre_run:
13+
14+
run: pre_run
15+
16+
post_run: run
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
set_device GW1NR-LV9QN88PC6/I5
2+
3+
4+
add_file -type sdc "sdc_file"
5+
add_file -type verilog "sv_file.sv"
6+
source tcl_file.tcl
7+
add_file -type verilog "vlog_file.v"
8+
add_file -type verilog "vlog_with_define.v"
9+
add_file -type verilog "vlog_incfile"
10+
add_file -type VHDL_FILE "vhdl_file.vhd"
11+
add_file -type VHDL_FILE "vhdl_lfile"
12+
set_file_prop -lib libx "vhdl_lfile"
13+
add_file -type verilog "another_sv_file.sv"
14+
15+
set_option -top_module top_module
16+
set_option -vhdl_std vhd2008
17+
set_option -verilog_std sysv2017
18+
19+
20+
21+
run syn
22+
run pnr

tests/flows/icestorm/Makefile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#Auto generated by Edalize
2+
3+
all: post_build
4+
5+
synth: design.json
6+
7+
bitstream: design.bin
8+
9+
pre_build:
10+
11+
design.json: edalize_yosys_template.tcl sv_file.sv tcl_file.tcl vlog_file.v vlog_with_define.v vlog05_file.v vlog_incfile another_sv_file.sv | pre_build
12+
$(EDALIZE_LAUNCHER) yosys -l yosys.log -p 'tcl edalize_yosys_template.tcl'
13+
14+
design.asc: design.json
15+
$(EDALIZE_LAUNCHER) nextpnr-ice40 -l next.log --pcf pcf_file.pcf --json design.json --asc design.asc
16+
17+
build-gui: design.json
18+
$(EDALIZE_LAUNCHER) nextpnr-ice40 -l next.log --pcf pcf_file.pcf --json design.json --asc design.asc --gui
19+
20+
design.bin: design.asc
21+
$(EDALIZE_LAUNCHER) icepack design.asc design.bin
22+
23+
design.tim: design.asc
24+
$(EDALIZE_LAUNCHER) icetime -r design.tim design.asc
25+
26+
timing: design.tim
27+
28+
design.stat: design.asc
29+
$(EDALIZE_LAUNCHER) icebox_stat design.asc design.stat
30+
31+
stats: design.stat
32+
33+
post_build: bitstream
34+
35+
pre_run:
36+
37+
run: pre_run
38+
39+
post_run: run

tests/flows/vivado/Makefile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#Auto generated by Edalize
2+
3+
all: post_build
4+
5+
pre_build:
6+
7+
design.xpr design.xpr.marker: design.tcl sdc_file sv_file.sv tcl_file.tcl vlog_file.v vlog_with_define.v vlog05_file.v vlog_incfile vhdl_file.vhd vhdl_lfile vhdl2008_file xci_file.xci xdc_file.xdc bootrom.mem another_sv_file.sv | pre_build
8+
$(EDALIZE_LAUNCHER) vivado -notrace -mode batch -source design.tcl
9+
10+
design.v design.edn: design_synth.tcl design_netlist.tcl design.xpr.marker | pre_build design.xpr
11+
$(EDALIZE_LAUNCHER) vivado -notrace -mode batch -source design_synth.tcl design_netlist.tcl design.xpr
12+
13+
synth: design.v design.edn | pre_build
14+
15+
design.bit: design_synth.tcl design_run.tcl design.xpr.marker | pre_build design.xpr
16+
$(EDALIZE_LAUNCHER) vivado -notrace -mode batch -source design_synth.tcl design_run.tcl design.xpr
17+
18+
build-gui: design.xpr | pre_build
19+
$(EDALIZE_LAUNCHER) vivado design.xpr
20+
21+
pgm: design_pgm.tcl design.bit | pre_build
22+
$(EDALIZE_LAUNCHER) vivado -quiet -nolog -notrace -mode batch -source design_pgm.tcl -tclargs xc7a35tcsg324-1 design.bit
23+
24+
post_build: design.bit
25+
26+
pre_run:
27+
28+
run: pre_run
29+
30+
post_run: run

tests/flows/vivado/design.tcl

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Auto-generated project tcl file
2+
3+
4+
create_project design -force
5+
6+
set_property part xc7a35tcsg324-1 [current_project]
7+
8+
#Default since Vivado 2016.1
9+
set_param project.enableVHDL2008 1
10+
set_property generic {vlogparam_bool=1 vlogparam_int=42 vlogparam_str=hello } [get_filesets sources_1]
11+
12+
set_property verilog_define {vlogdefine_bool=1 vlogdefine_int=42 vlogdefine_str=hello } [get_filesets sources_1]
13+
read_xdc -unmanaged {sdc_file}
14+
read_verilog -sv {sv_file.sv}
15+
source {tcl_file.tcl}
16+
read_verilog {vlog_file.v}
17+
read_verilog {vlog_with_define.v}
18+
read_verilog {vlog05_file.v}
19+
read_vhdl {vhdl_file.vhd}
20+
read_vhdl -library libx {vhdl_lfile}
21+
read_vhdl -vhdl2008 {vhdl2008_file}
22+
read_ip {xci_file.xci}
23+
read_xdc {xdc_file.xdc}
24+
read_mem {bootrom.mem}
25+
read_verilog -sv {another_sv_file.sv}
26+
27+
set_property include_dirs [list . .] [get_filesets sources_1]
28+
set_property top top_module [current_fileset]
29+
set_property source_mgmt_mode None [current_project]
30+
31+
# Vivado treats IP integrator entities as nested sub-designs and prevents core
32+
# generation from the base project in non-GUI flow raising
33+
# ERROR: [Vivado 12-3563] The Nested sub-design '...xci' can only be generated
34+
# by its parent sub-design.
35+
# These cores are created and generated separately by Tcl scripts.
36+
# exported from IP integrator. To prevent this error, Ip cores that are part of
37+
# a block design must be excluded from generation at the top level. This can be
38+
# done using `get_ips -filter {SCOPE !~ "*.bd"}`. In Vivado >= 2019.1 the same
39+
# can be achieved using `get_ips -exclude_bd_ips`
40+
upgrade_ip [get_ips -filter {SCOPE !~ "*.bd"}]
41+
generate_target all [get_ips -filter {SCOPE !~ "*.bd"}]
42+
43+
# Update marker file for Make. (Run the subsequent jobs only if the marker has been updated)
44+
# This prevents the synthesis from being triggered again if Vivado randomly updates the XPR file's timestamp.
45+
set marker_file [open "design.xpr.marker" w]
46+
puts $marker_file [clock seconds]
47+
close $marker_file
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
open_run synth_1
2+
write_edif [current_project].edn
3+
write_verilog [current_project].v

tests/flows/vivado/design_pgm.tcl

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Auto-generated program tcl file
2+
3+
set part [lindex $argv 0]
4+
set bitstream [lindex $argv 1]
5+
6+
7+
if {[info exists env(HW_TARGET)]} {
8+
set explicit_hw_target $env(HW_TARGET)
9+
} else {
10+
set explicit_hw_target ""
11+
}
12+
if {[info exists env(JTAG_FREQ)]} {
13+
set jtag_freq $env(JTAG_FREQ)
14+
} else {
15+
set jtag_freq ""
16+
}
17+
18+
puts "FuseSoC Xilinx FPGA Programming Tool"
19+
puts "===================================="
20+
puts ""
21+
puts "INFO: Programming part $part with bitstream $bitstream"
22+
if { $explicit_hw_target != "" } {
23+
puts "INFO: Programming target $explicit_hw_target"
24+
}
25+
26+
# Connect to Xilinx Hardware Server
27+
if { [ catch { open_hw_manager } ] } { open_hw }
28+
connect_hw_server
29+
30+
if { $explicit_hw_target == "" } {
31+
set hw_targets [get_hw_targets]
32+
} else {
33+
set hw_targets [get_hw_targets $explicit_hw_target]
34+
}
35+
36+
if { [llength $hw_targets] == 0 } {
37+
if { $explicit_hw_target == "" } {
38+
puts "ERROR: Failed to find any targets"
39+
} else {
40+
puts "ERROR: Failed to find target: $target"
41+
}
42+
}
43+
44+
# Find the first target and device that contains a FPGA $part.
45+
set hw_device_found 0
46+
foreach hw_target $hw_targets {
47+
puts "INFO: Trying to use hardware target $hw_target"
48+
current_hw_target $hw_target
49+
50+
# Open hardware target
51+
# The Vivado hardware server isn't always able to reliably open a target.
52+
# Try three times before giving up.
53+
set hw_target_opened 0
54+
for {set open_hw_target_try 1} {$open_hw_target_try <= 3} {incr open_hw_target_try} {
55+
if {[catch {open_hw_target} res_open_hw_target] == 0} {
56+
set hw_target_opened 1
57+
break
58+
}
59+
}
60+
if { $hw_target_opened == 0 } {
61+
puts "WARNING: Unable to open hardware target $hw_target after " \
62+
"$open_hw_target_try tries. Skipping."
63+
continue
64+
}
65+
puts "INFO: Opened hardware target $hw_target on try $open_hw_target_try."
66+
67+
# Iterate through all devices and find one which contains $part
68+
foreach { hw_device } [get_hw_devices] {
69+
if { [string first [get_property PART $hw_device] $part] == 0 } {
70+
puts "INFO: Found $part as part of $hw_device."
71+
current_hw_device $hw_device
72+
set hw_device_found 1
73+
break
74+
}
75+
}
76+
77+
if { $hw_device_found == 1 } {
78+
break
79+
} else {
80+
# Close currently tried device, and try with next one.
81+
puts "INFO: Part not found as part of $hw_target. Trying next device."
82+
close_hw_target
83+
}
84+
}
85+
if { $hw_device_found == 0 } {
86+
puts "ERROR: None of the hardware targets included a $part FPGA part. \
87+
Check cables and ensure that jumpers are correct for JTAG programming."
88+
exit 1
89+
}
90+
puts "INFO: Programming bitstream to device $hw_device on target $hw_target."
91+
92+
# Do the programming
93+
current_hw_device $hw_device
94+
set_property PROGRAM.FILE $bitstream [current_hw_device]
95+
if {$jtag_freq != ""} {
96+
set_property PARAM.FREQUENCY $jtag_freq [get_hw_targets $hw_target]
97+
}
98+
program_hw_devices [current_hw_device]
99+
100+
# Disconnect from Xilinx Hardware Server
101+
close_hw_target
102+
disconnect_hw_server
103+
104+
puts ""
105+
puts "INFO: SUCCESS! FPGA $part successfully programmed with bitstream $bitstream."

0 commit comments

Comments
 (0)