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!

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Contributor
Contributor
145 Views
Registered: ‎04-14-2008

Commands fail when ran from within a proc

I have an IP Packager script in which I add and configure a bunch of files in the following manner

ipx::add_file <some/file> [ipx::get_file_groups <some/group> -of_objects [ipx::current_core]]
set_property library_name <some/lib> [ipx::get_files <some/file> -of_objects [ipx::get_file_groups <some/group> -of_objects [ipx::current_core]]]

which I want to simplify to reduce the footprint of all this boilerplate code so it's easier to maintain. To do that, I created a function that take the file name as the first argument and keyword arguments with the required arguments (some of them are optional), so I could do

# Setup with all args
add_and_setup <some/file> -library <some/library> -group <some/group>
# Setup without specifying the library for example
add_and_setup <some/file> -group <some/group>

The function body is as follows:

proc add_and_setup { args } {
  # filename is the first and mandatory arg. Grab the value and remove it from
  # the list
  set filename [ lindex $args 0 ]
  array set kwargs [lreplace $args 0 0]

  set file [ ipx::add_file $filename [ ipx::get_file_groups $kwargs(-group) -of_objects [ipx::current_core] ] ]

  if { [ info exists kwargs(-library) ] } {
    set_property library_name $kwargs(-library) $file
  }
  if { [ info exists kwargs(-type) ] } {
    set_property type $kwargs(-type) $file
  }

}

 

When I call in the original way, everything works. When I call using the function, I get the following error while running the ipx::add_file command:

ERROR: [Common 17-69] Command failed: Multiple '-file_group' values are not supported

From the log, Vivado shows that $kwargs(-group) is empty (it's not), so instead of calling ipx::get_file_groups with the <group/name> as argument, it's called without any, which seems to return all groups.

Any ideas of what might be wrong??

Tags (3)
0 Kudos