( ESNUG 335 Item 7 ) ---------------------------------------------- [11/3/99]
Subject: ( ESNUG 334 #9 ) My "Translating Dc_shell To TCL" Horror Story
> Hope this is helpful for someone out there. It took me ALOT of hair
> pulling to even get ONE of my scripts running. I've pretty much decided
> that I have many too many personal man-years invested into my scripts,
> and if Synopsys ever forces me to go pure TCL I'll jump off a building
> (or quit engineering, whichever would make my wife happier at the time -)
>
> - Gzim Derti
> Intrinsix Corp. Rochester, NY
From: Rodney Ramsay <rramsay1@ford.com>
Hi, John,
Gzim forgot to add Headache Number 8 :
Synopsys has a tough *%&^%^% attitude. As far as they are concerned, their
TCL translating tool, Transcript, works fine. I wish they would just give
us the darned source code for Transcript so we could fix it for them.
- Rodney Ramsay
Ford Microelectronics
---- ---- ---- ---- ---- ---- ----
From: [ Tickle Me Elmo ]
Hi John,
As a "TCL advocate" I thought I'd write a few lines that just might make
Gzim's TCL a bit less painful. Forgive me if you already know this!
Normally you don't need all those calls to "format %s%s"; use "" instead:
write -f db [get_object_name $module] \
-o [format "%s%s" [get_object_name $module] {.db.elab}]
could become
write -f db [get_object_name $module] \
-o "[get_object_name $module].db.elab"
or perhaps
set module_name [get_object_name $module]
becomes
write -f db $module_name -o "${module_name}.db.elab"
Note the {} around module_name inside the "" - this is optional and is
useful in ambiguous cases like "$x_y", which could be "${x}_y" or
"${x_y}".) Sometimes concat or join might be better to use. You should
only need to use "format" if you're trying to output numbers in hex or
enforce particular field widths or something like that.
> In my dc_shell scripts, I leave places for the user to create a
> <blockname>.dscr (designer script) so that they can add some special
> stuff to blocks such as set_implementation, set_loads, etc. In dc_shell,
> if these files DON'T exist, then dc_shell notes the problem in the log
> file, but continues on with the rest of the compile like nothing major
> happened...
>
> include module + ".dscr"
>
> Is all I had to had to have for things to run along without a problem.
> BUT, in tshell I had to use the following to get the TCL parser to get
> past the problem:
>
> if { [file exists [format "%s%s" [get_object_name $module] {.dscr}]] }
> {
> source -echo -verbose [format "%s%s" [get_object_name $module] {.dscr}]
> }
>
> As if THAT's intuitively obvious...
Here's how I'd do your "user include file" thing:
proc source_if_exists {fn} {
if {[file exists $fn]} {
uplevel source $fn
}
}
(You need the "uplevel" as otherwise variables in the file become local
variables in the proc, not globals.) Then invoke it as
source_if_exists "[get_object_name $module].descr"
(I like that I can define functions like this and then use them in lots of
different tools -- ModelSim and Leonardo at the moment.)
> I looked for this in the big black TCL book by Welch and didn't find it,
> but if you are trying to do a compare of a boolean to true or false, as
> in an if statement, here's the syntax...
>
> if {[is_true <boolvar>]} { do stuff here }
> if {[is_false <boolvar>]} { do other stuff here }
I'm not sure why you need this - it must be some sort of Synopsys magic. In
"normal" tcl, booleans store 0 and 1 for false and true respectively, and
you just write
if {$var} {....}
if {!$var} {....}
Regards,
- [ Tickle Me Elmo ]
---- ---- ---- ---- ---- ---- ----
From: Gzim Derti <gderti@intrinsix.com>
Good Morning "Elmo",
Thanks for the reply to my post!! Just so you know, I have used TCL before
to so some little stuff, but mostly I was playing with TCL/TK once I found
out about it and have written some frontend to some scripts that are
basically push button using this stuff...
The results that you saw were basically direct dumps of what the
dc-transcript -source_for_include
command gave me. You're right, I could have swore that string concatination
was ALOT easier when I did it before than the result that Synopsys sent out.
I don't know if there's a reason that Synopsys translates things the way
they do (using format.)
Thanks for the procedure. It makes sense to do it like that, but my only
issue is adding MORE things to source in order to run my scripts. I already
use a lot of files and this is just more overhead. My original gripe with
this was that of the fact that DC_shell acts differently than TCL_shell.
Just as sort of a heads up.
And as far as the boolean check goes, I could have sworn that I tried that
originally and found that TCL_shell basically blew through the if statement
when I assumed the usage of the boolean as you show it. I'll have to
check again, but I seem to remember that the only way I could get those
checks to work was to use the "is_true" and "is_false" checks.
In the end, it took me the better part of a day to get ONE of my scripts
even partially working in TCL_shell. While I'm all for some sort of
standarization, I just feel that after fighting with DC_shell for nearly
decade and learning the quirks of one methodology it's REALLY hard to
change gears...
PLUS, while TCL is all well and good, there are probably alot of reasons
why the original designers of the environment did things the way they did,
maybe to make life as easy as possible for the tool in question?? I'm not
against using TCL, it's just that DC_shell makes so much MORE sense when
you're actually trying to root around within a design.
ANYWAY, again, thanks for the notes... If I get back into this thing I'll
try and work someother things out with what you've given me.
- Gzim Derti
Intrinsix Rochester, NY
|
|