forked from tanchou/Verilog
88 lines
2.5 KiB
Tcl
88 lines
2.5 KiB
Tcl
# Tcl script for iverilog simulation
|
|
namespace eval gtkwave {
|
|
|
|
|
|
# Help information for this script
|
|
proc print_help {} {
|
|
variable script_file "run_gtkwave.tcl"
|
|
puts "\nDescription:"
|
|
puts "Runs the iverilog simulation.\n"
|
|
puts "Syntax:"
|
|
puts "$script_file"
|
|
puts "$script_file \[action\] \[args\]"
|
|
puts "Usage:"
|
|
puts "Name Description"
|
|
puts "-------------------------------------------------------------------------"
|
|
puts "\[action\] Determine the action to be performed. Default value: help\n"
|
|
puts " Current actions: help, clean\n"
|
|
puts "\[args\] Arguments related to the action.\n"
|
|
puts " --root <dir> changes the root reference for the project.\n"
|
|
puts "-------------------------------------------------------------------------\n"
|
|
exit 0
|
|
}
|
|
|
|
|
|
proc main {} {
|
|
|
|
variable root_dir
|
|
# Set the reference directory to where the script is
|
|
#set root_dir [file dirname [info script]]
|
|
|
|
# Set the reference directory for source file relative paths (by default the value is script directory path)
|
|
set root_dir "."
|
|
|
|
if { [info exists ::root_dir_loc] } {
|
|
set root_dir $::root_dir_loc
|
|
}
|
|
|
|
if { $::argc > 0 } {
|
|
set root_dir [lindex $::argv 0]
|
|
}
|
|
|
|
puts "Starting gtkwave. The root dir is: $root_dir"
|
|
|
|
# variable root [file dirname [file normalize [info script]]]
|
|
# variable root [file dirname [file dirname [info script]]]
|
|
variable root $root_dir
|
|
|
|
variable view_file $root/runs/sim/iverilog/counter_tb.vcd
|
|
|
|
variable gtkwave_script $root/scripts/gtk_wave_all_signals.tcl
|
|
|
|
proc run_view {res} {
|
|
set name [file rootname $res]
|
|
|
|
# set iverilog_args "$sim_iverilog::additional_options -g2012 -Wall -I $sim_iverilog::source_path -Y .sv -y $sim_iverilog::source_path -o $sim_iverilog::output_dir/$name.vvp $sim_iverilog::tb_path/$tb $sim_iverilog::sources_full_path"
|
|
#set gtkwave_args "-S $gtkwave::gtkwave_script $gtkwave::view_file"
|
|
set gtkwave_args "$gtkwave::view_file"
|
|
|
|
#puts $gtkwave_args
|
|
try {
|
|
set results [exec gtkwave {*}$gtkwave_args]
|
|
set status 0
|
|
} trap CHILDSTATUS {results options} {
|
|
set status [lindex [dict get $options -errorcode] 2]
|
|
}
|
|
|
|
if {$status != 0} {
|
|
puts "Problem running gtkwave :"
|
|
puts $results
|
|
return
|
|
}
|
|
|
|
# output iverilog result
|
|
puts $results
|
|
|
|
|
|
}
|
|
|
|
run_view $root_dir
|
|
|
|
exit 0
|
|
}
|
|
|
|
# run main
|
|
|
|
main
|
|
|
|
} |