AnsweredAssumed Answered

Problems with breakpoints in Tcl under Modelsim

Question asked by on Oct 29, 2015

Hi all!


I'm new in this forum and I still don't know what are the politcs regarding posting. Sorry if I do something wrong. In fact, I'm not sure if this is the right forum to post. If not, please tell me which is the right one.


First, I'll explain what I'm trying to do, and then I'll show summarily 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. According to the manual, enablebp should work with both bp and when breakpoints, but it doesn't! Perhaps am I doing something wrong?


In a file named "Breakpoints" I have defined a set of when-type breakpoints:


set when_id_list [list]

set bp_time 320001


when -id 1 "\$now == $bp_time" {

  lappend when_id_list 1




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







enablebp 1


"When #1" sets a time-based breakpoint, and "when #2" and subsequent set condition-based breakpoints. At the beginning, only the time-based one should be active. However, I've added a echo [bp] sentence after enablebp 1, and no (when) breakpoints are enabled. This is my first problem. Am I doing anythig wrong?


Later, there is a macro that intends to manage a model simulation performing several actions at different time instants (specified by "bp_time" variable, defined in "Breakpoints") and when breakpoint conditions occur. When this macro receives actions to carry out for a condition-based breakpoint, it enables it (by running enablebp $when_id), where "where_id" is a variable containing the id of the when condition to be checked. Like in previous case, nothing happens actually (I've inserted echo [bp] again after enablebp $when_id, and no breakpoints are active at all, not even the #1.


When this macro ends, an error appear when it tries to disable all the condition-based breakpoints (whens) activated in the call (by executing disablebp $when_id in a loop, where "when_id" contains every when id). Obviously, if no breakpoints are enabled, no breakpoints can be disabled. But why?


I've tried to replace when ids with labels (when -label when1 ..., ..., enablebp when1, enablebp $when_label, disablebp $when_label), but nothing changes.


I've been unable to find any examples using when breakpoints in Tcl macros, and the Tcl manual is ambiguous about how bp and when breakpoints are distinguished, given that they can share id numbers (that is to say, it is possible to define bp ... -id 1 ..., and a when ... -id 1 ...), so I don't understand what is wrong with my code. Any idea?


Thank you so much for your attention.


Best regards,

P.S. Of course, if I should write or upload the full code, don't hesitate to ask.