debug.tcl 3.68 KB
Newer Older
1 2 3
#
# Copyright (C) 2014 Jens Korinth, TU Darmstadt
#
4
# This file is part of Tapasco (TPC).
5
#
6
# Tapasco is free software: you can redistribute it and/or modify
7 8 9 10
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
11
# Tapasco is distributed in the hope that it will be useful,
12 13 14 15 16
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
17
# along with Tapasco.  If not, see <http://www.gnu.org/licenses/>.
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
#
# @file   debug.tcl
# @brief  Plugin to add ILA cores to the design. GP0, HP0, HP2 and ACP are
#         addded by default; other nets can be added as strings via feature.
# @author J. Korinth, TU Darmstadt (jk@esa.cs.tu-darmstadt.de)
#
namespace eval debug {
  namespace export debug_feature

  proc get_debug_nets {} {
    puts "Adding default signals to the ILA core ..."
    set ret [list [get_nets -hier "*irq_out*"]]
    set defsignals [list \
      "_RDATA*" \
      "_WDATA*" \
      "_ARADDR*" \
      "_AWADDR*" \
      "_AWVALID" \
      "_AWREADY" \
      "_ARVALID" \
      "_ARREADY" \
      "_WVALID" \
      "_WREADY" \
      "_WSTRB*" \
      "_RVALID" \
      "_RREADY" \
      "_ARBURST*" \
      "_AWBURST*" \
      "_ARLEN*" \
      "_AWLEN*" \
      "_WLAST" \
      "_RLAST" \
    ]
    foreach m [arch::get_masters] {
      set name [get_property NAME $m]
      foreach s $defsignals {
        set net [get_nets -hier "*$name$s"]
        puts "  adding net $net for signal $s ..."
56
        if {[llength $net] > 1} { lappend ret $net } { lappend ret [list $net] }
57 58 59 60 61 62
      }
    }
    foreach m {"system_i/Host_M_AXI_GP0"} {
      foreach s $defsignals {
        set net [get_nets "$m$s"]
        puts "  adding net $net for signal $s ..."
63
        if {[llength $net] > 1} { lappend ret $net} { lappend ret [list $net] }
64 65 66 67 68 69 70
      }
    }
    puts "  signal list: $ret"
    return $ret
  }

  proc debug_feature {} {
71
    if {[tapasco::is_platform_feature_enabled "Debug"]} {
72 73
      puts "Creating ILA debug core, will require re-run of synthesis."
      # get config
74
      set debug [tapasco::get_platform_feature "Debug"]
75 76 77 78 79 80 81 82 83 84 85 86 87 88
      puts "  Debug = $debug"
      # default values
      set depth        4096
      set stages       0
      set use_defaults true
      set nets         {}
      if {[dict exists $debug "depth"]} { set depth [dict get $debug "depth"] }
      if {[dict exists $debug "stages"]} { set stages [dict get $debug "stages"] }
      if {[dict exists $debug "use_defaults"]} { set use_defaults [dict get $debug "use_defaults"] }
      if {[dict exists $debug "nets"]} { set nets [dict get $debug "nets"] }
      set dnl {}
      if {$use_defaults} { foreach n [get_debug_nets] { lappend dnl $n }}
      if {[llength $nets] > 0} {
        foreach n $nets {
89 90 91 92
          set nnets [get_nets -hier $n]
          puts "  for '$n' found [llength $nnets] nets: $nnets"
          foreach nn $nnets { lappend dnl [list $nn] }
        }
93 94
      }
      # create ILA core
95
      tapasco::create_debug_core [get_nets system_i/Host_fclk0_aclk] $dnl $depth $stages
96 97
      reset_run synth
    }
98
    return {}
99 100 101 102
  }

  proc write_ltx {} {
    global bitstreamname
103
    if {[tapasco::is_platform_feature_enabled "Debug"]} {
104 105 106
      puts "Writing debug probes into file ${bitstreamname}.ltx ..."
      write_debug_probes -force -verbose "${bitstreamname}.ltx"
    }
107
    return {}
108 109 110
  }
}

111 112
tapasco::register_plugin "platform::zynq::debug::debug_feature" "post-synth"
tapasco::register_plugin "platform::zynq::debug::write_ltx" "post-impl"