]> rtime.felk.cvut.cz Git - fpga/zynq/canbench-sw.git/blob - system/script/recreate.tcl
system: build fix, removed generated HDL wrappers
[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 # Set project properties
62 set obj [get_projects canbench]
63 set_property "board_part" "em.avnet.com:microzed_7010:part0:1.0" $obj
64 set_property "default_lib" "xil_defaultlib" $obj
65 set_property "sim.ip.auto_export_scripts" "1" $obj
66 set_property "simulator_language" "Mixed" $obj
67 set_property "target_language" "VHDL" $obj
68
69 # Create 'sources_1' fileset (if not found)
70 if {[string equal [get_filesets -quiet sources_1] ""]} {
71   create_fileset -srcset sources_1
72 }
73
74 # Set IP repository paths
75 set obj [get_filesets sources_1]
76 set_property "ip_repo_paths" "[file normalize "$origin_dir/../ip/can_merge"]" $obj
77
78 # Rebuild user ip_repo's index before adding any source files
79 update_ip_catalog -rebuild
80
81 # Set 'sources_1' fileset object
82 set obj [get_filesets sources_1]
83 set files [list \
84  "[file normalize "$origin_dir/../src/top/top.bd"]"\
85 ]
86 add_files -norecurse -fileset $obj $files
87
88 # Set 'sources_1' fileset file properties for remote files
89 # None
90
91 # Set 'sources_1' fileset file properties for local files
92 set file "top/top.bd"
93 set file_obj [get_files -of_objects [get_filesets sources_1] [list "*$file"]]
94 if { ![get_property "is_locked" $file_obj] } {
95   set_property "synth_checkpoint_mode" "Hierarchical" $file_obj
96 }
97
98 # Create 'constrs_1' fileset (if not found)
99 if {[string equal [get_filesets -quiet constrs_1] ""]} {
100   create_fileset -constrset constrs_1
101 }
102
103 # Set 'constrs_1' fileset object
104 set obj [get_filesets constrs_1]
105 # Empty (no sources present)
106
107 # Set 'constrs_1' fileset properties
108 set obj [get_filesets constrs_1]
109
110 # Create 'sim_1' fileset (if not found)
111 if {[string equal [get_filesets -quiet sim_1] ""]} {
112   create_fileset -simset sim_1
113 }
114
115 # Set 'sim_1' fileset object
116 set obj [get_filesets sim_1]
117 # Empty (no sources present)
118
119 # Set 'sim_1' fileset properties
120 set obj [get_filesets sim_1]
121 set_property "xelab.nosort" "1" $obj
122 set_property "xelab.unifast" "" $obj
123
124 # Create 'synth_1' run (if not found)
125 if {[string equal [get_runs -quiet synth_1] ""]} {
126   create_run -name synth_1 -part xc7z010clg400-1 -flow {Vivado Synthesis 2015} -strategy "Vivado Synthesis Defaults" -constrset constrs_1
127 } else {
128   set_property strategy "Vivado Synthesis Defaults" [get_runs synth_1]
129   set_property flow "Vivado Synthesis 2015" [get_runs synth_1]
130 }
131 set obj [get_runs synth_1]
132 set_property "needs_refresh" "1" $obj
133
134 # set the current synth run
135 current_run -synthesis [get_runs synth_1]
136
137 # Create 'impl_1' run (if not found)
138 if {[string equal [get_runs -quiet impl_1] ""]} {
139   create_run -name impl_1 -part xc7z010clg400-1 -flow {Vivado Implementation 2015} -strategy "Vivado Implementation Defaults" -constrset constrs_1 -parent_run synth_1
140 } else {
141   set_property strategy "Vivado Implementation Defaults" [get_runs impl_1]
142   set_property flow "Vivado Implementation 2015" [get_runs impl_1]
143 }
144
145 # Create block design
146 #source ../src/top/top.tcl
147
148 # Generate the wrapper
149 open_bd_design ../src/top/top.bd
150 set design_name [get_bd_designs]
151 set obj [get_files $design_name.bd]
152 make_wrapper -files $obj -top -import
153
154 # set the current impl run
155 set obj [get_runs impl_1]
156 set_property "needs_refresh" "1" $obj
157 set_property "steps.write_bitstream.args.readback_file" "0" $obj
158 set_property "steps.write_bitstream.args.verbose" "0" $obj
159 current_run -implementation [get_runs impl_1]
160
161
162
163 puts "INFO: Project created:canbench"