首次提交
This commit is contained in:
147
stream_tx_ctrl/sim/parse_args.tcl
Normal file
147
stream_tx_ctrl/sim/parse_args.tcl
Normal file
@@ -0,0 +1,147 @@
|
||||
|
||||
set SIM_TYPE func ;
|
||||
set CASE_NUM 1 ;
|
||||
set SIM_TIME 100sec ;#as all
|
||||
set CORNER_TYPE max ;
|
||||
set COPY_RUN_TEMPLATE no;
|
||||
|
||||
#declear a empty list
|
||||
|
||||
set args [list];
|
||||
#put the do command $1-$9 to list,because we can't use the argv,we should construct the "argv" mannully.
|
||||
for {set i 1} {$i <= $argc} {incr i 1} {
|
||||
lappend args [set $i];
|
||||
}
|
||||
puts "---->parsing the command line....argc=$argc,args=$args*************************"
|
||||
|
||||
#get the max index of the list,the "expr" command should be use to calculate out the express
|
||||
set max_index [expr $argc-1];
|
||||
|
||||
#search copy templation option
|
||||
for {set i 0} {$i < $argc} {incr i 1} {
|
||||
|
||||
set para [lindex $args $i]
|
||||
if {[string equal $para "-c"]} {
|
||||
set COPY_RUN_TEMPLATE yes
|
||||
puts "whether to copy run.tcl template=$COPY_RUN_TEMPLATE"
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#search generate instantiate_top.sv opton
|
||||
for {set i 0} {$i < $argc} {incr i 1} {
|
||||
|
||||
set para [lindex $args $i]
|
||||
if {[string equal $para "-g"]} {
|
||||
set GEN_INSTANTIATE_TOP yes
|
||||
puts "force generate instantiate_top.sv and override exist file"
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#search case number
|
||||
for {set i 0} {$i < $argc} {incr i 1} {
|
||||
set para [lindex $args $i];
|
||||
if {[string equal $para "-n"] } {
|
||||
|
||||
if {$i < $max_index} {
|
||||
set num [lindex $args [expr [expr $i+1]]];
|
||||
if { [string is digit $num] } {
|
||||
set CASE_NUM [format "%03d" $num];
|
||||
puts "case number=$CASE_NUM"
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#search simulation time
|
||||
for {set i 0} {$i < $argc} {incr i 1} {
|
||||
|
||||
set para [lindex $args $i]
|
||||
if {[string equal $para "-t"]} {
|
||||
if {$i < $max_index} {
|
||||
set time [lindex $args [expr $i+1]]
|
||||
if {[regexp {^[0-9]+((n|u|m)s|sec)$} $time]} {
|
||||
set SIM_TIME $time
|
||||
puts "simulation time=$SIM_TIME"
|
||||
} else {
|
||||
puts "unknow simulation time,set to 1us"
|
||||
set SIM_TIME 1us
|
||||
puts "simulation time=$SIM_TIME"
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#search simulation type
|
||||
for {set i 0} {$i < $argc} {incr i 1} {
|
||||
|
||||
set para [lindex $args $i]
|
||||
if {[string equal $para "-timing"]} {
|
||||
set SIM_TYPE "timing"
|
||||
puts "simulation type=$SIM_TYPE"
|
||||
break;
|
||||
} elseif {[string equal $para "-func"]} {
|
||||
set SIM_TYPE "func"
|
||||
puts "simulation type=$SIM_TYPE"
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#search corner type
|
||||
for {set i 0} {$i < $argc} {incr i 1} {
|
||||
|
||||
set para [lindex $args $i]
|
||||
if {[string equal $para "-corner"]} {
|
||||
if {$i < $max_index } {
|
||||
set corner [lindex $args [expr $i+1]]
|
||||
|
||||
#处理run.tcl中再次调用本脚本导致的bug ,删除前导的数字
|
||||
regsub -nocase {[0-9]+_} $corner "" corner
|
||||
|
||||
switch -glob $corner {
|
||||
"max" {
|
||||
set CORNER_TYPE 03_max
|
||||
}
|
||||
"min" {
|
||||
set CORNER_TYPE 01_min
|
||||
}
|
||||
"type" {
|
||||
set CORNER_TYPE 02_type
|
||||
}
|
||||
default {
|
||||
puts "unknow corner type,set to 03_max"
|
||||
set CORNER_TYPE 03_max
|
||||
}
|
||||
|
||||
}
|
||||
puts "corner type=$CORNER_TYPE"
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#search simulation type
|
||||
for {set i 0} {$i < $argc} {incr i 1} {
|
||||
|
||||
set para [lindex $args $i]
|
||||
if {[string equal $para "-h"]} {
|
||||
puts "------------------------help------------------------"
|
||||
puts "-n x:specify case number to be excuted,x stand for case number,default to 0"
|
||||
puts "-t x:specify simulation time to be excuted,x stand for time,unit may be ns,us,ms,sec,default to 1us"
|
||||
puts "-timing:specify to excute in timing simulation mode"
|
||||
puts "-corner x:specify the timing simulation corner,may be max,min,type,default to max"
|
||||
puts "-c:force to override run.tcl scripts in case directory,be carefull"
|
||||
puts "-h:to display this help information,it has the highest priority,thus block other options"
|
||||
puts "----------------------------------------------------"
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
puts "---->parsing the command line complete ***************************"
|
||||
Reference in New Issue
Block a user