cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
FPGADude99
Visitor
Visitor
616 Views
Registered: ‎04-29-2020

Vivado 2019 TCL BUG... matching curly parentheses when code is commented out and reporting fail error in code.

I just found a bug in the Vivado TCL interpreter...  When you have an unbalanced parantheses in commented out code ... it still reports it as an error.  Example:

{code}

# proc test1 {args} {
#     if ($stuff} {
#         puts "do something"
#     }
# }
{code}

Notice that I used the wrong parenthesis for beginning tcl if statement using "(" instead of "{"...  however, when i source this tcl code from vivado... it reports an error even when the error code is commented out...

0 Kudos
3 Replies
ashishd
Xilinx Employee
Xilinx Employee
597 Views
Registered: ‎02-14-2014

Hi @FPGADude99 ,

Is it fine for you to attach complete script to debug this further ? 

Regards,
Ashish
----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------------
0 Kudos
FPGADude99
Visitor
Visitor
588 Views
Registered: ‎04-29-2020

Sorry... I didn't check the code snippet to see if it recreates the bug.. here's some code that I just tried that does:

{code}

Vivado% source stuff.tcl
# proc dfsdf {args} {
# # # Instantiate + Generate all + Synthesize Core
# # if ($level == 3} {
# # return
# # }
wrong # args: should be "proc name args body"
while executing
"proc dfsdf {args} {
# # Instantiate + Generate all + Synthesize Core
# if ($level == 3} {
# return
# }"
(file "stuff.tcl" line 1)

Vivado% version
Vivado v2019.1 (64-bit)
SW Build 2552052 on Fri May 24 14:49:42 MDT 2019
IP Build 2548770 on Fri May 24 18:01:18 MDT 2019
Copyright 1986-2019 Xilinx, Inc. All Rights Reserved.
Vivado%

{code}

 

0 Kudos
ashishd
Xilinx Employee
Xilinx Employee
487 Views
Registered: ‎02-14-2014

Hi @FPGADude99 ,

This is not a bug.

There is fundamental difference in the behavior of tcl interpreter when it comes to dealing with comments inside proc and outside proc. Outside proc, things are pretty clear that string starting with '#' till next newline character is treated as comment (unless it is escaped or quoted). No characters in this line are interpreted and no command execution is attempted. As a result, if you simply type the content which is inside proc 'dfsdf' in attached stuff.tcl, there will not be any error reported at tcl console.

But while dealing with contents inside proc, tcl interpreter deals with them in a way you would not expect it to. For this case, you can conceptually bifurcate interpreter into two parts i.e. parser and executer. The parser aspect of interpreter checks each and every line inside proc including comments. Hence parantheses mismatch (like the one you've in your script) is not allowed. The executer aspect of interpreter comes into picture when you call this proc. At this time, these strings are treated as comments and will be skipped from execution.

This is the expected behavior of tcl interpreter and hence cannot be reported as bug. 

Regards,
Ashish
----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------------
Tags (1)