Hog v9.9.0
pre-bitstream.tcl
Go to the documentation of this file.
1 #!/usr/bin/env tclsh
2 # Copyright 2018-2024 The University of Birmingham
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 
16 set old_path [pwd]
17 set tcl_path [file normalize "[file dirname [info script]]/.."]
18 source $tcl_path/hog.tcl
19 
20 if {[IsQuartus]} {
21  # Quartus
22  Msg Error "Pre-module scripts are not supported in Quartus mode!"
23  return TCL_ERROR
24 }
25 
26 # Go to repository path
27 cd "$tcl_path/../.."
28 
29 if {[IsXilinx]} {
30  # Vivado + PlanAhead
31  # Vivado + PlanAhead
32  if {[IsISE]} {
33  # planAhead
34  set work_path [get_property DIRECTORY [get_runs impl_1]]
35  } else {
36  # Vivado
37  set work_path $old_path
38  }
39 
40  set proj_name [file tail [file normalize $work_path/../../]]
41  set proj_dir [file normalize "$work_path/../.."]
42 
43  set group_name [GetGroupName $proj_dir "$tcl_path/../.."]
44 
45 } else {
46  #Tclssh
47  set proj_name [file tail [file normalize $old_path/../..]]
48  Msg CriticalWarning "You seem to be running locally on tclsh, so this is a debug, the project file will be set to $proj_file and was derived from the path you launched this script from: $old_path. If you want this script to work properly in debug mode, please launch it from the top folder of one project, for example Repo/Projects/fpga1/ or Repo/Top/fpga1/"
49 }
50 
51 
52 #number of threads
53 set maxThreads [GetMaxThreads [file normalize $tcl_path/../../Top/$group_name/$proj_name]]
54 if {$maxThreads != 1} {
55  Msg CriticalWarning "Multithreading enabled. Bitfile will not be deterministic. Number of threads: $maxThreads"
56 } else {
57  Msg Info "Disabling multithreading to assure deterministic bitfile"
58 }
59 
60 if {[IsXilinx]} {
61  # Vivado
62  set_param general.maxThreads $maxThreads
63 } else {
64  #Tclssh
65 }
66 
67 ######## Reset files before bitstream creation ###########
68 ResetRepoFiles "./Projects/hog_reset_files"
69 
70 set user_pre_bitstream_file "./Top/$group_name/$proj_name/pre-bitstream.tcl"
71 if {[file exists $user_pre_bitstream_file]} {
72  Msg Info "Sourcing user pre-bitstream file $user_pre_bitstream_file"
73  source $user_pre_bitstream_file
74 }
75 
76 cd $old_path
77 Msg Info "All done."