OpenCores
URL https://opencores.org/ocsvn/sv_dir_tb/sv_dir_tb/trunk

Subversion Repositories sv_dir_tb

[/] [sv_dir_tb/] [trunk/] [tb_gen/] [tb_gen.tcl] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 sckoarn
#! /usr/bin/env wish
2
##-------------------------------------------------------------------------------
3 6 sckoarn
##                     Copyright 2019 Ken Campbell
4 2 sckoarn
##
5
##   Licensed under the Apache License, Version 2.0 (the "License");
6
##   you may not use this file except in compliance with the License.
7
##   You may obtain a copy of the License at
8
##
9
##     http://www.apache.org/licenses/LICENSE-2.0
10
##
11
##   Unless required by applicable law or agreed to in writing, software
12
##   distributed under the License is distributed on an "AS IS" BASIS,
13
##   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
##   See the License for the specific language governing permissions and
15
##   limitations under the License.
16
##-------------------------------------------------------------------------------
17
##-- $Author:  $ Ken Campbell
18
##--
19 6 sckoarn
##-- $Date:  $ April 2019
20 2 sckoarn
##--
21
##-- $Id:  $
22
##--
23
##-- $Source:  $
24
##--
25
##-- Description :
26
##--      This application takes a text file containing the definition of a Verilog
27
##           module, produces a file set for the SV Directed Test Bench.
28 5 sckoarn
##--      This file is the GUI items.
29 2 sckoarn
##------------------------------------------------------------------------------
30
 
31
## package requires
32 5 sckoarn
package require Ttk
33
package require Tk
34 2 sckoarn
 
35
## set the current version info
36 6 sckoarn
set version "Version 1.2"
37 2 sckoarn
## put up a title on the main window boarder
38
wm title . "SV TB Gen $version"
39
 
40
## the location of the template by default
41
set template "./tb_mod_template.sv"
42
 
43
set use_list 0
44
 
45
##  Working Directory or vhdl directory
46
set workd [frame .wdf]
47 5 sckoarn
set ent_lbl [label $workd.lbl1 -text "Top mod loc" -justify left]
48
set ent_dir [entry $workd.ent1]
49 2 sckoarn
button $workd.br0 -text "Browse" -command {fill_list}
50 5 sckoarn
pack $ent_lbl -side left
51 2 sckoarn
pack $workd.br0 -side right
52
pack $ent_dir -fill x
53
pack $workd -fill x -pady 6
54
 
55
##  Output directory
56
set tlist [frame .lstf]
57 5 sckoarn
set odir_lbl [label $tlist.lbl2 -text "Output loc" -justify left]
58
set odir [entry $tlist.ent2]
59 2 sckoarn
set lbut [button $tlist.br1 -text "Browse" -command {browsed_from_set $odir $odir}]
60 5 sckoarn
pack $odir_lbl -side left
61 2 sckoarn
pack $lbut -side right
62
pack $odir -fill x
63
pack $tlist -fill x
64
 
65
##  Template location
66
set tdirf [frame .tmpf]
67 5 sckoarn
set tdir_lbl [label $tdirf.lbl3 -text "Template loc" -justify left]
68
set tdir [entry $tdirf.ent3]
69 2 sckoarn
set tbut [button $tdirf.br2 -text "Browse" -command {browse_set_entry $tdir}]
70 5 sckoarn
pack $tdir_lbl -side left
71 2 sckoarn
pack $tbut -side right
72
pack $tdir -fill x
73
pack $tdirf -fill x -pady 6
74
$tdir delete 0 end
75
$tdir insert end $template
76
$tdir configure -state readonly
77
 
78
## type spec
79
set tsf [frame .tsfr]
80
set load_but [button $tsf.bt1 -text "Generate" -command ttb_gen]
81 6 sckoarn
## this button enables quicker development of the parser.  If 
82 5 sckoarn
set test_but [button $tsf.bt2 -text "Source" -command {source tb_gen_parser.tcl}]
83
set comb_vals {"No mod" "Gen mod"}
84
set comb_val "No mod"
85
set mo_sel [ttk::combobox $tsf.mode -textvariable comb_val -values $comb_vals -state readonly]
86 2 sckoarn
set gbatv 0
87
set cpakv 0
88 5 sckoarn
$mo_sel insert end "No mod"
89
$mo_sel insert end "Gen mod"
90
#"Gen mod"
91
set gen_prog 0.0
92
set p_view [ttk::progressbar $tsf.fb1 -variable gen_prog]
93 2 sckoarn
set statsVar ""
94
set stat_txt [label .lb1 -textvariable statsVar]
95
 
