Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
12 years ago

Quartus TCL Problems - get_all_global_assignments

I'm trying to figure out how to use the get_all_global_assignments TCL command. I might be using it incorrectly, but I strongly suspect there is a bug in the tool.

I have a project who's qsf file is as follows:

set_global_assignment -name FAMILY "Cyclone II"
set_global_assignment -name DEVICE EP2C35F484C8
set_global_assignment -name TOP_LEVEL_ENTITY toplevel
set_global_assignment -name ORIGINAL_QUARTUS_VERSION "13.0 SP1"
set_global_assignment -name PROJECT_CREATION_TIME_DATE "13:53:34  NOVEMBER 14, 2013"
set_global_assignment -name LAST_QUARTUS_VERSION "13.0 SP1"
set_global_assignment -name PROJECT_OUTPUT_DIRECTORY output_files
set_global_assignment -name MIN_CORE_JUNCTION_TEMP 0
set_global_assignment -name MAX_CORE_JUNCTION_TEMP 85
set_global_assignment -name ERROR_CHECK_FREQUENCY_DIVISOR 1
set_global_assignment -name EDA_SIMULATION_TOOL "ModelSim-Altera (Verilog)"
set_global_assignment -name EDA_OUTPUT_DATA_FORMAT "VERILOG HDL" -section_id eda_simulation
set_global_assignment -name VERILOG_INPUT_VERSION SYSTEMVERILOG_2005
set_global_assignment -name VERILOG_SHOW_LMF_MAPPING_MESSAGES OFF
set_global_assignment -name PARTITION_NETLIST_TYPE SOURCE -section_id Top
set_global_assignment -name PARTITION_FITTER_PRESERVATION_LEVEL PLACEMENT_AND_ROUTING -section_id Top
set_global_assignment -name PARTITION_COLOR 16764057 -section_id Top
set_global_assignment -name VERILOG_FILE SPIBlaster.v
set_global_assignment -name VERILOG_FILE RTL_Sandbox/SPIBlaster.v
set_global_assignment -name BDF_FILE RTL_Sandbox/toplevel.bdf
set_instance_assignment -name PARTITION_HIERARCHY root_partition -to | -section_id Top

In the TCL console, I can extract a single assignment no problem:

tcl> get_global_assignment -name BDF_FILE
RTL_Sandbox/toplevel.bdf

Now, if I try to extract an item that has multiple values, it tells me to use another command...

tcl> get_global_assignment -name VERILOG_FILE
Error:ERROR: Assignment VERILOG_FILE has multiple values. Use the "get_all_global_assignments" command to get all values or use the "get_global_assignment -front" command to get the first value.
Error:    while executing
Error:"get_global_assignment -name VERILOG_FILE"

Now, I try to use the get_all_global_assignments command as shown in the documetation and it returns an empty array:

tcl> set verfiles 
_col31
tcl> foreach_in_collection afile $verfiles {
> puts 
> }

Nothing is printed out!

I've examined the returned array, it's empty, but it does give an array of the correct size. I expect the results of this command to return the TWO VERILOG_FILE names, it returns empty by does have a length of two:

tcl> set verfiles 
_col31
tcl> foreach_in_collection afile $verfiles {
> puts "test"
> }
test
test

Any ideas about what's going wrong?

Thanks!

