[1328] | 1 | ############################################################################### |
---|
| 2 | ## |
---|
| 3 | ## Copyright (c) 1995-2002 Xilinx, Inc. All rights reserved. |
---|
| 4 | ## |
---|
| 5 | ## genace.tcl |
---|
| 6 | ## Generate SystemACE configuration file from FPGA bitstream |
---|
| 7 | ## and PowerPC ELF program |
---|
| 8 | ## |
---|
| 9 | ## $Header: /devl/xcs/repo/env/Jobs/MDT/sw/Apps/debug/new_xmd/DataFiles/Attic/genace.tcl,v 1.1.2.10.10.1 2008/03/20 18:32:16 boq Exp $ |
---|
| 10 | ############################################################################### |
---|
| 11 | |
---|
| 12 | # Quick Start: |
---|
| 13 | # |
---|
| 14 | # USAGE: |
---|
| 15 | # xmd -tcl genace.tcl [-opt <genace options file>] [-jprog] [-target <target type>] |
---|
| 16 | # [-hw <bitstream>] [-elf <Elf Files>] [-data <Data files>] [-board <board type>] -ace <ACE file> |
---|
| 17 | # |
---|
| 18 | # |
---|
| 19 | # Note: |
---|
| 20 | # This script has been tested for ML300 V2P4/7,Memec V2P4/7 boards and Microblaze Demo Board |
---|
| 21 | # For other boards, the options that may have to be modified below are : |
---|
| 22 | # "xmd_options", "jtag_fpga_position" and "jtag_devices" |
---|
| 23 | # |
---|
| 24 | # Raj: Added Boards ML401, ML402 and ML403 |
---|
| 25 | |
---|
| 26 | |
---|
| 27 | set usage "\nUSAGE: |
---|
| 28 | xmd -tcl genace.tcl \[-opt <genace options file>\] | |
---|
| 29 | \[-jprog\] \[-hw <bitstream>\] \[-elf {ELF files}\] \[-data {<Data file> <load address>}\] -board <target board> -target <target type> -ace <output ACE file>\n\n\ |
---|
| 30 | \t<target type> - \[ppc_hw|mdm\]\n\ |
---|
| 31 | \t\[bitstream\] - bit/svf file\n\ |
---|
| 32 | \t\[ELF files\] - elf/svf files\n\ |
---|
| 33 | \t\[Data file\] - data/svf file loaded at <load address>\n\ |
---|
| 34 | \t<target board> - \[user|<supported board name>\]\n\ |
---|
| 35 | \t\tSupported board name -> Supported Board Name\n\ |
---|
| 36 | \t\tuser -> User Specified Config parameters\n\n" |
---|
| 37 | |
---|
| 38 | #--------------------------------------------------------------------- |
---|
| 39 | # |
---|
| 40 | # Supported Board Settings |
---|
| 41 | # The following are the list of Supported Boards. The JTAG Chain |
---|
| 42 | # devices information and FPGA position in the Chain are captured. |
---|
| 43 | # a. jtag_chain_options - |
---|
| 44 | # b. jtag_fpga_position - |
---|
| 45 | # c. jtag_devices - |
---|
| 46 | # |
---|
| 47 | # Use the "-board <board name>" to select a particular board. |
---|
| 48 | # |
---|
| 49 | # Note: To Specify the JTAG Chain information for a custom board, use |
---|
| 50 | # "-board user" option and specify them in a genace option file. |
---|
| 51 | # |
---|
| 52 | #--------------------------------------------------------------------- |
---|
| 53 | |
---|
| 54 | set ml300(jtag_chain_options) "-configdevice devicenr 1 idcode 0x123e093 irlength 10 partname xc2vp7" |
---|
| 55 | set ml300(jtag_fpga_position) 1 |
---|
| 56 | set ml300(jtag_devices) "xc2vp7" |
---|
| 57 | |
---|
| 58 | set ml310(jtag_chain_options) "-configdevice devicenr 1 idcode 0x127E093 irlength 14 partname xc2vp30" |
---|
| 59 | set ml310(jtag_fpga_position) 1 |
---|
| 60 | set ml310(jtag_devices) "xc2vp30" |
---|
| 61 | |
---|
| 62 | set ml410(jtag_chain_options) "-configdevice devicenr 1 idcode 0x01EB4093 irlength 14 partname xc4vfx60" |
---|
| 63 | set ml410(jtag_fpga_position) 1 |
---|
| 64 | set ml410(jtag_devices) "xc4vfx60" |
---|
| 65 | |
---|
| 66 | set ml411(jtag_chain_options) "-configdevice devicenr 1 idcode 0x01EE4093 irlength 14 partname xc4vfx100" |
---|
| 67 | set ml411(jtag_fpga_position) 1 |
---|
| 68 | set ml411(jtag_devices) "xc4vfx100" |
---|
| 69 | |
---|
| 70 | set memec(jtag_chain_options) "-configdevice devicenr 1 irlength 8 partname xc18v04 -configdevice devicenr 2 irlength 8 partname xc18v04 -configdevice devicenr 3 idcode 0x123E093 irLength 10 partname xc2vp4" |
---|
| 71 | set memec(jtag_fpga_position) 3 |
---|
| 72 | set memec(jtag_devices) "xc18v04 xc18v04 xc2vp4" |
---|
| 73 | |
---|
| 74 | set mbdemo(jtag_chain_options) "-configdevice devicenr 1 idcode 0x1028093 irlength 6 partname xc2v1000" |
---|
| 75 | set mbdemo(jtag_fpga_position) 1 |
---|
| 76 | set mbdemo(jtag_devices) "xc2v1000" |
---|
| 77 | |
---|
| 78 | # Production ML403 |
---|
| 79 | set ml403(jtag_chain_options) "-configdevice devicenr 1 idcode 0x05059093 irlength 16 partname xcf32p -configdevice devicenr 2 idcode 0x01E58093 irlength 10 partname xc4vfx12 -configdevice devicenr 3 idcode 0x09608093 irlength 8 partname xc95144xl" |
---|
| 80 | set ml403(jtag_fpga_position) 2 |
---|
| 81 | set ml403(jtag_devices) "xcf32p xc4vfx12 xc95144xl" |
---|
| 82 | |
---|
| 83 | # Production ML402 |
---|
| 84 | set ml402(jtag_chain_options) "-configdevice devicenr 1 idcode 0x05059093 irlength 16 partname xcf32p -configdevice devicenr 2 idcode 0x02088093 irlength 10 partname xc4vsx35 -configdevice devicenr 3 idcode 0x09608093 irlength 8 partname xc95144xl" |
---|
| 85 | set ml402(jtag_fpga_position) 2 |
---|
| 86 | set ml402(jtag_devices) "xcf32p xc4vsx35 xc95144xl" |
---|
| 87 | |
---|
| 88 | # Production ML401 |
---|
| 89 | set ml401(jtag_chain_options) "-configdevice devicenr 1 idcode 0x05059093 irlength 16 partname xcf32p -configdevice devicenr 2 idcode 0x0167C093 irlength 10 partname xc4vlx25 -configdevice devicenr 3 idcode 0x09608093 irlength 8 partname xc95144xl" |
---|
| 90 | set ml401(jtag_fpga_position) 2 |
---|
| 91 | set ml401(jtag_devices) "xcf32p xc4vlx25 xc95144xl" |
---|
| 92 | |
---|
| 93 | # ML401 Engineering Sample |
---|
| 94 | set ml401_es(jtag_chain_options) "-configdevice devicenr 1 idcode 0x05059093 irlength 16 partname xcf32p -configdevice devicenr 2 idcode 0x0167C093 irlength 10 partname xc4vlx25 -configdevice devicenr 3 idcode 0x09608093 irlength 8 partname xc95144xl -bscan USER1" |
---|
| 95 | set ml401_es(jtag_fpga_position) 2 |
---|
| 96 | set ml401_es(jtag_devices) "xcf32p xc4vlx25 xc95144xl" |
---|
| 97 | |
---|
| 98 | # Production ML405 |
---|
| 99 | set ml405(jtag_chain_options) "-configdevice devicenr 1 idcode 0x05059093 irlength 16 partname xcf32p -configdevice devicenr 2 idcode 0x01E64093 irlength 10 partname xc4vFx20 -configdevice devicenr 3 idcode 0x09608093 irlength 8 partname xc95144xl" |
---|
| 100 | set ml405(jtag_fpga_position) 2 |
---|
| 101 | set ml405(jtag_devices) "xcf32p xc4vFx20 xc95144xl" |
---|
| 102 | |
---|
| 103 | # Production ML501 |
---|
| 104 | set ml501(jtag_chain_options) "-configdevice devicenr 1 idcode 0x02896093 irlength 10 partname xc5vlx50" |
---|
| 105 | set ml501(jtag_fpga_position) 1 |
---|
| 106 | set ml501(jtag_devices) "xc5vlx50" |
---|
| 107 | |
---|
| 108 | # Production ML505 |
---|
| 109 | set ml505(jtag_chain_options) "-configdevice devicenr 1 idcode 0x02a96093 irlength 10 partname xc5vlx50t" |
---|
| 110 | set ml505(jtag_fpga_position) 1 |
---|
| 111 | set ml505(jtag_devices) "xc5vlx50t" |
---|
| 112 | |
---|
| 113 | # Production ML506 |
---|
| 114 | set ml506(jtag_chain_options) "-configdevice devicenr 1 idcode 0x02E9A093 irlength 10 partname xc5vsx50t" |
---|
| 115 | set ml506(jtag_fpga_position) 1 |
---|
| 116 | set ml506(jtag_devices) "xc5vsx50t" |
---|
| 117 | |
---|
| 118 | # Production ML507 |
---|
| 119 | set ml507(jtag_chain_options) "-configdevice devicenr 1 idcode 0x032c6093 irlength 10 partname xc5vfx70t_u" |
---|
| 120 | set ml507(jtag_fpga_position) 1 |
---|
| 121 | set ml507(jtag_devices) "xc5vfx70t_u" |
---|
| 122 | |
---|
| 123 | # Production WARP FPGA Board v1.2 |
---|
| 124 | set wfv2p(jtag_chain_options) "-configdevice devicenr 1 idcode 0x112ba093 irlength 14 partname XC2VP70" |
---|
| 125 | set wfv2p(jtag_fpga_position) 1 |
---|
| 126 | set wfv2p(jtag_devices) "xc2vp70" |
---|
| 127 | |
---|
[1425] | 128 | # Production WARP FPGA Board v2.2 |
---|
| 129 | set wfv4(jtag_chain_options) "-configdevice devicenr 1 idcode 0x01ee4093 irlength 14 partname xc4vfx100" |
---|
| 130 | set wfv4(jtag_fpga_position) 1 |
---|
| 131 | set wfv4(jtag_devices) "xc4vfx100" |
---|
| 132 | |
---|
[1328] | 133 | #--------------------------------------------------------------------- |
---|
| 134 | # |
---|
| 135 | # Global Script Variables |
---|
| 136 | # |
---|
| 137 | #--------------------------------------------------------------------- |
---|
| 138 | # Setting some default options |
---|
| 139 | set param(board) "ml403" |
---|
| 140 | set param(hw) "" |
---|
| 141 | set param(jprog) "false" |
---|
| 142 | set param(ace) "" |
---|
| 143 | set param(xmd_options) "" |
---|
| 144 | set param(jtag_fpga_position) "" |
---|
| 145 | set param(jtag_devices) "" |
---|
| 146 | set param(jtag_chain_options) [list] |
---|
| 147 | set param(ncpu) 0 |
---|
| 148 | set param(sw) [list] |
---|
| 149 | set param(data) [list] |
---|
| 150 | # Processor Specific information |
---|
| 151 | set cpu_nr(0) [list] |
---|
| 152 | set cpu_target(0) [list] |
---|
| 153 | set cpu_debugdevice(0) [list] |
---|
| 154 | set cpu_elf(0) [list] |
---|
| 155 | set cpu_data(0) [list] |
---|
| 156 | set cpu_startaddr(0) [list] |
---|
| 157 | |
---|
| 158 | set final_svf 0 |
---|
| 159 | set fpga_irlength 0 |
---|
| 160 | |
---|
| 161 | # |
---|
| 162 | # |
---|
| 163 | # Detailed description of the genace.tcl script : |
---|
| 164 | # |
---|
| 165 | # |
---|
| 166 | # This script works in xmd (EDK3.2 or later) and generates a SystemACE file |
---|
| 167 | # from a bitstream and one or more PowerPC software(ELF) program or Data Files. |
---|
| 168 | # |
---|
| 169 | # The main steps in generating the SystemACE file are : |
---|
| 170 | # 1. Converting a bitstream into an SVF file using iMPACT |
---|
| 171 | # The SVF file contains the sequence of JTAG instructions |
---|
| 172 | # used to configure the FPGA and bring it up. (Done pin going high) |
---|
| 173 | # NOTE: |
---|
| 174 | # In order to create a valid SVF file, the JTAG chain of the |
---|
| 175 | # board has to be specified correctly in the "jtag_fpga_position", |
---|
| 176 | # and "jtag_devices" options at the beginning of this script. |
---|
| 177 | # |
---|
| 178 | # 2. Converting executables into SVF files using XMD |
---|
| 179 | # This SVF file contains the JTAG sequence used by XMD to |
---|
| 180 | # download the ELF executable to internal/external memory |
---|
| 181 | # through the JTAG debug port of the PowerPC on the Virtex2Pro or |
---|
| 182 | # through the MDM debug port of Microblaze |
---|
| 183 | # NOTE: |
---|
| 184 | # (i) This step assumes that the FPGA was configured with a |
---|
| 185 | # bitstream containing a PowerPC/Microblaze hardware system in which |
---|
| 186 | # the JTAG debug port has been connected to the FPGA JTAG pins |
---|
| 187 | # using the JTAGPPC or Microblaze hardware system with opb_mdm. |
---|
| 188 | # (ii) In order to create a valid SVF file, |
---|
| 189 | # the position of the PowerPC/Microblaze and the JTAG chain of |
---|
| 190 | # the board has to be specified correctly in the |
---|
| 191 | # "xmd_options" at the beginning of this script. Refer the |
---|
| 192 | # XMD documentation for more information about these options. |
---|
| 193 | # NOTE on NOTE: |
---|
| 194 | # These options could be used to create ACE files that would |
---|
| 195 | # directly write to PPC I/DCaches, etc |
---|
| 196 | # 3. Converting data/binary into SVF files using XMD |
---|
| 197 | # 4. Concatenating the SVF files from step 1 and 2 |
---|
| 198 | # 5. Generating a SystemACE file from the combined SVF file using iMPACT |
---|
| 199 | # |
---|
| 200 | # IMPORTANT NOTE: |
---|
| 201 | # The JTAG chain options for step 1,2 and 3 have to be specified based on |
---|
| 202 | # the relative position of each device in the JTAG chain from |
---|
| 203 | # the SystemACE controller. |
---|
| 204 | # |
---|
| 205 | |
---|
| 206 | |
---|
| 207 | #--------------------------------------------------------------------- |
---|
| 208 | # |
---|
| 209 | # Helper Procedures to convert bit->svf, elf->svf, data->svf and svf->ave |
---|
| 210 | # |
---|
| 211 | #--------------------------------------------------------------------- |
---|
| 212 | |
---|
| 213 | proc impact_bit2svf { bitfile jtag_fpga_position jtag_devices } { |
---|
| 214 | |
---|
| 215 | set svffile "[file rootname $bitfile].svf" |
---|
| 216 | set script [open "bit2svf.scr" "w"] |
---|
| 217 | puts $script "setmode -bs" |
---|
| 218 | puts $script "setCable -p svf -file $svffile" |
---|
| 219 | |
---|
| 220 | set devicePos 0 |
---|
| 221 | foreach device $jtag_devices { |
---|
| 222 | incr devicePos |
---|
| 223 | if { $devicePos != $jtag_fpga_position } { |
---|
| 224 | puts $script "addDevice -p $devicePos -part $device" |
---|
| 225 | } else { |
---|
| 226 | puts $script "addDevice -p $jtag_fpga_position -file $bitfile" |
---|
| 227 | } |
---|
| 228 | } |
---|
| 229 | puts $script "program -p $jtag_fpga_position" |
---|
| 230 | puts $script "quit" |
---|
| 231 | close $script |
---|
| 232 | |
---|
| 233 | puts "\n############################################################" |
---|
| 234 | puts "Converting Bitstream '$bitfile' to SVF file '$svffile'" |
---|
| 235 | puts "Executing 'impact -batch bit2svf.scr'" |
---|
| 236 | if { [catch {exec impact -batch bit2svf.scr} msg] } { |
---|
| 237 | if { ![string match "*Programmed successfully.*" $msg] } { |
---|
| 238 | puts $msg |
---|
| 239 | error "ERROR in SVF file generation" |
---|
| 240 | } |
---|
| 241 | } |
---|
| 242 | return |
---|
| 243 | } |
---|
| 244 | |
---|
| 245 | proc xmd_elf2svf { target_type elffile xmd_options } { |
---|
| 246 | set svffile "[file rootname $elffile].svf" |
---|
| 247 | puts "\n############################################################" |
---|
| 248 | puts "Converting ELF file '$elffile' to SVF file '$svffile'" |
---|
| 249 | |
---|
| 250 | set tgt 0 |
---|
| 251 | if { $target_type == "ppc_hw" } { |
---|
| 252 | set a "xconnect ppc hw -cable type xilinx_svffile fname $svffile $xmd_options" |
---|
| 253 | } else { |
---|
| 254 | set a "xconnect mb mdm -cable type xilinx_svffile fname $svffile $xmd_options" |
---|
| 255 | } |
---|
| 256 | if { [catch {set tgt [eval_xmd_cmd $a]} retval] } { |
---|
| 257 | puts "$retval" |
---|
| 258 | error "ERROR: Unable to create SVF file '$svffile' for ELF file : $elffile" |
---|
| 259 | } |
---|
| 260 | |
---|
| 261 | xdebugconfig $tgt -reset_on_run disable |
---|
| 262 | xdownload $tgt $elffile |
---|
| 263 | |
---|
| 264 | # Fix for PowerPC CPU errata 212/213 on Virtex4. Causes erroneous data to be loaded when data |
---|
| 265 | # cache is loaded. Workaround is to set 1 and 3 bits of CCR0 |
---|
| 266 | if { $target_type == "ppc_hw" } { |
---|
| 267 | xwreg $tgt 68 0x50700000 |
---|
| 268 | } |
---|
| 269 | |
---|
| 270 | xdisconnect $tgt |
---|
| 271 | xdisconnect -cable |
---|
| 272 | return |
---|
| 273 | } |
---|
| 274 | |
---|
| 275 | proc xmd_data2svf { target_type dfile load_addr xmd_options } { |
---|
| 276 | set svffile "[file rootname $dfile].svf" |
---|
| 277 | puts "\n############################################################" |
---|
| 278 | puts "Converting Data file '$dfile' to SVF file '$svffile'" |
---|
| 279 | |
---|
| 280 | set tgt 0 |
---|
| 281 | if { $target_type == "ppc_hw" } { |
---|
| 282 | set a "xconnect ppc hw -cable type xilinx_svffile fname $svffile $xmd_options" |
---|
| 283 | } else { |
---|
| 284 | set a "xconnect mb mdm -cable type xilinx_svffile fname $svffile $xmd_options" |
---|
| 285 | } |
---|
| 286 | if { [catch {set tgt [eval_xmd_cmd $a]} retval] } { |
---|
| 287 | puts "$retval" |
---|
| 288 | error "ERROR: Unable to create SVF file '$svffile' for Data file : $dfile" |
---|
| 289 | } |
---|
| 290 | |
---|
| 291 | xdebugconfig $tgt -reset_on_run disable |
---|
| 292 | xdownload $tgt -data $dfile $load_addr |
---|
| 293 | |
---|
| 294 | xdisconnect $tgt |
---|
| 295 | xdisconnect -cable |
---|
| 296 | return |
---|
| 297 | } |
---|
| 298 | |
---|
| 299 | proc write_swsuffix { target_type elffile xmd_options saddr } { |
---|
| 300 | set svffile "[file rootname $elffile].svf" |
---|
| 301 | puts "\n############################################################" |
---|
| 302 | puts "Writing Processor JTAG \"continue\" command to SVF file '$svffile'" |
---|
| 303 | |
---|
| 304 | set tgt 0 |
---|
| 305 | if { $target_type == "ppc_hw" } { |
---|
| 306 | set a "xconnect ppc hw -cable type xilinx_svffile fname $svffile $xmd_options" |
---|
| 307 | } else { |
---|
| 308 | set a "xconnect mb mdm -cable type xilinx_svffile fname $svffile $xmd_options" |
---|
| 309 | } |
---|
| 310 | if { [catch {set tgt [eval_xmd_cmd $a]} retval] } { |
---|
| 311 | puts "$retval" |
---|
| 312 | error "ERROR: Unable to create SVF file '$svffile' for ELF file : $elffile" |
---|
| 313 | } |
---|
| 314 | xdebugconfig $tgt -reset_on_run disable |
---|
| 315 | |
---|
| 316 | xwreg $tgt 32 [format "0x%x" $saddr] |
---|
| 317 | xcontinue $tgt |
---|
| 318 | xdisconnect $tgt |
---|
| 319 | xdisconnect -cable |
---|
| 320 | return |
---|
| 321 | } |
---|
| 322 | |
---|
| 323 | proc impact_svf2ace { acefile } { |
---|
| 324 | set svffile "[file rootname $acefile].svf" |
---|
| 325 | set script [open "svf2ace.scr" "w"] |
---|
| 326 | puts $script "svf2ace -wtck -d -m 16776192 -i $svffile -o $acefile" |
---|
| 327 | puts $script quit |
---|
| 328 | close $script |
---|
| 329 | |
---|
| 330 | puts "\n############################################################" |
---|
| 331 | puts "Converting SVF file '$svffile' to SystemACE file '$acefile'" |
---|
| 332 | puts "Executing 'impact -batch svf2ace.scr'" |
---|
| 333 | catch {exec impact -batch svf2ace.scr} |
---|
| 334 | return |
---|
| 335 | } |
---|
| 336 | |
---|
| 337 | proc write_swprefix { target_type svffile xmd_options final_svf } { |
---|
| 338 | set tgt 0 |
---|
| 339 | if { $target_type == "ppc_hw" } { |
---|
| 340 | set a "xconnect ppc hw -cable type xilinx_svffile fname $svffile $xmd_options" |
---|
| 341 | } else { |
---|
| 342 | set a "xconnect mb mdm -cable type xilinx_svffile fname $svffile $xmd_options" |
---|
| 343 | } |
---|
| 344 | if { [catch {set tgt [eval_xmd_cmd $a]} retval] } { |
---|
| 345 | puts "$retval" |
---|
| 346 | error "ERROR: Failed to Write SW Prefix for SVF generation" |
---|
| 347 | } |
---|
| 348 | xreset $tgt -processor |
---|
| 349 | |
---|
| 350 | xdisconnect $tgt |
---|
| 351 | xdisconnect -cable |
---|
| 352 | |
---|
| 353 | puts $final_svf " |
---|
| 354 | //======================================================= |
---|
| 355 | // |
---|
| 356 | STATE RESET IDLE; |
---|
| 357 | RUNTEST 100000 TCK; |
---|
| 358 | HIR 0 ; |
---|
| 359 | HDR 0 ; |
---|
| 360 | TIR 0 ; |
---|
| 361 | TDR 0 ; |
---|
| 362 | // Reset the System |
---|
| 363 | //=======================================================" |
---|
| 364 | |
---|
| 365 | set prefixsvf [open $svffile "r"] |
---|
| 366 | fcopy $prefixsvf $final_svf |
---|
| 367 | close $prefixsvf |
---|
| 368 | |
---|
| 369 | puts $final_svf " |
---|
| 370 | //======================================================= |
---|
| 371 | // |
---|
| 372 | STATE RESET IDLE; |
---|
| 373 | RUNTEST 100000 TCK; |
---|
| 374 | HIR 0 ; |
---|
| 375 | HDR 0 ; |
---|
| 376 | TIR 0 ; |
---|
| 377 | TDR 0 ; |
---|
| 378 | // Start ELF downloading here |
---|
| 379 | //=======================================================" |
---|
| 380 | return |
---|
| 381 | } |
---|
| 382 | |
---|
| 383 | proc write_hwprefix { svffile use_jprog fpga_irlength } { |
---|
| 384 | puts $svffile " |
---|
| 385 | //======================================================= |
---|
| 386 | // Initial JTAG Reset |
---|
| 387 | // |
---|
| 388 | HIR 0 ; |
---|
| 389 | TIR 0 ; |
---|
| 390 | TDR 0 ; |
---|
| 391 | HDR 0 ; |
---|
| 392 | STATE RESET IDLE; |
---|
| 393 | //=======================================================" |
---|
| 394 | if { $fpga_irlength <= 5 } { |
---|
| 395 | return |
---|
| 396 | } |
---|
| 397 | if { $use_jprog == "true" } { |
---|
| 398 | set jprog 3fcb |
---|
| 399 | set smask 3fff |
---|
| 400 | switch -- $fpga_irlength { |
---|
| 401 | 6 { |
---|
| 402 | set jprog 0b |
---|
| 403 | set smask 3f |
---|
| 404 | } |
---|
| 405 | 10 { |
---|
| 406 | set jprog 3cb |
---|
| 407 | set smask 3ff |
---|
| 408 | } |
---|
| 409 | 14 { |
---|
| 410 | set jprog 3fcb |
---|
| 411 | set smask 3fff |
---|
| 412 | } |
---|
| 413 | } |
---|
| 414 | puts $svffile " |
---|
| 415 | // For runtime reconfiguration, using 'jprog_b' instruction |
---|
| 416 | // Loading device with 'jprog_b' instruction. |
---|
| 417 | SIR $fpga_irlength TDI ($jprog) SMASK ($smask) ; |
---|
| 418 | RUNTEST 1000 TCK ; |
---|
| 419 | // end of jprog_b |
---|
| 420 | // NOTE - The following delay will have to be modified in genace.tcl |
---|
| 421 | // for non-ML300, non-xc2vp7 devices. The frame information is |
---|
| 422 | // available in <Device> user guide (Configration Details) |
---|
| 423 | // Send into bypass and idle until program latency is over |
---|
| 424 | // 4 us per frame. XC2VP7 is 1320 frames = 5280 us |
---|
| 425 | // @maximum TCK freq 33 MHz = 174240 cycles |
---|
| 426 | // Setting it to max value.. XC2VP100 = 3500 frames |
---|
| 427 | SIR $fpga_irlength TDI ($smask) SMASK ($smask) ; |
---|
| 428 | RUNTEST 462000 TCK ; |
---|
| 429 | //=======================================================" |
---|
| 430 | } |
---|
| 431 | return |
---|
| 432 | } |
---|
| 433 | |
---|
| 434 | |
---|
| 435 | proc write_prefix { svffile argv } { |
---|
| 436 | puts $svffile " |
---|
| 437 | //======================================================= |
---|
| 438 | //======================================================= |
---|
| 439 | // SVF file automatically created using XMD + genace.tcl |
---|
| 440 | // Commandline : xmd genace.tcl $argv |
---|
| 441 | // Date/Time : [clock format [clock seconds]] |
---|
| 442 | //======================================================= |
---|
| 443 | //======================================================= |
---|
| 444 | " |
---|
| 445 | return |
---|
| 446 | } |
---|
| 447 | |
---|
| 448 | proc get_elf_startaddr { target_type elffile } { |
---|
| 449 | if { ![file exists $elffile] } { |
---|
| 450 | puts "Error: File $elffile not found\n" |
---|
| 451 | return -code error |
---|
| 452 | } |
---|
| 453 | |
---|
| 454 | if { $target_type == "ppc_hw" } { |
---|
| 455 | if { [catch {set saddr [exec powerpc-eabi-objdump -x $elffile | grep -w "start address"]} err] } { |
---|
| 456 | puts "Error: Executable $elffile does not contain start address.." |
---|
| 457 | return -code error |
---|
| 458 | } |
---|
| 459 | } else { |
---|
| 460 | if { [catch {set saddr [exec mb-objdump -x $elffile | grep -w "start address"]} err] } { |
---|
| 461 | puts "Error: Executable $elffile does not contain start address.." |
---|
| 462 | return -code error |
---|
| 463 | } |
---|
| 464 | } |
---|
| 465 | set saddr_list [string trimleft $saddr] |
---|
| 466 | set saddr [lindex $saddr_list end] |
---|
| 467 | return $saddr |
---|
| 468 | } |
---|
| 469 | |
---|
| 470 | |
---|
| 471 | #--------------------------------------------------------------------- |
---|
| 472 | # |
---|
| 473 | # Procedures to Generate SVF file |
---|
| 474 | # |
---|
| 475 | #--------------------------------------------------------------------- |
---|
| 476 | |
---|
| 477 | ####################################################################### |
---|
| 478 | # Procedure to generate the SVF file from .bit |
---|
| 479 | ####################################################################### |
---|
| 480 | proc genace_hw { } { |
---|
| 481 | global param |
---|
| 482 | global fpga_irlength final_svf |
---|
| 483 | |
---|
| 484 | set acefile $param(ace) |
---|
| 485 | |
---|
| 486 | # Convert bit->svf file |
---|
| 487 | set bitfile $param(hw) |
---|
| 488 | if { $bitfile != "" } { |
---|
| 489 | if { ![file readable $bitfile] } { |
---|
| 490 | error "Unable to open Bitstream file : $bitfile" |
---|
| 491 | } |
---|
| 492 | |
---|
| 493 | write_hwprefix $final_svf $param(jprog) $fpga_irlength |
---|
| 494 | if { ![string match "[file extension $bitfile]" ".svf"] } { |
---|
| 495 | # Generate the .svf file for .bit file |
---|
| 496 | impact_bit2svf $bitfile $param(jtag_fpga_position) $param(jtag_devices) |
---|
| 497 | } |
---|
| 498 | set bitsvf [open "[file rootname $bitfile].svf" "r"] |
---|
| 499 | puts "\nCopying [file rootname $bitfile].svf File to \ |
---|
| 500 | [file rootname $acefile].svf File\n" |
---|
| 501 | fcopy $bitsvf $final_svf |
---|
| 502 | close $bitsvf |
---|
| 503 | |
---|
| 504 | # Move the SVF to the Current directory |
---|
| 505 | file rename -force [file rootname $bitfile].svf [pwd] |
---|
| 506 | } |
---|
| 507 | } |
---|
| 508 | |
---|
| 509 | ####################################################################### |
---|
| 510 | # Procedure to generate the SVF file from .elf/data file |
---|
| 511 | ####################################################################### |
---|
| 512 | proc genace_sw_download { } { |
---|
| 513 | global param |
---|
| 514 | global final_svf |
---|
| 515 | |
---|
| 516 | set acefile $param(ace) |
---|
| 517 | |
---|
| 518 | write_swprefix $param(target) "sw_prefix.svf" $param(xmd_options) $final_svf |
---|
| 519 | |
---|
| 520 | # Convert data->svf files |
---|
| 521 | set data_files $param(data) |
---|
| 522 | if { [llength $data_files] > 0 } { |
---|
| 523 | set i 0 |
---|
| 524 | while { $i < [llength $data_files] } { |
---|
| 525 | set dfile [lindex $data_files $i] |
---|
| 526 | set laddr [lindex $data_files [incr i 1]] |
---|
| 527 | incr i 1 |
---|
| 528 | if { ![file readable $dfile] } { |
---|
| 529 | error "Unable to open data file : $dfile" |
---|
| 530 | } |
---|
| 531 | |
---|
| 532 | if { ![string match "[file extension $dfile]" ".svf"] } { |
---|
| 533 | # Generate the .svf file for data file |
---|
| 534 | xmd_data2svf $param(target) $dfile $laddr $param(xmd_options) |
---|
| 535 | } |
---|
| 536 | set datasvf [open "[file rootname $dfile].svf" "r"] |
---|
| 537 | puts $final_svf "\n// Starting Download of Data file : $dfile\n" |
---|
| 538 | puts "\nCopying [file rootname $dfile].svf File to \ |
---|
| 539 | [file rootname $acefile].svf File\n" |
---|
| 540 | fcopy $datasvf $final_svf |
---|
| 541 | close $datasvf |
---|
| 542 | |
---|
| 543 | # Move the SVF to the Current directory |
---|
| 544 | file rename -force [file rootname $dfile].svf [pwd] |
---|
| 545 | } |
---|
| 546 | } |
---|
| 547 | |
---|
| 548 | # Convert elf->svf files. |
---|
| 549 | set elf_files $param(sw) |
---|
| 550 | if { [llength $elf_files] > 0 } { |
---|
| 551 | foreach elf $elf_files { |
---|
| 552 | if { ![file readable $elf] } { |
---|
| 553 | error "Unable to open executable file : $elf" |
---|
| 554 | } |
---|
| 555 | |
---|
| 556 | if { ![string match "[file extension $elf]" ".svf"] } { |
---|
| 557 | # Generate the .svf file for .elf file |
---|
| 558 | xmd_elf2svf $param(target) $elf $param(xmd_options) |
---|
| 559 | } |
---|
| 560 | set elfsvf [open "[file rootname $elf].svf" "r"] |
---|
| 561 | puts $final_svf "\n// Starting Download of ELF file : $elf\n" |
---|
| 562 | puts "\nCopying [file rootname $elf].svf File to \ |
---|
| 563 | [file rootname $acefile].svf File\n" |
---|
| 564 | fcopy $elfsvf $final_svf |
---|
| 565 | close $elfsvf |
---|
| 566 | |
---|
| 567 | # Move the SVF to the Current directory |
---|
| 568 | file rename -force [file rootname $elf].svf [pwd] |
---|
| 569 | } |
---|
| 570 | } |
---|
| 571 | } |
---|
| 572 | |
---|
| 573 | ####################################################################### |
---|
| 574 | # Procedure to generate the SVF file to run processor |
---|
| 575 | # saddr - is the PC value of Processor Execution |
---|
| 576 | ####################################################################### |
---|
| 577 | proc genace_sw_run { saddr } { |
---|
| 578 | global param |
---|
| 579 | global final_svf |
---|
| 580 | |
---|
| 581 | write_swsuffix $param(target) "sw_suffix.elf" $param(xmd_options) $saddr |
---|
| 582 | # Generate code to execute the program downloaded |
---|
| 583 | set suffixsvf [open "sw_suffix.svf" "r"] |
---|
| 584 | puts $final_svf "\n// Issuing Run command to PowerPC to start execution\n" |
---|
| 585 | fcopy $suffixsvf $final_svf |
---|
| 586 | close $suffixsvf |
---|
| 587 | } |
---|
| 588 | |
---|
| 589 | |
---|
| 590 | #--------------------------------------------------------------------- |
---|
| 591 | # |
---|
| 592 | # Procedures to parse GenACE Options |
---|
| 593 | # |
---|
| 594 | #--------------------------------------------------------------------- |
---|
| 595 | |
---|
| 596 | ####################################################################### |
---|
| 597 | # Proc to parse genace option file options |
---|
| 598 | ####################################################################### |
---|
| 599 | proc parse_genace_optfile { optfilename } { |
---|
| 600 | global param cpu_nr cpu_debugdevice cpu_target cpu_elf cpu_data cpu_startaddr |
---|
| 601 | |
---|
| 602 | if { ![file readable $optfilename] } { |
---|
| 603 | error "Unable to open GenACE option file : $optfilename" |
---|
| 604 | } |
---|
| 605 | set optfile [open "$optfilename" "r"] |
---|
| 606 | puts "Using GenACE option file : $optfilename" |
---|
| 607 | |
---|
| 608 | set debugdevice 1 |
---|
| 609 | set configdevice 1 |
---|
| 610 | set first_cpu 1 |
---|
| 611 | set ncpu 1 |
---|
| 612 | set cpu_nr($ncpu) 1 |
---|
| 613 | while { [gets $optfile optline] != -1 } { |
---|
| 614 | set llist [concat $optline] |
---|
| 615 | set genace_opt [lindex $llist 0] |
---|
| 616 | # Skip Comments |
---|
| 617 | if { [string match -nocase "#*" $genace_opt] } { |
---|
| 618 | continue |
---|
| 619 | } |
---|
| 620 | if { [string match -nocase "" $genace_opt] } { |
---|
| 621 | continue |
---|
| 622 | } |
---|
| 623 | switch -- $genace_opt { |
---|
| 624 | -jprog { |
---|
| 625 | # |
---|
| 626 | # Partial Configuration |
---|
| 627 | set param(jprog) "true" |
---|
| 628 | } |
---|
| 629 | -hw { |
---|
| 630 | # |
---|
| 631 | # Bitstream |
---|
| 632 | set param(hw) [lindex $llist 1] |
---|
| 633 | } |
---|
| 634 | -board { |
---|
| 635 | # |
---|
| 636 | # Board Type |
---|
| 637 | set param(board) [lindex $llist 1] |
---|
| 638 | } |
---|
| 639 | -ace { |
---|
| 640 | # |
---|
| 641 | # Output ACE file name |
---|
| 642 | set param(ace) [lindex $llist 1] |
---|
| 643 | } |
---|
| 644 | -configdevice { |
---|
| 645 | # |
---|
| 646 | # Board Jtag Chain information - Get the JTAG Devices Name from this option |
---|
| 647 | if { ![info exists param(jtag_chain_options)] } { |
---|
| 648 | set param(jtag_chain_options) $llist |
---|
| 649 | } |
---|
| 650 | set param(jtag_chain_options) [concat $param(jtag_chain_options) [lrange $llist 0 end]] |
---|
| 651 | set i 1 |
---|
| 652 | while { $i < [llength $llist] } { |
---|
| 653 | if {[string match -nocase "partname" [lindex $llist $i]]} { |
---|
| 654 | set param(jtag_devices) [concat $param(jtag_devices) [lindex $llist [expr $i+1]]] |
---|
| 655 | break |
---|
| 656 | } |
---|
| 657 | incr i 2 |
---|
| 658 | } |
---|
| 659 | if { $i >= [llength $llist] } { |
---|
| 660 | error "Device partname not specifed in -configdevice option" |
---|
| 661 | } |
---|
| 662 | set configdevice 0 |
---|
| 663 | } |
---|
| 664 | -debugdevice { |
---|
| 665 | # |
---|
| 666 | # FPGA position in the Chain. Also the CPU Nr of the processor |
---|
| 667 | set i 1 |
---|
| 668 | while { $i < [llength $llist] } { |
---|
| 669 | if {[string match -nocase "devicenr" [lindex $llist $i]]} { |
---|
| 670 | set jtag_fpga_position [lindex $llist [expr $i+1]] |
---|
| 671 | if { $param(jtag_fpga_position) == "" } { |
---|
| 672 | set param(jtag_fpga_position) $jtag_fpga_position |
---|
| 673 | set debugdevice 0 |
---|
| 674 | } else { |
---|
| 675 | if { $param(jtag_fpga_position) != $jtag_fpga_position } { |
---|
| 676 | error "JTAG FPGA position($jtag_fpga_position) is INVALID\n Previous value specified was $param(jtag_fpga_position)" |
---|
| 677 | } |
---|
| 678 | } |
---|
| 679 | } |
---|
| 680 | # |
---|
| 681 | # CPU Nr of the processor |
---|
| 682 | if {[string match -nocase "cpunr" [lindex $llist $i]]} { |
---|
| 683 | set cpunr [lindex $llist [expr $i+1]] |
---|
| 684 | if { !$first_cpu } { |
---|
| 685 | incr ncpu 1 |
---|
| 686 | } |
---|
| 687 | set first_cpu 0 |
---|
| 688 | set cpu_nr($ncpu) $cpunr |
---|
| 689 | } |
---|
| 690 | incr i 2 |
---|
| 691 | } |
---|
| 692 | set cpu_debugdevice($ncpu) $llist |
---|
| 693 | } |
---|
| 694 | -jtag_fpga_position { |
---|
| 695 | # |
---|
| 696 | # FPGA position in the Chain. |
---|
| 697 | set jtag_fpga_position [lindex $llist 1] |
---|
| 698 | if { $param(jtag_fpga_position) == "" } { |
---|
| 699 | set param(jtag_fpga_position) $jtag_fpga_position |
---|
| 700 | set debugdevice 0 |
---|
| 701 | } else { |
---|
| 702 | if { $param(jtag_fpga_position) != $jtag_fpga_position } { |
---|
| 703 | error "JTAG FPGA position($jtag_fpga_position) is INVALID\n Previous value specified was $param(jtag_fpga_position)" |
---|
| 704 | } |
---|
| 705 | } |
---|
| 706 | } |
---|
| 707 | -target { |
---|
| 708 | # |
---|
| 709 | # Processor Target Type (ppc, mdm) |
---|
| 710 | set cpu_target($ncpu) [lindex $llist 1] |
---|
| 711 | } |
---|
| 712 | -elf { |
---|
| 713 | # |
---|
| 714 | # ELF files to write for the Processor |
---|
| 715 | if { ![info exists cpu_elf($ncpu)] } { |
---|
| 716 | set cpu_elf($ncpu) [list] |
---|
| 717 | } |
---|
| 718 | set cpu_elf($ncpu) [concat $cpu_elf($ncpu) [lrange $llist 1 end]] |
---|
| 719 | } |
---|
| 720 | -data { |
---|
| 721 | # |
---|
| 722 | # Data files & Start Address to write for the Processor |
---|
| 723 | if { ![info exists cpu_data($ncpu)] } { |
---|
| 724 | set cpu_data($ncpu) [list] |
---|
| 725 | } |
---|
| 726 | set data_ip [llength $llist] |
---|
| 727 | incr data_ip -1 |
---|
| 728 | if { [expr $data_ip % 2] } { |
---|
| 729 | error "Incorrect -data option. Check if the Load Address is Specified" |
---|
| 730 | } |
---|
| 731 | set cpu_data($ncpu) [concat $cpu_data($ncpu) [lrange $llist 1 end]] |
---|
| 732 | } |
---|
| 733 | -start_address { |
---|
| 734 | # |
---|
| 735 | # Address to Start Program Execution |
---|
| 736 | set cpu_startaddr($ncpu) [lrange $llist 1 end] |
---|
| 737 | } |
---|
| 738 | default { |
---|
| 739 | error "Unknown option $genace_opt" |
---|
| 740 | } |
---|
| 741 | } |
---|
| 742 | } |
---|
| 743 | close $optfile |
---|
| 744 | set param(ncpu) $ncpu |
---|
| 745 | |
---|
| 746 | set i 1 |
---|
| 747 | while { $i <= $param(ncpu) } { |
---|
| 748 | set cpunr $cpu_nr($i) |
---|
| 749 | if { ![info exists cpu_target($i)] } { |
---|
| 750 | puts "Target Type not defined for Processor $cpunr, Using default Target Type ppc_hw" |
---|
| 751 | set cpu_target($i) "ppc_hw" |
---|
| 752 | } |
---|
| 753 | incr i 1 |
---|
| 754 | } |
---|
| 755 | |
---|
| 756 | if { [string match -nocase $param(board) "user"] && [expr $configdevice || $debugdevice]} { |
---|
| 757 | error "\[-board user\] option missing either -configdevice or -debugdevice options" |
---|
| 758 | } |
---|
| 759 | |
---|
| 760 | #puts "\nGenACE Options" |
---|
| 761 | #puts "Jtag Chain : $param(jtag_chain_options)" |
---|
| 762 | #puts "jtag_fpga_position : $param(jtag_fpga_position)" |
---|
| 763 | #puts "jtag_devices : $param(jtag_devices)" |
---|
| 764 | #puts "NCPUs : $param(ncpu)" |
---|
| 765 | #set i 1 |
---|
| 766 | #while { $i <= $param(ncpu) } { |
---|
| 767 | #set cpunr $cpu_nr($i) |
---|
| 768 | #puts "\nProcessor $cpu_target($i)_$cpu_nr($i) Information" |
---|
| 769 | #if { [info exists cpu_elf($i)] } { |
---|
| 770 | #puts "ELF files : $cpu_elf($i)" |
---|
| 771 | #} |
---|
| 772 | #if { [info exists cpu_data($i)] } { |
---|
| 773 | #puts "ELF files : $cpu_data($i)" |
---|
| 774 | #} |
---|
| 775 | #incr i 1 |
---|
| 776 | #} |
---|
| 777 | return |
---|
| 778 | } |
---|
| 779 | |
---|
| 780 | |
---|
| 781 | ####################################################################### |
---|
| 782 | # Proc to parse genace commandline options |
---|
| 783 | ####################################################################### |
---|
| 784 | proc parse_genace_options {optc optv} { |
---|
| 785 | global param cpu_nr cpu_target cpu_elf cpu_data cpu_startaddr |
---|
| 786 | |
---|
| 787 | if {[string match -nocase "-opt" [lindex $optv 0]]} { |
---|
| 788 | if { [catch {parse_genace_optfile [lindex $optv 1]} err] } { |
---|
| 789 | error "(OptFile) $err" |
---|
| 790 | } |
---|
| 791 | return |
---|
| 792 | } |
---|
| 793 | |
---|
| 794 | set first_cpu 1 |
---|
| 795 | set ncpu 1 |
---|
| 796 | set cpu_nr($ncpu) 1 |
---|
| 797 | for {set i 0} { $i < $optc } { incr i } { |
---|
| 798 | set arg [lindex $optv $i] |
---|
| 799 | switch -- $arg { |
---|
| 800 | -jprog { |
---|
| 801 | set param(jprog) "true" |
---|
| 802 | } |
---|
| 803 | -hw { |
---|
| 804 | incr i |
---|
| 805 | set param(hw) [lindex $optv $i] |
---|
| 806 | } |
---|
| 807 | -board { |
---|
| 808 | incr i |
---|
| 809 | set param(board) [lindex $optv $i] |
---|
| 810 | } |
---|
| 811 | -ace { |
---|
| 812 | incr i |
---|
| 813 | set param(ace) [lindex $optv $i] |
---|
| 814 | } |
---|
| 815 | -target { |
---|
| 816 | incr i |
---|
| 817 | # No check done !! |
---|
| 818 | set cpu_target($ncpu) [lindex $optv $i] |
---|
| 819 | } |
---|
| 820 | -elf { |
---|
| 821 | incr i |
---|
| 822 | set next_option_index [lsearch [lrange $optv $i end] "-*"] |
---|
| 823 | if {$next_option_index == -1 } { |
---|
| 824 | set next_option_index $optc |
---|
| 825 | } else { |
---|
| 826 | incr next_option_index $i |
---|
| 827 | } |
---|
| 828 | |
---|
| 829 | while {$i < $next_option_index} { |
---|
| 830 | set elf [lindex $optv $i] |
---|
| 831 | incr i |
---|
| 832 | } |
---|
| 833 | # go back one arg as outer loop would "incr i" too |
---|
| 834 | incr i -1 |
---|
| 835 | |
---|
| 836 | if { ![info exists cpu_elf($ncpu)] } { |
---|
| 837 | set cpu_elf($ncpu) [list] |
---|
| 838 | } |
---|
| 839 | set cpu_elf($ncpu) [concat $cpu_elf($ncpu) $elf] |
---|
| 840 | } |
---|
| 841 | -data { |
---|
| 842 | incr i |
---|
| 843 | set next_option_index [lsearch [lrange $optv $i end] "-*"] |
---|
| 844 | if {$next_option_index == -1 } { |
---|
| 845 | set next_option_index $optc |
---|
| 846 | } else { |
---|
| 847 | incr next_option_index $i |
---|
| 848 | } |
---|
| 849 | if { [expr ($next_option_index - $i)%2] != 0 } { |
---|
| 850 | error "Missing load address for data file" |
---|
| 851 | } |
---|
| 852 | |
---|
| 853 | set data [list] |
---|
| 854 | while {$i < $next_option_index} { |
---|
| 855 | set data [concat $data [lrange $optv $i [incr i]]] |
---|
| 856 | incr i |
---|
| 857 | } |
---|
| 858 | # go back one arg as outer loop would "incr i" too |
---|
| 859 | incr i -1 |
---|
| 860 | |
---|
| 861 | if { ![info exists cpu_data($ncpu)] } { |
---|
| 862 | set cpu_data($ncpu) [list] |
---|
| 863 | } |
---|
| 864 | set cpu_data($ncpu) [concat $cpu_data($ncpu) $data] |
---|
| 865 | } |
---|
| 866 | -start_address { |
---|
| 867 | incr i |
---|
| 868 | set cpu_startaddr($ncpu) [lindex $optv $i] |
---|
| 869 | } |
---|
| 870 | default { |
---|
| 871 | error "Unknown option $arg" |
---|
| 872 | } |
---|
| 873 | } |
---|
| 874 | } |
---|
| 875 | set param(ncpu) $ncpu |
---|
| 876 | |
---|
| 877 | set i 1 |
---|
| 878 | while { $i <= $param(ncpu) } { |
---|
| 879 | set cpunr $cpu_nr($i) |
---|
| 880 | if { ![info exists cpu_target($i)] } { |
---|
| 881 | puts "Target Type not defined for Processor $cpunr, Using default Target Type ppc_hw" |
---|
| 882 | set cpu_target($i) "ppc_hw" |
---|
| 883 | } |
---|
| 884 | incr i 1 |
---|
| 885 | } |
---|
| 886 | return |
---|
| 887 | } |
---|
| 888 | |
---|
| 889 | #--------------------------------------------------------------------- |
---|
| 890 | # |
---|
| 891 | # Start GenACE |
---|
| 892 | # |
---|
| 893 | #--------------------------------------------------------------------- |
---|
| 894 | |
---|
| 895 | puts "\n#######################################################################" |
---|
| 896 | puts "XMD GenACE utility. Generate SystemACE File from bit/elf/data Files" |
---|
| 897 | puts "#######################################################################" |
---|
| 898 | |
---|
| 899 | |
---|
| 900 | # Platform Check - Solaris NOT Supported |
---|
| 901 | set platform [lindex [array get tcl_platform os] 1] |
---|
| 902 | if { [string match -nocase $platform "SunOS"] } { |
---|
| 903 | puts "\nERROR : Solaris platform NOT supported by GenACE Utility" |
---|
| 904 | return |
---|
| 905 | } |
---|
| 906 | |
---|
| 907 | # Parse Genace script Options |
---|
| 908 | if { [catch {parse_genace_options $argc $argv} err] } { |
---|
| 909 | puts "\nCmdline Error: $err" |
---|
| 910 | puts $usage |
---|
| 911 | return |
---|
| 912 | } |
---|
| 913 | |
---|
| 914 | # Check if either -elf or -hw options are specified |
---|
| 915 | set i 1 |
---|
| 916 | set sw_exists 0 |
---|
| 917 | # Used for Filename check - See below |
---|
| 918 | set flist "" |
---|
| 919 | while { $i <= $param(ncpu) } { |
---|
| 920 | if { [info exists cpu_elf($i)] } { |
---|
| 921 | set flist [concat $flist $cpu_elf($i)] |
---|
| 922 | set sw_exists 1 |
---|
| 923 | #break |
---|
| 924 | } |
---|
| 925 | if { [info exists cpu_data($i)] } { |
---|
| 926 | set flist [concat $flist $cpu_data($i)] |
---|
| 927 | set sw_exists 1 |
---|
| 928 | #break |
---|
| 929 | } |
---|
| 930 | incr i 1 |
---|
| 931 | } |
---|
| 932 | if { $sw_exists == 0 && $param(hw) == "" } { |
---|
| 933 | puts "\nERROR : Either a hw bitstream or sw ELF/data file should be provided to generate the ACE file" |
---|
| 934 | puts $usage |
---|
| 935 | return |
---|
| 936 | } |
---|
| 937 | |
---|
| 938 | # Check if -ace option has been specified |
---|
| 939 | if { $param(ace) == "" } { |
---|
| 940 | puts "\nERROR : An output ACE file should be specified using the -ace option" |
---|
| 941 | puts $usage |
---|
| 942 | return |
---|
| 943 | } |
---|
| 944 | |
---|
| 945 | # Check Filenames. BIT/ELF/Data filename prefix should not match ACE filename prefix |
---|
| 946 | # -- Backward Compatibility |
---|
| 947 | set ace_prefix [file tail $param(ace)] |
---|
| 948 | set ace_prefix [file rootname $ace_prefix] |
---|
| 949 | set flist [concat $param(hw) $flist] |
---|
| 950 | foreach filename $flist { |
---|
| 951 | set tfilename [file tail $filename] |
---|
| 952 | set fname_prefix [file rootname $tfilename] |
---|
| 953 | if { [string match $ace_prefix $fname_prefix] } { |
---|
| 954 | puts "\nERROR : Output ACE File($param(ace)) & I/P ($filename) have same Filename prefix \"$ace_prefix\"" |
---|
| 955 | puts "ERROR : Please provide a different ACE file name\n" |
---|
| 956 | return |
---|
| 957 | } |
---|
| 958 | } |
---|
| 959 | |
---|
| 960 | |
---|
| 961 | ####################################################################### |
---|
| 962 | # |
---|
| 963 | # Actually Start the ACE file generation Process |
---|
| 964 | # |
---|
| 965 | ####################################################################### |
---|
| 966 | #silent_mode on |
---|
| 967 | # Get the Board Information - Jtag Chain, FPGA device on the chain. |
---|
| 968 | # For Board Type user - get the board config information from user |
---|
| 969 | set board [string tolower $param(board)] |
---|
| 970 | if {![string match $board "user"] && ![array exist $board] } { |
---|
| 971 | puts "ERROR: $board is not a valid board name.\n" |
---|
| 972 | return |
---|
| 973 | } |
---|
| 974 | if { ![string match $board "user"]} { |
---|
| 975 | set param(jtag_chain_options) [lindex [array get $board "jtag_chain_options"] 1] |
---|
| 976 | set param(jtag_devices) [lindex [array get $board "jtag_devices"] 1] |
---|
| 977 | set param(jtag_fpga_position) [lindex [array get $board "jtag_fpga_position"] 1] |
---|
| 978 | } |
---|
| 979 | |
---|
| 980 | # Get the Start PC address for each Processor |
---|
| 981 | set i 1 |
---|
| 982 | while { $i <= $param(ncpu) } { |
---|
| 983 | set cpunr $cpu_nr($i) |
---|
| 984 | if { ![info exists cpu_startaddr($i)] } { |
---|
| 985 | if { [info exists cpu_elf($i)] } { |
---|
| 986 | set elflist $cpu_elf($i) |
---|
| 987 | set lastelf [lindex $elflist end] |
---|
| 988 | if { [catch {set cpu_startaddr($i) [get_elf_startaddr $cpu_target($i) $lastelf]} err] } { |
---|
| 989 | puts "\nError: $err" |
---|
| 990 | return |
---|
| 991 | } |
---|
| 992 | } else { |
---|
| 993 | if { [info exists cpu_data($i)] } { |
---|
| 994 | error "Address to Start Processor Execution Not Specified" |
---|
| 995 | } |
---|
| 996 | } |
---|
| 997 | } |
---|
| 998 | incr i 1 |
---|
| 999 | } |
---|
| 1000 | |
---|
| 1001 | puts "GenACE Options:" |
---|
| 1002 | puts "\tBoard : $param(board)" |
---|
| 1003 | puts "\tJtag Devs : $param(jtag_devices)" |
---|
| 1004 | puts "\tFPGA pos : $param(jtag_fpga_position)" |
---|
| 1005 | puts "\tJPROG : $param(jprog)" |
---|
| 1006 | puts "\tHW File : $param(hw)" |
---|
| 1007 | puts "\tACE File : $param(ace)" |
---|
| 1008 | puts "\tnCPUs : $param(ncpu)" |
---|
| 1009 | set i 1 |
---|
| 1010 | while { $i <= $param(ncpu) } { |
---|
| 1011 | set cpunr $cpu_nr($i) |
---|
| 1012 | puts "\n\tProcessor $cpu_target($i)_$cpu_nr($i) Information" |
---|
| 1013 | if { ![info exists cpu_debugdevice($i)] } { |
---|
| 1014 | set cpu_debugdevice($i) "-debugdevice devicenr $param(jtag_fpga_position) cpunr $cpu_nr($i)" |
---|
| 1015 | } else { |
---|
| 1016 | if { [lsearch $cpu_debugdevice($i) "devicenr"] == -1 } { |
---|
| 1017 | set cpu_debugdevice($i) [concat $cpu_debugdevice($i) "devicenr $param(jtag_fpga_position)"] |
---|
| 1018 | } |
---|
| 1019 | if { [lsearch $cpu_debugdevice($i) "cpunr"] == -1 } { |
---|
| 1020 | set cpu_debugdevice($i) [concat $cpu_debugdevice($i) "cpunr $cpu_nr($i)"] |
---|
| 1021 | } |
---|
| 1022 | } |
---|
| 1023 | puts "\t\tDebug opt : $cpu_debugdevice($i)" |
---|
| 1024 | if { [info exists cpu_elf($i)] } { |
---|
| 1025 | puts "\t\tELF files : $cpu_elf($i)" |
---|
| 1026 | } |
---|
| 1027 | if { [info exists cpu_data($i)] } { |
---|
| 1028 | puts "\t\tData files : $cpu_data($i)" |
---|
| 1029 | } |
---|
| 1030 | if { [info exists cpu_startaddr($i)] } { |
---|
| 1031 | puts "\t\tStart PC Address : $cpu_startaddr($i)" |
---|
| 1032 | } |
---|
| 1033 | incr i 1 |
---|
| 1034 | } |
---|
| 1035 | |
---|
| 1036 | # Get the irLength of FPGA. |
---|
| 1037 | set options_list [concat $param(jtag_chain_options)] |
---|
| 1038 | set index $param(jtag_fpga_position) |
---|
| 1039 | set i 0 |
---|
| 1040 | while { $i < [llength $options_list] } { |
---|
| 1041 | if {[string match -nocase "irlength" [lindex $options_list $i]]} { |
---|
| 1042 | incr index -1 |
---|
| 1043 | if { $index == 0 } { |
---|
| 1044 | set fpga_irlength [lindex $options_list [expr $i+1]] |
---|
| 1045 | break |
---|
| 1046 | } |
---|
| 1047 | } |
---|
| 1048 | incr i 1 |
---|
| 1049 | } |
---|
| 1050 | if { $index > 0 } { |
---|
| 1051 | error "Cannot find FPGA Instr Register Length.. Please check your JTAG options" |
---|
| 1052 | } |
---|
| 1053 | |
---|
| 1054 | # |
---|
| 1055 | # Open the SVF File |
---|
| 1056 | set final_svf [open "[file rootname $param(ace)].svf" "w"] |
---|
| 1057 | write_prefix $final_svf $argv |
---|
| 1058 | |
---|
| 1059 | # |
---|
| 1060 | # Generate ACE for H/W BitStream |
---|
| 1061 | if { $param(hw) != "" } { |
---|
| 1062 | if { [catch {genace_hw} err] } { |
---|
| 1063 | puts "Error: $err" |
---|
| 1064 | return |
---|
| 1065 | } |
---|
| 1066 | } |
---|
| 1067 | |
---|
| 1068 | if { $sw_exists } { |
---|
| 1069 | # |
---|
| 1070 | # Generate ACE for S/W files, for each processor |
---|
| 1071 | set i 1 |
---|
| 1072 | while { $i <= $param(ncpu) } { |
---|
| 1073 | set cpunr $cpu_nr($i) |
---|
| 1074 | set param(target) $cpu_target($i) |
---|
| 1075 | set param(xmd_options) [concat $param(jtag_chain_options) $cpu_debugdevice($i)] |
---|
| 1076 | if { [info exists cpu_elf($i)] } { |
---|
| 1077 | set param(sw) $cpu_elf($i) |
---|
| 1078 | } |
---|
| 1079 | if { [info exists cpu_data($i)] } { |
---|
| 1080 | set param(data) $cpu_data($i) |
---|
| 1081 | } |
---|
| 1082 | if { [catch {genace_sw_download} err] } { |
---|
| 1083 | puts "Error: $err" |
---|
| 1084 | return |
---|
| 1085 | } |
---|
| 1086 | incr i 1 |
---|
| 1087 | } |
---|
| 1088 | |
---|
| 1089 | # |
---|
| 1090 | # Generate ACE to Run each processor |
---|
| 1091 | set i 1 |
---|
| 1092 | while { $i <= $param(ncpu) } { |
---|
| 1093 | set cpunr $cpu_nr($i) |
---|
| 1094 | set param(target) $cpu_target($i) |
---|
| 1095 | set param(xmd_options) [concat $param(jtag_chain_options) $cpu_debugdevice($i)] |
---|
| 1096 | if { [info exists cpu_startaddr($i)] } { |
---|
| 1097 | if { [catch {genace_sw_run $cpu_startaddr($i)} err] } { |
---|
| 1098 | puts "Error: $err" |
---|
| 1099 | return |
---|
| 1100 | } |
---|
| 1101 | } |
---|
| 1102 | incr i 1 |
---|
| 1103 | } |
---|
| 1104 | } |
---|
| 1105 | |
---|
| 1106 | close $final_svf |
---|
| 1107 | |
---|
| 1108 | # |
---|
| 1109 | # Convert the SVF -> ACE |
---|
| 1110 | impact_svf2ace $param(ace) |
---|
| 1111 | |
---|
| 1112 | puts "\nSystemACE file '$param(ace)' created successfully" |
---|
| 1113 | return |
---|
| 1114 | |
---|