/usr/share/tkgate/scripts/vpd.tcl is in tkgate-data 2.0~b10-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | # Copyright (C) 1987-2005 by Jeffery P. Hansen
#
# 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.
#
# Last edit by hansen on Sun Dec 7 20:44:06 2008
namespace eval VPD {
variable shutdown_cmd
variable outSignals {}
variable allowed_procs {}
variable disllowed_procs {}
variable loaded {}
variable insignalCommand
variable insignalVariable
variable insignalFormat
#############################################################################
#
# Register a VPD
#
proc register {name} {
variable loaded
lappend loaded $name
}
#############################################################################
#
# Register tcl proceedures patterns that are allowed to be executed from verilog.
#
proc allow {args} {
variable allowed_procs
foreach p $args { lappend allowed_procs $p }
}
#############################################################################
#
# Register tcl proceedures patterns that are disallowed from being executed
# from verilog.
#
proc disallow {args} {
variable disllowed_procs
foreach p $args { lappend disallowed_procs $p }
}
#############################################################################
#
# Post a VPD
#
# Parameters:
# name Type name of the VPD
# inst Instance name of the VPD
#
proc post {name inst} {
variable loaded
# puts "VPD::post $name $inst"
#
# Only allow post of registered VPDs
#
if {[lsearch -exact $loaded $name] < 0} {
return
}
# puts "exec VPD::post $name $inst"
${name}::post $inst
# puts "done VPD::post $name $inst"
}
#############################################################################
#
# Respond to data received on a named pipe.
#
proc qdata {name value} {
variable insignalCommand
variable insignalVariable
variable insignalFormat
# puts "VPD::qdata $name $value"
if {[info exists insignalCommand($name)]} {
eval "$insignalCommand($name) $value"
}
if {[info exists insignalVariable($name)]} {
uplevel \#0 set $insignalVariable($name) $value
}
}
#############################################################################
#
# Check a command to see if it is allowed
#
proc isallowed {cmd} {
variable allowed_procs
variable disllowed_procs
#
# Check for disallowed proceedures
#
set ok 1
foreach p $disllowed_procs {
if {[string match $p $cmd]} {
set ok 0
break
}
}
if {!$ok} { return 0 }
set ok 0
foreach p $allowed_procs {
if {[string match $p $cmd]} {
set ok 1
break
}
}
if {!$ok} { return 0 }
return 1
}
#############################################################################
#
# Respond to a shutdown of the simulator.
#
proc execShutdown {w args} {
variable shutdown_cmd
variable outSignals
global simOn
if { !$simOn } {
trace vdelete ::simOn w "VPD::execShutdown $w"
eval $shutdown_cmd($w)
catch { destroy $w }
}
}
#############################################################################
#
# Close a channel
#
proc closeChannel {chan var args} {
global simOn
variable insignalCommand
variable insignalVariable
if { !$simOn } {
trace vdelete $var w "VPD::dataOut $chan $var"
trace vdelete ::simOn w "VPD::closeChannel $chan $var"
catch { array unset insignalCommand }
catch { array unset insignalVariable }
catch { array unset insignalFormat }
}
}
#############################################################################
#
# Respond to a change in data and convey it to the verilog description.
#
proc dataOut {chan var args} {
set data [uplevel 0 { set $var}]
set n [llength $data]
if {$n > 1} {
set data [encodeBits 1 $data]
}
# puts "VPD::dataOut $chan $data"
Simulator::cmdSend "\$write $chan $data"
}
#############################################################################
#
# Register a variable as an output signal
#
proc signal {chan var args} {
variable outSignals
trace variable $var w "VPD::dataOut $chan $var"
trace variable ::simOn w "VPD::closeChannel $chan $var"
}
#############################################################################
#
# Register a variable as an output signal
#
proc outsignal {chan var args} {
variable outSignals
trace variable $var w "VPD::dataOut $chan $var"
trace variable ::simOn w "VPD::closeChannel $chan $var"
}
#############################################################################
#
# Register a variable as an input signal
#
# insignal $name.EMPTY -command "UserVPD::seeEmpty $name" -format decimal
# insignal $name.EMPTY -variable "UserVPD::empty($name)" -format verilog
#
proc insignal {chan args} {
variable insignalCommand
variable insignalVariable
variable insignalFormat
set command ""
set variable ""
set format "%h"
parseargs $args {-command -variable -format}
Simulator::cmdSend "\$qwatch $chan -format $format"
set insignalFormat($chan) $format
if { $command != "" } { set insignalCommand($chan) $command }
if { $variable != "" } { set insignalVariable($chan) $variable }
}
#############################################################################
#
# Create a top-level window for a user device that will automatically be
# deleted when the simulator is closed
#
proc createWindow {title args} {
variable shutdown_cmd
set i 0
set shutdowncommand ""
parseargs $args {-shutdowncommand}
while { [catch { set w [toplevel .udev_$i] }] } {
incr i
}
wm resizable $w 0 0
wm title $w "TkGate: $title"
wm geometry $w [offsetgeometry . [expr 50 * ( $i + 1 )] [expr 50 * ( $i + 1 )]]
set shutdown_cmd($w) $shutdowncommand
trace variable ::simOn w "VPD::execShutdown $w"
return $w
}
proc loadScripts {} {
global tkg_simVPDPath
variable loaded
# set loaded {}
foreach directory $tkg_simVPDPath {
set directory [namespace eval :: "eval concat $directory"]
foreach file [glob -nocomplain $directory/*.tcl] {
# lappend loaded [file rootname [file tail $file]]
namespace eval :: "source $file"
}
}
if {[llength $loaded] > 0} {
global tkg_statusMessage
InfoPanel::log "\[Loaded VPDs: $loaded\]" -noshow 1
}
}
}
|