9 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Hi mmTsuchi,

    Thanks for your response. Unfortunately, this does not work. I've tried to using index 0, 1, 2, etc... nothing is returned for any of them.

    The syntax defined in the help indicates the result should be located at index 2:

    
    tcl> help get_all_global_assignments
    --------------
    Example Usage:
    --------------
    # # Print out all the registered source files
    # # using the foreach_in_collection method
    set file_asgn_col 
    foreach_in_collection file_asgn $file_asgn_col {
       # # Each element in the collection has the following
       # # format: {} {SOURCE_FILE} {<file_name>}
        puts 
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I'll wager you forgot to open the project. You are running this from a PRE_FLOW_SCRIPT_FILE ?

    This worked for me:

    set project [lindex $quartus(args) 1]

    set revision [lindex $quartus(args) 2]

    project_open $project -revision $revision

    set verfiles [get_all_global_assignments -name VERILOG_FILE]

    foreach_in_collection afile $verfiles {

    post_message "file: $afile"

    }

    In Quartus 13.1 I saw these sorts of output:

    Info: file: {} VERILOG_FILE ../../../ip_cores/wr-cores/platform/altera/arria5_pll/sys_pll5/sys_pll5_0002.v {} {}

    Info: file: {} VERILOG_FILE ../../../ip_cores/wr-cores/platform/altera/arria5_pll/ref_pll5/ref_pll5_0002.v {} {}

    Info: file: {} VERILOG_FILE ../../../ip_cores/wr-cores/platform/altera/arria5_pll/dmtd_pll5/dmtd_pll5_0002.v {} {}
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    It appears that get_all_global_assignments doesn't work correctly in the Quartus GUI Tcl interpreter, but it does work in the command-line Tcl interpreter (quartus_sh -s). I've submitted a bug report to get the problem resolved in the next software release (ACDS 14.0). If you are using a flow script, it won't work correctly when the flow is launched from the GUI because the script will be executed in the GUI's Tcl interpreter. However, compiling on the command-line should work correctly.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    My preflow script works when I hit the compile button in the GUI. I agree that the "alt-2" Tcl interpreter seems to be broken, though.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Thanks for looking into this terpstra and HDL Guru.

    I'm only using the TCL Interpreter, so I'll have to figure out some alternative until the next software release.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    My preflow script works when I hit the compile button in the GUI. I agree that the "alt-2" Tcl interpreter seems to be broken, though.

    --- Quote End ---

    You're right terpstra. I take back my earlier statement. The flow script will be run using whatever EXE you specified in the assignment value rather than the Tcl interpreter in the GUI process.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I took another look. It seems that the elements of the collection are not Tcl lists but are actually just references to the collection itself. You need to use get_assignment_info to retrieve the assignment properties. Unfortunately, in a non-GUI process, the get_all_global_assignments command returns a list!

    <code>

    foreach_in_collection a [get_all_global_assignments -name SYSTEMVERILOG_FILE] {

    puts $outfile "[get_assignment_info -value $a]"

    }

    </code>
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Nice! Thanks HDL Guru. I just gave your code a try and it works like a charm.

    Looks like the help and example code in the get_all_global_assignments should be updated to say it returns a collection of <asgn_id>

    --------------------------------------------------------------------

    For future reference, and to help google indexing, here is the long_help for get_assignment_info:

    Usage: get_assignment_info            <asgn_id>
            -h | -help: Short help
            -long_help: Long help with examples and possible return values
            -comments: Option to get the assignment comment
            -entity: Option to get the assignment entity
            -from: Option to get the assignment source
            -get_tcl_command: Option to get the tcl command that sets the assignment
            -name: Option to get the assignment name
            -section_id: Option to get the assignment section id
            -tag: Option to get the assignment tag
            -to: Option to get the assignment destination
            -value: Option to get the assignment value
            <asgn_id>: Assignment id
    ------------------------
    Tcl Package and Version:
    ------------------------
    Belongs to ::quartus::project_ui 1.0
    ------------
    Description:
    ------------
    Returns information for the assignment id based on the
    specified option.
    The assignment id is obtained from the "get_all_assignments"
    Tcl command.
    --------------
    Example Usage:
    --------------
       # # View all the instance assignments
    foreach_in_collection asgn_id  {
        set from   
        set to     
        set name   
        set value  
        set entity 
        set tag    
        puts "$entity: $name ($from -> $to) = $value"
    }
    -------------
    Return Value:
    -------------
    Code Name	Code	String Return
    ---------	----	-------------
    TCL_OK   	0   	INFO: Operation successful
    TCL_ERROR	1   	ERROR: Illegal assignment id: <string>. Specify a legal assignment id that was retrieved from the Tcl command "get_all_assignments".
    ---------------------------------------------------------------------------