|
| 1 | +#------------------------------------------------------------------------------ |
| 2 | +# compile.tcl |
| 3 | +# Konstantin Pavlov, [email protected] |
| 4 | +#------------------------------------------------------------------------------ |
| 5 | + |
| 6 | +# INFO ------------------------------------------------------------------------ |
| 7 | +# Modelsim compile script |
| 8 | +# based on "ModelSimSE general compile script version 1.1" by Doulos |
| 9 | + |
| 10 | +# launch the script by "vsim -do compile.tcl" command on linux |
| 11 | +# or by "modelsim.exe -do compile.tcl" on windows |
| 12 | + |
| 13 | + |
| 14 | +# Simply change the project settings in this section |
| 15 | +# for each new project. There should be no need to |
| 16 | +# modify the rest of the script. |
| 17 | +set library_file_list { |
| 18 | + |
| 19 | + work {reverse_dimensions_tb.sv |
| 20 | + ../reverse_dimensions.sv |
| 21 | + c_rand.v |
| 22 | + ../edge_detect.sv |
| 23 | + ../clk_divider.sv} |
| 24 | +} |
| 25 | + |
| 26 | +set vsim_params "-L altera_mf_ver -L altera_mf -L lpm_ver -L lpm" |
| 27 | + |
| 28 | +set top_level work.reverse_dimensions_tb |
| 29 | + |
| 30 | +# Console commands: |
| 31 | +# r = Recompile changed and dependent files |
| 32 | +# rr = Recompile everything |
| 33 | +# q = Quit without confirmation |
| 34 | + |
| 35 | +# After sourcing the script from ModelSim for the |
| 36 | +# first time use these commands to recompile. |
| 37 | +proc r {} {uplevel #0 source compile.tcl} |
| 38 | +proc rr {} {global last_compile_time |
| 39 | + set last_compile_time 0 |
| 40 | + r } |
| 41 | +proc q {} {quit -force } |
| 42 | + |
| 43 | +#Does this installation support Tk? |
| 44 | +set tk_ok 1 |
| 45 | +if [catch {package require Tk}] {set tk_ok 0} |
| 46 | + |
| 47 | +# Prefer a fixed point font for the transcript |
| 48 | +set PrefMain(font) {Courier 10 roman normal} |
| 49 | + |
| 50 | +# Compile out of date files |
| 51 | +set time_now [clock seconds] |
| 52 | +if [catch {set last_compile_time}] { |
| 53 | + set last_compile_time 0 |
| 54 | +} |
| 55 | +foreach {library file_list} $library_file_list { |
| 56 | + vlib $library |
| 57 | + vmap work $library |
| 58 | + foreach file $file_list { |
| 59 | + if { $last_compile_time < [file mtime $file] } { |
| 60 | + if [regexp {.vhdl?$} $file] { |
| 61 | + vcom -93 $file |
| 62 | + } else { |
| 63 | + vlog -sv $file |
| 64 | + } |
| 65 | + set last_compile_time 0 |
| 66 | + } |
| 67 | + } |
| 68 | +} |
| 69 | +set last_compile_time $time_now |
| 70 | + |
| 71 | +# Load the simulation |
| 72 | +eval vsim $top_level $vsim_params |
| 73 | + |
| 74 | +# Load saved wave patterns |
| 75 | +do wave.do |
| 76 | + |
| 77 | +# Run the simulation |
| 78 | +run 100us |
| 79 | + |
| 80 | +wave zoom range 0 100us |
| 81 | + |
| 82 | +# How long since project began? |
| 83 | +if {[file isfile start_time.txt] == 0} { |
| 84 | + set f [open start_time.txt w] |
| 85 | + puts $f "Start time was [clock seconds]" |
| 86 | + close $f |
| 87 | +} else { |
| 88 | + set f [open start_time.txt r] |
| 89 | + set line [gets $f] |
| 90 | + close $f |
| 91 | + regexp {\d+} $line start_time |
| 92 | + set total_time [expr ([clock seconds]-$start_time)/60] |
| 93 | + puts "Project time is $total_time minutes" |
| 94 | +} |
| 95 | + |
0 commit comments