96
##   about button
97
button $tsf.bout1 -text "About" -command show_about
98
 
99
pack $mo_sel -side left
100
pack $load_but -side left -padx 20
101 5 sckoarn
pack $test_but -side left -padx 20
102 2 sckoarn
pack $p_view -side left
103
pack $tsf.bout1 -side right
104
pack $tsf -fill x
105
pack $stat_txt -fill x
106
 
107
## create paned window
108 5 sckoarn
set win [panedwindow .pw -width 200 -height 300 -orient horizontal]
109 2 sckoarn
pack $win -fill both -expand yes
110 5 sckoarn
set wtop [frame $win.wf1]
111
set wmid [frame $win.wf2]
112
 
113
$win add $wtop $wmid
114
 
115 2 sckoarn
## create two object boxes
116 5 sckoarn
set sel_lst {}
117
set m_select ""
118
set list_win [listbox $wtop.sb -listvariable sel_lst -height 16]
119
set list_ent [entry $wtop.lent -textvariable m_select]
120
set view_win [text $wmid.rts -borderwidth 2 -wrap none]
121 2 sckoarn
pack $list_win -fill both -expand yes
122 5 sckoarn
pack $list_ent -anchor s -fill x -expand yes
123 2 sckoarn
pack $view_win -fill both -expand yes
124
 
125 6 sckoarn
## tag for the view window
126 2 sckoarn
$view_win tag configure highlite -background grey80
127
 
128
###########################################################################
129
##  some debug and help procs
130
##    Message Error, terminate
131
proc msg_error { msg } {
132
  tk_messageBox -message $msg -type ok
133
  exit
134
}
135
###########################################################################
136
##  Message, continue
137
proc dbg_msg { msg } {
138
  tk_messageBox -message $msg -type ok
139
}
140
#########################################################################
141
##  browse and get directory
142
##    Using extfileselectiondialog get a directory and update the
143
##    field passed to it
144
proc browsed_from_set { src dest } {
145
    set wdir [$src get]
146 6 sckoarn
    #puts $wdir
147 2 sckoarn
    if {$wdir == ""} {
148 5 sckoarn
        set curd [pwd]
149 6 sckoarn
        #puts $curd
150 5 sckoarn
        set fn [tk_chooseDirectory -title "Choose a directory" -initialdir $curd]
151 2 sckoarn
    } else {
152 5 sckoarn
        set fn [tk_chooseDirectory -initialdir $wdir -title "Choose a directory"]
153 2 sckoarn
    }
154
 
155 5 sckoarn
  if {$fn != ""} {
156 2 sckoarn
      $dest configure -state normal
157
      $dest delete 0 end
158 5 sckoarn
      $dest insert 0 "$fn"
159 2 sckoarn
      $dest configure -state readonly
160
  }
161
  destroy .dsb
162
}
163
#########################################################################
164
##  browse and get file name
165
##    Using extfileselectiondialog get a directory and update the
166
##    field passed to it
167
proc browse_set_entry { dest } {
168 5 sckoarn
    set fn [tk_getOpenFile]
169 2 sckoarn
 
170 5 sckoarn
  if {$fn != ""} {
171 2 sckoarn
      $dest configure -state normal
172
      $dest delete 0 end
173 5 sckoarn
      $dest insert 0 "$fn"
174 2 sckoarn
      $dest configure -state readonly
175
  }
176
  destroy .dsb
177
}
178
 
179 5 sckoarn
##################################################
180
##  Now with the GUI set up, load the parser
181
source "tb_gen_parser.tcl"
182 2 sckoarn
 
183
## end ttb_gen
184
#################################################
185
##  show  about message
186
proc show_about {} {
187
    global version
188 3 sckoarn
 
189 5 sckoarn
                set msg "Copyright 2019 Ken Campbell\n
190 2 sckoarn
Version $version\n
191
Licensed under the Apache License, Version 2.0 (the \"License\"); You may not use this file except in compliance with the License. You may obtain a copy of the License at\n
192
http://www.apache.org/licenses/LICENSE-2.0\n
193
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
194
See the License for the specific language governing permissions and limitations under the License."
195
 
196
    dbg_msg $msg
197
}
198
 
199
## enable pop up console for debug
200
bind . <F12> {catch {console show}}
201 6 sckoarn
bind  $list_win <<ListboxSelect>> {process_selected}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.