-
Notifications
You must be signed in to change notification settings - Fork 517
/
step_user.tcl
executable file
·157 lines (143 loc) · 6.57 KB
/
step_user.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# Amazon FPGA Hardware Development Kit
#
# Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Amazon Software License (the "License"). You may not use
# this file except in compliance with the License. A copy of the License is
# located at
#
# http://aws.amazon.com/asl/
#
# or in the "license" file accompanying this file. This file is distributed on
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or
# implied. See the License for the specific language governing permissions and
# limitations under the License.
proc impl_step {phase top {options none} {directive none} {pre none} {post none} } {
upvar bitDir bitDir
upvar implDir implDir
upvar rptDir rptDir
upvar timestamp timestamp
if {[string match $phase "write_bitstream"]} {
set stepDir $bitDir
} else {
set stepDir $implDir
}
#Set value > 1 to get DCPs and reports for all phases
set verbose 1
#Make sure $phase is valid and set checkpoint in case no design is open
if {[string match $phase "opt_design"]} {
set checkpoint1 "$implDir/${timestamp}.post_link_design.dcp"
} elseif {[string match $phase "place_design"]} {
set checkpoint1 "$implDir/${timestamp}.post_opt_design.dcp"
} elseif {[string match $phase "phys_opt_design"]} {
set checkpoint1 "$implDir/${timestamp}.post_place_design.dcp"
} elseif {[string match $phase "route_design"]} {
set checkpoint1 "$implDir/${timestamp}.post_phys_opt_design.dcp"
set checkpoint2 "$implDir/${timestamp}.post_place_design.dcp"
} elseif {[string match $phase "route_phys_opt_design"]} {
set checkpoint1 "$implDir/${timestamp}.post_route_design.dcp"
} elseif {[string match $phase "write_bitstream"]} {
set checkpoint1 "$implDir/${timestamp}.post_route_phys_opt_design.dcp"
set checkpoint2 "$implDir/${timestamp}.post_route_design.dcp"
} else {
set errMsg "\nERROR: Value $phase is not a recognized step of implementation. Valid values are:\n\topt_design\n\tplace_design\n\tphys_opt_design\n\troute_design\n\troute_phys_opt_design\n\twrite_bitstream\n"
error $errMsg
}
#If no design is open
if { [catch {current_instance} errMsg]} {
puts "\tNo open design"
if {[info exists checkpoint1] || [info exists checkpoint2]} {
if {[file exists $checkpoint1]} {
puts "\tOpening checkpoint $checkpoint1 for $timestamp"
open_checkpoint $checkpoint1
} elseif {[file exists $checkpoint2]} {
puts "\tOpening checkpoint $checkpoint2 for $timestamp"
open_checkpoint $checkpoint2
} else {
set errMsg "\nERROR: Checkpoint required for step $phase not found. Rerun necessary previous steps first."
error $errMsg
}
} else {
set errMsg "\nERROR: No checkpoint defined."
error $errMsg
}
}
#Setup phase-specific settings.
if {[string match $phase "write_bitstream"]} {
set impl_step "$phase -force -file $bitDir/$timestamp"
} elseif {[string match $phase "route_phys_opt_design"]} {
set impl_step "phys_opt_design"
} else {
set impl_step $phase
}
#Run any specified pre-phase scripts
if {![string match $pre "none"] && ![string match $pre ""] } {
foreach script $pre {
if {[file exists $script]} {
puts "\tRunning pre-$phase script $script"
source $script
} else {
set errMsg "\nERROR: Script $script specified for pre-${phase} does not exist"
error $errMsg
}
}
}
#Append options to command
if {[string match $options "none"]==0 && [string match $options ""]==0} {
append impl_step " $options"
}
#Append directives to command
if {[string match $directive "none"]==0 && [string match $directive ""]==0} {
append impl_step " -directive $directive"
}
#Run the specified Implementation phase
set start_time [clock seconds]
puts "\n\t################################"
puts "\t$phase start time: \[[clock format $start_time -format {%a %b %d %H:%M:%S %Y}]\]"
puts "\tCOMMAND: $impl_step"
if {[catch $impl_step $errMsg]} {
if {[string match $phase "route_design"]} {
puts "\tERROR: $phase failed. Writing $phase checkpoint for debug\n\t$stepDir/${timestamp}.post_${phase}_error.dcp"
write_checkpoint -force $stepDir/${timestamp}.post_${phase}_error.dcp
}
append errMsg "\nERROR: $phase failed."
error $errMsg
}
if {![string match $phase "write_bitstream"]} {
set SLACK [get_property SLACK [get_timing_paths]]
puts "\tCompleted: $phase (WNS=$SLACK)"
} else {
puts "\tCompleted: $phase"
}
puts "\t################################"
#Run any specified post-phase scripts
if {![string match $post "none"] && ![string match $post ""] } {
foreach script $post {
if {[file exists $script]} {
puts "\tRunning post-$phase script $script"
source $script
} else {
set errMsg "\nERROR: Script $script specified for post-${phase} does not exist"
error $errMsg
}
}
}
#Write out checkpoint for successfully completed phase
if {($verbose > 1 || [string match $phase "opt_design"] || [string match $phase "route_design"] || [string match $phase "route_phys_opt_design"]) && ![string match $phase "write_bitstream"]} {
set start_time [clock seconds]
puts "\tWriting $phase checkpoint: $stepDir/${timestamp}.post_$phase.dcp \[[clock format $start_time -format {%a %b %d %H:%M:%S %Y}]\]\n"
write_checkpoint -force $stepDir/${timestamp}.post_$phase.dcp
report_timing -cell WRAPPER_INST/CL -delay_type max -max_paths 10 -sort_by group -input_pins -file $rptDir/${timestamp}.post${phase}_timing_max.rpt
report_timing -cell WRAPPER_INST/CL -delay_type min -max_paths 10 -sort_by group -input_pins -file $rptDir/${timestamp}.post${phase}_timing_min.rpt
}
#Write out additional reports controled by verbose level
if {($verbose > 1 || [string match $phase "route_design"] || [string match $phase "route_phys_opt_design"]) && ![string match $phase "write_bitstream"]} {
puts "\tGenerating report files"
report_utilization -pblock [get_pblocks pblock_CL] -file $rptDir/${timestamp}.utilization_${phase}.rpt
report_timing_summary -cell WRAPPER_INST/CL -file $rptDir/${timestamp}.timing_summary_$phase.rpt
}
if {[string match $phase "route_design"]} {
puts "\tGenerating route_status report"
report_route_status -file $rptDir/${timestamp}.route_status.rpt
}
}