bluespec.com Forum Index bluespec.com
Bluespec Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Where are script for flag -cc -r -ss?

 
Post new topic   Reply to topic    bluespec.com Forum Index -> Tools: Bluesim
View previous topic :: View next topic  
Author Message
test001
Guest





PostPosted: Fri Oct 17, 2008 11:02 pm    Post subject: Where are script for flag -cc -r -ss? Reply with quote

In the latest Bluesim, it do not support flag -cc -r -ss, the document said that new tcl support can do that function, so you remove them.
Unfortunately, I can not found script in the software. if develop by myself, it will many time to write tcl script.

I trace the MC2008 code, but bsim dumped vcd has miss many signal, so I want use -cc -r -ss to dump all of state, value and info (ex, who fired at every cycle), then I can write own tools to help me debug.
Back to top
jnewbern



Joined: 18 Jul 2007
Posts: 71

PostPosted: Mon Oct 20, 2008 10:43 am    Post subject: Bluesim debugging Reply with quote

First, you should make sure that you are using the -keep-fires flag both when elaborating (bsc -u ...) and when linking for bluesim (bsc -sim -e ...). This will ensure that no signals that are useful for debugging get optimized away within the Bluesim backend.

If that doesn't give you enough visibility, or if you want more control over the debugging output, then you can use the TCL scripting feature to drive the Bluesim tool and extract the information you want.

The scripting support is described in the user guide, which provides some sample scripts. I will give you some more examples that show how the debug scripting is done in this message.

If you just want to insert cycle boundary markers into the simulation output:

Code:
while {true} {
  if [catch {sim step}] {break}
  puts "---- [sim time] ----"
}


A simple replacement for the old "-cc" option, which causes the simulator to single-step through every clock edge and print the current state of the clocks:

Code:
# show the clock edges at the current simulation time
proc showclk {} {
  set t [sim time]
  set clks [sim clock]
  foreach clk $clks {
    set name [lindex $clk 2]
    set cycles [lindex $clk 7]
    set val [lindex $clk 8]
    set edge_at [lindex $clk 9]
    if {$edge_at == $t} {
       if {$val == 1} then {
          puts "/$name ($cycles) at $edge_at"
       } else {
          puts "\\$name ($cycles) at $edge_at"
       }
    }
  }
}

while {true} {
  if [catch {sim nextedge}] {break}
  showclk
}


If you want to watch rule firings in the whole design, similar to the old "-r" option:

Code:

# show rule firings

set level 0
set fireinfo []

proc find_rules {} {
  global fireinfo
  global level
  set level [expr $level + 1]
  set dir [sim pwd]
  set hdls []
  foreach entry [sim ls] {
    if {[lindex $entry 1] == "rule"} {
      set rl_name [lindex $entry 0]
      set wf_name [join [list "WILL_FIRE_" $rl_name] ""]
      set wf_hdl [sim lookup $wf_name]
      set cf_name [join [list "CAN_FIRE_" $rl_name] ""]
      set cf_hdl [sim lookup $cf_name]
      lappend hdls "$rl_name $cf_hdl $wf_hdl"
    }
  }
  lappend fireinfo "$level [sim pwd] $hdls"
  foreach entry [sim ls] {
    if {[lindex $entry 1] == "module"} {
      sim cd [lindex $entry 0]
      find_rules
      sim up
    }
  }
  set level [expr $level - 1]
}

find_rules

while {true} {
  if [catch {sim step}] {break}
  puts "---- Rules firing at [sim time] ----"
  foreach info $fireinfo {
    set lvl [lindex $info 0]
    set mod [lindex $info 1]
    set rls [lrange $info 2 end]
    set msgs []
    foreach rl $rls {
      set rl_name [lindex $rl 0]
      set cf_hdl  [lindex $rl 1]
      set wf_hdl  [lindex $rl 2]
      if {[sim get $wf_hdl] == "1'h1"} {
        lappend msgs "$rl_name fired"
      } elseif {[sim get $cf_hdl] == "1'h1"} {
        lappend msgs "$rl_name was blocked by a more urgent rule"
      }
    }
    if {[llength $msgs] != 0} {
      puts "In module $mod:"
      foreach msg $msgs {
        puts "  $msg"
      }
    }
  }
}


If you want to trace particular values, method calls, etc:

Code:
sim cd gcd

# get handles for start method enable and arguments
set hdl_of(EN_start)   [sim lookup EN_start]
set hdl_of(num1)       [sim lookup start_num1]
set hdl_of(num2)       [sim lookup start_num2]

# step and log start method calls
while {true} {
  if [catch {sim step}] {break}
  if {[sim get $hdl_of(EN_start)] == "1'h1"} {
     set num1 [sim get $hdl_of(num1)]
     set num2 [sim get $hdl_of(num2)]
     puts "[sim time]: start($num1,$num2)"
  }
}
Back to top
View user's profile Send private message
test001
Guest





PostPosted: Mon Oct 20, 2008 8:50 pm    Post subject: Reply with quote

Great!
Thanks for your example, I will write some debug tools later.

btw:
I think all of your example can be found in document except "show rule firings", this is my really needed. I suggest add this to next release.
I do not forget compile with -keep-fires, but bsim dumped vcd miss many signal, the VCS's correct. Certainly, it run slower than bsim.
I think this is a problem in bsim. you can replay with "training/BSV/tutorials/counter/Ch03_Counter.bspec"
Back to top
Display posts from previous:   
Post new topic   Reply to topic    bluespec.com Forum Index -> Tools: Bluesim All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
bluespec.com topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP