Hog Hog2025.1-6
pre-implementation.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 # Go to repository path
37 cd "$tcl_path/../.."
38 
39 if {[IsXilinx]} {
40  # Vivado
41  if {[IsISE]} {
42  set proj_dir [get_property DIRECTORY [current_project]]
43  set project [file tail $proj_dir]
44  set proj_file $proj_dir/$project.prr
45  } else {
46  set proj_file [get_property parent.project_path [current_project]]
47  }
48  set proj_dir [file normalize [file dirname $proj_file]]
49  set proj_name [file rootname [file tail $proj_file]]
50 } elseif {[IsDiamond]} {
51  set proj_dir [file normalize "[pwd]/.."]
52  set proj_name [file tail $proj_dir]
53  set project $proj_name
54 } else {
55  #Tclssh
56  set proj_file $old_path/[file tail $old_path].xpr
57  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/"
58 }
59 
60 set group_name [GetGroupName $proj_dir "$tcl_path/../.."]
61 
62 #number of threads
63 set maxThreads [GetMaxThreads [file normalize $tcl_path/../../Top/$group_name/$proj_name]]
64 
65 if {$maxThreads != 1} {
66  Msg CriticalWarning "Multithreading enabled. Bitfile will not be deterministic. Number of threads: $maxThreads"
67 } else {
68  Msg Info "Disabling multithreading to assure deterministic bitfile"
69 }
70 
71 if {[IsXilinx]} {
72  # Vivado
73  set_param general.maxThreads $maxThreads
74 } else {
75  #Tclssh
76 }
77 
78 
79 ######## Reset files before implementation ###########
80 ResetRepoFiles "./Projects/hog_reset_files"
81 
82 set user_pre_implementation_file "./Top/$group_name/$proj_name/pre-implementation.tcl"
83 if {[file exists $user_pre_implementation_file]} {
84  Msg Status "Sourcing user pre-implementation file $user_pre_implementation_file"
85  source $user_pre_implementation_file
86 }
87 
88 cd $old_path
89 Msg Info "All done"