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 | ###############################################################################
# Copyright (c) 2022-2024 by Altair Engineering, Inc.
# All rights reserved.
#
# Altair Engineering, Inc. makes this software available as part of the Vision
# tool platform. As long as you are a licensee of the Vision tool platform
# you may make copies of the software and modify it to be used within the
# Vision tool platform, but you must include all of this notice on any copy.
# Redistribution without written permission to any third party, with or
# without modification, is not permitted.
# Altair Engineering, Inc. does not warrant that this software is error free
# or fit for any purpose. Altair Engineering, Inc. disclaims any liability for
# all claims, expenses, losses, damages and costs any user may incur as a
# result of using, copying or modifying the software.
# =============================================================================
# @script
# Load multiple board netlist files and connect them in a virtual
# top module.
###############################################################################
##
# Load the `postProcessBoard.tcl` script.
#
set useInBatchMode true
source [file join [file dirname [info script]] "postProcessBoard.tcl"]
##
# Configuration:
#
set topModuleName "ConnectedBoards"
set boardFiles {
Edif /path/to/file1.edf
Verilog /path/to/file2.v
...
Edif /path/to/fileN.edf
}
set connectorTable {
BoardName.designatorName BoardName.designatorName
BoardName.instancePath BoardName.instancePath
...
}
# =============================================================================
# CreateDatabase - Create, fill and process the database.
# =============================================================================
#
proc ConnectBoard:CreateDatabase {boardFiles connectorTable topModuleName} {
set db [zdb new]
foreach {fileType fileName} $boardFiles {
z[string tolower $fileType] -into $db $fileName
}
ConnectBoard:_createConnectionPorts $db $connectorTable
ConnectBoard:_interconnectBoards $db $connectorTable $topModuleName
PostProcessBoard:Start false $db
##
# Show the database in the GUI.
#
gui database changed $db
}
# -----------------------------------------------------------------------------
# _createConnectionPorts - Create ports for the board interconnection.
# -----------------------------------------------------------------------------
#
proc ConnectBoard:_createConnectionPorts {db connectorTable} {
##
# Collect the current top modules.
#
set tops {}
$db foreach top top {
lappend tops $top
}
if {$tops == {}} {
error "No top module."
}
##
# Create the connector pins at the top level of each beard.
#
foreach {con1 con2} $connectorTable {
ConnectBoard:_addConnectorPorts $db $con1 input
ConnectBoard:_addConnectorPorts $db $con2 output
}
foreach top $tops {
$db top unset $top
}
}
# -----------------------------------------------------------------------------
# _interconnectBoards - Connect the boards.
# -----------------------------------------------------------------------------
#
proc ConnectBoard:_interconnectBoards {db connectorTable topModuleName} {
##
# Create a virtual top and instantiate every board.
#
$db load module $topModuleName -top
set top [$db search module $topModuleName]
set i -1
array set conTops {}
foreach {con1 con2} $connectorTable {
set top1 [lindex [split $con1 "."] 0]
set top2 [lindex [split $con2 "."] 0]
if {[info exists conTops($top1:$top2)]} {
continue
}
set conTops($top1:$top2) 1
set iName1 i_[incr i]
set iName2 i_[incr i]
$db load inst $iName1 $top1
$db load inst $iName2 $top2
set inst1 [$db search inst $top $iName1]
set inst2 [$db search inst $top $iName2]
$db foreach pin $inst1 pin {
set pName [$db oid pname $pin]
$db load net $pName -pin $iName1 $pName -pin $iName2 $pName
}
}
}
# -----------------------------------------------------------------------------
# _getInsts - Get all instances of the given designator cell name.
# -----------------------------------------------------------------------------
#
proc ConnectBoard:_getInsts {db boardName designator} {
set instList {}
##
# Check if the designator refers to an instance, if not the it is a cell
# name and all instances of this cell are connectors.
#
$db find -type inst -top $boardName -hiersep . $designator inst {
lappend instList $inst
}
if {[llength $instList] > 0} {
return $instList
}
$db foreach cell cell {
$db flag $cell clear blue
}
set cellList {}
$db foreach cell cell {
if {[$db attr $cell getValue "designator"] eq $designator} {
lappend cellList $cell
}
}
foreach cell $cellList {
$db flag $cell set blue
}
set designTop [$db search top $boardName]
$db flat foreach instOfCell $designTop blue inst {
lappend instList $inst
}
$db foreach cell cell {
$db flag $cell clear blue
}
return $instList
}
# -----------------------------------------------------------------------------
# _addConnectorPorts -
# -----------------------------------------------------------------------------
#
proc ConnectBoard:_addConnectorPorts {db conInfo dir} {
##
# Get the board name and connection designator from the connection info.
#
set boardName [lindex [split $conInfo "."] 0]
set designator [lindex [split $conInfo "."] 1]
##
# Search for the board module.
#
set module [$db search module $boardName]
if {[$db oid isnull $module]} {
zmessage print ERR "Board '$boardName' not found."
return
}
##
# Get the list of all connector instances.
#
set instList [ConnectBoard:_getInsts $db $boardName $designator]
$db reloadModule $boardName
foreach inst $instList {
$db foreach pin $inst pin {
set portName ${designator}_[$db oid pname $pin]
$db load port $portName $dir
if {![$db isConnected $pin]} {
continue
}
set net [$db connectedNet $pin]
set signal [$db flat signalOf $net]
set signalName [$db oid oname $signal]
$db load net $signalName -port $portName
}
$db flag $inst set zombie
}
$db deleteZombies
}
##
# Run the main procedure to create the connected board database.
#
ConnectBoard:CreateDatabase $boardFiles $connectorTable $topModuleName
|