Commit ecc9e235 authored by Jens Korinth's avatar Jens Korinth
Browse files

WIP: Implement special synthesis optimization evaluation level

* level 42 activates a sweep search that iterates over
    - clock periods 0.5 - 5 (0.125 steps)
    - optimization levels 3 - 0
* it also logs the runtimes of each step and outputs them in a
  synthesis_runtimes.tsv file
* resulting WNS is logged in synthesis_results.tsv for each step
* useful for analysis of evaluation runs
* careful - regular evaluation is currently broken by the changes
parent 5d081bae
Pipeline #244 passed with stage
in 4 minutes and 13 seconds
......@@ -33,7 +33,6 @@ create_project -in_memory -part @@PART@@
# set parameters
set opt @@OPTIMIZATION@@
set synth_options "@@SYNTH_OPTIONS@@"
# add files
add_files @@SRC_FILES@@
......@@ -52,62 +51,123 @@ foreach script [list @@TCL_FILES@@] { source $script }
# find top
set top [lindex [find_top] 0]
# synthesize and optimize netlist
if {$opt >= 1} {
set synth_options "$synth_options -retiming -fanout_limit 400 -shreg_min_size 5"
}
if {$opt >= 2} {
set synth_options "$synth_options -fsm_extraction one_hot"
}
if {$opt >= 3} {
set synth_options "$synth_options -keep_equivalent_registers -resource_sharing off -no_lc"
}
puts synth_design \
-part @@PART@@ \
-top $top \
-mode out_of_context \
$synth_options
# read switching activity files (if any)
foreach saif [glob -nocomplain *.saif] {
read_saif $saif
}
# write design checkpoint
write_checkpoint -force @@SYNTH_CHECKPOINT@@
# set clock
set clock_ports [get_ports -filter {DIRECTION == IN && (NAME =~ *clk* || NAME =~ *CLK* || NAME =~ clock)}]
puts "clock_ports = $clock_ports"
create_clock -name clk -period @@PERIOD@@ $clock_ports
set_property HD.CLK_SRC BUFGCTRL_X0Y0 $clock_ports
# place and route
set opt_directive "RuntimeOptimized"
if {$opt >= 1} { set opt_directive "Default" }
if {$opt >= 2} { set opt_directive "Explore" }
opt_design -directive $opt_directive
set place_directive "RuntimeOptimized"
if {$opt >= 1} { set place_directive "Default" }
if {$opt >= 1} { set place_directive "Explore" }
place_design -directive $place_directive
set physopt1_directive "RuntimeOptimized"
if {$opt >= 1} { set physopt1_directive "Default" }
if {$opt >= 2} { set physopt1_directive "Explore" }
if {$opt >= 3} { set physopt1_directive "AggressiveExplore" }
phys_opt_design -directive $physopt1_directive
set route_directive "RuntimeOptimized"
if {$opt >= 1} { set route_directive "Default" }
if {$opt >= 2} { set route_directive "Explore" }
route_design
set physopt2_directive "Explore"
if {$opt > 2} { set physopt2_directive "AggressiveExplore" }
if {$opt >= 2} {
phys_opt_design -directive $physopt2_directive
set period @@PERIOD@@
if {@@OPTIMIZATION@@ == 42} {
set result_file [open [file join [file dirname "@@REPORTS_TIMING@@"] "synthesis_results.tsv"] "w+"]
puts $result_file "Target Period\tTarget F(MHz)\t\Opt\tWNS (ns)\tT (ns)\tF (ns)"
set runtimes_file [open [file join [file dirname "@@REPORTS_TIMING@@"] "synthesis_runtimes.tsv"] "w+"]
puts $runtimes_file "Target Period\tTarget F(Mhz)\tOpt\tPhase\tStart\t\End\tDuration (s)"
for {set period 0.5} {$period <= 5.0} {set period [expr $period + 0.125]} {
for {set opt 3} {$opt >= 0} {incr opt -1} {
set synth_start [clock seconds]
set synth_options [list {-part} {@@PART@@} {-top} $top {-mode} {out_of_context}]
lappend synth_options @@SYNTH_OPTIONS@@
# synthesize and optimize netlist
if {$opt >= 1} {
lappend synth_options {-retiming} {-fanout_limit} 400 {-shreg_min_size} 5 {-flatten_hierarchy} {full}
}
if {$opt >= 2} {
lappend synth_options {-fsm_extraction} {one_hot}
}
if {$opt >= 3} {
lappend synth_options {-keep_equivalent_registers} {-resource_sharing} {off} {-no_lc}
}
synth_design {*}$synth_options
set opt_start [clock seconds]
opt_design
set synth_finish [clock seconds]
set ur [file join [file dirname "@@REPORTS_UTILIZATION@@"] "synth_utilization_period${period}_opt${opt}.rpt"]
puts "writing utilization report $ur ..."
report_utilization -quiet -file $ur
set tr [file join [file dirname "@@REPORTS_TIMING@@"] "synth_timing_period${period}_opt${opt}.rpt"]
puts "writing timing report summary $tr ..."
report_timing_summary -quiet -file $tr
puts "synth_design for O$opt took [expr $synth_finish - $opt_start] sec, opt_design took [expr $opt_start - $synth_finish] sec."
puts $runtimes_file "$period\t[expr 1000.0/$period]\t$opt\tsynth_design\t$synth_start\t$opt_start\t[expr $opt_start - $synth_start]"
puts $runtimes_file "$period\t[expr 1000.0/$period]\t$opt\topt_design\t$opt_start\t$synth_finish\t[expr $synth_finish - $opt_start]"
puts $runtimes_file "$period\t[expr 1000.0/$period]\t$opt\ttotal_synth\t$synth_start\t$synth_finish\t[expr $synth_start - $synth_start]"
}
# write design checkpoint
write_checkpoint -force @@SYNTH_CHECKPOINT@@
# set clock
set clock_ports [get_ports -filter {DIRECTION == IN && (NAME =~ *clk* || NAME =~ *CLK* || NAME =~ clock)}]
puts "clock_ports = $clock_ports"
create_clock -name clk -period $period $clock_ports
#set_property HD.CLK_SRC BUFGCTRL_X0Y0 $clock_ports
set pnr_start [clock seconds]
# place and route
set opt_directive "RuntimeOptimized"
if {$opt >= 1} { set opt_directive "Default" }
if {$opt >= 2} { set opt_directive "Explore" }
puts "running opt_design -directive $opt_directive ..."
opt_design -directive $opt_directive
set opt_design_finish [clock seconds]
set place_directive "RuntimeOptimized"
if {$opt >= 1} { set place_directive "Default" }
if {$opt >= 1} { set place_directive "Explore" }
puts "running place_design -directive $place_directive ..."
place_design -directive $place_directive
set place_design_finish [clock seconds]
set physopt1_directive "RuntimeOptimized"
if {$opt >= 1} { set physopt1_directive "Default" }
if {$opt >= 2} { set physopt1_directive "Explore" }
if {$opt >= 3} { set physopt1_directive "AggressiveExplore" }
puts "running phys_opt_design -directive $physopt1_directive ..."
phys_opt_design -directive $physopt1_directive
set physopt1_finish [clock seconds]
set route_directive "RuntimeOptimized"
if {$opt >= 1} { set route_directive "Default" }
if {$opt >= 2} { set route_directive "Explore" }
puts "running route_design -directive $route_directive ..."
route_design -directive $route_directive
set route_design_finish [clock seconds]
set physopt2_directive "Explore"
if {$opt > 2} { set physopt2_directive "AggressiveExplore" }
if {$opt >= 2} {
puts "phys_opt_design -directive $physopt2_directive ..."
phys_opt_design -directive $physopt2_directive
set physopt2_finish [clock seconds]
}
set pnr_finish [clock seconds]
# report timing
set tr [file join [file dirname "@@REPORT_TIMING@@"] "pnr_timing_period${period}_opt${opt}.rpt"]
report_timing_summary -quiet -datasheet -file $tr
# report utilization
report_utilization -quiet -file [file join [file dirname "@@REPORT_UTILIZATION@@"] "pnr_utilization_period${period}_opt${opt}.rpt"]
set wns [tapasco::get_wns_from_timing_report $tr]
set clk [expr "$period - $wns"]
puts "O$opt RESULT: WNS = $wns PERIOD = $clk F = [expr 1000.0 / $clk]"
puts $results_file "$period\t[expr 1000.0/$period]\t$opt\$wns\t$clk\t[expr 1000.0/$clk]"
puts $runtimes_file "$period\t[expr 1000.0/$period]\t$opt\tpnr_opt_design\t$pnr_start\t$opt_design_finish\t[expr $opt_design_finish - $pnr_start]"
puts $runtimes_file "$period\t[expr 1000.0/$period]\t$opt\tplace_design\t$opt_design_finish\t$place_design_finish\t[expr $place_design_finish - $opt_design_finish]"
puts $runtimes_file "$period\t[expr 1000.0/$period]\t$opt\tphys_opt_design\t$place_design_finish\t$physopt1_finish\t[expr $physopt1_finish - $place_design_finish]"
puts $runtimes_file "$period\t[expr 1000.0/$period]\t$opt\troute_design\t$physopt1_finish\t$route_design_finish\t[expr $route_design_finish - $physopt1_finish]"
if {$opt >= 2} {
puts $runtimes_file "$period\t[expr 1000.0/$period]\t$opt\tphys_opt_design2\t$route_design_finish\t$physop2_finish\t[expr $physopt2_finish - $route_design_finish]"
}
puts $runtimes_file "$period\t[expr 1000.0/$period]\t$opt\ttotal_pnr\t$pnr_start\t$pnr_finish\t[expr $pnr_finish - $pnr_start]"
}
close $runtimes_file
close $results_file
}
# write design checkpoint
......@@ -121,7 +181,7 @@ report_utilization -quiet -file @@REPORT_UTILIZATION@@
# recalculate achieved frequency and set new period (for realistic power values)
set wns [tapasco::get_wns_from_timing_report @@REPORT_TIMING@@]
if {$wns < 0} {
create_clock -name clk -period [expr "@@PERIOD@@ - $wns"] $clock_ports
create_clock -name clk -period [expr "$period - $wns"] $clock_ports
}
# report power
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment