-
Notifications
You must be signed in to change notification settings - Fork 0
/
Nand2TetrisVivado.tcl
396 lines (343 loc) · 15.2 KB
/
Nand2TetrisVivado.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
#*****************************************************************************************
# Vivado (TM) v2023.2 (64-bit)
#
# Nand2TetrisVivado.tcl: Tcl script for re-creating project 'Nand2TetrisVivado'
#
# Generated by Vivado on Sat Jan 13 20:09:25 PST 2024
# IP Build 4028589 on Sat Oct 14 00:45:43 MDT 2023
#
# This file contains the Vivado Tcl commands for re-creating the project to the state*
# when this script was generated. In order to re-create the project, please source this
# file in the Vivado Tcl Shell.
#
# * Note that the runs in the created project will be configured the same way as the
# original project, however they will not be launched automatically. To regenerate the
# run results please launch the synthesis/implementation runs as needed.
#
#*****************************************************************************************
# NOTE: In order to use this script for source control purposes, please make sure that the
# following files are added to the source control system:-
#
# 1. This project restoration tcl script (Nand2TetrisVivado.tcl) that was generated.
#
# 3. The following remote source files that were added to the original project:-
#
# "/home/ubuntu/Nand2TetrisFPGA/Hack/src/ALU.v"
# "/home/ubuntu/Nand2TetrisFPGA/Hack/src/CPU.v"
# "/home/ubuntu/Nand2TetrisFPGA/Hack/src/PC.v"
# "/home/ubuntu/Nand2TetrisFPGA/Hack/src/VGA/Pixelclk.v"
# "/home/ubuntu/Nand2TetrisFPGA/Hack/src/RAMROM.v"
# "/home/ubuntu/Nand2TetrisFPGA/Hack/src/VGA/Screen_Memory_Counter.v"
# "/home/ubuntu/Nand2TetrisFPGA/Hack/src/VGA/VGA320x240_Controller.v"
# "/home/ubuntu/Nand2TetrisFPGA/Hack/src/VGA/VGA640x480Synch.v"
# "/home/ubuntu/Nand2TetrisFPGA/Hack/src/Hack.v"
# "/home/ubuntu/Nand2TetrisFPGA/Hack/src/constraints.xdc"
# "/home/ubuntu/Nand2TetrisFPGA/Hack/src/PC.v"
# "/home/ubuntu/Nand2TetrisFPGA/Hack/test/PC_tb.v"
# "/home/ubuntu/Nand2TetrisFPGA/Hack/src/ALU.v"
# "/home/ubuntu/Nand2TetrisFPGA/Hack/test/ALU_tb.v"
# "/home/ubuntu/Nand2TetrisFPGA/Hack/src/RAMROM.v"
# "/home/ubuntu/Nand2TetrisFPGA/Hack/test/ROM_tb.v"
# "/home/ubuntu/Nand2TetrisFPGA/Hack/src/RAMROM.v"
# "/home/ubuntu/Nand2TetrisFPGA/Hack/test/RAM_tb.v"
# "/home/ubuntu/Nand2TetrisFPGA/Hack/src/ALU.v"
# "/home/ubuntu/Nand2TetrisFPGA/Hack/src/CPU.v"
# "/home/ubuntu/Nand2TetrisFPGA/Hack/src/PC.v"
# "/home/ubuntu/Nand2TetrisFPGA/Hack/test/CPU_tb.v"
#
#*****************************************************************************************
# Check file required for this script exists
proc checkRequiredFiles { origin_dir} {
set status true
set files [list \
"[file normalize "$origin_dir/Hack/src/ALU.v"]"\
"[file normalize "$origin_dir/Hack/src/CPU.v"]"\
"[file normalize "$origin_dir/Hack/src/PC.v"]"\
"[file normalize "$origin_dir/Hack/src/VGA/Pixelclk.v"]"\
"[file normalize "$origin_dir/Hack/src/RAMROM.v"]"\
"[file normalize "$origin_dir/Hack/src/VGA/Screen_Memory_Counter.v"]"\
"[file normalize "$origin_dir/Hack/src/VGA/VGA320x240_Controller.v"]"\
"[file normalize "$origin_dir/Hack/src/VGA/VGA640x480Synch.v"]"\
"[file normalize "$origin_dir/Hack/src/Hack.v"]"\
"[file normalize "$origin_dir/Hack/src/constraints.xdc"]"\
"[file normalize "$origin_dir/Hack/src/PC.v"]"\
"[file normalize "$origin_dir/Hack/test/PC_tb.v"]"\
"[file normalize "$origin_dir/Hack/src/ALU.v"]"\
"[file normalize "$origin_dir/Hack/test/ALU_tb.v"]"\
"[file normalize "$origin_dir/Hack/src/RAMROM.v"]"\
"[file normalize "$origin_dir/Hack/test/ROM_tb.v"]"\
"[file normalize "$origin_dir/Hack/src/RAMROM.v"]"\
"[file normalize "$origin_dir/Hack/test/RAM_tb.v"]"\
"[file normalize "$origin_dir/Hack/src/ALU.v"]"\
"[file normalize "$origin_dir/Hack/src/CPU.v"]"\
"[file normalize "$origin_dir/Hack/src/PC.v"]"\
"[file normalize "$origin_dir/Hack/test/CPU_tb.v"]"\
]
foreach ifile $files {
if { ![file isfile $ifile] } {
puts " Could not find remote file $ifile "
set status false
}
}
return $status
}
# Set the reference directory for source file relative paths (by default the value is script directory path)
set origin_dir "."
# Use origin directory path location variable, if specified in the tcl shell
if { [info exists ::origin_dir_loc] } {
set origin_dir $::origin_dir_loc
}
# Set the project name
set _xil_proj_name_ "Nand2TetrisVivado"
# Use project name variable, if specified in the tcl shell
if { [info exists ::user_project_name] } {
set _xil_proj_name_ $::user_project_name
}
variable script_file
set script_file "Nand2TetrisVivado.tcl"
# Help information for this script
proc print_help {} {
variable script_file
puts "\nDescription:"
puts "Recreate a Vivado project from this script. The created project will be"
puts "functionally equivalent to the original project for which this script was"
puts "generated. The script contains commands for creating a project, filesets,"
puts "runs, adding/importing sources and setting properties on various objects.\n"
puts "Syntax:"
puts "$script_file"
puts "$script_file -tclargs \[--origin_dir <path>\]"
puts "$script_file -tclargs \[--project_name <name>\]"
puts "$script_file -tclargs \[--help\]\n"
puts "Usage:"
puts "Name Description"
puts "-------------------------------------------------------------------------"
puts "\[--origin_dir <path>\] Determine source file paths wrt this path. Default"
puts " origin_dir path value is \".\", otherwise, the value"
puts " that was set with the \"-paths_relative_to\" switch"
puts " when this script was generated.\n"
puts "\[--project_name <name>\] Create project with the specified name. Default"
puts " name is the name of the project from where this"
puts " script was generated.\n"
puts "\[--help\] Print help information for this script"
puts "-------------------------------------------------------------------------\n"
exit 0
}
if { $::argc > 0 } {
for {set i 0} {$i < $::argc} {incr i} {
set option [string trim [lindex $::argv $i]]
switch -regexp -- $option {
"--origin_dir" { incr i; set origin_dir [lindex $::argv $i] }
"--project_name" { incr i; set _xil_proj_name_ [lindex $::argv $i] }
"--help" { print_help }
default {
if { [regexp {^-} $option] } {
puts "ERROR: Unknown option '$option' specified, please type '$script_file -tclargs --help' for usage info.\n"
return 1
}
}
}
}
}
# Set the directory path for the original project from where this script was exported
set orig_proj_dir "[file normalize "$origin_dir/Nand2TetrisVivado"]"
# Check for paths and files needed for project creation
set validate_required 0
if { $validate_required } {
if { [checkRequiredFiles $origin_dir] } {
puts "Tcl file $script_file is valid. All files required for project creation is accesable. "
} else {
puts "Tcl file $script_file is not valid. Not all files required for project creation is accesable. "
return
}
}
# Create project
create_project ${_xil_proj_name_} ./${_xil_proj_name_} -part xc7a35tcpg236-1
# Set the directory path for the new project
set proj_dir [get_property directory [current_project]]
# Reconstruct message rules
# None
# Set the board repository path
set_param board.repoPaths $origin_dir/Nand2TetrisVivado/boards/Digilent/basys3/1.2/
# Set project properties
set obj [current_project]
set_property -name "board_part" -value "digilentinc.com:basys3:part0:1.2" -objects $obj
set_property -name "default_lib" -value "xil_defaultlib" -objects $obj
set_property -name "enable_resource_estimation" -value "0" -objects $obj
set_property -name "enable_vhdl_2008" -value "1" -objects $obj
set_property -name "feature_set" -value "FeatureSet_Classic" -objects $obj
set_property -name "ip_cache_permissions" -value "read write" -objects $obj
set_property -name "ip_output_repo" -value "$proj_dir/${_xil_proj_name_}.cache/ip" -objects $obj
set_property -name "mem.enable_memory_map_generation" -value "1" -objects $obj
set_property -name "platform.board_id" -value "basys3" -objects $obj
set_property -name "revised_directory_structure" -value "1" -objects $obj
set_property -name "sim.central_dir" -value "$proj_dir/${_xil_proj_name_}.ip_user_files" -objects $obj
set_property -name "sim.ip.auto_export_scripts" -value "1" -objects $obj
set_property -name "simulator_language" -value "Mixed" -objects $obj
set_property -name "sim_compile_state" -value "1" -objects $obj
set_property -name "webtalk.xsim_launch_sim" -value "24" -objects $obj
set_property -name "xsim.array_display_limit" -value "1000000" -objects $obj
set_property -name "xsim.trace_limit" -value "1000000" -objects $obj
# Create 'sources_1' fileset (if not found)
if {[string equal [get_filesets -quiet sources_1] ""]} {
create_fileset -srcset sources_1
}
# Set 'sources_1' fileset object
set obj [get_filesets sources_1]
set files [list \
[file normalize "${origin_dir}/Hack/src/ALU.v"] \
[file normalize "${origin_dir}/Hack/src/CPU.v"] \
[file normalize "${origin_dir}/Hack/src/PC.v"] \
[file normalize "${origin_dir}/Hack/src/VGA/Pixelclk.v"] \
[file normalize "${origin_dir}/Hack/src/RAMROM.v"] \
[file normalize "${origin_dir}/Hack/src/VGA/Screen_Memory_Counter.v"] \
[file normalize "${origin_dir}/Hack/src/VGA/VGA320x240_Controller.v"] \
[file normalize "${origin_dir}/Hack/src/VGA/VGA640x480Synch.v"] \
[file normalize "${origin_dir}/Hack/src/Hack.v"] \
]
add_files -norecurse -fileset $obj $files
# Set 'sources_1' fileset file properties for remote files
# None
# Set 'sources_1' fileset file properties for local files
# None
# Set 'sources_1' fileset properties
set obj [get_filesets sources_1]
set_property -name "dataflow_viewer_settings" -value "min_width=16" -objects $obj
set_property -name "top" -value "Hack" -objects $obj
set_property -name "top_auto_set" -value "0" -objects $obj
# Create 'constrs_1' fileset (if not found)
if {[string equal [get_filesets -quiet constrs_1] ""]} {
create_fileset -constrset constrs_1
}
# Set 'constrs_1' fileset object
set obj [get_filesets constrs_1]
# Add/Import constrs file and set constrs file properties
set file "[file normalize "$origin_dir/Hack/src/constraints.xdc"]"
set file_added [add_files -norecurse -fileset $obj [list $file]]
set file "$origin_dir/Hack/src/constraints.xdc"
set file [file normalize $file]
set file_obj [get_files -of_objects [get_filesets constrs_1] [list "*$file"]]
set_property -name "file_type" -value "XDC" -objects $file_obj
# Set 'constrs_1' fileset properties
set obj [get_filesets constrs_1]
set_property -name "target_constrs_file" -value "[file normalize "$origin_dir/Hack/src/constraints.xdc"]" -objects $obj
set_property -name "target_ucf" -value "[file normalize "$origin_dir/Hack/src/constraints.xdc"]" -objects $obj
# Create 'sim_1' fileset (if not found)
if {[string equal [get_filesets -quiet sim_1] ""]} {
create_fileset -simset sim_1
}
# Set 'sim_1' fileset object
set obj [get_filesets sim_1]
# Empty (no sources present)
# Set 'sim_1' fileset properties
set obj [get_filesets sim_1]
set_property -name "top" -value "Hack" -objects $obj
set_property -name "top_auto_set" -value "0" -objects $obj
set_property -name "top_lib" -value "xil_defaultlib" -objects $obj
# Create 'PC_sim' fileset (if not found)
if {[string equal [get_filesets -quiet PC_sim] ""]} {
create_fileset -simset PC_sim
}
# Set 'PC_sim' fileset object
set obj [get_filesets PC_sim]
set files [list \
[file normalize "${origin_dir}/Hack/src/PC.v"] \
[file normalize "${origin_dir}/Hack/test/PC_tb.v"] \
]
add_files -norecurse -fileset $obj $files
# Set 'PC_sim' fileset file properties for remote files
# None
# Set 'PC_sim' fileset file properties for local files
# None
# Set 'PC_sim' fileset properties
set obj [get_filesets PC_sim]
set_property -name "source_set" -value "" -objects $obj
set_property -name "top" -value "PC_tb" -objects $obj
set_property -name "top_auto_set" -value "0" -objects $obj
set_property -name "top_lib" -value "xil_defaultlib" -objects $obj
# Create 'ALU_sim' fileset (if not found)
if {[string equal [get_filesets -quiet ALU_sim] ""]} {
create_fileset -simset ALU_sim
}
# Set 'ALU_sim' fileset object
set obj [get_filesets ALU_sim]
set files [list \
[file normalize "${origin_dir}/Hack/src/ALU.v"] \
[file normalize "${origin_dir}/Hack/test/ALU_tb.v"] \
]
add_files -norecurse -fileset $obj $files
# Set 'ALU_sim' fileset file properties for remote files
# None
# Set 'ALU_sim' fileset file properties for local files
# None
# Set 'ALU_sim' fileset properties
set obj [get_filesets ALU_sim]
set_property -name "source_set" -value "" -objects $obj
set_property -name "top" -value "ALU_tb" -objects $obj
set_property -name "top_auto_set" -value "0" -objects $obj
set_property -name "top_lib" -value "xil_defaultlib" -objects $obj
# Create 'ROM_sim' fileset (if not found)
if {[string equal [get_filesets -quiet ROM_sim] ""]} {
create_fileset -simset ROM_sim
}
# Set 'ROM_sim' fileset object
set obj [get_filesets ROM_sim]
set files [list \
[file normalize "${origin_dir}/Hack/src/RAMROM.v"] \
[file normalize "${origin_dir}/Hack/test/ROM_tb.v"] \
]
add_files -norecurse -fileset $obj $files
# Set 'ROM_sim' fileset file properties for remote files
# None
# Set 'ROM_sim' fileset file properties for local files
# None
# Set 'ROM_sim' fileset properties
set obj [get_filesets ROM_sim]
set_property -name "source_set" -value "" -objects $obj
set_property -name "top" -value "ROM_tb" -objects $obj
set_property -name "top_auto_set" -value "0" -objects $obj
set_property -name "top_lib" -value "xil_defaultlib" -objects $obj
# Create 'RAM_sim' fileset (if not found)
if {[string equal [get_filesets -quiet RAM_sim] ""]} {
create_fileset -simset RAM_sim
}
# Set 'RAM_sim' fileset object
set obj [get_filesets RAM_sim]
set files [list \
[file normalize "${origin_dir}/Hack/src/RAMROM.v"] \
[file normalize "${origin_dir}/Hack/test/RAM_tb.v"] \
]
add_files -norecurse -fileset $obj $files
# Set 'RAM_sim' fileset file properties for remote files
# None
# Set 'RAM_sim' fileset file properties for local files
# None
# Set 'RAM_sim' fileset properties
set obj [get_filesets RAM_sim]
set_property -name "source_set" -value "" -objects $obj
set_property -name "top" -value "RAM_tb" -objects $obj
set_property -name "top_auto_set" -value "0" -objects $obj
set_property -name "top_lib" -value "xil_defaultlib" -objects $obj
# Create 'CPU_sim' fileset (if not found)
if {[string equal [get_filesets -quiet CPU_sim] ""]} {
create_fileset -simset CPU_sim
}
# Set 'CPU_sim' fileset object
set obj [get_filesets CPU_sim]
set files [list \
[file normalize "${origin_dir}/Hack/src/ALU.v"] \
[file normalize "${origin_dir}/Hack/src/CPU.v"] \
[file normalize "${origin_dir}/Hack/src/PC.v"] \
[file normalize "${origin_dir}/Hack/test/CPU_tb.v"] \
]
add_files -norecurse -fileset $obj $files
# Set 'CPU_sim' fileset file properties for remote files
# None
# Set 'CPU_sim' fileset file properties for local files
# None
# Set 'CPU_sim' fileset properties
set obj [get_filesets CPU_sim]
set_property -name "source_set" -value "" -objects $obj
set_property -name "top" -value "CPU_tb" -objects $obj
set_property -name "top_auto_set" -value "0" -objects $obj
set_property -name "top_lib" -value "xil_defaultlib" -objects $obj
puts "INFO: Project created:${_xil_proj_name_}"