Hi all!
I'm new in this forum and I still don't know what are the politcs regarding posting. In fact, I'm not sure if this is the right forum to post. I hope it is and I can get some valuable help.
First, I'll explain what I'm trying to do, and then I'll show how I'm doing. Here I go.
I want to make a Tcl macro running under Modelsim which is able to control a HDL model simulation by setting time-based breakpoints (that is, to stop at given simulation times) and condition-based breakpoints (for instance, when a rising edge on a signal occurs). Depending on the type of breakpoint hit, some tasks are performed that affect the model simulation, but this is not the important issue.
Having a look to Tcl manual, when sentence seems to be more suitable than bp to set the breakpoints that I intend to implement. From the manual, enablebp should work with both bp and when breakpoints. But it doesn't! Perhaps am I doing something wrong?
The main macro is like this (called MyMacro):
The most important elements in the call to "RunMacro" function are:
-bp, that represents a condition-based breakpoint. After -bp, I list the breakpoint id (starting from 2) and a number of parameters that mean what to do in case of accomplishing the condition (described in file "Breakpoints" as I explain later). As multiple condition-based breakpoints can be set in every simulation, this set of parameters can appear repeatedly until a -1 is inserted.
Then, the simulation parameters are listed. This list includes the time instants where the simulation has to be stopped (by the time-based breakpoint), and what to do at every time. To make evolve the simulation time, I use a variable called bp_time. The simulation parameters end with a new -1.
The last parameter to "RunMacro" is the total simulation time.
In "Macro" file I implement the aforementionned "RunMacro" function, which is in charge of processing the breakpoint and simulation parameters to control the simulation. This is the most important piece of code, and I'll describe later.
"InitModel" file is in charge of initializing the Wodelsim List View.
"Breakpoints" file defines all the time-based and condition-based breakpoints:
when_id_list variable contains all the breakpoints hit at a given time (in case a time-based and one or more condition-based breakpoints are hit simultaneously). After a breakpoint is processed, it will be removed from this list.
At the end of this code, only the time-based breakpoint (when #1) should be enabled. However, here I get my first problem. I've put an echo [bp] sentence after the enablebp 1, but no breakpoint is active.
The idea is that when #1 stops the simulation whenever the simulation time (now) matches a value set in variable bp_time. This variable is initialized at the simulation time plus 1, but RunMacro updates this value according to the list of temporal events in "MyMacro".
Finally, I'll show the most critical parts of the code of "RunMacro" function, explaining what problems I get:
The capture of breakpoint and simulation parameters works well, except for one detail. Again, I've inserted a echo [bp] sentence after the enablebp $bp_id, and again no breakpoints are active. As I mentionned at the beginning, enablebp sentence should work also with when breakpoints, but it doesn't.
As I'm having such trouble at this point, I haven't implemented the onbreak routine (where the actions to be performed in each type of brekpoint are specified) yet.
When I run this macro in Modelsim, I get an ERROR message at the end of the execution of RunMacro:
# ERROR: Breakpoint 2 not found.
# Error in macro RunMacro line ...
# Breakpoint 2 not found.
# while executing
# "disablebp $bp_id"
Obviously, if no breakpoints have been enabled despite the enablebp sentences, they cannot be disabled either. So, the problem seems to be simple: Why the when sentences are not enabled? I've tried using labels instead of ids (when -label when1 ...), but nothing changes.
Well, I know thqat it's "a bit" much a mess. Sorry! If you consider I should upload all the code files, please don't hesitate to ask.
Many thanks to all!
Regards,
Juan-Carlos
I'm new in this forum and I still don't know what are the politcs regarding posting. In fact, I'm not sure if this is the right forum to post. I hope it is and I can get some valuable help.
First, I'll explain what I'm trying to do, and then I'll show how I'm doing. Here I go.
I want to make a Tcl macro running under Modelsim which is able to control a HDL model simulation by setting time-based breakpoints (that is, to stop at given simulation times) and condition-based breakpoints (for instance, when a rising edge on a signal occurs). Depending on the type of breakpoint hit, some tasks are performed that affect the model simulation, but this is not the important issue.
Having a look to Tcl manual, when sentence seems to be more suitable than bp to set the breakpoints that I intend to implement. From the manual, enablebp should work with both bp and when breakpoints. But it doesn't! Perhaps am I doing something wrong?
The main macro is like this (called MyMacro):
Code:
source {.../Macro}
source {.../InitModel}
source {.../Breakpoints}
# Simulation no. 1
RunMacro -bp 2 "Breakpoint parameters"
-1 "Simulation parameters"
...
-1 320000
write list {SimulationTrace_001.lst}
...
# Simulation no. N
RunMacro -bp j "Breakpoint parameters"
...
-1 "Simulation parameters"
...
-1 320000
write list {SimulationTrace_N.lst}
The most important elements in the call to "RunMacro" function are:
-bp, that represents a condition-based breakpoint. After -bp, I list the breakpoint id (starting from 2) and a number of parameters that mean what to do in case of accomplishing the condition (described in file "Breakpoints" as I explain later). As multiple condition-based breakpoints can be set in every simulation, this set of parameters can appear repeatedly until a -1 is inserted.
Then, the simulation parameters are listed. This list includes the time instants where the simulation has to be stopped (by the time-based breakpoint), and what to do at every time. To make evolve the simulation time, I use a variable called bp_time. The simulation parameters end with a new -1.
The last parameter to "RunMacro" is the total simulation time.
In "Macro" file I implement the aforementionned "RunMacro" function, which is in charge of processing the breakpoint and simulation parameters to control the simulation. This is the most important piece of code, and I'll describe later.
"InitModel" file is in charge of initializing the Wodelsim List View.
"Breakpoints" file defines all the time-based and condition-based breakpoints:
Code:
set when_id_list [list]
set bp_time 320001
when -id 1 "\$now == $bp_time" {
lappend when_id_list 1
stop
}
when -id 2 {/tbench/u1_plasma/u2_ram/scrubbing_int'event and /tbench/u1_plasma/u2_ram/scrubbing_int = '0'} {
lappend when_id_list 2
stop
}
...
disablebp
enablebp 1
when_id_list variable contains all the breakpoints hit at a given time (in case a time-based and one or more condition-based breakpoints are hit simultaneously). After a breakpoint is processed, it will be removed from this list.
At the end of this code, only the time-based breakpoint (when #1) should be enabled. However, here I get my first problem. I've put an echo [bp] sentence after the enablebp 1, but no breakpoint is active.
The idea is that when #1 stops the simulation whenever the simulation time (now) matches a value set in variable bp_time. This variable is initialized at the simulation time plus 1, but RunMacro updates this value according to the list of temporal events in "MyMacro".
Finally, I'll show the most critical parts of the code of "RunMacro" function, explaining what problems I get:
Code:
proc InjectMTS {args} {
# Initialise lists and other global parameters
...
# Capture breakpoint parameters
while {[lindex $args 0] == "-bp"} {
# Breakpoint (when) label
set bp_id [lindex $args 1]
lshift args 2
...
# Add breakpoint to condition breakpoint list and enable
echo "Enabling when id no. $bp_id"
lappend bp_id_list $bp_id
enablebp $bp_id
}
# Capture simulation parameters
...
# Capture simulation time
set simulation_duration [lindex $args 1]
# Set first breakpoint (injection) time
set bp_time ...
}
# Set actions to perform when a breakpoint is hit
onbreak {
resume
}
# Run simulation
InitModel
run @$simulation_duration
# Clear variables
...
# Disable all condition breakpoints
set index 0
set n_bp [llength $bp_id_list]
while {$index < $n_bp} {
set bp_id [lindex $bp_id_list $index]
disablebp $bp_id
unset bp_id
incr index
}
unset n_bp
unset index
unset bp_id_list
# Clear breakpoint id list
unset when_id_list
set when_id_list [list]
return 0
}
The capture of breakpoint and simulation parameters works well, except for one detail. Again, I've inserted a echo [bp] sentence after the enablebp $bp_id, and again no breakpoints are active. As I mentionned at the beginning, enablebp sentence should work also with when breakpoints, but it doesn't.
As I'm having such trouble at this point, I haven't implemented the onbreak routine (where the actions to be performed in each type of brekpoint are specified) yet.
When I run this macro in Modelsim, I get an ERROR message at the end of the execution of RunMacro:
# ERROR: Breakpoint 2 not found.
# Error in macro RunMacro line ...
# Breakpoint 2 not found.
# while executing
# "disablebp $bp_id"
Obviously, if no breakpoints have been enabled despite the enablebp sentences, they cannot be disabled either. So, the problem seems to be simple: Why the when sentences are not enabled? I've tried using labels instead of ids (when -label when1 ...), but nothing changes.
Well, I know thqat it's "a bit" much a mess. Sorry! If you consider I should upload all the code files, please don't hesitate to ask.
Many thanks to all!
Regards,
Juan-Carlos