12     3.94093e-011
AT13     1.46601e-010
AY10     1.12798e-010
[Row]    H18
H18     9.62115e-009
J18     5.91262e-010
G18     7.53765e-011
F17     7.82691e-011
H19     8.12713e-011
G17     4.45676e-010
H20     2.40302e-011
J17     3.63033e-011
[Row]    A30
A30     1.05842e-008
A29     7.2713e-010
D31     9.28933e-011
E31     2.48301e-010
C30     3.13026e-011
A28     4.26549e-011
A27     1.99783e-011
[Row]    J24
J24     5.99444e-009
J23     4.77801e-010
H23     5.194e-011
H26     9.43159e-011
H25     2.98073e-010
G25     4.04166e-011
H24     1.30593e-010
K25     5.21258e-011
[Row]    J21
J21     5.52711e-009
K21     3.97494e-010
J22     8.17749e-011
K22     5.22014e-011
H19     5.97531e-011
H20     2.49962e-010
H21     9.3752e-011
G21     4.08239e-011
L22     2.18165e-011
[Row]    M10
M10     6.01259e-009
K10     3.36983e-011
K11     7.13484e-011
[Row]    E6
E6     7.37129e-009
B7     3.93697e-011
[Row]    D11
D11     6.71896e-009
B10     2.97825e-011
C10     9.18949e-011
B11     3.63554e-011
B12     3.63633e-011
D13     3.03281e-011
[Row]    B2
B2     8.79497e-009
A3     4.46821e-011
B3     1.63762e-010
A4     8.82955e-012
[Row]    AW20
AW20     3.36334e-009
AY19     6.33661e-011
AV21     8.37537e-011
AU21     5.3023e-011
AV19     4.6701e-011
AW21     7.98925e-011
[Row]    AV27
AV27     5.13413e-009
AV28     1.03448e-010
AU28     5.15329e-011
AU26     3.53265e-011
AU25     4.71748e-011
BA27     1.45794e-010
[Row]    BA10
BA10     8.04878e-009
AW15     4.17052e-011
AY10     1.09975e-010
[Row]    AW11
AW11     7.6379e-009
AT12     3.46694e-011
AT13     5.11183e-011
AY10     5.30964e-011
[Row]    J18
J18     9.31485e-009
H19     4.95786e-011
G17     7.08884e-011
H20     2.04496e-011
J17     7.66876e-011
[Row]    A29
A29     1.061e-008
D31     2.36523e-011
E31     8.7443e-011
B28     2.84347e-011
A28     9.94654e-011
A27     4.36549e-011
[Row]    J23
J23     6.33318e-009
G23     1.91714e-011
J22     5.45479e-011
H23     7.64376e-011
H25     8.52773e-011
H24     5.23454e-011
K25     4.23807e-011
[Row]    K21
K21    ###############################################################################
#
# Copyright (C) 2014 - 2015 Xilinx, Inc.  All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# Use of the Software is limited solely to applications:
# (a) running on a Xilinx device, or
# (b) that interact with a Xilinx device through a bus or interconnect.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# XILINX  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
# OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# Except as contained in this notice, the name of the Xilinx shall not be used
# in advertising or otherwise to promote the sale, use or other dealings in
# this Software without prior written authorization from Xilinx.
#
###############################################################################
##############################################################################
#
# Modification History
#
# Ver   Who  Date     Changes
# ----- ---- -------- -----------------------------------------------
# 3.0   pkp  12/01/15 Initial Release
##############################################################################

# Uses $XILINX_EDK/bin/lib/xillib_sw.tcl
# -----------------------------------------------------------------
# Software Project Types (swproj):
#   0 : MemoryTest - Calls basic  memorytest routines from common driver dir
#   1 : PeripheralTest - Calls any existing polled_example and/or selftest
# -----------------------------------------------------------------

# -----------------------------------------------------------------
# TCL Procedures:
# -----------------------------------------------------------------

proc gen_include_files {swproj mhsinst} {

    if {$swproj == 0} {
            return ""
    }
    if {$swproj == 1} {
    # exclude ttc3 if present for cortexR5 since R5 uses ttc3 for sleep when present

	set periph_include 1
	set procdrv [hsi::get_sw_processor]
	if {[string match "*psu_cortexr5_*" $procdrv]} {
		if {[string compare -nocase "psu_ttc_3" $mhsinst] == 0} {
			set periph_include 0
		}
	}
        set isintr [::hsi::utils::is_ip_interrupting_current_proc $mhsinst]
	if {$periph_include && $isintr} {
		set inc_file_lines {xttcps.h ttcps_header.h}
		return $inc_file_lines
	} else {
		return ""
        }
    }
}

