Stijn van Himste
05/13/2024, 12:55 PMset 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.
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
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
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:
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.Tim Edwards
05/13/2024, 1:10 PMset cell1 [lindex $argv 1]
set cell2 [lindex $argv 2]
...
lvs "$circuit1 $cell1" "$circuit2 $cell2" $setupfile
or possibly
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.Stijn van Himste
05/13/2024, 3:23 PM${[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:
netgen -batch source stndcelllvs.tcl -tclargs "~/layout.spice" "layout" "~/schematic.spice" "schematic"
error:
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?Tim Edwards
05/13/2024, 3:26 PM-batch lvs
to -batch source
?Stijn van Himste
05/13/2024, 3:35 PM-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
Tim Edwards
05/13/2024, 5:24 PM-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:
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.Stijn van Himste
05/13/2024, 7:23 PM