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 5

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 sckoarn
#! /usr/bin/env wish
2
##-------------------------------------------------------------------------------
3 5 sckoarn
##                     Copyright 2018 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 5 sckoarn
##-- $Date:  $ August 2018
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 5 sckoarn
set version "Version 1.0"
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 5 sckoarn
set test_but [button $tsf.bt2 -text "Source" -command {source tb_gen_parser.tcl}]
82
set comb_vals {"No mod" "Gen mod"}
83
set comb_val "No mod"
84
set mo_sel [ttk::combobox $tsf.mode -textvariable comb_val -values $comb_vals -state readonly]
85 2 sckoarn
set gbatv 0
86
set cpakv 0
87 5 sckoarn
$mo_sel insert end "No mod"
88
$mo_sel insert end "Gen mod"
89
#"Gen mod"
90
set gen_prog 0.0
91
set p_view [ttk::progressbar $tsf.fb1 -variable gen_prog]
92 2 sckoarn
set statsVar ""
93
##set stat_txt [label $tsf.lb1 -textvariable 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 $cpak -side left
100
#pack $gbat -side left
101
pack $mo_sel -side left
102
pack $load_but -side left -padx 20
103 5 sckoarn
pack $test_but -side left -padx 20
104 2 sckoarn
pack $p_view -side left
105
pack $tsf.bout1 -side right
106
pack $tsf -fill x
107
pack $stat_txt -fill x
108
 
109
## create paned window
110 5 sckoarn
set win [panedwindow .pw -width 200 -height 300 -orient horizontal]
111 2 sckoarn
pack $win -fill both -expand yes
112 5 sckoarn
set wtop [frame $win.wf1]
113
set wmid [frame $win.wf2]
114
 
115
$win add $wtop $wmid
116
 
117 2 sckoarn
## create two object boxes
118 5 sckoarn
set sel_lst {}
119
set m_select ""
120
set list_win [listbox $wtop.sb -listvariable sel_lst -height 16]
121
set list_ent [entry $wtop.lent -textvariable m_select]
122
#set view_win [iwidgets::scrolledtext $wbot.rts -borderwidth 2 -wrap none]
123
set view_win [text $wmid.rts -borderwidth 2 -wrap none]
124 2 sckoarn
pack $list_win -fill both -expand yes
125 5 sckoarn
pack $list_ent -anchor s -fill x -expand yes
126 2 sckoarn
pack $view_win -fill both -expand yes
127
 
128
##  some tags for the view window
129
##$view_win tag configure highlite -background #a0b7ce
130
$view_win tag configure highlite -background grey80
131
 
132
###########################################################################
133
##  some debug and help procs
134
##    Message Error, terminate
135
proc msg_error { msg } {
136
  tk_messageBox -message $msg -type ok
137
  exit
138
}
139
###########################################################################
140
##  Message, continue
141
proc dbg_msg { msg } {
142
  tk_messageBox -message $msg -type ok
143
}
144
#########################################################################
145
##  browse and get directory
146
##    Using extfileselectiondialog get a directory and update the
147
##    field passed to it
148
proc browsed_from_set { src dest } {
149
    set wdir [$src get]
150 5 sckoarn
    puts $wdir
151 2 sckoarn
    if {$wdir == ""} {
152 5 sckoarn
        set curd [pwd]
153
        puts $curd
154
        set fn [tk_chooseDirectory -title "Choose a directory" -initialdir $curd]
155 2 sckoarn
    } else {
156 5 sckoarn
        set fn [tk_chooseDirectory -initialdir $wdir -title "Choose a directory"]
157 2 sckoarn
    }
158
 
159 5 sckoarn
  if {$fn != ""} {
160 2 sckoarn
      $dest configure -state normal
161
      $dest delete 0 end
162 5 sckoarn
      $dest insert 0 "$fn"
163 2 sckoarn
      $dest configure -state readonly
164
  }
165
  destroy .dsb
166
}
167
#########################################################################
168
##  browse and get file name
169
##    Using extfileselectiondialog get a directory and update the
170
##    field passed to it
171
proc browse_set_entry { dest } {
172 5 sckoarn
    set fn [tk_getOpenFile]
173 2 sckoarn
 
174 5 sckoarn
  if {$fn != ""} {
175 2 sckoarn
      $dest configure -state normal
176
      $dest delete 0 end
177 5 sckoarn
      $dest insert 0 "$fn"
178 2 sckoarn
      $dest configure -state readonly
179
  }
180
  destroy .dsb
181
}
182
 
183 5 sckoarn
##################################################
184
##  Now with the GUI set up, load the parser
185
source "tb_gen_parser.tcl"
186 2 sckoarn
 
187
## end ttb_gen
188
#################################################
189
##  show  about message
190
proc show_about {} {
191
    global version
192 3 sckoarn
 
193 5 sckoarn
                set msg "Copyright 2019 Ken Campbell\n
194 2 sckoarn
Version $version\n
195
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
196
http://www.apache.org/licenses/LICENSE-2.0\n
197
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.
198
See the License for the specific language governing permissions and limitations under the License."
199
 
200
    dbg_msg $msg
201
}
202
 
203
## enable pop up console for debug
204
bind . <F12> {catch {console show}}
205 5 sckoarn
#bind  $list_win <<ListboxSelect>> {load_ent_file}
206
#bind  $list_win <<ListboxSelect>> {set m_select [$list_win curselection]}
207
bind  $list_win <<ListboxSelect>> {set sel_dx [$list_win curselection]; set m_select [$list_win get $sel_dx]; load_ent_file}

powered by: WebSVN 2.1.0

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