proc gen_src_files {swproj mhsinst} {
  if {$swproj == 0} {
    return ""
  }
  if {$swproj == 1} {
  # exclude ttc3 if present for cortexR5 since R5 uses ttc3 for sleep when present
	set periph_include 1
	set procdrv [hsi::get_sw_processor]
	if {[string match "*psu_cortexr5_*" $procdrv]} {
		if {[string compare -nocase "psu_ttc_3" $mhsinst] == 0} {
			set periph_include 0
		}
	}
        set isintr [::hsi::utils::is_ip_interrupting_current_proc $mhsinst]
	if {$periph_include && $isintr} {
		set inc_file_lines {examples/xttcps_tapp_example.c data/ttcps_header.h}
		return $inc_file_lines
	} else {
		return ""
	}
  }
}

proc gen_testfunc_def {swproj mhsinst} {
  return ""
}

proc gen_init_code {swproj mhsinst} {

    if {$swproj == 0} {
        return ""
    }
    if {$swproj == 1} {
    # exclude ttc3 if present for cortexR5 since R5 uses ttc3 for sleep when present
	set periph_include 1
	set procdrv [hsi::get_sw_processor]
	if {[string match "*psu_cortexr5_*" $procdrv]} {
		if {[string compare -nocase "psu_ttc_3" $mhsinst] == 0} {
			set periph_include 0
		}
	}
        set isintr [::hsi::utils::is_ip_interrupting_current_proc $mhsinst]
	if {$periph_include && $isintr} {
		set ipname [get_property NAME $mhsinst]
		set decl "   static XTtcPs ${ipname};"
		set inc_file_lines $decl
		return $inc_file_lines
	} else {
		return ""
        }
    }

}

proc gen_testfunc_call {swproj mhsinst} {

    if {$swproj == 0} {
        return ""
    }

    set ipname [get_property NAME $mhsinst]
    set deviceid [::hsi::utils::get_ip_param_name $mhsinst "DEVICE_ID"]
    set stdout [get_property CONFIG.STDOUT [get_os]]
    if { $stdout == "" || $stdout == "none" } {
       set hasStdout 0
    } else {
       set hasStdout 1
    }

    set intsnum [string index $mhsinst end]
    set device_id [expr {$intsnum * 3}]
    set deviceidname $deviceid
    set deviceid [format %s%d%s [string range $deviceidname 0 12] $device_id [string range $deviceidname 14 end]]
    set isintr [::hsi::utils::is_ip_interrupting_current_proc $mhsinst]
    set intcvar intc
    set testfunc_call ""
    # exclude ttc3 if present for cortexR5 since R5 uses ttc3 for sleep when present
    set periph_include 1
    set procdrv [hsi::get_sw_processor]
    if {[string match "*psu_cortexr5_*" $procdrv]} {
	if {[string compare -nocase "psu_ttc_3" $mhsinst] == 0} {
		set periph_include 0
	}
    }
    if {$periph_include} {

    if {${hasStdout} == 0} {

	if {$isintr == 1} {
        set intr_id [format %s_INTR [string range $deviceid 0 13]]
	set intr_id [string toupper $intr_id]

      append testfunc_call "

   {
      int Status;
      Status = TmrInterruptExample(&$ipname, \\
				$deviceid, \\
				$intr_id, &${intcvar});
   }"

   }


  } else {

	if {$isintr == 1} {
        set intr_id [format %s_INTR [string range $deviceid 0 13]]
	set intr_id [string toupper $intr_id]

      append testfunc_call "
   {
      int Status;

      print(\"\\r\\n Running Interrupt Test  for ${ipname}...\\r\\n\");

      Status = TmrInterruptExample(&$ipname, \\
				$deviceid, \\
				$intr_id, &${intcvar});

      if (Status == 0) {
         print(\"TtcIntrExample PASSED\\r\\n\");
      }
      else {
         print(\"TtcIntrExample FAILED\\r\\n\");
      }

   }"

   }

 }
}
  return $testfunc_call
}
