0
set pwr_rpt [split [report_power -quiet -return_string -xpe ${pd}_${rd}.xpe] \n]
for {set i 0} {$i<150} {incr i} {
    set line [clean_line [lindex $pwr_rpt $i]]
    if {[lrange $line 1 4] == "Total On-Chip Power W"} {
        puts total_power [lindex $line 6]; # Am getting an error here as variable not declared 
        set total_power [lindex $line 6]
    }
}

Getting error as no variable declared

2 Answers 2

2

Your error is probably not "no variable declared" but is probably "can not find channel named 'total_power'"

You're using the puts commands with two arguments.

puts total_power [lindex $line 6]

where total_power is the first argument and [lindex $line 6] is the second argument.

When used with two arguments, the first argument must be an open channel and the second argument is the string to write to the open channel. You don't have an open channel named "total_power".

You need to simply group these together with double quotes:

puts "total_power [lindex $line 6]"
Sign up to request clarification or add additional context in comments.

Comments

0

I think you need quotes on your "puts" command:

set pwr_rpt [split [report_power -quiet -return_string -xpe ${pd}_${rd}.xpe] \n]
for {set i 0} {$i<150} {incr i} {
    set line [clean_line [lindex $pwr_rpt $i]]
    if {[lrange $line 1 4] == "Total On-Chip Power W"} {
        puts "total_power [lindex $line 6]" ; # Quotes here
        set total_power [lindex $line 6]
    }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.