]> rtime.felk.cvut.cz Git - fpga/zynq/canbench-sw.git/blob - system/script/recreate.tcl
system: removed reference to post-write_bitstream dist script
[fpga/zynq/canbench-sw.git] / system / script / recreate.tcl
1 # Set the reference directory for source file relative paths (by default the value is script directory path)
2 set origin_dir "."
3
4 # Use origin directory path location variable, if specified in the tcl shell
5 if { [info exists ::origin_dir_loc] } {
6   set origin_dir $::origin_dir_loc
7 }
8
9 variable script_file
10 set script_file "recreate.tcl"
11
12 # Help information for this script
13 proc help {} {
14   variable script_file
15   puts "\nDescription:"
16   puts "Recreate a Vivado project from this script. The created project will be"
17   puts "functionally equivalent to the original project for which this script was"
18   puts "generated. The script contains commands for creating a project, filesets,"
19   puts "runs, adding/importing sources and setting properties on various objects.\n"
20   puts "Syntax:"
21   puts "$script_file"
22   puts "$script_file -tclargs \[--origin_dir <path>\]"
23   puts "$script_file -tclargs \[--help\]\n"
24   puts "Usage:"
25   puts "Name                   Description"
26   puts "-------------------------------------------------------------------------"
27   puts "\[--origin_dir <path>\]  Determine source file paths wrt this path. Default"
28   puts "                       origin_dir path value is \".\", otherwise, the value"
29   puts "                       that was set with the \"-paths_relative_to\" switch"
30   puts "                       when this script was generated.\n"
31   puts "\[--help\]               Print help information for this script"
32   puts "-------------------------------------------------------------------------\n"
33   exit 0
34 }
35
36 if { $::argc > 0 } {
37   for {set i 0} {$i < [llength $::argc]} {incr i} {
38     set option [string trim [lindex $::argv $i]]
39     switch -regexp -- $option {
40       "--origin_dir" { incr i; set origin_dir [lindex $::argv $i] }
41       "--help"       { help }
42       default {
43         if { [regexp {^-} $option] } {
44           puts "ERROR: Unknown option '$option' specified, please type '$script_file -tclargs --help' for usage info.\n"
45           return 1
46         }
47       }
48     }
49   }
50 }
51
52 # Set the directory path for the original project from where this script was exported
53 set orig_proj_dir "[file normalize "$origin_dir/../project"]"
54
55 # Create project
56 create_project canbench ../project
57
58 # Set the directory path for the new project
59 set proj_dir [get_property directory [current_project]]
60
61 # Reconstruct message rules
62 # None
63
64 # Set project properties
65 set obj [get_projects canbench]
66 set_property "board_part" "em.avnet.com:microzed_7010:part0:1.0" $obj
67 set_property "default_lib" "xil_defaultlib" $obj
68 set_property "sim.ip.auto_export_scripts" "1" $obj
69 set_property "simulator_language" "Mixed" $obj
70 set_property "target_language" "VHDL" $obj
71
72 # Create 'sources_1' fileset (if not found)
73 if {[string equal [get_filesets -quiet sources_1] ""]} {
74   create_fileset -srcset sources_1
75 }
76
77 # Set IP repository paths
78 set obj [get_filesets sources_1]
79 #set_property "ip_repo_paths" "[file normalize "$origin_dir/../ip/sja1000_1.0"] [file normalize "$origin_dir/../ip/can_crossbar_1.0"] [file normalize "$origin_dir/../ip/can_merge"] [file normalize "$origin_dir/../ip/canbench_cc_gpio"]" $obj
80 set_property "ip_repo_paths" "[file normalize "$origin_dir/../ip"]" $obj
81
82 # Rebuild user ip_repo's index before adding any source files
83 update_ip_catalog -rebuild
84
85 # Set 'sources_1' fileset object
86 set obj [get_filesets sources_1]
87 set files [list \
88  "[file normalize "$origin_dir/../src/top/top.bd"]"\
89 ]
90 add_files -norecurse -fileset $obj $files
91
92 # Set 'sources_1' fileset file properties for remote files
93 set file "$origin_dir/../src/top/top.bd"
94 set file [file normalize $file]
95 set file_obj [get_files -of_objects [get_filesets sources_1] [list "*$file"]]
96 if { ![get_property "is_locked" $file_obj] } {
97   set_property "synth_checkpoint_mode" "Hierarchical" $file_obj
98 }
99
100 # Set 'sources_1' fileset file properties for local files
101 # None
102
103 # Set 'sources_1' fileset properties
104 #set obj [get_filesets sources_1]
105 #set_property "top" "top_wrapper" $obj
106
107 # Create 'constrs_1' fileset (if not found)
108 if {[string equal [get_filesets -quiet constrs_1] ""]} {
109   create_fileset -constrset constrs_1
110 }
111
112 # Set 'constrs_1' fileset object
113 set obj [get_filesets constrs_1]
114
115 # Add/Import constrs file and set constrs file properties
116 set file "[file normalize "$origin_dir/../src/constrs/microzed_CAN-CC_RevA.xdc"]"
117 set file_added [add_files -norecurse -fileset $obj $file]
118 set file "$origin_dir/../src/constrs/microzed_CAN-CC_RevA.xdc"
119 set file [file normalize $file]
120 set file_obj [get_files -of_objects [get_filesets constrs_1] [list "*$file"]]
121 set_property "file_type" "XDC" $file_obj
122
123 # Set 'constrs_1' fileset properties
124 #set obj [get_filesets constrs_1]
125 #set_property "target_constrs_file" "$orig_proj_dir/canbench.srcs/constrs_1/new/test.xdc" $obj
126
127 # Create 'sim_1' fileset (if not found)
128 if {[string equal [get_filesets -quiet sim_1] ""]} {
129   create_fileset -simset sim_1
130 }
131
132 # Set 'sim_1' fileset object
133 set obj [get_filesets sim_1]
134 # Empty (no sources present)
135
136 # Set 'sim_1' fileset properties
137 set obj [get_filesets sim_1]
138 set_property "transport_int_delay" "0" $obj
139 set_property "transport_path_delay" "0" $obj
140 set_property "xelab.nosort" "1" $obj
141 set_property "xelab.unifast" "" $obj
142
143 # Create 'synth_1' run (if not found)
144 if {[string equal [get_runs -quiet synth_1] ""]} {
145   create_run -name synth_1 -part xc7z010clg400-1 -flow {Vivado Synthesis 2016} -strategy "Vivado Synthesis Defaults" -constrset constrs_1
146 } else {
147   set_property strategy "Vivado Synthesis Defaults" [get_runs synth_1]
148   set_property flow "Vivado Synthesis 2016" [get_runs synth_1]
149 }
150 set obj [get_runs synth_1]
151 set_property "part" "xc7z010clg400-1" $obj
152
153 # set the current synth run
154 current_run -synthesis [get_runs synth_1]
155
156 # Create 'impl_1' run (if not found)
157 if {[string equal [get_runs -quiet impl_1] ""]} {
158   create_run -name impl_1 -part xc7z010clg400-1 -flow {Vivado Implementation 2016} -strategy "Vivado Implementation Defaults" -constrset constrs_1 -parent_run synth_1
159 } else {
160   set_property strategy "Vivado Implementation Defaults" [get_runs impl_1]
161   set_property flow "Vivado Implementation 2016" [get_runs impl_1]
162 }
163 set obj [get_runs impl_1]
164 set_property "part" "xc7z010clg400-1" $obj
165 set_property "steps.write_bitstream.args.readback_file" "0" $obj
166 set_property "steps.write_bitstream.args.verbose" "0" $obj
167
168 # set the current impl run
169 current_run -implementation [get_runs impl_1]
170
171 # Create block design
172 #source ../src/top/top.tcl
173
174 # Upgrade IPs
175 #upgrade_ip [get_ips]
176
177 # Generate the wrapper
178 open_bd_design "$origin_dir/../src/top/top.bd"
179 set design_name [get_bd_designs]
180 set obj [get_files $design_name.bd]
181 make_wrapper -files $obj -top -import
182
183 # set the current impl run
184 set obj [get_runs impl_1]
185 set_property "needs_refresh" "1" $obj
186 set_property "steps.write_bitstream.args.readback_file" "0" $obj
187 set_property "steps.write_bitstream.args.verbose" "0" $obj
188 current_run -implementation [get_runs impl_1]
189
190 check_ip_cache -import_from_project -use_project_cache
191
192 #set_property STEPS.WRITE_BITSTREAM.TCL.POST $origin_dir/script/dist.tcl [get_runs impl_1]
193
194 puts "INFO: Project created:canbench"