XDC: Expand comment and fix small bug

Signed-off-by: Tomasz Michalak <tmichalak@antmicro.com>
diff --git a/xdc-plugin/xdc.cc b/xdc-plugin/xdc.cc
index 4d427f2..cf821d4 100644
--- a/xdc-plugin/xdc.cc
+++ b/xdc-plugin/xdc.cc
@@ -385,16 +385,27 @@
 		std::string content{std::istreambuf_iterator<char>(*f), std::istreambuf_iterator<char>()};
 		log("%s\n", content.c_str());
 
-		// According to page 6 of UG903 XDC is tcl, hence quuoting of bracketed numbers,
-		// such as bus indexes, is required. However, it's quite common for EDA tools
-		// to allow for correct processing of the bracketed numbers without quoting.
+		// According to page 6 of UG903 XDC is tcl, hence quoting of bracketed numbers,
+		// such as bus indexes, is required. For example "signal[5]" would be typically
+		// expanded to the concatenation of the string "signal" and result of the function call "5"
+		// with no arguments. Therefore in TCL the signal indices have to be wrapped in curly braces
+		// e.g "{signal[5]}" in order for the interpreter to not perform any variable substitution
+		// or function calls on the wrapped content.
+		//
+		// Nevertheless, it's quite common for EDA tools to allow for specifying signal indices
+		// (e.g. "signal[5]") without using non-expanding quotes.
 		// Possible TCL implementations of such a feature include registering a TCL command
-		// for each integer which returns itself but surrounded with brackets or
-		// using the 'unknown' command which is invoked by the Tcl interpreter
-		// whenever a script tries to invoke a command that does not exist.
-		// In the XDC plugin the latter approach is used, however it's limited to
-		// the read_xdc command, hence the 'unknown' command works solely or the
-		// content of the XDC file.
+		// for each integer which returns itself but surrounded with brackets or using the 'unknown'
+		// command which is invoked by the Tcl interpreter whenever a script tries to invoke a command
+		// that does not exist. In the XDC plugin the latter approach is used, however it's limited to
+		// the 'read_xdc' command, hence the 'unknown' command works solely on the content of the XDC file.
+		//
+		// In this implementation the signal "signal[5]" is expanded in TCL to the concatenation of a string
+		// and function call, however this time the handling of the non-existent command '5' is passed by
+		// the interpreter to the 'unknown' command which returns a string that consists of the indice
+		// integer surrounded by square brackets, i.e. "[5]", effectively expanding the signal to "signal[5]"
+		// string.
+		//
 		Tcl_Interp* interp = yosys_get_tcl_interp();
 		Tcl_Eval(interp, "rename unknown _original_unknown");
 		Tcl_Eval(interp, "proc unknown args { return \\[[lindex $args 0]\\] }");
@@ -402,7 +413,7 @@
                         log_cmd_error("TCL interpreter returned an error: %s\n", Tcl_GetStringResult(interp));
 		}
 		Tcl_Eval(interp, "rename unknown \"\"");
-		Tcl_Eval(interp, "rename unknown _original_unknown");
+		Tcl_Eval(interp, "rename _original_unknown unknown");
 	}
 	const BankTilesMap& get_bank_tiles() {
 		return bank_tiles;