Hog v9.67.0
pre-bitstream.tcl
Go to the documentation of this file.
1 #!/usr/bin/env tclsh
2 # Copyright 2018-2025 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 # Import tcllib
21 if {[IsSynplify] || [IsDiamond]} {
22  if {[info exists env(HOG_TCLLIB_PATH)]} {
23  lappend auto_path $env(HOG_TCLLIB_PATH)
24  } else {
25  puts "ERROR: To run Hog with Microsemi Libero SoC, you need to define the HOG_TCLLIB_PATH variable."
26  return
27  }
28 }
29 
30 if {[IsQuartus]} {
31  # Quartus
32  Msg Error "Pre-module scripts are not supported in Quartus mode!"
33  return TCL_ERROR
34 }
35 
36 
37 if {[IsXilinx]} {
38  # Vivado + PlanAhead
39  if {[IsISE]} {
40  # PlanAhead
41  set work_path [get_property DIRECTORY [get_runs impl_1]]
42  } else {
43  # Vivado
44  set work_path $old_path
45  }
46 
47  set proj_name [file tail [file normalize $work_path/../../]]
48  set proj_dir [file normalize "$work_path/../.."]
49 } elseif {[IsDiamond]} {
50  set proj_dir [file normalize "[pwd]/.."]
51  set proj_name [file tail $proj_dir]
52  set project $proj_name
53 } else {
54  #Tclssh
55  set proj_name [file tail [file normalize $old_path/../..]]
56  Msg CriticalWarning "You seem to be running locally on tclsh, so this is a debug message. \
57  The project file will be set to $proj_file and was derived from the path you launched this script from: $old_path. \
58  If you want this script to work properly in debug mode, please launch it from the top folder of one project, \
59  for example Repo/Projects/fpga1/ or Repo/Top/fpga1/"
60 }
61 
62 set group_name [GetGroupName $proj_dir "$tcl_path/../.."]
63 
64 # Go to repository path
65 cd "$tcl_path/../.."
66 
67 #number of threads
68 set maxThreads [GetMaxThreads [file normalize $tcl_path/../../Top/$group_name/$proj_name]]
69 if {$maxThreads != 1} {
70  Msg CriticalWarning "Multithreading enabled. Bitfile will not be deterministic. Number of threads: $maxThreads"
71 } else {
72  Msg Info "Disabling multithreading to assure deterministic bitfile"
73 }
74 
75 if {[IsXilinx]} {
76  # Vivado
77  set_param general.maxThreads $maxThreads
78 } else {
79  #Tclssh
80 }
81 
82 ######## Reset files before bitstream creation ###########
83 ResetRepoFiles "./Projects/hog_reset_files"
84 
85 set user_pre_bitstream_file "./Top/$group_name/$proj_name/pre-bitstream.tcl"
86 if {[file exists $user_pre_bitstream_file]} {
87  Msg Info "Sourcing user pre-bitstream file $user_pre_bitstream_file"
88  source $user_pre_bitstream_file
89 }
90 
91 cd $old_path
92 Msg Info "All done."