Hello everyone, I would like to create a script w...
# analog-design
s
Hello everyone, I would like to create a script where I can do LVS checks of an analog design which includes standard cells. Down below i have a script that works fine, but i have to manually adjust the script everytime for different cells.
Copy code
set pdklib $::env(PDK_ROOT)/$::env(PDK)
set techlibs ${pdklib}/libs.tech
set reflibs ${pdklib}/libs.ref

set setupfile ${techlibs}/netgen/sky130A_setup.tcl
set hdlib ${reflibs}/sky130_fd_sc_hd/spice/sky130_fd_sc_hd.spice

set circuit1 [readnet spice layout.spice]
set circuit2 [readnet spice $hdlib]
readnet spice schematic.spice $circuit2

lvs "$circuit1 cell1" "$circuit2 cell2" $setupfile
Therefore i would like to build the script as follows where i hope to insert arguments from the command line.
Copy code
set pdklib $::env(PDK_ROOT)/$::env(PDK)
set techlibs ${pdklib}/libs.tech
set reflibs ${pdklib}/libs.ref

set setupfile ${techlibs}/netgen/sky130A_setup.tcl
set hdlib ${reflibs}/sky130_fd_sc_hd/spice/sky130_fd_sc_hd.spice

set circuit1 [readnet spice ${[lindex $argv 0]}]
set circuit2 [readnet spice $hdlib]
readnet spice ${[lindex $argv 2]} $circuit2

lvs "$circuit1 ${[lindex $argv 1]}]" "$circuit2 ${[lindex $argv 3]}]" $setupfile
Whenever I try to use the command prompt below i get the following error
Copy code
netgen -batch source stndcelllvs.tcl -tclargs "layout.spice" "cell1" "schematic.spice" "cell2"
Warning: netgen command 'format' use fully-qualified name ':netgen:format' Warning: netgen command 'global' use fully-qualified name ':netgen:global' wrong # args: should be "source ?-encoding name? fileName" while executing "source stndcelllvs.tcl -tclargs layout.spice cell1 schematic.spice cell2" ("eval" body line 1) invoked from within "eval $argv" Therefore i changed the script so i can call upon it with the following command
Copy code
tclsh stndcelllvs.tcl "layout.spice" "cell1" "schematic.spice" "cell2"
This does insert the arguments in my script, but it does not allow netgen to do any lvs. Here i tried to call upon netgen by changing the last line to:
Copy code
netgen -batch lvs "$circuit1 ${[lindex $argv 1]}]" "$circuit2 ${[lindex $argv 3]}]" $setupfile
Does anyone have any ideas on how i could pass on arguments into the top script? Thank you in advance.
t
Try doing
Copy code
set cell1 [lindex $argv 1]
set cell2 [lindex $argv 2]

...

lvs "$circuit1 $cell1" "$circuit2 $cell2" $setupfile
or possibly
Copy code
lvs {$circuit1 $cell1} {$circuit2 $cell2} $setupfile
I am not sure what you are trying to accomplish with the syntax
${[lindex $argv 1]}
. . . You are taking the cell name from the command line argument and then treating that as a Tcl variable. However, if you did not add a typo, then all of your
lvs
commands contain too many closing brackets:
${[lindex $argv 1]}]
has a dangling closing bracket on the end.
s
With the syntax
${[lindex $argv 1]}
. . . I was trying to write the argument of the command line to a variable without creating a new variable. I tried changing the script based on what you suggested, however, I get the following error when using the following invocation:
Copy code
netgen -batch source stndcelllvs.tcl -tclargs "~/layout.spice" "layout" "~/schematic.spice" "schematic"
error:
Copy code
Netgen 1.5.272 compiled on do 21 mrt 2024 11:44:29 CET
Warning: netgen command 'format' use fully-qualified name '::netgen::format'
Warning: netgen command 'global' use fully-qualified name '::netgen::global'
wrong # args: should be "source ?-encoding name? fileName"
    while executing
"source stndcelllvs.tcl -tclargs ~/layout.spice layout ~/schematic.spice schematic"
    ("eval" body line 1)
    invoked from within
"eval $argv"
Is there a way to change this so that arguments can be passed on?
t
Why did you switch from
-batch lvs
to
-batch source
?
s
ah my bad, I did not make it clear in my first message. I tried two solutions in my first message, the first one using
-batch source
where I tried to add -tclargs to push arguments into lvs.tcl For the second solution I tried to run a tclsh lvs2.tcl where I add arguments and in lvs2.tcl I tried running netgen at the end with
-batch lvs
t
For the last thing you did, I don't think
-tclargs
is standard, at least I don't see it in the Tcl manual pages fro the
source
command. This link is old but appropriate: https://stackoverflow.com/questions/37474938/can-we-pass-options-to-tcl-source-command-in-tcl-8-5 It suggests that the only way to pass arguments through
source
is through the global
$argv
variable, such as:
Copy code
set ::argv [list "~/layout.spice" "layout" "~/schematic.spice" "schematic"]
source stndcelllvs.tcl
However, that doesn't work with
netgen -batch source
and I don't think you can do
netgen -batch {set ::argv [...] ; source ...}
, which means that the only solution is to do the following (a bit complicated, but it works): 1. The outer wrapper is a shell script; you pass variables to the shell script 2. The shell script writes out a Tcl script 3. The shell script invokes "netgen -batch source name_of_tcl_script" 4. The shell script removes the temporary Tcl script A similar method is to use
<< EOF
to pass Tcl commands to netgen from within the shell script; it does the same thing as above, but without requiring creating a temporary file.
s
Thank you! I will try that.