( ESNUG 371 Item 8 ) -------------------------------------------- [05/23/01]
Subject: Maybe This Is How You Compare Two Strings In PrimeTime Tcl? Yes?
> I'd like to compare two strings in PrimeTime as:
>
> pt_shell> query $tmp_pins
> {"DMAC0_inst/IRQ_request/SCAND", "DMAC0_inst/IRQ_request/U0/SCAND"}
> pt_shell> query $tmp_net
> {"DMAC0_inst/IRQ_request/SCAND"}
> pt_shell> foreach_in_collection comp $tmp_pins {
> ? set res [string compare $comp $tmp_net]
> ? echo $res
> ? }
> Information: Defining new variable 'comp'. (CMD-041)
> 1
> 1
>
> But the result shows two mismatches. I would appreciate advice on how to
> compare two strings in PrimeTime.
>
> - Klaus Vongehr
> Philips Semiconductors Munich, Germany
From: jmcalvez@club-internet.fr (Jean-Marc Calvez)
I suppose that, in the above, tmp_pins and tmp_nets are two collections,
returned by get_pins and get_nets? You cannot compare directly two
collection elements, so you should try to compare the names (query_objects
will display the names, which may be identical, but the objects themselves
cannot be compared).
Two possible solutions: either use get_object_name (I think; I hope I
haven't forgotten an 's' somewhere), as in [get_object_name $tmp_net], or
you can use the name attribute, with [get_attribute $tmp_net name]. Note
that in some cases, name is not the correct attribute name; you may want
to use full_name instead. There are also restrictions when using
get_object_name. I think you cannot use it with collections of more
than one element. You will need to experiment a bit, I'm afraid.
So your script would become something like:
set net_name [get_object_name $tmp_net]
foreach_in_collection comp $tmp_pins {
set pin_name [get_object_name $comp]
set res [string compare $pin_name $net_name]
echo $res
}
Regards,
- Jean-Marc Calvez Grenoble, France
|
|