Commit 74d948f8 authored by Jens Korinth's avatar Jens Korinth

Closes #53, #68, #80 - Capabilities and Status Core

* backported device capability interface
* extended status core with new registers:
  + Vivado version
  + Tapasco version
  + Timestamp (UNIX)
  + Clocks (host, mem, design)
* added new common methods to query the frequencies and globals to set
* used as default by create_subsystem_clocks_and_resets
* extended Platform to contain optional frequencies
* implemented unit tests for each new property
* if set, they are written to Tcl in VivadoComposer
parent d9ea378f
//
// Copyright (C) 2014 Jens Korinth, TU Darmstadt
//
// This file is part of Tapasco (TPC).
// This file is part of Tapasco (TAPASCO).
//
// Tapasco is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
......@@ -25,7 +25,7 @@
//! @version 1.2.1
//! @copyright Copyright 2014, 2015 J. Korinth, TU Darmstadt
//!
//! This file is part of Tapasco (TPC).
//! This file is part of Tapasco (TAPASCO).
//!
//! Tapasco is free software: you can redistribute it
//! and/or modify it under the terms of the GNU Lesser General
......@@ -42,6 +42,8 @@
//! License along with Tapasco. If not, see
//! <http://www.gnu.org/licenses/>.
//! @details ### Change Log ###
//! - Version 1.3 (jk)
//! + added device capabilities
//! - Version 1.2.1 (jk)
//! + renamed to 'tapasco.h'
//! - Version 1.2 (jk)
......@@ -56,8 +58,8 @@
//!
//! @todo device enumeration?
//!
#ifndef TAPASCO_API_H__
#define TAPASCO_API_H__
#ifndef TAPASCO_H__
#define TAPASCO_H__
#ifdef __cplusplus
#include <cstdint>
......@@ -152,6 +154,15 @@ typedef enum {
TAPASCO_DEVICE_JOB_LAUNCH_NONBLOCKING = 1,
} tapasco_device_job_launch_flag_t;
/** Capabilities: Optional device capabilities. **/
typedef enum {
/** PCIe devices: Adress Translation Services and Page Request Interface
* support activated. **/
TAPASCO_DEVICE_CAP_ATSPRI = 1,
/** PCIe devices: interactive ATS check core is present. **/
TAPASCO_DEVICE_CAP_ATSCHECK = 2,
} tapasco_device_capability_t;
/** @} **/
......@@ -159,7 +170,7 @@ typedef enum {
* @{
**/
#define TAPASCO_API_VERSION "1.2.1"
#define TAPASCO_API_VERSION "1.3"
/**
* Returns the version string of the library.
......@@ -197,7 +208,7 @@ const char *const tapasco_strerror(tapasco_res_t const res);
/**
* Global initialization: Setup a context for management of threadpool devices.
* Should not be called directly; @see tapasco_init.
* @param version version string of expected TPC API version
* @param version version string of expected TAPASCO API version
* @param pctx pointer to context pointer (will be set on success)
* @return TAPASCO_SUCCESS if successful, an error code otherwise
**/
......@@ -407,9 +418,25 @@ tapasco_res_t tapasco_device_job_get_return(tapasco_dev_ctx_t *dev_ctx,
/** @} **/
/** @defgroup caps Device capability query
* @{
**/
/**
* Checks if the specified capability is available in the current bitstream.
* @param dev_ctx device context
* @param cap capability
* @return TAPASCO_SUCCESS, if available, TAPASCO_FAILURE otherwise.
**/
tapasco_res_t tapasco_device_has_capability(tapasco_dev_ctx_t *dev_ctx,
tapasco_device_capability_t cap);
/** @} **/
#ifdef __cplusplus
} /* extern "C" */ } /* namespace tapasco */
#endif /* __cplusplus */
#endif /* TAPASCO_API_H__ */
#endif /* TAPASCO_H__ */
/* vim: set foldmarker=@{,@} foldlevel=0 foldmethod=marker : */
//
// Copyright (C) 2015 Jens Korinth, TU Darmstadt
//
// This file is part of Tapasco (TPC).
// This file is part of Tapasco (TAPASCO).
//
// Tapasco is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
......@@ -17,13 +17,13 @@
// along with Tapasco. If not, see <http://www.gnu.org/licenses/>.
//
//! @file tapasco.hpp
//! @brief Primitive C++ wrapper class for TPC API: Simplifies calls to
//! @brief Primitive C++ wrapper class for TAPASCO API: Simplifies calls to
//! FPG and handling of device memory, jobs, etc.
//! @authors J. Korinth, TU Darmstadt (jk@esa.cs.tu-darmstadt.de)
//! @version 1.2
//! @copyright Copyright 2015 J. Korinth, TU Darmstadt
//!
//! This file is part of Tapasco (TPC).
//! This file is part of Tapasco (TAPASCO).
//!
//! Tapasco is free software: you can redistribute it
//! and/or modify it under the terms of the GNU Lesser General
......@@ -40,12 +40,14 @@
//! License along with Tapasco. If not, see
//! <http://www.gnu.org/licenses/>.
//! @details ### Change Log ###
//! - 03/2016 Version 1.3 (jk)
//! + added device capabilities
//! - 03/2016 Version 1.2.1 (jk)
//! + renamed to 'tapasco.hpp'
//! - 03/2016 Version 1.2 (jk)
//! + added compiler check: header requires g++ >= 5.x.x
//! - 02/2016 Version 1.2 (jk)
//! + renamed class to 'Tapasco' instead of 'TPC' acro
//! + renamed class to 'Tapasco' instead of 'TAPASCO' acro
//! + removed rpr namespace
//! + moved device id to class instance member (instead of type)
//! + new async_launch* methods return futures
......@@ -58,13 +60,13 @@
//! + added compile-time flag TAPASCO_COPY_MT to use multi-threaded
//! data transfers (based on std::future + async)
//! - 10/2015 Version 1.1 (jk)
//! + updated to TPC API 1.1
//! + updated to TAPASCO API 1.1
//! + several minor improvements (error handling, copying)
//! - 08/2015 Version 1.0 (jk)
//! + initial prototype version
//!
#ifndef TAPASCO_API_HPP__
#define TAPASCO_API_HPP__
#ifndef TAPASCO_HPP__
#define TAPASCO_HPP__
#ifndef __clang__
#if __GNUC__ && __GNUC__< 5
......@@ -90,7 +92,7 @@ using namespace std;
namespace tapasco {
/**
* Type annotation for TPC launch argument pointers: output only, i.e., only copy
* Type annotation for TAPASCO launch argument pointers: output only, i.e., only copy
* from device to host after execution, don't copy from host to device prior.
* The other two possibilities (input-only, in-and-out/reference) can be expressed
* via the type system (const vs. non-const), but this use pattern requires a
......@@ -111,7 +113,7 @@ struct Tapasco {
/**
* Constructor. Initializes device by default.
* Note: Need to check is_ready if using auto-initialization before use.
* @param initialize initializes TPC during constructor (may throw exception!)
* @param initialize initializes TAPASCO during constructor (may throw exception!)
* @param dev_id device id of this instance (default: 0)
**/
Tapasco(bool const initialize = true, tapasco_dev_id_t const dev_id = 0) {
......@@ -128,7 +130,7 @@ struct Tapasco {
}
}
/** A TPC runtime error. **/
/** A TAPASCO runtime error. **/
class tapasco_error : public runtime_error {
public:
explicit tapasco_error (const string& msg) : runtime_error(msg) {}
......@@ -312,6 +314,16 @@ struct Tapasco {
return tapasco_device_func_instance_count(dev_ctx, func_id);
}
/**
* Checks if the current bitstream supports a given capability.
* @param cap capability to check
* @return TAPASCO_SUCCESS, if capability is available, TAPASCO_FAILURE otherwise
**/
tapasco_res_t has_capability(tapasco_device_capability_t cap) const noexcept
{
return tapasco_device_has_capability(dev_ctx, cap);
}
private:
/** Sets a single value argument. **/
template<typename T>
......@@ -470,4 +482,4 @@ private:
} /* namespace tapasco */
#endif /* TAPASCO_API_HPP__ */
#endif /* TAPASCO_HPP__ */
//
// Copyright (C) 2014 Jens Korinth, TU Darmstadt
//
// This file is part of Tapasco (TPC).
// This file is part of Tapasco (TAPASCO).
//
// Tapasco is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
......@@ -30,9 +30,33 @@
typedef struct tapasco_status tapasco_status_t;
struct tapasco_status {
tapasco_func_id_t id[TAPASCO_MAX_INSTANCES];
uint32_t gen_ts;
uint32_t vivado_version;
uint32_t tapasco_version;
uint32_t host_clk;
uint32_t mem_clk;
uint32_t design_clk;
uint32_t num_intcs;
uint32_t cap0_flags;
};
typedef enum {
TAPASCO_CAP0_ATSPRI = (1 << 0),
TAPASCO_CAP0_ATSCHECK = (1 << 1),
} tapasco_capabilities_0_t;
#define TAPASCO_VERSION_MAJOR(v) ((v) >> 16)
#define TAPASCO_VERSION_MINOR(v) ((v) & 0xFFFF)
tapasco_res_t tapasco_status_init(tapasco_status_t **status);
void tapasco_status_deinit(tapasco_status_t *status);
int tapasco_status_has_capability_0(const tapasco_status_t *status,
tapasco_capabilities_0_t caps);
uint32_t tapasco_status_get_vivado_version(const tapasco_status_t *status);
uint32_t tapasco_status_get_tapasco_version(const tapasco_status_t *status);
uint32_t tapasco_status_get_gen_ts(const tapasco_status_t *status);
uint32_t tapasco_status_get_host_clk(const tapasco_status_t *status);
uint32_t tapasco_status_get_mem_clk(const tapasco_status_t *status);
uint32_t tapasco_status_get_design_clk(const tapasco_status_t *status);
#endif /* TAPASCO_STATUS_H__ */
//
// Copyright (C) 2014 Jens Korinth, TU Darmstadt
//
// This file is part of Tapasco (TPC).
// This file is part of Tapasco (TAPASCO).
//
// Tapasco is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
......@@ -46,9 +46,48 @@ static tapasco_res_t read_tapasco_status(tapasco_status_t **status)
// check magic number
platform_read_ctl(h, sizeof(d), &d, PLATFORM_CTL_FLAGS_NONE);
if (d != 0xE5AE1337) {
ERR("no TPC bitstream detected, load bitstream and restart");
ERR("no TAPASCO bitstream detected, load bitstream and restart");
return TAPASCO_ERR_STATUS_CORE_NOT_FOUND;
}
// read number of INTCs
platform_read_ctl(h + sizeof(uint32_t), sizeof(d),
&(*status)->num_intcs, PLATFORM_CTL_FLAGS_NONE);
// read capabilities
platform_read_ctl(h + 2 * sizeof(uint32_t), sizeof(d),
&(*status)->cap0_flags, PLATFORM_CTL_FLAGS_NONE);
LOG(LALL_STATUS, "cap-0 bitfield: 0x%08x", (*status)->cap0_flags);
if ((*status)->cap0_flags == 0x13371337) // filter old dead register val
(*status)->cap0_flags = 0;
// read vivado version
platform_read_ctl(h + 4 * sizeof(uint32_t), sizeof(d),
&(*status)->vivado_version, PLATFORM_CTL_FLAGS_NONE);
LOG(LALL_STATUS, "vivado version: 0x%08x (%d.%d)",
(*status)->vivado_version,
TAPASCO_VERSION_MAJOR((*status)->vivado_version),
TAPASCO_VERSION_MINOR((*status)->vivado_version));
// read tapasco version
platform_read_ctl(h + 5 * sizeof(uint32_t), sizeof(d),
&(*status)->tapasco_version, PLATFORM_CTL_FLAGS_NONE);
LOG(LALL_STATUS, "tapasco version: 0x%08x (%d.%d)",
(*status)->tapasco_version,
TAPASCO_VERSION_MAJOR((*status)->tapasco_version),
TAPASCO_VERSION_MINOR((*status)->tapasco_version));
// read timestamp
platform_read_ctl(h + 6 * sizeof(uint32_t), sizeof(d),
&(*status)->gen_ts, PLATFORM_CTL_FLAGS_NONE);
LOG(LALL_STATUS, "generated timestamp: 0x%08x", (*status)->gen_ts);
// read host clk
platform_read_ctl(h + 7 * sizeof(uint32_t), sizeof(d),
&(*status)->host_clk, PLATFORM_CTL_FLAGS_NONE);
LOG(LALL_STATUS, "host clock: % 3d MHz", (*status)->host_clk);
// read mem clk
platform_read_ctl(h + 8 * sizeof(uint32_t), sizeof(d),
&(*status)->mem_clk, PLATFORM_CTL_FLAGS_NONE);
LOG(LALL_STATUS, "memory clock: % 3d MHz", (*status)->mem_clk);
// read design clk
platform_read_ctl(h + 9 * sizeof(uint32_t), sizeof(d),
&(*status)->design_clk, PLATFORM_CTL_FLAGS_NONE);
LOG(LALL_STATUS, "design clock: % 3d MHz", (*status)->design_clk);
h += TAPASCO_STATUS_SLOT_BASE;
for (int i = 0; i < TAPASCO_MAX_INSTANCES; ++i, h += TAPASCO_STATUS_SLOT_OFFSET) {
......@@ -59,6 +98,12 @@ static tapasco_res_t read_tapasco_status(tapasco_status_t **status)
return TAPASCO_SUCCESS;
}
int tapasco_status_has_capability_0(const tapasco_status_t *status,
tapasco_capabilities_0_t caps)
{
return (status->cap0_flags & caps) > 0 ? 1 : 0;
}
tapasco_res_t tapasco_status_init(tapasco_status_t **status)
{
*status = (tapasco_status_t *)malloc(sizeof(**status));
......@@ -78,3 +123,33 @@ void tapasco_status_deinit(tapasco_status_t *status)
LOG(LALL_STATUS, "releasing status info");
free(status);
}
uint32_t tapasco_status_get_vivado_version(const tapasco_status_t *status)
{
return status->vivado_version;
}
uint32_t tapasco_status_get_tapasco_version(const tapasco_status_t *status)
{
return status->tapasco_version;
}
uint32_t tapasco_status_get_gen_ts(const tapasco_status_t *status)
{
return status->gen_ts;
}
uint32_t tapasco_status_get_host_clk(const tapasco_status_t *status)
{
return status->host_clk;
}
uint32_t tapasco_status_get_mem_clk(const tapasco_status_t *status)
{
return status->mem_clk;
}
uint32_t tapasco_status_get_design_clk(const tapasco_status_t *status)
{
return status->design_clk;
}
......@@ -60,6 +60,11 @@ namespace eval tapasco {
puts "Skipping IP catalog."
}
# Returns the Tapasco version.
proc get_tapasco_version {} {
return "2017.1"
}
# Instantiates an AXI4 Interconnect IP.
# @param name Name of the instance.
# @param no_slaves Number of AXI4 Slave interfaces.
......@@ -381,7 +386,18 @@ namespace eval tapasco {
}
incr slot
}
# get version strings
set vversion [split [version -short] {.}]
set tversion [split [tapasco::get_tapasco_version] {.}]
lappend props "CONFIG.C_INTC_COUNT" "[expr [llength $c] > 96 ? 4 : ([llength $c] > 64 ? 3 : ([llength $c] > 32 ? 2 : 1))]"
lappend props "CONFIG.C_GEN_TS" "[clock seconds]"
lappend props "CONFIG.C_VIVADO_VERSION" [format "0x%04x%04x" [expr [lindex $vversion 0]] [expr [lindex $vversion 1]]]
lappend props "CONFIG.C_TAPASCO_VERSION" [format "0x%04x%04x" [expr [lindex $tversion 0]] [expr [lindex $tversion 1]]]
lappend props "CONFIG.C_HOST_CLK_MHZ" [format "%d" [tapasco::get_host_frequency]]
lappend props "CONFIG.C_MEM_CLK_MHZ" [format "%d" [tapasco::get_mem_frequency]]
lappend props "CONFIG.C_DESIGN_CLK_MHZ" [format "%d" [tapasco::get_design_frequency]]
puts " properties: $props"
set_property -dict $props $inst
return $inst
......@@ -449,11 +465,47 @@ namespace eval tapasco {
return [get_bd_intf_pins -of_objects $cell -filter "VLNV =~ xilinx.com:interface:aximm_rtl:* && MODE == $mode"]
}
# Returns a key-value list of frequencies in the design.
proc get_frequencies {} {
return [list "host" [get_host_frequency] "design" [get_design_frequency] "memory" [get_mem_frequency]]
}
# Returns the host interface clock frequency (in MHz).
proc get_host_frequency {} {
global tapasco_host_freq
if {[info exists tapasco_host_freq]} {
return $tapasco_host_freq
} else {
puts "WARNING: tapasco_host_freq is not set, using design frequency of [tapasco::get_design_frequency] MHz"
return [tapasco::get_design_frequency]
}
}
# Returns the memory interface clock frequency (in MHz).
proc get_mem_frequency {} {
global tapasco_mem_freq
if {[info exists tapasco_mem_freq]} {
return $tapasco_mem_freq
} else {
set mem_freq 200
if {[tapasco::get_speed_grade] > -2} {
puts " speed grade: [tapasco::get_speed_grade], reducing mem speed to 158 MHz"
set mem_freq 158
}
puts "WARNING: tapasco_mem_freq is not set! Using fallback: $mem_freq MHz"
return $mem_freq
}
}
# Returns the desired design clock frequency (in MHz) selected by the user.
# Default: 250
# Default: 50 MHz
proc get_design_frequency {} {
global tapasco_freq
return $tapasco_freq
if {[info exists tapasco_freq]} {
return $tapasco_freq
} else {
error "ERROR: tapasco_freq is not set!"
}
}
# Returns the desired design clock period (in ns) selected by the user.
......@@ -746,7 +798,7 @@ namespace eval tapasco {
# @param freqs list of name frequency (MHz) pairs, e.g., [list design 100 memory 250]
# @param name Name of the subsystem group
# @return Subsystem group
proc create_subsystem_clocks_and_resets {freqs {name ClockResets}} {
proc create_subsystem_clocks_and_resets {{freqs [get_frequencies]} {name ClockResets}} {
puts "Creating clock and reset subsystem ..."
puts " frequencies: $freqs"
set instance [current_bd_instance .]
......
......@@ -17,5 +17,5 @@ dict set stdcomps mm_to_lite vlnv "esa.cs.tu-darmstadt.de:user:mm_to_lite:1.0"
dict set stdcomps system_cache vlnv "xilinx.com:ip:system_cache:3.1"
dict set stdcomps mig_core vlnv "xilinx.com:ip:mig_7series:4.0"
dict set stdcomps axi_pcie3_0 vlnv "xilinx.com:ip:axi_pcie3:2.1"
dict set stdcomps tapasco_status vlnv "esa.cs.tu-darmstadt.de:user:tapasco_status:1.0"
dict set stdcomps tapasco_status vlnv "esa.cs.tu-darmstadt.de:user:tapasco_status:1.1"
dict set stdcomps clk_wiz "xilinx.com:ip:clk_wiz:5.3"
......@@ -17,5 +17,5 @@ dict set stdcomps mm_to_lite vlnv "esa.cs.tu-darmstadt.de:user:mm_to_lite:1.0"
dict set stdcomps system_cache vlnv "xilinx.com:ip:system_cache:3.1"
dict set stdcomps mig_core vlnv "xilinx.com:ip:mig_7series:4.0"
dict set stdcomps axi_pcie3_0 vlnv "xilinx.com:ip:axi_pcie3:3.0"
dict set stdcomps tapasco_status vlnv "esa.cs.tu-darmstadt.de:user:tapasco_status:1.0"
dict set stdcomps tapasco_status vlnv "esa.cs.tu-darmstadt.de:user:tapasco_status:1.1"
dict set stdcomps clk_wiz "xilinx.com:ip:clk_wiz:5.3"
......@@ -17,5 +17,5 @@ dict set stdcomps mm_to_lite vlnv "esa.cs.tu-darmstadt.de:user:mm_to_lite:1.0"
dict set stdcomps system_cache vlnv "xilinx.com:ip:system_cache:3.1"
dict set stdcomps mig_core vlnv "xilinx.com:ip:mig_7series:4.0"
dict set stdcomps axi_pcie3_0 vlnv "xilinx.com:ip:axi_pcie3:3.0"
dict set stdcomps tapasco_status vlnv "esa.cs.tu-darmstadt.de:user:tapasco_status:1.0"
dict set stdcomps tapasco_status vlnv "esa.cs.tu-darmstadt.de:user:tapasco_status:1.1"
dict set stdcomps clk_wiz "xilinx.com:ip:clk_wiz:5.3"
......@@ -17,5 +17,5 @@ dict set stdcomps mm_to_lite vlnv "esa.cs.tu-darmstadt.de:user:mm_to_lite:1.0"
dict set stdcomps system_cache vlnv "xilinx.com:ip:system_cache:3.1"
dict set stdcomps mig_core vlnv "xilinx.com:ip:mig_7series:4.0"
dict set stdcomps axi_pcie3_0 vlnv "xilinx.com:ip:axi_pcie3:3.0"
dict set stdcomps tapasco_status vlnv "esa.cs.tu-darmstadt.de:user:tapasco_status:1.0"
dict set stdcomps tapasco_status vlnv "esa.cs.tu-darmstadt.de:user:tapasco_status:1.1"
dict set stdcomps clk_wiz "xilinx.com:ip:clk_wiz:5.4"
This source diff could not be displayed because it is too large. You can view the blob instead.
OPTION psf_version = 2.1;
BEGIN DRIVER tapasco_status
OPTION supported_peripherals = (tapasco_status);
OPTION copyfiles = all;
OPTION VERSION = 1.0;
OPTION NAME = tapasco_status;
END DRIVER
#
# Copyright (C) 2014 Jens Korinth, TU Darmstadt
#
# This file is part of Tapasco (TPC).
#
# Tapasco is free software: you can redistribute it and/or modify
# 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.
#
# Tapasco is distributed in the hope that it will be useful,
# 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
# along with Tapasco. If not, see <http://www.gnu.org/licenses/>.
#
proc generate {drv_handle} {
xdefine_include_file $drv_handle "xparameters.h" "tapasco_status" "NUM_INSTANCES" "DEVICE_ID" "C_S00_AXI_BASEADDR" "C_S00_AXI_HIGHADDR"
}
COMPILER=
ARCHIVER=
CP=cp
COMPILER_FLAGS=
EXTRA_COMPILER_FLAGS=
LIB=libxil.a
RELEASEDIR=../../../lib
INCLUDEDIR=../../../include
INCLUDES=-I./. -I${INCLUDEDIR}
INCLUDEFILES=*.h
LIBSOURCES=*.c
OUTS = *.o
libs:
echo "Compiling tapasco_status..."
$(COMPILER) $(COMPILER_FLAGS) $(EXTRA_COMPILER_FLAGS) $(INCLUDES) $(LIBSOURCES)
$(ARCHIVER) -r ${RELEASEDIR}/${LIB} ${OUTS}
make clean
include:
${CP} $(INCLUDEFILES) $(INCLUDEDIR)
clean:
rm -rf ${OUTS}
//
// Copyright (C) 2014 Jens Korinth, TU Darmstadt
//
// This file is part of Tapasco (TPC).
//
// Tapasco is free software: you can redistribute it and/or modify
// 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.
//
// Tapasco is distributed in the hope that it will be useful,
// 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
// along with Tapasco. If not, see <http://www.gnu.org/licenses/>.
//
/***************************** Include Files *******************************/
#include "tapasco_status.h"
/************************** Function Definitions ***************************/
//
// Copyright (C) 2014 Jens Korinth, TU Darmstadt
//
// This file is part of Tapasco (TPC).
//
// Tapasco is free software: you can redistribute it and/or modify
// 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.
//
// Tapasco is distributed in the hope that it will be useful,
// 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
// along with Tapasco. If not, see <http://www.gnu.org/licenses/>.
//
/***************************** Include Files *******************************/
#include "tapasco_status.h"
#include "xparameters.h"
#include "stdio.h"
#include "xil_io.h"
/************************** Constant Definitions ***************************/
#define READ_WRITE_MUL_FACTOR 0x10
/************************** Function Definitions ***************************/
/**
*
* Run a self-test on the driver/device. Note this may be a destructive test if
* resets of the device are performed.
*
* If the hardware system is not built correctly, this function may never
* return to the caller.
*
* @param baseaddr_p is the base address of the TAPASCO_STATUSinstance to be worked on.
*
* @return
*
* - XST_SUCCESS if all self-test code passed
* - XST_FAILURE if any self-test code failed
*
* @note Caching must be turned off for this function to work.
* @note Self test may fail if data memory and device are not on the same bus.
*
*/
XStatus TAPASCO_STATUS_Reg_SelfTest(void * baseaddr_p)
{
u32 baseaddr;
int write_loop_index;
int read_loop_index;
int Index;
baseaddr = (u32) baseaddr_p;
xil_printf("******************************\n\r");
xil_printf("* User Peripheral Self Test\n\r");
xil_printf("******************************\n\n\r");
/*
* Write to user logic slave module register(s) and read back
*/
xil_printf("User logic slave module test...\n\r");
for (write_loop_index = 0 ; write_loop_index < 4; write_loop_index++)
TAPASCO_STATUS_mWriteReg (baseaddr, write_loop_index*4, (write_loop_index+1)*READ_WRITE_MUL_FACTOR);
for (read_loop_index = 0 ; read_loop_index < 4; read_loop_index++)
if ( TAPASCO_STATUS_mReadReg (baseaddr, read_loop_index*4) != (read_loop_index+1)*READ_WRITE_MUL_FACTOR){
xil_printf ("Error reading register value at address %x\n", (int)baseaddr + read_loop_index*4);
return XST_FAILURE;
}
xil_printf(" - slave register write/read passed\n\n\r");
return XST_SUCCESS;
}
#
# Copyright (C) 2014 Jens Korinth, TU Darmstadt
#
# This file is part of Tapasco (TPC).
#
# Tapasco is free software: you can redistribute it and/or modify
# 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.
#
# Tapasco is distributed in the hope that it will be useful,
# 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
# along with Tapasco. If not, see <http://www.gnu.org/licenses/>.
#
proc create_ipi_design { offsetfile design_name } {
create_bd_design $design_name
open_bd_design $design_name
# Create Clock and Reset Ports
set ACLK [ create_bd_port -dir I -type clk ACLK ]
set_property -dict [ list CONFIG.FREQ_HZ {100000000} CONFIG.PHASE {0.000} CONFIG.CLK_DOMAIN "${design_name}_ACLK" ] $ACLK
set ARESETN [ create_bd_port -dir I -type rst ARESETN ]
set_property -dict [ list CONFIG.POLARITY {ACTIVE_LOW} ] $ARESETN
set_property CONFIG.ASSOCIATED_RESET ARESETN $ACLK
# Create instance: tapasco_status_0, and set properties
set tapasco_status_0 [ create_bd_cell -type ip -vlnv user.org:user:tapasco_status:1.0 tapasco_status_0]
# Create instance: master_0, and set properties
set master_0 [ create_bd_cell -type ip -vlnv xilinx.com:ip:cdn_axi_bfm master_0]
set_property -dict [ list CONFIG.C_PROTOCOL_SELECTION {2} ] $master_0
# Create interface connections
connect_bd_intf_net [get_bd_intf_pins master_0/M_AXI_LITE] [get_bd_intf_pins tapasco_status_0/S00_AXI]
# Create port connections
connect_bd_net -net aclk_net [get_bd_ports ACLK] [get_bd_pins master_0/M_AXI_LITE_ACLK] [get_bd_pins tapasco_status_0/S00_AXI_ACLK]
connect_bd_net -net aresetn_net [get_bd_ports ARESETN] [get_bd_pins master_0/M_AXI_LITE_ARESETN] [get_bd_pins tapasco_status_0/S00_AXI_ARESETN]
# Auto assign address
assign_bd_address
# Copy all address to interface_address.vh file
set bd_path [file dirname [get_property NAME [get_files ${design_name}.bd]]]
upvar 1 $offsetfile offset_file
set offset_file "${bd_path}/tapasco_status_v1_0_tb_include.vh"
set fp [open $offset_file "w"]
puts $fp "`ifndef tapasco_status_v1_0_tb_include_vh_"
puts $fp "`define tapasco_status_v1_0_tb_include_vh_\n"
puts $fp "//Configuration current bd names"
puts $fp "`define BD_INST_NAME ${design_name}_i"
puts $fp "`define BD_WRAPPER ${design_name}_wrapper\n"
puts $fp "//Configuration address parameters"
set offset [get_property OFFSET [get_bd_addr_segs -of_objects [get_bd_addr_spaces master_0/Data_lite]]]
set offset_hex [string replace $offset 0 1 "32'h"]
puts $fp "`define S00_AXI_SLAVE_ADDRESS ${offset_hex}"
puts $fp "`endif"
close $fp
}
set ip_path [file dirname [file normalize [get_property XML_FILE_NAME [ipx::get_cores user.org:user:tapasco_status:1.0]]]]
set test_bench_file ${ip_path}/example_designs/bfm_design/tapasco_status_v1_0_tb.v
set interface_address_vh_file ""
# Set IP Repository and Update IP Catalogue
set repo_paths [get_property ip_repo_paths [current_fileset]]
if { [lsearch -exact -nocase $repo_paths $ip_path ] == -1 } {
set_property ip_repo_paths "$ip_path [get_property ip_repo_paths [current_fileset]]" [current_fileset]
update_ip_catalog
}
set design_name ""
set all_bd {}
set all_bd_files [get_files *.bd -quiet]
foreach file $all_bd_files {
set file_name [string range $file [expr {[string last "/" $file] + 1}] end]
set bd_name [string range $file_name 0 [expr {[string last "." $file_name] -1}]]
lappend all_bd $bd_name
}
for { set i 1 } { 1 } { incr i } {
set design_name "tapasco_status_v1_0_bfm_${i}"
if { [lsearch -exact -nocase $all_bd $design_name ] == -1 } {