UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

AR# 30962

Tcl - Is there a way in the Xilinx Tcl shell to list all of the properties available for the current project?

Description

Is there a way to generate a list of all the options that can be set for a Project Navigator Project?

Solution

All of the project process properties available in the Project Navigator GUI are available to read or be set through the Tcl shell. The property names in Tcl are the same as displayed in the GUI.

To view the available properties, enter the following command:

project properties

For a line-separated list of available properties, enter the following command:

for each prop [project properties] {puts "$prop"}

To obtain the current value of a specific process property, enter "project get "<process name>"

Example:

project get "Macro Search Path"

If more than one process uses the same property name, process must also be specified.

Example:

project get "Register Duplication" -process "Synthesize - XST"

To set a process property from Tcl, type "project set <property_name> <property_value>"

Example:

project set "Macro Search Path" "c:/Ip/netlist_directory"

For more information on these or any Xilinx Tcl command, type "help <command name>"

#!xtclsh

#

# Example script for ISE xtclsh. This script reads all of the process

# properties from an open ISE project and creates two files:

# 1. <project name>_process_properties.txt is a human readable report

# with all of the properties and their values listed in a table.

# 2. <project name>_process_properties.csv is designed to be imported

# into a spreadshet program such as Micorsoft Excel.

# 3. <project name>_clone_script.tcl will create a Tcl script that

# can be used to clone the current open project into another

# project.

#

# To run this script, a project must be open and it must have one or

# more design files in the synthesis view, such as HDL, EDIF, NGO, etc.

# Then, source the scipt with the source command:

# % source generate_process_property_report.tcl

#

# Documentation on ISE's Tcl commands can be found in the

# ISE 9.1i Development Reference Guide, Chapter 3.

# Documentation on Tcl's native commands can be found at http://tcl.tk.

#

#

#

# $Id: generate_process_property_report.tcl,v 1.2 2007/06/07 22:45:28 hgebb Exp $

#

# proc get_properties

#

# Build up the variable which stores the process, properties of the processes,

# and their values. This data strucuture is a list of lists and looks like

# {{proc1 {{prop1 val1} {prop2 val2}}} {proc2 {{prop1 val1}}}}

#

# arguments:

# props_name: inout data structure which stores the process property values

# return: none

#

proc get_properties {props_name} {

upvar $props_name props

set processes [project get_processes]

set projName [project get name]

puts "Reading process properties from $projName"

foreach proc_iter $processes {

puts " $proc_iter "

set properties [project properties -process $proc_iter]

puts " $properties" ;# DEBUG

foreach prop_iter $properties {

puts " $prop_iter" ;# DEBUG

set val [project get $prop_iter -process $proc_iter]

puts " $prop_iter $val" ;#DEBUG

lappend prop_list [list $prop_iter $val]

}

lappend props [list $proc_iter $prop_list]

unset prop_list

}

}

# proc create_text

#

# Create the text file report.

#

# Arguments:

# props: input data structure holding the process properies. See get_properties

# for a description

# fileName: input name of file to create. It will be overwritten if it exists.

# Return: none.

#

proc create_text {props fileName} {

set fid [open $fileName w]

set name_len 0

set val_len 0

foreach proc_iter $props {

foreach prop_iter [lindex $proc_iter 1] {

set x [string length [lindex $prop_iter 0]]

if {$x > $name_len} {set name_len $x}

set x [string length [lindex $prop_iter 1]]

if {$x > $val_len} {set val_len $x}

}

}

set majorDivide [string repeat "=" [expr $name_len + $val_len + 7]]

set majorDivide [string replace $majorDivide 0 0 "|"]

set majorDivide [string replace $majorDivide end end "|"]

set minorDivide [string repeat "-" [expr $name_len + $val_len + 7]]

set minorDivide [string replace $minorDivide 0 0 "|"]

set minorDivide [string replace $minorDivide end end "|"]

set lineTemplate "| "

append lineTemplate [string repeat " " $name_len]

append lineTemplate " | "

append lineTemplate [string repeat " " $val_len]

append lineTemplate " |"

set name_start 2

set val_start [expr $name_len + 5]

puts $fid "Copyright (c) 1995-2007 Xilinx, Inc. All rights reserved.\n"

puts $fid "[clock format [clock seconds] -format %c\n]"

puts $fid "INFO: Process property values for an ISE project."

puts $fid "1. The <project name>_process_properties.txt file (this file)"

puts $fid " reports process property values in a human readable ASCII text format."

puts $fid "2. The <project name>_propcess_properties.csv file for use with spreadsheet"

puts $fid " programs such as MS Excel.\n"

puts $fid "INPUT FILE: [project get name]"

puts $fid "OUTPUT FILE: $fileName\n"

foreach proc_iter $props {

set proc_name [lindex $proc_iter 0]

puts $fid $majorDivide

set line $lineTemplate

set line [string replace $line [expr $name_len + 3] [expr $name_len + 3] " "]

set line [string replace $line $name_start [expr $name_start + [string length $proc_name] - 1] $proc_name]

puts $fid $line

puts $fid $minorDivide

foreach prop_iter [lindex $proc_iter 1] {

set prop_name [lindex $prop_iter 0]

set prop_val [lindex $prop_iter 1]

set line $lineTemplate

set line [string replace $line $name_start [expr $name_start + [string length $prop_name] - 1] $prop_name]

set line [string replace $line $val_start [expr $val_start + [string length $prop_val] - 1] $prop_val]

puts $fid $line

}

}

puts $fid $majorDivide

close $fid

puts "Generated Process Properties report file $fileName"

}

