-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadept_tcl.tcl
167 lines (140 loc) · 5.15 KB
/
adept_tcl.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
# Adept Export Tool
# Engineer: Steve Grace
# Description: This is a package that does the equivalent of
# exporting Excel/CSV files of Jim Wu's Adept Tool
# BEGIN USER MODIFICATION
# Modify this block of code to point to other packages needed
set MYREPOPATH {lib/tcom}
#puts $auto_path
lappend auto_path [file join "[pwd]/$MYREPOPATH"]
puts $auto_path
set user_pkg_list [list tcom]
# END USER MODIFICATION
# Require these packages
set default_pkg_list [list cmdline csv struct::matrix]
set pkg_list [concat $user_pkg_list $default_pkg_list]
#set pkg_list $default_pkg_list
# END USER MODIFICATION
foreach pkg $pkg_list {
if {[catch {package require $pkg} _msg]} {
puts "Package $pkg was nto loaded."
#exit 1
} else {
puts "Loaded Package: $pkg"
}
}
namespace eval adept_tcl {
namespace export *
# Variables
variable header
# Aliases
interp alias {} write_orcad {} adept_tcl::write_pkgorcad
interp alias {} create_header_template {} adept_tcl::pkgorcad_header_template
}
proc adept_tcl::write_pkgorcad { args } {
set ::argv0 "write_pkgorcad"
array set options [::cmdline::getoptions args {
{force "Forces the file to be written if one already exists"}
{return_string "Prints out data to local console."}
{file.arg "Writes file to location as CSV."}
}]
set file $options(file)
set force $options(force)
set return_string $options(return_string)
# Create matrix object
struct::matrix orcadm
adept_tcl::orcadm add columns 8
adept_tcl::orcadm add rows 5
# Add header
create_header_template
# Loop through the header variable and add the rows
set i 0
foreach row $adept_tcl::header {
adept_tcl::orcadm set cell 0 $i $row
incr i
}
adept_tcl::orcadm add row {Number Name Type PinVisiblity Shape PinGroup Position Section}
# Gather data needed and cache them in an ordered list for processing
set number [get_package_pins]; # Package Pin
set name [get_property PIN_FUNC [get_package_pins]]; # Site type
set type {Input Output Bidirectional Power}; # Input/output/bidirectional/Power
set pinVisibility 1
set shape Line
set pinGroup 1
set position Left
set section_io [get_iobanks]; # Based upon bank
set section_gt [get_gtbanks]; # Gets gt banks
# Process the data into the matrix appropriately
# Keys:
# - IO_* - Bidirectional
# - GND* - Power
# - VCCO_* - Power
# - VCCINT_* - Power
# - VCCAUX_* - Power
# - VCCBRAM_* - Power
# - VP, VN, CFGBVS, DXN, DXP, M0, M1, M2, PROGRAM_B, TCK, TDI, TMS, VCCADC, VCCBATT, VREFN, VREFP - Input
# - CCLK, DONE, INIT_B - Bidirectional
# - TDO - Output
# - PS_* - Bidirectional
set input_only {VP_0 VN_0 CFGBVS_0 DXN_0 DXP_0 M0_0 M1_0 M2_0 PROGRAM_B_0 TCK_0 TDI_0 TMS_0 VCCADC_0 VCCBATT_0 VREFN_0 VREFP_0}
set output_only {TDO_0}
set bidir_only [get_property PIN_FUNC [get_package_pins -filter {PIN_FUNC =~ IO_* || PIN_FUNC =~ PS_* || PIN_FUNC =~ CCLK* || PIN_FUNC =~ DONE* || PIN_FUNC =~ INIT_B*}]]
set power_only [get_property PIN_FUNC [get_package_pins -filter {PIN_FUNC =~ GND* || PIN_FUNC =~ VCCO* || PIN_FUNC =~ VCCINT* || PIN_FUNC =~ VCCAUX* || PIN_FUNC =~ VCCBRAM* || PIN_FUNC =~ VCCP* || PIN_FUNC =~ RSVD*}]]
# Row Header: Number, Name, Type, PinVisibility Shape PinGroup Position Section
set data_row ""
foreach num $number {
# Regular IO or GT?
set temp_num $num
set temp_name [get_property PIN_FUNC [get_package_pins $num]]
if { $temp_name in $input_only } {
set temp_type Input
set section_io [get_iobanks -of_objects [get_package_pins $num]]
} elseif { $temp_name in $output_only } {
set temp_type Output
set section_io [get_iobanks -of_objects [get_package_pins $num]]
} elseif { $temp_name in $power_only } {
set temp_type Power
set section_io 0
} elseif { $temp_name in $bidir_only } {
set temp_type Bidirectional
set section_io [get_iobanks -of_objects [get_package_pins $num]]
} else {
puts "NOT A VALID PORT! EXITING!"
puts $num
}
set insert_row "$temp_num $temp_name $temp_type $pinVisibility $shape $pinGroup $position $section_io"
adept_tcl::orcadm add row $insert_row
}
# Write out CSV file
set fid [open $file w]
csv::writematrix adept_tcl::orcadm $fid
close $fid
puts $file
adept_tcl::orcadm destroy
}
proc adept_tcl::pkgorcad_header_template {} {
set vivado_ver "[lindex [version] 0] [lindex [version] 1] [lindex [version] 2]"
set adept_tcl::header "{# This file was automatically generated by adept_tcl::write_pkgorcad with $vivado_ver}"
lappend adept_tcl::header {# Please open this file in Excel and then copy and paste pin info}
lappend adept_tcl::header {# to part generation spreadsheet in Orcad capture}
lappend adept_tcl::header "\# [clock format [clock seconds]]"
lappend adept_tcl::header "\# Part number = [get_property part [current_project]]"
#lappend adept_tcl::header {Number Name Type PinVisiblity Shape PinGroup Position Section}
}
proc adept_tcl::write_mgtpinview {} {
# Command Line Options
# Create sturct::matrix object
# Get the following MGT data:
# - Pin Number
# - Signal Name (if it exists)
# - IO Name
# - IO Type
# - PAD Name
# - MGT_XY (Channel name)
set mgt_pin_number []
set mgt_signal_name []
set mgt_io_name []
set mgt_io_type []
set mgt_pad_name []
set mgt_location []
}