1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400
|
################################################################################################
# Copyright (c) 2006-2010 Trevor Williams #
# #
# This program is free software; you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by the Free Software #
# Foundation; either version 2 of the License, or (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; #
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. #
# See the GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License along with this program; #
# if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #
################################################################################################
set cdd_name ""
set uncov_type 1
set cov_type 0
set race_type 0
set mod_inst_type "Module"
set last_mod_inst_type ""
set file_types {
{{Code Coverage Database Files} {.cdd}}
{{All Files} * }
}
set rpt_file_types {
{{Covered Report Files} {.rpt}}
{{All Files} * }
}
proc do_keybind {.menubar} {
# Add Mac OS X familiar shortcuts for the menubar
if {[tk windowingsystem] eq "aqua"} {
bind all <Command-o> {.menubar.file invoke 0}
bind all <Command-s> {.menubar.file invoke 3}
bind all <Command-w> {.menubar.file invoke 4}
}
bind all <Control-o> {.menubar.file invoke 0}
bind all <Control-O> {.menubar.file invoke 0}
bind all <Control-s> {.menubar.file invoke 3}
bind all <Control-S> {.menubar.file invoke 3}
bind all <Control-w> {.menubar.file invoke 4}
bind all <Control-W> {.menubar.file invoke 4}
bind all <Control-x> {.menubar.file invoke 8}
bind all <Control-X> {.menubar.file invoke 8}
bind all <Shift-Control-n> {.menubar.file.gen invoke 0}
bind all <Shift-Control-N> {.menubar.file.gen invoke 0}
bind all <Shift-Control-r> {.menubar.file.gen invoke 1}
bind all <Shift-Control-R> {.menubar.file.gen invoke 1}
bind all <Shift-Control-c> {.menubar.file.gen invoke 2}
bind all <Shift-Control-C> {.menubar.file.gen invoke 2}
bind all <Control-n> {.menubar.view invoke 0}
bind all <Control-N> {.menubar.view invoke 0}
bind all <Control-p> {.menubar.view invoke 1}
bind all <Control-P> {.menubar.view invoke 1}
bind all <Control-c> {.menubar.view invoke 2}
bind all <Control-C> {.menubar.view invoke 2}
}
proc enable_cdd_save {} {
.menubar.file entryconfigure 3 -state normal
}
proc menu_create {} {
global start_line end_line
global cdd_name
global BROWSER
global prev_uncov_index next_uncov_index
# Create the menubar frame
#frame .menubar -width 710 -relief raised -borderwidth 1
set mb [menu .menubar -tearoff false]
. configure -menu $mb
# Configure the file option
set tfm [menu $mb.file -tearoff false]
$mb add cascade -label "File" -menu $tfm
# FILE - entry 0
$tfm add command -label "Open/Merge CDDs..." -accelerator "Ctrl-o" -underline 0 -command {
# Get a list of files to open
set fnames [tk_getOpenFile -multiple 1 -filetypes $file_types -parent .]
if {$fnames ne ""} {
open_files $fnames
}
}
# FILE - entry 1
$tfm add command -label "View Loaded CDD(s)..." -state disabled -underline 0 -command {
create_cdd_viewer
}
# FILE - entry 2
$tfm add separator
# FILE - entry 3
$tfm add command -label "Save CDD..." -accelerator "Ctrl-s" -state disabled -underline 0 -command {
set save_name [tk_getSaveFile -filetypes $file_types -initialfile [file tail $cdd_name] -title "Save CDD As" -parent .]
if {$save_name != ""} {
if {[file extension $save_name] != ".cdd"} {
set save_name "$save_name.cdd"
}
tcl_func_save_cdd $save_name
.info configure -text "$save_name successfully saved"
.menubar.file entryconfigure 3 -state disabled
}
}
# FILE - entry 4
$tfm add command -label "Close CDD(s)" -accelerator "Ctrl-w" -state disabled -underline 0 -command {
check_to_save_and_close_cdd closing
.info configure -text "$cdd_name closed"
set cdd_name ""
set curr_block 0
clear_cdd_filelist
populate_listbox
clear_all_windows
.menubar.file entryconfigure 1 -state disabled
.menubar.file entryconfigure 3 -state disabled
.menubar.file entryconfigure 4 -state disabled
.menubar.file.gen entryconfigure 1 -state disabled
}
# FILE - entry 5
$tfm add separator
# FILE - entry 6
$tfm add cascade -label "Generate" -menu $tfm.gen -underline 0
menu $tfm.gen -tearoff false
# FILE-GEN - entry 0
$tfm.gen add command -label "New CDD..." -accelerator "Ctrl-Shift-n" -command {
create_new_cdd
}
$tfm.gen add command -label "ASCII Report..." -accelerator "Ctrl-Shift-r" -state disabled -command {
create_report_generation_window
}
$tfm.gen add command -label "CDD Ranking Report..." -accelerator "Ctrl-Shift-c" -command {
create_rank_cdds
}
# We don't need the exit function if we are running the Aqua version
if {[tk windowingsystem] ne "aqua"} {
# FILE - entry 7
$tfm add separator
# FILE - entry 8
$tfm add command -label Exit -accelerator "Ctrl-x" -underline 1 -command {
check_to_save_and_close_cdd exiting
save_gui_elements . .
destroy .
}
}
# Configure the report option
set report [menu $mb.report -tearoff false]
$mb add cascade -label "Report" -menu $report
global mod_inst_type cov_uncov_type cov_rb
$report add radiobutton -label "Module-based" -variable mod_inst_type -value "Module" -underline 0
$report add radiobutton -label "Instance-based" -variable mod_inst_type -value "Instance" -underline 0
$report add separator
$report add radiobutton -label "Line" -variable cov_rb -value "Line" -underline 0
$report add radiobutton -label "Toggle" -variable cov_rb -value "Toggle" -underline 0
$report add radiobutton -label "Memory" -variable cov_rb -value "Memory" -underline 1
$report add radiobutton -label "Logic" -variable cov_rb -value "Logic" -underline 2
$report add radiobutton -label "FSM" -variable cov_rb -value "FSM" -underline 0
$report add radiobutton -label "Assert" -variable cov_rb -value "Assert" -underline 0
$report add separator
$report add checkbutton -label "Show Uncovered" -variable uncov_type -onvalue 1 -offvalue 0 -underline 5 -command {
set text_x [.bot.right.txt xview]
set text_y [.bot.right.txt yview]
if {$cov_rb == "Line"} {
display_line_cov
} elseif {$cov_rb == "Toggle"} {
display_toggle_cov
} elseif {$cov_rb == "Memory"} {
display_memory_cov
} elseif {$cov_rb == "Logic"} {
display_comb_cov
} elseif {$cov_rb == "FSM"} {
display_fsm_cov
} elseif {$cov_rb == "Assert"} {
display_assert_cov
} else {
# Error
}
.bot.right.txt xview moveto [lindex $text_x 0]
.bot.right.txt yview moveto [lindex $text_y 0]
}
$report add checkbutton -label "Show Covered" -variable cov_type -onvalue 1 -offvalue 0 -underline 5 -command {
set text_x [.bot.right.txt xview]
set text_y [.bot.right.txt yview]
if {$cov_rb == "Line"} {
display_line_cov
} elseif {$cov_rb == "Toggle"} {
display_toggle_cov
} elseif {$cov_rb == "Memory"} {
display_memory_cov
} elseif {$cov_rb == "Logic"} {
display_comb_cov
} elseif {$cov_rb == "FSM"} {
display_fsm_cov
} elseif {$cov_rb == "Assert"} {
display_assert_cov
} else {
# Error
}
.bot.right.txt xview moveto [lindex $text_x 0]
.bot.right.txt yview moveto [lindex $text_y 0]
}
$report add checkbutton -label "Show Race Conditions" -variable race_type -onvalue 1 -offvalue 0 -underline 5 -command {
set text_x [.bot.right.txt xview]
set text_y [.bot.right.txt yview]
if {$cov_rb == "Line"} {
display_line_cov
} elseif {$cov_rb == "Toggle"} {
display_toggle_cov
} elseif {$cov_rb == "Memory"} {
display_memory_cov
} elseif {$cov_rb == "Logic"} {
display_comb_cov
} elseif {$cov_rb == "FSM"} {
display_fsm_cov
} elseif {$cov_rb == "Assert"} {
display_assert_cov
} else {
# Error
}
.bot.right.txt xview moveto [lindex $text_x 0]
.bot.right.txt yview moveto [lindex $text_y 0]
}
set mod_inst_type "Module"
# Configure the color options
set m [menu $mb.view -tearoff false]
$mb add cascade -label "View" -menu $m
$m add command -label "Next Uncovered" -state disabled -accelerator "Ctrl-n" -underline 0 -command {
goto_uncov $next_uncov_index
}
$m add command -label "Previous Uncovered" -state disabled -accelerator "Ctrl-p" -underline 0 -command {
goto_uncov $prev_uncov_index
}
$m add command -label "Show Current Selection" -state disabled -accelerator "Ctrl-c" -underline 5 -command {
if {$cov_rb == "Toggle"} {
if {$curr_toggle_ptr != ""} {
.bot.right.txt see $curr_toggle_ptr.0
}
} elseif {$cov_rb == "Logic"} {
if {$curr_comb_ptr != ""} {
.bot.right.txt see $curr_comb_ptr.0
}
}
}
$m add separator
$m add command -label "Wizard..." -underline 0 -command {
create_wizard
}
# If we are running on Mac OS X, add preferences to applications menu
if {[tk windowingsystem] eq "aqua"} {
proc ::tk::mac::ShowPreferences {} { create_preferences -1 }
} else {
$m add separator
$m add command -label "Preferences..." -underline 0 -command {
create_preferences -1
}
}
# Configure the help option
set thm [menu $mb.help -tearoff false]
$mb add cascade -label "Help" -menu $thm
# Add Manual and About information
$thm add command -label "Manual" -state disabled -underline 0 -command {
help_show_manual index ""
}
# Do not display the About information in the help menu if we are running on Mac OS X
if {[tk windowingsystem] ne "aqua"} {
$thm add separator
$thm add command -label "About Covered" -underline 0 -command {
help_show_about
}
}
# If we are running on Mac OS X, add items to the applications menu
if {[tk windowingsystem] eq "aqua"} {
set appl [menu $mb.apple -tearoff false]
$mb add cascade -menu $appl
$appl add command -label "About Covered" -command {
help_show_about
}
$appl add separator
}
# Enable the manual help entry if we have a browser to use
if {$BROWSER != ""} {
$thm entryconfigure 0 -state normal
}
# Do key bindings for the Top Level Menus
do_keybind .menubar
}
# Opens/merges a CDD file and handles the GUI cursors and listbox initialization.
proc open_files {fnames} {
global file_types cdd_name fname open_type
global win_cursor txt_cursor e_cursor
global exclude_resolution
# Get all cursor values from various widgets (so we can properly restore them after the open)
set win_cursor [. cget -cursor]
set txt_cursor [.bot.right.txt cget -cursor]
set e_cursor [.bot.right.h.search.e cget -cursor]
foreach fname $fnames {
if {$cdd_name == ""} {
set open_type "open"
.info configure -text "Opening $fname..."
puts "Opening $fname..."
add_cdd_to_filelist $fname 1
} else {
set open_type "merge"
.info configure -text "Merging $fname..."
puts "Merging $fname..."
add_cdd_to_filelist $fname 0
}
# Set all widget cursors to the watch
. configure -cursor watch
.bot.right.txt configure -cursor watch
.bot.right.h.search.e configure -cursor watch
if {$open_type == "open"} {
after 100 {
tcl_func_open_cdd $fname
populate_listbox
}
} else {
after 100 {
tcl_func_merge_cdd $fname $exclude_resolution
.menubar.file entryconfigure 3 -state normal
populate_listbox
}
}
if {$cdd_name == ""} {
set cdd_name $fname
}
}
# Place new information in the info box
.info configure -text "Select a module/instance at left for coverage details"
# Reset the cursors
. configure -cursor $win_cursor
.bot.right.txt configure -cursor $txt_cursor
.bot.right.h.search.e configure -cursor $e_cursor
# Change some of the GUI elements
if {$cdd_name ne ""} {
.menubar.file entryconfigure 1 -state normal
.menubar.file entryconfigure 4 -state normal
.menubar.file.gen entryconfigure 1 -state normal
}
return $cdd_name
}
# Call this function when the main window will be destroyed or when a CDD is attempting to be closed
proc check_to_save_and_close_cdd {msg} {
if {[.menubar.file entrycget 3 -state] == "normal"} {
set exit_status [tk_messageBox -message "Opened database has changed. Would you like to save before $msg?" -type yesnocancel -icon warning]
if {$exit_status == "yes"} {
.menubar.file invoke 3
} elseif {$exit_status == "cancel"} {
return
}
}
if {[.menubar.file entrycget 4 -state] == "normal"} {
tcl_func_close_cdd
puts "Closed all opened/merged CDD files"
}
}
|