# proc create_excel

#

# Create the CSV file designed to be imported into a spreadsheet program.

#

# Arguments:

# props: input data structure holding the process properies. See get_properties

# for a description

# fileName: input name of file to create. It will be overwritten if it exists.

# Return: none.

#

proc create_excel {props fileName} {

set fid [open $fileName w]

puts $fid "\# Copyright (c) 1995-2007 Xilinx, Inc. All rights reserved.\n\#"

puts $fid "\# [clock format [clock seconds] -format %c\n\#]"

puts $fid "\# INFO: Process property values for an ISE project."

puts $fid "\# 1. The <project name>_process_properties.csv file (this file)"

puts $fid "\# reports process property values in a format designed to be imported into a"

puts $fid "\# spreadsheet program such as Microsoft Excel for viewing, printing and sorting.\n\#"

puts $fid "\# INPUT FILE: [project get name]"

puts $fid "\# OUTPUT FILE: $fileName\n\#\n\#"

foreach proc_iter $props {

set proc_name [lindex $proc_iter 0]

foreach prop_iter [lindex $proc_iter 1] {

set prop_name [lindex $prop_iter 0]

set prop_val [lindex $prop_iter 1]

puts $fid "$proc_name,$prop_name,$prop_val"

}

}

close $fid

puts "Generated Process Properties spreadsheet file $fileName"

}

proc handleSpecialCharsImpl {x chr} {

upvar $x str

set lastmatch 0

while {[set idx [string first $chr $str $lastmatch]] >= 0} {

set lastmatch [expr {$idx + 2}]

set str [string replace $str $idx $idx "\\$chr"]

}

}

proc handleSpecialChars {x} {

upvar $x str

handleSpecialCharsImpl str \\

handleSpecialCharsImpl str \$

}

# proc create_excel

#

# Create the CSV file designed to be imported into a spreadsheet program.

#

# Arguments:

# props: input data structure holding the process properies. See get_properties

# for a description

# fileName: input name of file to create. It will be overwritten if it exists.

# Return: none.

#

proc create_clone_script {props fileName} {

set fid [open $fileName w]

puts $fid "\# Copyright (c) 1995-2007 Xilinx, Inc. All rights reserved.\n\#"

puts $fid "\# [clock format [clock seconds] -format %c\n\#]"

puts $fid "\# INFO: Clone process property values for an ISE project."

puts $fid "\# 1. The <project name>_clone_sciprt.tcl file (this file)"

puts $fid "\# is designed to clone one ISE project into another one."

puts $fid "\# This is limited to implementation process properties."

puts $fid "\# Simulation process properties are not supported.\n\#"

puts $fid "\# INPUT FILE: [project get name]"

puts $fid "\# OUTPUT FILE: $fileName\n\#\n\#"

foreach proc_iter $props {

set proc_name [lindex $proc_iter 0]

foreach prop_iter [lindex $proc_iter 1] {

set prop_name [lindex $prop_iter 0]

set prop_val [lindex $prop_iter 1]

set lastMatch 0

handleSpecialChars prop_name

handleSpecialChars prop_val

if {$prop_name == "name" || $prop_name == "top"} {

puts $fid "puts \{===== filtering out project set \"$prop_name\" \"$prop_val\" -process \"$proc_name\"\}"

puts $fid "# project set \"$prop_name\" \"$prop_val\" -process \"$proc_name\""

} else {

puts $fid "puts \{executing project set \"$prop_name\" \"$prop_val\" -process \"$proc_name\"\}"

puts $fid "project set \"$prop_name\" \"$prop_val\" -process \"$proc_name\""

}

}

}

close $fid

puts "Generated Process Properties spreadsheet file $fileName"

}

# Verify that a project is open

if [catch {project get name} iseName] {

error $iseName

}

set textFile "[file rootname $iseName]_process_properties.txt"

set csvFile "[file rootname $iseName]_process_properties.csv"

set cloneFile "[file rootname $iseName]_clone_script.tcl"

get_properties properties

create_text $properties $textFile

create_excel $properties $csvFile

create_clone_script $properties $cloneFile

AR# 30962
Date Created 05/19/2008
Last Updated 12/15/2012
Status Active
Type General Article