summaryrefslogtreecommitdiff
path: root/src/systemc/ext/tlm_utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/systemc/ext/tlm_utils')
-rw-r--r--src/systemc/ext/tlm_utils/Makefile.am62
-rw-r--r--src/systemc/ext/tlm_utils/Makefile.in731
-rw-r--r--src/systemc/ext/tlm_utils/README.txt85
-rw-r--r--src/systemc/ext/tlm_utils/convenience_socket_bases.h77
-rw-r--r--src/systemc/ext/tlm_utils/instance_specific_extensions.h124
-rw-r--r--src/systemc/ext/tlm_utils/instance_specific_extensions_int.h174
-rw-r--r--src/systemc/ext/tlm_utils/multi_passthrough_initiator_socket.h286
-rw-r--r--src/systemc/ext/tlm_utils/multi_passthrough_target_socket.h328
-rw-r--r--src/systemc/ext/tlm_utils/multi_socket_bases.h440
-rw-r--r--src/systemc/ext/tlm_utils/passthrough_target_socket.h477
-rw-r--r--src/systemc/ext/tlm_utils/peq_with_cb_and_phase.h301
-rw-r--r--src/systemc/ext/tlm_utils/peq_with_get.h94
-rw-r--r--src/systemc/ext/tlm_utils/simple_initiator_socket.h316
-rw-r--r--src/systemc/ext/tlm_utils/simple_target_socket.h1132
-rw-r--r--src/systemc/ext/tlm_utils/tlm_quantumkeeper.h172
15 files changed, 4799 insertions, 0 deletions
diff --git a/src/systemc/ext/tlm_utils/Makefile.am b/src/systemc/ext/tlm_utils/Makefile.am
new file mode 100644
index 000000000..cd9e960a1
--- /dev/null
+++ b/src/systemc/ext/tlm_utils/Makefile.am
@@ -0,0 +1,62 @@
+## ****************************************************************************
+##
+## Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+## more contributor license agreements. See the NOTICE file distributed
+## with this work for additional information regarding copyright ownership.
+## Accellera licenses this file to you under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with the
+## License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+## implied. See the License for the specific language governing
+## permissions and limitations under the License.
+##
+## ****************************************************************************
+##
+## src/tlm_utils/Makefile.am --
+## Process this file with automake to produce a Makefile.in file.
+##
+## Original Author: Alan Fitch, Doulos, 2012-03-10
+##
+## ****************************************************************************
+##
+## MODIFICATION LOG - modifiers, enter your name, affiliation, date and
+## changes you are making here.
+##
+## Name, Affiliation, Date:
+## Description of Modification:
+##
+## ****************************************************************************
+
+include $(top_srcdir)/config/Make-rules.sysc
+
+H_FILES = \
+ convenience_socket_bases.h \
+ instance_specific_extensions.h \
+ instance_specific_extensions_int.h \
+ multi_passthrough_initiator_socket.h \
+ multi_passthrough_target_socket.h \
+ multi_socket_bases.h \
+ passthrough_target_socket.h \
+ peq_with_cb_and_phase.h \
+ peq_with_get.h \
+ simple_initiator_socket.h \
+ simple_target_socket.h \
+ tlm_quantumkeeper.h
+
+CXX_FILES = \
+ convenience_socket_bases.cpp \
+ instance_specific_extensions.cpp
+
+EXTRA_DIST += \
+ README.txt
+
+localincludedir = $(includedir)/tlm_utils
+nobase_localinclude_HEADERS = $(H_FILES)
+
+noinst_LTLIBRARIES = libtlm_utils.la
+libtlm_utils_la_SOURCES = $(NO_H_FILES) $(CXX_FILES)
diff --git a/src/systemc/ext/tlm_utils/Makefile.in b/src/systemc/ext/tlm_utils/Makefile.in
new file mode 100644
index 000000000..6c1469c4a
--- /dev/null
+++ b/src/systemc/ext/tlm_utils/Makefile.in
@@ -0,0 +1,731 @@
+# Makefile.in generated by automake 1.14 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# top-level SystemC include directory is added in Make-rules.{sysc,examples}
+
+# build flags
+
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+DIST_COMMON = $(top_srcdir)/config/Make-rules.sysc \
+ $(top_srcdir)/config/Make-rules.common $(srcdir)/Makefile.in \
+ $(srcdir)/Makefile.am $(top_srcdir)/config/depcomp \
+ $(nobase_localinclude_HEADERS)
+@WANT_DEBUG_TRUE@am__append_1 = $(DEBUG_CXXFLAGS)
+@WANT_DEBUG_TRUE@am__append_2 = $(DEBUG_CXXFLAGS)
+@WANT_DEBUG_TRUE@am__append_3 = $(DEBUG_CXXFLAGS)
+@WANT_OPTIMIZE_TRUE@am__append_4 = $(OPT_CXXFLAGS)
+@WANT_OPTIMIZE_TRUE@am__append_5 = $(OPT_CXXFLAGS)
+
+# either for async_update locking or pthread processes
+@USES_PTHREADS_LIB_TRUE@am__append_6 = $(PTHREAD_CFLAGS)
+@USES_PTHREADS_LIB_TRUE@am__append_7 = $(PTHREAD_CFLAGS)
+@USES_PTHREADS_LIB_TRUE@am__append_8 = $(PTHREAD_LIBS)
+@DISABLE_ASYNC_UPDATES_TRUE@am__append_9 = -DSC_DISABLE_ASYNC_UPDATES
+@ENABLE_CALLBACKS_TRUE@am__append_10 = -DSC_ENABLE_SIMULATION_PHASE_CALLBACKS
+@ENABLE_CALLBACKS_TRACING_TRUE@am__append_11 = -DSC_ENABLE_SIMULATION_PHASE_CALLBACKS_TRACING
+@WANT_PTHREADS_THREADS_TRUE@am__append_12 = -DSC_USE_PTHREADS
+@DISABLE_VCD_SCOPES_TRUE@am__append_13 = -DSC_DISABLE_VCD_SCOPES
+subdir = src/tlm_utils
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/config/ax_check_define.m4 \
+ $(top_srcdir)/config/ax_pthread.m4 \
+ $(top_srcdir)/config/libtool.m4 \
+ $(top_srcdir)/config/ltoptions.m4 \
+ $(top_srcdir)/config/ltsugar.m4 \
+ $(top_srcdir)/config/ltversion.m4 \
+ $(top_srcdir)/config/lt~obsolete.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libtlm_utils_la_LIBADD =
+am__objects_1 = convenience_socket_bases.lo \
+ instance_specific_extensions.lo
+am_libtlm_utils_la_OBJECTS = $(am__objects_1)
+libtlm_utils_la_OBJECTS = $(am_libtlm_utils_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 =
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
+DEFAULT_INCLUDES = -I.@am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/config/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_@AM_V@)
+am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@)
+am__v_CXX_0 = @echo " CXX " $@;
+am__v_CXX_1 =
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
+am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
+am__v_CXXLD_0 = @echo " CXXLD " $@;
+am__v_CXXLD_1 =
+SOURCES = $(libtlm_utils_la_SOURCES)
+DIST_SOURCES = $(libtlm_utils_la_SOURCES)
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+ test -z "$$files" \
+ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+ $(am__cd) "$$dir" && rm -f $$files; }; \
+ }
+am__installdirs = "$(DESTDIR)$(localincludedir)"
+HEADERS = $(nobase_localinclude_HEADERS)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCAS = @CCAS@
+CCASDEPMODE = @CCASDEPMODE@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEBUG_CXXFLAGS = @DEBUG_CXXFLAGS@
+DEFS = $(PKGCONFIG_DEFINES) $(EXTRA_DEFINES)
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+EXPLICIT_LPTHREAD = @EXPLICIT_LPTHREAD@
+EXTRA_ASFLAGS = @EXTRA_ASFLAGS@
+EXTRA_CFLAGS = @EXTRA_CFLAGS@
+EXTRA_CXXFLAGS = @EXTRA_CXXFLAGS@
+EXTRA_LDFLAGS = @EXTRA_LDFLAGS@
+FGREP = @FGREP@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LDFLAG_RPATH = @LDFLAG_RPATH@
+LIBCONFIG_DEFINES = @LIBCONFIG_DEFINES@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIB_ARCH_SUFFIX = @LIB_ARCH_SUFFIX@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OPT_CXXFLAGS = @OPT_CXXFLAGS@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKGCONFIG_CFLAGS = @PKGCONFIG_CFLAGS@
+PKGCONFIG_DEFINES = @PKGCONFIG_DEFINES@
+PKGCONFIG_LDPRIV = @PKGCONFIG_LDPRIV@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+QT_ARCH = @QT_ARCH@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+TARGET_ARCH = @TARGET_ARCH@
+TLM_PACKAGE_VERSION = @TLM_PACKAGE_VERSION@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+ax_pthread_config = @ax_pthread_config@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+examplesdir = @examplesdir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libarchdir = @libarchdir@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+rootdocdir = @rootdocdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CPPFLAGS = -I$(top_srcdir)/src
+AM_CFLAGS = $(EXTRA_CFLAGS) $(am__append_2) $(am__append_5) \
+ $(am__append_7)
+AM_CXXFLAGS = $(EXTRA_CXXFLAGS) $(am__append_1) $(am__append_4) \
+ $(am__append_6)
+AM_CCASFLAGS = $(EXTRA_ASFLAGS) $(am__append_3)
+AM_LDFLAGS = $(EXTRA_LDFLAGS) $(am__append_8)
+
+# always add fix-point support
+EXTRA_DEFINES = -DSC_INCLUDE_FX -DSC_BUILD $(am__append_9) \
+ $(am__append_10) $(am__append_11) $(am__append_12) \
+ $(am__append_13)
+
+# initialize some useful variables (filled later)
+CLEANFILES =
+EXTRA_DIST = README.txt
+H_FILES = \
+ convenience_socket_bases.h \
+ instance_specific_extensions.h \
+ instance_specific_extensions_int.h \
+ multi_passthrough_initiator_socket.h \
+ multi_passthrough_target_socket.h \
+ multi_socket_bases.h \
+ passthrough_target_socket.h \
+ peq_with_cb_and_phase.h \
+ peq_with_get.h \
+ simple_initiator_socket.h \
+ simple_target_socket.h \
+ tlm_quantumkeeper.h
+
+CXX_FILES = \
+ convenience_socket_bases.cpp \
+ instance_specific_extensions.cpp
+
+localincludedir = $(includedir)/tlm_utils
+nobase_localinclude_HEADERS = $(H_FILES)
+noinst_LTLIBRARIES = libtlm_utils.la
+libtlm_utils_la_SOURCES = $(NO_H_FILES) $(CXX_FILES)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/config/Make-rules.sysc $(top_srcdir)/config/Make-rules.common $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/tlm_utils/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign src/tlm_utils/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+$(top_srcdir)/config/Make-rules.sysc $(top_srcdir)/config/Make-rules.common:
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; \
+ locs=`for p in $$list; do echo $$p; done | \
+ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+ sort -u`; \
+ test -z "$$locs" || { \
+ echo rm -f $${locs}; \
+ rm -f $${locs}; \
+ }
+
+libtlm_utils.la: $(libtlm_utils_la_OBJECTS) $(libtlm_utils_la_DEPENDENCIES) $(EXTRA_libtlm_utils_la_DEPENDENCIES)
+ $(AM_V_CXXLD)$(CXXLINK) $(libtlm_utils_la_OBJECTS) $(libtlm_utils_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/convenience_socket_bases.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/instance_specific_extensions.Plo@am__quote@
+
+.cpp.o:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
+@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
+@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
+@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
+@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+install-nobase_localincludeHEADERS: $(nobase_localinclude_HEADERS)
+ @$(NORMAL_INSTALL)
+ @list='$(nobase_localinclude_HEADERS)'; test -n "$(localincludedir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(localincludedir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(localincludedir)" || exit 1; \
+ fi; \
+ $(am__nobase_list) | while read dir files; do \
+ xfiles=; for file in $$files; do \
+ if test -f "$$file"; then xfiles="$$xfiles $$file"; \
+ else xfiles="$$xfiles $(srcdir)/$$file"; fi; done; \
+ test -z "$$xfiles" || { \
+ test "x$$dir" = x. || { \
+ echo " $(MKDIR_P) '$(DESTDIR)$(localincludedir)/$$dir'"; \
+ $(MKDIR_P) "$(DESTDIR)$(localincludedir)/$$dir"; }; \
+ echo " $(INSTALL_HEADER) $$xfiles '$(DESTDIR)$(localincludedir)/$$dir'"; \
+ $(INSTALL_HEADER) $$xfiles "$(DESTDIR)$(localincludedir)/$$dir" || exit $$?; }; \
+ done
+
+uninstall-nobase_localincludeHEADERS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(nobase_localinclude_HEADERS)'; test -n "$(localincludedir)" || list=; \
+ $(am__nobase_strip_setup); files=`$(am__nobase_strip)`; \
+ dir='$(DESTDIR)$(localincludedir)'; $(am__uninstall_files_from_dir)
+
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ set x; \
+ here=`pwd`; \
+ $(am__define_uniq_tagged_files); \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(HEADERS)
+installdirs:
+ for dir in "$(DESTDIR)$(localincludedir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+
+clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-nobase_localincludeHEADERS
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-nobase_localincludeHEADERS
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \
+ ctags-am distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-data \
+ install-data-am install-dvi install-dvi-am install-exec \
+ install-exec-am install-html install-html-am install-info \
+ install-info-am install-man install-nobase_localincludeHEADERS \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \
+ uninstall-nobase_localincludeHEADERS
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/systemc/ext/tlm_utils/README.txt b/src/systemc/ext/tlm_utils/README.txt
new file mode 100644
index 000000000..8be587bdf
--- /dev/null
+++ b/src/systemc/ext/tlm_utils/README.txt
@@ -0,0 +1,85 @@
+
+TLM-2.0 standard utilities
+==========================
+
+Dir: include/tlm_utils
+
+SubDirs:
+
+Files: README.txt
+ instance_specific_extensions.h
+ multi_passthrough_initiator_socket.h
+ multi_passthrough_target_socket.h
+ multi_socket_bases.h
+ peq_with_get.h
+ simple_initiator_socket.h
+ simple_target_socket.h
+ peq_with_cb_and_phase.h
+ passthrough_target_socket.h
+ tlm_quantumkeeper.h
+
+
+Comments
+========
+
+This directory contains a number of ease-of-use and convenience implementations
+for the interoperability standard. All objects defined in the header files of
+this directory are contained in the tlm_util namespace.
+There is no tlm_utils.h header files containing all includes in order to avoid
+additional dependencies for TLM 2.0
+
+Files:
+ simple_initiator_socket.h
+ version of an initiator socket that has a default implementation of all
+ interfaces and allows to register an implementation for any of the
+ interfaces to the socket, either unique interfaces or tagged interfaces
+ (carrying an additional id)
+
+ simple_target_socket.h
+ version of a target socket that has a default implementation of all
+ interfaces and allows to register an implementation for any of the
+ interfaces to the socket, either unique interfaces or tagged interfaces
+ (carrying an additional id)
+ This socket allows to register only 1 of the transport interfaces
+ (blocking or non-blocking) and implements a conversion in case the
+ socket is used on the other interface
+
+ passthrough_target_socket.h
+ version of a target socket that has a default implementation of all
+ interfaces and allows to register an implementation for any of the
+ interfaces to the socket.
+
+ multi_passthrough_initiator_socket.h
+ an implementation of a socket that allows to bind multiple targets to the
+ same initiator socket. Implements a mechanism to allow to identify in the
+ backward path through which index of the socket the call passed through
+
+ multi_passthrough_target_socket.h
+ an implementation of a socket that allows to bind multiple initiators to
+ the same target socket. Implements a mechanism to allow to identify in the
+ forward path through which index of the socket the call passed through
+
+ multi_socket_bases.h
+ contains base class definitions used by the multi_passthrough sockets
+
+ peq_with_get.h
+ payload event queue (PEQ) implementation using a pull interface.
+ Has a get_next_transaction API that returns the transaction that is
+ scheduled in the event queue
+
+ peq_with_cb_and_phase.h
+ another payload event queue, this one with a push interface (callback
+ mechanism ). Allows to register a callback that will be called whenever
+ the event in the event queue is triggered, the callback gets transaction
+ and phase as arguments
+
+ instance_specific_extensions.h
+ is an implementation for adding extentions in the generic payload that
+ are specific to an instance along the path of a transaction, to allow that
+ extentions of the same type can be used by the different blocks along
+ the path of the transaction
+
+ tlm_quantumkeeper.h
+ is an convenience object used to keep track of the local time in
+ an initiator (how much it has run ahead of the SystemC time), to
+ synchronize with SystemC time etc.
diff --git a/src/systemc/ext/tlm_utils/convenience_socket_bases.h b/src/systemc/ext/tlm_utils/convenience_socket_bases.h
new file mode 100644
index 000000000..81efaac09
--- /dev/null
+++ b/src/systemc/ext/tlm_utils/convenience_socket_bases.h
@@ -0,0 +1,77 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+#ifndef TLM_UTILS_CONVENIENCE_SOCKET_BASES_H_INCLUDED_
+#define TLM_UTILS_CONVENIENCE_SOCKET_BASES_H_INCLUDED_
+
+#include <sysc/kernel/sc_cmnhdr.h>
+
+namespace sc_core { class SC_API sc_object; }
+
+namespace tlm_utils {
+
+// implementation-defined base class helper for convenience sockets
+class SC_API convenience_socket_base
+{
+public:
+ void display_warning(const char* msg) const;
+ void display_error(const char* msg) const;
+protected:
+ virtual ~convenience_socket_base(){}
+private:
+ virtual const char* get_report_type() const = 0;
+ virtual const sc_core::sc_object* get_socket() const = 0;
+};
+
+// implementation-defined base class helper for simple sockets
+class SC_API simple_socket_base : public convenience_socket_base
+{
+ virtual const char* get_report_type() const;
+protected:
+ void elaboration_check(const char* action) const;
+};
+
+// implementation-defined base class helper for passthrough sockets
+class SC_API passthrough_socket_base : public convenience_socket_base
+{
+ virtual const char* get_report_type() const;
+};
+
+// implementation-defined base class helper for multi sockets
+class SC_API multi_socket_base : public convenience_socket_base
+{
+ virtual const char* get_report_type() const;
+};
+
+// implementation-defined base class for callback helpers
+class SC_API convenience_socket_cb_holder
+{
+public:
+ void display_warning(const char* msg) const;
+ void display_error(const char* msg) const;
+
+protected:
+ explicit convenience_socket_cb_holder(convenience_socket_base* owner)
+ : m_owner(owner) {}
+
+private:
+ convenience_socket_base* m_owner;
+};
+
+} // namespace tlm_utils
+#endif // TLM_UTILS_CONVENIENCE_SOCKET_BASES_H_INCLUDED_
diff --git a/src/systemc/ext/tlm_utils/instance_specific_extensions.h b/src/systemc/ext/tlm_utils/instance_specific_extensions.h
new file mode 100644
index 000000000..5d9f66b13
--- /dev/null
+++ b/src/systemc/ext/tlm_utils/instance_specific_extensions.h
@@ -0,0 +1,124 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+/*
+Instance specific extensions, are extension that only a single instance of a module
+may access. They are invisible to all other modules; they are private to this
+instance so to speak.
+
+As they are only of value to a certain instance, this instance knows very well
+when it needs them and when it does not need them any longer (usually when
+a transaction passes through a module for the last time).
+It does not have to care if anyone else in the system may still have a
+reference to the transaction as this one is not able to access the extension
+anyway.
+Therefore the instance is obliged to call set_extension when it wants to add a
+private extension and clear_extension when it does not need it any more.
+
+To get access to an instance specifc extension the module must own a so called
+instance_specific_extension_accessor that provides the exclusive access rights.
+Assuming the instance_specific_extension_accessor of a given module is called m_accessor
+and the transaction of which the private extension is about to be accessed
+is called txn, then the calls have to be
+
+m_accessor(txn).set_extension(...);
+or
+m_accessor(txn).clear_extension(...);
+
+The owner of the private extension is responsible to allocate/deallocate
+the extension before/after setting/clearing the extension.
+*/
+
+#ifndef TLM_UTILS_INSTANCE_SPECIFIC_EXTENSIONS_H_INCLUDED_
+#define TLM_UTILS_INSTANCE_SPECIFIC_EXTENSIONS_H_INCLUDED_
+
+#include "tlm_utils/instance_specific_extensions_int.h"
+
+namespace tlm_utils {
+
+//The templated private extension. Similar to normal extension
+template <typename T>
+class instance_specific_extension : public ispex_base {
+public:
+ virtual ~instance_specific_extension() {}
+ const static unsigned int priv_id;
+};
+
+template <typename T>
+const unsigned int instance_specific_extension<T>::priv_id
+ = ispex_base::register_private_extension(typeid(T));
+
+// ----------------------------------------------------------------------------
+
+// This is the class that actually sits in the extension array
+// - we keep this small since that one gets allocated and deallocated all the times
+// - we keep the implementation in the header to avoid registration
+// of the extension itself unless used in the model
+class instance_specific_extension_carrier
+ : public tlm::tlm_extension<instance_specific_extension_carrier>
+{
+ friend class instance_specific_extension_accessor;
+public:
+ instance_specific_extension_carrier()
+ : m_container()
+ {}
+
+ virtual tlm::tlm_extension_base* clone() const {
+ //we don't clone since private info is instance specific and associated to a given txn (the original)
+ //so the deep copied txn will be virgin in terms of private info
+ return NULL;
+ }
+
+ void copy_from(tlm::tlm_extension_base const &) { return; }
+ void free() { return; }
+
+private:
+ instance_specific_extension_container* m_container;
+};
+
+// ----------------------------------------------------------------------------
+
+template<typename T>
+instance_specific_extensions_per_accessor&
+instance_specific_extension_accessor::operator()(T& txn)
+{
+ instance_specific_extension_carrier* carrier = NULL;
+ txn.get_extension(carrier);
+ if (!carrier) {
+ carrier = new instance_specific_extension_carrier();
+ carrier->m_container = instance_specific_extension_container::create();
+ carrier->m_container->attach_carrier(carrier, &txn, &release_carrier<T>);
+ txn.set_extension(carrier);
+ }
+ return *carrier->m_container->get_accessor(m_index);
+}
+
+template<typename T>
+void
+instance_specific_extension_accessor::
+ release_carrier(instance_specific_extension_carrier* carrier, void* txn)
+{
+ T* typed_txn = static_cast<T*>(txn);
+ typed_txn->clear_extension(carrier);
+ delete carrier;
+}
+
+} // namespace tlm_utils
+
+#endif // TLM_UTILS_INSTANCE_SPECIFIC_EXTENSIONS_H_INCLUDED_
diff --git a/src/systemc/ext/tlm_utils/instance_specific_extensions_int.h b/src/systemc/ext/tlm_utils/instance_specific_extensions_int.h
new file mode 100644
index 000000000..192a600ba
--- /dev/null
+++ b/src/systemc/ext/tlm_utils/instance_specific_extensions_int.h
@@ -0,0 +1,174 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+#ifndef TLM_UTILS_INSTANCE_SPECIFIC_EXTENSIONS_INT_H_INCLUDED_
+#define TLM_UTILS_INSTANCE_SPECIFIC_EXTENSIONS_INT_H_INCLUDED_
+
+#ifndef SC_BUILD // incluce full TLM, when not building the library
+#include <tlm>
+#else
+#include "tlm_core/tlm_2/tlm_generic_payload/tlm_gp.h"
+#endif // SC_BUILD
+
+namespace tlm_utils {
+class SC_API ispex_base;
+class SC_API instance_specific_extension_accessor;
+class SC_API instance_specific_extension_container;
+class instance_specific_extension_carrier;
+class instance_specific_extension_container_pool;
+}
+
+namespace tlm {
+SC_API_TEMPLATE_DECL_ tlm_array<tlm_utils::ispex_base*>;
+} // namespace tlm
+
+namespace tlm_utils {
+
+//The private extension base. Similar to normal extension base, but without clone and free
+class SC_API ispex_base
+{
+ friend class tlm::tlm_array<ispex_base*>;
+ void free() {} // needed for explicit tlm_array instantiation
+public:
+ virtual ~ispex_base() {}
+protected:
+ static unsigned int register_private_extension(const std::type_info&);
+};
+
+//this thing is basically a snippet of the generic_payload
+// it contains all the extension specific code (the extension API so to speak)
+// the differences are:
+// - it calls back to its owner whenever a real (==non-NULL) extension gets set for the first time
+// - it calls back to its owner whenever a living (==non-NULL) extension gets cleared
+class SC_API instance_specific_extensions_per_accessor
+{
+public:
+ typedef instance_specific_extension_container container_type;
+
+ explicit
+ instance_specific_extensions_per_accessor(container_type* container)
+ : m_container(container)
+ {}
+
+ template <typename T> T* set_extension(T* ext)
+ {
+ return static_cast<T*>( set_extension(T::priv_id, ext) );
+ }
+
+ // non-templatized version with manual index:
+ ispex_base* set_extension(unsigned int index, ispex_base* ext);
+
+ // Check for an extension, ext will point to 0 if not present
+ template <typename T> void get_extension(T*& ext) const
+ {
+ ext = static_cast<T*>(get_extension(T::priv_id));
+ }
+ // Non-templatized version:
+ ispex_base* get_extension(unsigned int index) const;
+
+ // Clear extension, the argument is needed to find the right index:
+ template <typename T> void clear_extension(const T*)
+ {
+ clear_extension(T::priv_id);
+ }
+
+ // Non-templatized version with manual index
+ void clear_extension(unsigned int index);
+
+ // Make sure the extension array is large enough. Can be called once by
+ // an initiator module (before issuing the first transaction) to make
+ // sure that the extension array is of correct size. This is only needed
+ // if the initiator cannot guarantee that the generic payload object is
+ // allocated after C++ static construction time.
+ void resize_extensions();
+
+private:
+ tlm::tlm_array<ispex_base*> m_extensions;
+ container_type* m_container;
+
+}; // class instance_specific_extensions_per_accessor
+
+#if defined(_MSC_VER) && !defined(SC_WIN_DLL_WARN)
+#pragma warning(push)
+#pragma warning(disable: 4251) // DLL import for vector
+#endif
+
+//this thing contains the vector of extensions per accessor
+//which can be really large so this one should be pool allocated
+// therefore it keeps a use_count of itself to automatically free itself
+// - to this end it provides callbacks to the extensions per accessor
+// to increment and decrement the use_count
+class SC_API instance_specific_extension_container
+{
+ friend class instance_specific_extension_accessor;
+ friend class instance_specific_extension_carrier;
+ friend class instance_specific_extension_container_pool;
+ friend class instance_specific_extensions_per_accessor;
+
+ typedef void release_fn(instance_specific_extension_carrier*,void*);
+
+ instance_specific_extension_container();
+ ~instance_specific_extension_container();
+
+ void resize();
+
+ void inc_use_count();
+ void dec_use_count();
+
+ static instance_specific_extension_container* create();
+ void attach_carrier(instance_specific_extension_carrier*, void* txn, release_fn*);
+
+ instance_specific_extensions_per_accessor* get_accessor(unsigned int index);
+
+ std::vector<instance_specific_extensions_per_accessor*> m_ispex_per_accessor;
+ unsigned int use_count;
+ void* m_txn;
+ release_fn* m_release_fn;
+ instance_specific_extension_carrier* m_carrier;
+ instance_specific_extension_container* next; //for pooling
+
+}; // class instance_specific_extension_container
+
+#if defined(_MSC_VER) && !defined(SC_WIN_DLL_WARN)
+#pragma warning(pop)
+#endif
+
+// ----------------------------------------------------------------------------
+
+//This class 'hides' all the instance specific extension stuff from the user
+// he instantiates one of those (e.g. instance_specific_extension_accessor extAcc;) and can then access
+// the private extensions
+// extAcc(txn).extensionAPIFnCall()
+// where extensionAPIFnCall is set_extension, get_extension, clear_extension,...
+class SC_API instance_specific_extension_accessor
+{
+public:
+ instance_specific_extension_accessor();
+
+ template<typename T> // implementation in instance_specific_extensions.h
+ inline instance_specific_extensions_per_accessor& operator()(T& txn);
+
+protected:
+ template<typename T>
+ static void release_carrier(instance_specific_extension_carrier*, void* txn);
+
+ unsigned int m_index;
+}; // class instance_specific_extension_accessor
+
+} // namespace tlm_utils
+#endif // TLM_UTILS_INSTANCE_SPECIFIC_EXTENSIONS_INT_H_INCLUDED_
diff --git a/src/systemc/ext/tlm_utils/multi_passthrough_initiator_socket.h b/src/systemc/ext/tlm_utils/multi_passthrough_initiator_socket.h
new file mode 100644
index 000000000..0a0dd6993
--- /dev/null
+++ b/src/systemc/ext/tlm_utils/multi_passthrough_initiator_socket.h
@@ -0,0 +1,286 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+#ifndef TLM_UTILS_MULTI_PASSTHROUGH_INITIATOR_SOCKET_H_INCLUDED_
+#define TLM_UTILS_MULTI_PASSTHROUGH_INITIATOR_SOCKET_H_INCLUDED_
+
+#include "multi_socket_bases.h"
+
+namespace tlm_utils {
+
+/*
+This class implements a trivial multi initiator socket.
+The triviality refers to the fact that the socket does not
+do blocking to non-blocking or non-blocking to blocking conversions.
+
+It allows to connect multiple targets to this socket.
+The user has to register callbacks for the bw interface methods
+he likes to use. The callbacks are basically equal to the bw interface
+methods but carry an additional integer that indicates to which
+index of this socket the calling target is connected.
+*/
+template <typename MODULE,
+ unsigned int BUSWIDTH = 32,
+ typename TYPES = tlm::tlm_base_protocol_types,
+ unsigned int N=0, sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
+class multi_passthrough_initiator_socket
+ : public multi_init_base< BUSWIDTH, TYPES, N, POL>
+{
+public:
+
+ //typedefs
+ // tlm 2.0 types for nb_transport
+ typedef typename TYPES::tlm_payload_type transaction_type;
+ typedef typename TYPES::tlm_phase_type phase_type;
+ typedef tlm::tlm_sync_enum sync_enum_type;
+
+ // typedefs to keep the fn ptr notations short
+ typedef sync_enum_type (MODULE::*nb_cb)(int,
+ transaction_type&,
+ phase_type&,
+ sc_core::sc_time&);
+ typedef void (MODULE::*dmi_cb)(int, sc_dt::uint64, sc_dt::uint64);
+
+ typedef multi_init_base<BUSWIDTH, TYPES, N, POL> base_type;
+
+ typedef typename base_type::base_target_socket_type base_target_socket_type;
+
+ static const char* default_name()
+ { return sc_core::sc_gen_unique_name("multi_passthrough_initiator_socket"); }
+
+ //CTOR
+ explicit multi_passthrough_initiator_socket(const char* name = default_name())
+ : base_type(name)
+ , m_hierarch_bind(0)
+ , m_beoe_disabled(false)
+ , m_dummy(this,42)
+ {
+ }
+
+ ~multi_passthrough_initiator_socket(){
+ //clean up everything allocated by 'new'
+ for (unsigned int i=0; i<m_binders.size(); i++) delete m_binders[i];
+ }
+
+ //register callback for nb transport of bw interface
+ void register_nb_transport_bw(MODULE* mod,
+ sync_enum_type (MODULE::*cb)(int,
+ transaction_type&,
+ phase_type&,
+ sc_core::sc_time&))
+ {
+ //warn if there already is a callback
+ if (m_nb_f.is_valid()){
+ display_warning("NBTransport_bw callback already registered.");
+ return;
+ }
+
+ //set the functor
+ m_nb_f.set_function(mod, cb);
+ }
+
+ //register callback for dmi function of bw interface
+ void register_invalidate_direct_mem_ptr(MODULE* mod,
+ void (MODULE::*cb)(int, sc_dt::uint64, sc_dt::uint64))
+ {
+ //warn if there already is a callback
+ if (m_dmi_f.is_valid()){
+ display_warning("InvalidateDMI callback already registered.");
+ return;
+ }
+
+ //set the functor
+ m_dmi_f.set_function(mod, cb);
+ }
+
+ //Override virtual functions of the tlm_initiator_socket:
+ // this function is called whenever an sc_port (as part of a target socket)
+ // wants to bind to the export of the underlying tlm_initiator_socket
+ //At this time a callback binder is created an returned to the sc_port
+ // of the target socket, so that it binds to the callback binder
+ virtual tlm::tlm_bw_transport_if<TYPES>& get_base_interface()
+ {
+ m_binders.push_back(new callback_binder_bw<TYPES>(this, m_binders.size()));
+ return *m_binders[m_binders.size()-1];
+ }
+
+ // const overload not allowed for multi-sockets
+ virtual const tlm::tlm_bw_transport_if<TYPES>& get_base_interface() const
+ {
+ display_error("'get_base_interface()' const not allowed for multi-sockets.");
+ return base_type::get_base_interface();
+ }
+
+ //Override virtual functions of the tlm_initiator_socket:
+ // this function is called whenever an sc_export (as part of a initiator socket)
+ // wants to bind to the export of the underlying tlm_initiator_socket
+ // i.e. a hierarchical bind takes place
+ virtual sc_core::sc_export<tlm::tlm_bw_transport_if<TYPES> >& get_base_export()
+ {
+ if (!m_beoe_disabled) //we are not bound hierarchically
+ base_type::m_export.bind(m_dummy); //so we bind the dummy to avoid a SystemC error
+ return base_type::get_base_export(); //and then return our own export so that the hierarchical binding is set up properly
+ }
+
+ virtual const sc_core::sc_export<tlm::tlm_bw_transport_if<TYPES> >& get_base_export() const
+ {
+ return base_type::get_base_export();
+ }
+
+ //bind against a target socket
+ virtual void bind(base_target_socket_type& s)
+ {
+ //error if this socket is already bound hierarchically
+ if (m_hierarch_bind) {
+ display_error("Already hierarchically bound.");
+ return;
+ }
+
+ base_type::bind(s); //satisfy systemC, leads to a call to get_base_interface()
+
+ //try to cast the target socket into a fw interface
+ sc_core::sc_export<tlm::tlm_fw_transport_if<TYPES> >* p_ex_s=dynamic_cast<sc_core::sc_export<tlm::tlm_fw_transport_if<TYPES> >*>(&s);
+ if (!p_ex_s) {
+ display_error("Multi socket not bound to tlm_socket.");
+ return;
+ }
+
+ //try a cast into a multi sockets
+ multi_to_multi_bind_base<TYPES>* test=dynamic_cast<multi_to_multi_bind_base<TYPES>*> (p_ex_s);
+ if (test) //did we just do a multi-multi bind??
+ //if that is the case the multi target socket must have just created a callback binder
+ // which we want to get from it.
+ //Moreover, we also just created one, which we will pass to it.
+ m_sockets.push_back(test->get_last_binder(m_binders[m_binders.size()-1]));
+ else{ // if not just bind normally
+ sc_core::sc_export<tlm::tlm_fw_transport_if<TYPES> >& ex_s=*p_ex_s;
+ m_sockets.push_back(&((tlm::tlm_fw_transport_if<TYPES>&)ex_s)); //store the interface we are bound against
+ }
+ }
+
+ //operator notation for direct bind
+ void operator() (base_target_socket_type& s)
+ {
+ bind(s);
+ }
+
+ //SystemC standard callback before end of elaboration
+ void before_end_of_elaboration(){
+ //if our export hasn't been bound yet (due to a hierarch binding)
+ // we bind it now to avoid a SystemC error.
+ //We must do that, because it is legal not to register a callback on this socket
+ // as the user might only use b_transport
+ if (!base_type::m_export.get_interface()){
+ base_type::m_export.bind(m_dummy);
+ }
+
+ //'break' here if the socket was told not to do callback binding
+ if (m_beoe_disabled) return;
+
+ //get the callback binders of the top of the hierachical bind chain
+ // NOTE: this could be the same socket if there is no hierachical bind
+ std::vector<callback_binder_bw<TYPES>* >& binders=get_hierarch_bind()->get_binders();
+
+ //get the interfaces bound to the top of the hierachical bind chain
+ // NOTE: this could be the same socket if there is no hierachical bind
+ m_used_sockets=get_hierarch_bind()->get_sockets();
+
+ //register the callbacks of this socket with the callback binders
+ // we just got from the top of the hierachical bind chain
+ for (unsigned int i=0; i<binders.size(); i++) {
+ binders[i]->set_callbacks(m_nb_f, m_dmi_f);
+ }
+ }
+
+ //
+ // Bind multi initiator socket to multi initiator socket (hierarchical bind)
+ //
+ virtual void bind(base_type& s)
+ {
+ if (m_binders.size()) {
+ //a multi socket is either bound hierarchically or directly
+ display_error("Socket already directly bound.");
+ return;
+ }
+ if (m_hierarch_bind){
+ display_warning("Socket already bound hierarchically. Bind attempt ignored.");
+ return;
+ }
+
+ //remember to which socket we are hierarchically bound and disable it,
+ // so that it won't try to register callbacks itself
+ s.disable_cb_bind();
+ m_hierarch_bind=&s;
+ base_type::bind(s); //satisfy SystemC
+ }
+
+ //operator notation for hierarchical bind
+ void operator() (base_type& s)
+ {
+ bind(s);
+ }
+
+ //get access to sub port
+ tlm::tlm_fw_transport_if<TYPES>* operator[](int i){return m_used_sockets[i];}
+
+ //get the number of bound targets
+ // NOTE: this is only valid at end of elaboration!
+ unsigned int size() {return get_hierarch_bind()->get_sockets().size();}
+
+protected:
+ using base_type::display_warning;
+ using base_type::display_error;
+
+ //implementation of base class interface
+ base_type* get_hierarch_bind(){if (m_hierarch_bind) return m_hierarch_bind->get_hierarch_bind(); else return this;}
+ void disable_cb_bind(){ m_beoe_disabled=true;}
+ std::vector<callback_binder_bw<TYPES>* >& get_binders(){return m_binders;}
+ std::vector<tlm::tlm_fw_transport_if<TYPES>*>& get_sockets(){return m_sockets;}
+ //vector of connected sockets
+ std::vector<tlm::tlm_fw_transport_if<TYPES>*> m_sockets;
+ std::vector<tlm::tlm_fw_transport_if<TYPES>*> m_used_sockets;
+ //vector of binders that convert untagged interface into tagged interface
+ std::vector<callback_binder_bw<TYPES>*> m_binders;
+
+ base_type* m_hierarch_bind; //pointer to hierarchical bound multi port
+ bool m_beoe_disabled; // bool that remembers whether this socket shall bind callbacks or not
+ callback_binder_bw<TYPES> m_dummy; //a callback binder that is bound to the underlying export
+ // in case there was no real bind
+
+ //callbacks as functors
+ // (allows to pass the callback to another socket that does not know the type of the module that owns
+ // the callbacks)
+ typename callback_binder_bw<TYPES>::nb_func_type m_nb_f;
+ typename callback_binder_bw<TYPES>::dmi_func_type m_dmi_f;
+};
+
+template <typename MODULE,
+ unsigned int BUSWIDTH = 32,
+ typename TYPES = tlm::tlm_base_protocol_types,
+ unsigned int N=0>
+class multi_passthrough_initiator_socket_optional
+ : public multi_passthrough_initiator_socket<MODULE,BUSWIDTH,TYPES,N,sc_core::SC_ZERO_OR_MORE_BOUND>
+{
+ typedef multi_passthrough_initiator_socket<MODULE,BUSWIDTH,TYPES,N,sc_core::SC_ZERO_OR_MORE_BOUND> socket_b;
+public:
+ multi_passthrough_initiator_socket_optional() : socket_b() {}
+ explicit multi_passthrough_initiator_socket_optional(const char* name) : socket_b(name) {}
+};
+
+} // namespace tlm_utils
+#endif // TLM_UTILS_MULTI_PASSTHROUGH_INITIATOR_SOCKET_H_INCLUDED_
diff --git a/src/systemc/ext/tlm_utils/multi_passthrough_target_socket.h b/src/systemc/ext/tlm_utils/multi_passthrough_target_socket.h
new file mode 100644
index 000000000..0b759d4aa
--- /dev/null
+++ b/src/systemc/ext/tlm_utils/multi_passthrough_target_socket.h
@@ -0,0 +1,328 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+#ifndef TLM_UTILS_MULTI_PASSTHROUGH_TARGET_SOCKET_H_INCLUDED_
+#define TLM_UTILS_MULTI_PASSTHROUGH_TARGET_SOCKET_H_INCLUDED_
+
+#include "tlm_utils/multi_socket_bases.h"
+
+namespace tlm_utils {
+
+/*
+This class implements a trivial multi target socket.
+The triviality refers to the fact that the socket does not
+do blocking to non-blocking or non-blocking to blocking conversions.
+
+It allows to connect multiple initiators to this socket.
+The user has to register callbacks for the fw interface methods
+he likes to use. The callbacks are basically equal to the fw interface
+methods but carry an additional integer that indicates to which
+index of this socket the calling initiator is connected.
+*/
+template <typename MODULE,
+ unsigned int BUSWIDTH = 32,
+ typename TYPES = tlm::tlm_base_protocol_types,
+ unsigned int N=0,
+ sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
+class multi_passthrough_target_socket
+ : public multi_target_base< BUSWIDTH, TYPES, N, POL>
+ , public multi_to_multi_bind_base<TYPES>
+{
+
+public:
+
+ //typedefs
+ // tlm 2.0 types for nb_transport
+ typedef typename TYPES::tlm_payload_type transaction_type;
+ typedef typename TYPES::tlm_phase_type phase_type;
+ typedef tlm::tlm_sync_enum sync_enum_type;
+
+ // typedefs to keep the fn ptr notations short
+ typedef sync_enum_type (MODULE::*nb_cb)(int, transaction_type&, phase_type&, sc_core::sc_time&);
+ typedef void (MODULE::*b_cb)(int, transaction_type&, sc_core::sc_time&);
+ typedef unsigned int (MODULE::*dbg_cb)(int, transaction_type& txn);
+ typedef bool (MODULE::*dmi_cb)(int, transaction_type& txn, tlm::tlm_dmi& dmi);
+
+ typedef multi_target_base<BUSWIDTH, TYPES, N, POL> base_type;
+
+ typedef typename base_type::base_initiator_socket_type base_initiator_socket_type;
+
+ static const char* default_name()
+ { return sc_core::sc_gen_unique_name("multi_passthrough_target_socket"); }
+
+ //CTOR
+ explicit multi_passthrough_target_socket(const char* name = default_name())
+ : base_type(name)
+ , m_hierarch_bind(0)
+ , m_eoe_disabled(false)
+ , m_export_callback_created(false)
+ {
+ }
+
+ ~multi_passthrough_target_socket(){
+ //clean up everything allocated by 'new'
+ for (unsigned int i=0; i<m_binders.size(); i++) delete m_binders[i];
+ }
+
+ void check_export_binding()
+ {
+ //if our export hasn't been bound yet (due to a hierarch binding)
+ // we bind it now.
+ //We do that here as the user of the target port HAS to bind at least on callback,
+ //otherwise the socket was useless. Nevertheless, the target socket may still
+ // stay unbound afterwards.
+ if (!sc_core::sc_export<tlm::tlm_fw_transport_if<TYPES> >::get_interface())
+ {
+ // We bind to a callback_binder that will be used as the first interface
+ // i.e. calls to the sc_export will have the same ID as calls from the first initator
+ // socket bound
+ callback_binder_fw<TYPES> * binder;
+
+ if (m_binders.size() == 0)
+ {
+ binder = new callback_binder_fw<TYPES>(this, m_binders.size());
+ m_binders.push_back(binder);
+ m_export_callback_created = true;
+ }
+ else
+ {
+ binder = m_binders[0];
+ }
+
+ sc_core::sc_export<tlm::tlm_fw_transport_if<TYPES> >::bind(*binder);
+ }
+ }
+
+ //register callback for nb transport of fw interface
+ void register_nb_transport_fw(MODULE* mod,
+ nb_cb cb)
+ {
+ check_export_binding();
+
+ //warn if there already is a callback
+ if (m_nb_f.is_valid()){
+ display_warning("NBTransport_bw callback already registered.");
+ return;
+ }
+
+ //set the functor
+ m_nb_f.set_function(mod, cb);
+ }
+
+ //register callback for b transport of fw interface
+ void register_b_transport(MODULE* mod,
+ b_cb cb)
+ {
+ check_export_binding();
+
+ //warn if there already is a callback
+ if (m_b_f.is_valid()){
+ display_warning("BTransport callback already registered.");
+ return;
+ }
+
+ //set the functor
+ m_b_f.set_function(mod, cb);
+ }
+
+ //register callback for debug transport of fw interface
+ void register_transport_dbg(MODULE* mod,
+ dbg_cb cb)
+ {
+ check_export_binding();
+
+ //warn if there already is a callback
+ if (m_dbg_f.is_valid()){
+ display_warning("DebugTransport callback already registered.");
+ return;
+ }
+
+ //set the functor
+ m_dbg_f.set_function(mod, cb);
+ }
+
+ //register callback for DMI of fw interface
+ void register_get_direct_mem_ptr(MODULE* mod,
+ dmi_cb cb)
+ {
+ check_export_binding();
+
+ //warn if there already is a callback
+ if (m_dmi_f.is_valid()){
+ display_warning("DMI callback already registered.");
+ return;
+ }
+
+ //set the functor
+ m_dmi_f.set_function(mod, cb);
+ }
+
+
+ //Override virtual functions of the tlm_target_socket:
+ // this function is called whenever an sc_port (as part of a init socket)
+ // wants to bind to the export of the underlying tlm_target_socket
+ //At this time a callback binder is created an returned to the sc_port
+ // of the init socket, so that it binds to the callback binder
+ virtual tlm::tlm_fw_transport_if<TYPES>& get_base_interface()
+ {
+ //error if this socket is already bound hierarchically
+ if (m_hierarch_bind) display_error("Socket already bound hierarchically.");
+
+ if (m_export_callback_created) {
+ // consume binder created from the callback registration
+ m_export_callback_created = false;
+ } else {
+ m_binders.push_back(new callback_binder_fw<TYPES>(this, m_binders.size()));
+ }
+
+ return *m_binders[m_binders.size()-1];
+ }
+
+ // const overload not allowed for multi-sockets
+ virtual const tlm::tlm_fw_transport_if<TYPES>& get_base_interface() const
+ {
+ display_error("'get_base_interface() const' not allowed for multi-sockets.");
+ return base_type::get_base_interface();
+ }
+
+ //just return the export of the underlying tlm_target_socket in case of a hierarchical bind
+ virtual sc_core::sc_export<tlm::tlm_fw_transport_if<TYPES> >& get_base_export()
+ {
+ return *this;
+ }
+
+ //just return the export of the underlying tlm_target_socket in case of a hierarchical bind
+ virtual const sc_core::sc_export<tlm::tlm_fw_transport_if<TYPES> >& get_base_export() const
+ {
+ return base_type::get_base_export();
+ }
+
+ //the standard end of elaboration callback
+ void end_of_elaboration(){
+ //'break' here if the socket was told not to do callback binding
+ if (m_eoe_disabled) return;
+
+ //get the callback binders and the multi binds of the top of the hierachical bind chain
+ // NOTE: this could be the same socket if there is no hierachical bind
+ std::vector<callback_binder_fw<TYPES>* >& binders=get_hierarch_bind()->get_binders();
+ std::map<unsigned int, tlm::tlm_bw_transport_if<TYPES>*>& multi_binds=get_hierarch_bind()->get_multi_binds();
+
+ // complete binding only if there has been a real bind
+ bool unbound = (binders.size() == 1 && m_export_callback_created);
+ // no call to get_base_interface has consumed the export - ignore
+ if (unbound) return;
+
+ // iterate over all binders
+ for (unsigned int i=0; i<binders.size(); i++) {
+ binders[i]->set_callbacks(m_nb_f, m_b_f, m_dmi_f, m_dbg_f); //set the callbacks for the binder
+ if (multi_binds.find(i)!=multi_binds.end()) //check if this connection is multi-multi
+ //if so remember the interface
+ m_sockets.push_back(multi_binds[i]);
+ else{ //if we are bound to a normal socket
+ //get the calling port and try to cast it into a tlm socket base
+ base_initiator_socket_type* test=dynamic_cast<base_initiator_socket_type*>(binders[i]->get_other_side());
+ if (!test){display_error("Not bound to tlm_socket.");}
+ m_sockets.push_back(&test->get_base_interface()); //remember the interface
+ }
+ }
+ }
+
+ //
+ // Bind multi target socket to multi target socket (hierarchical bind)
+ //
+ virtual void bind(base_type& s)
+ {
+ //warn if already bound hierarchically
+ if (m_eoe_disabled){
+ display_warning("Socket already bound hierarchically. Bind attempt ignored.");
+ return;
+ }
+
+ //disable our own end of elaboration call
+ disable_cb_bind();
+
+ //inform the bound target socket that it is bound hierarchically now
+ s.set_hierarch_bind((base_type*)this);
+ base_type::bind(s); //satisfy SystemC
+ }
+
+ //operator notation for hierarchical bind
+ void operator() (base_type& s)
+ {
+ bind(s);
+ }
+
+ //get access to sub port
+ tlm::tlm_bw_transport_if<TYPES>* operator[](int i){return m_sockets[i];}
+
+ //get number of bound initiators
+ // NOTE: this is only valid at end of elaboration!
+ unsigned int size(){return get_hierarch_bind()->get_binders().size();}
+
+protected:
+ using base_type::display_warning;
+ using base_type::display_error;
+
+ //implementation of base class interface
+ base_type* get_hierarch_bind(){if (m_hierarch_bind) return m_hierarch_bind->get_hierarch_bind(); else return this;}
+ std::map<unsigned int, tlm::tlm_bw_transport_if<TYPES>*>& get_multi_binds(){return m_multi_binds;}
+ void set_hierarch_bind(base_type* h){m_hierarch_bind=h;}
+ tlm::tlm_fw_transport_if<TYPES>* get_last_binder(tlm::tlm_bw_transport_if<TYPES>* other){
+ m_multi_binds[m_binders.size()-1]=other;
+ return m_binders[m_binders.size()-1];
+ }
+
+ //map that stores to which index a multi init socket is connected
+ // and the interface of the multi init socket
+ std::map<unsigned int, tlm::tlm_bw_transport_if<TYPES>*> m_multi_binds;
+
+ void disable_cb_bind(){ m_eoe_disabled=true;}
+ std::vector<callback_binder_fw<TYPES>* >& get_binders(){return m_binders;}
+ //vector of connected sockets
+ std::vector<tlm::tlm_bw_transport_if<TYPES>*> m_sockets;
+ //vector of binders that convert untagged interface into tagged interface
+ std::vector<callback_binder_fw<TYPES>*> m_binders;
+
+ base_type* m_hierarch_bind; //pointer to hierarchical bound multi port
+ bool m_eoe_disabled; //bool that disables callback bindings at end of elaboration
+ bool m_export_callback_created; //bool that indicates that a binder has been created from a callback registration
+
+ //callbacks as functors
+ // (allows to pass the callback to another socket that does not know the type of the module that owns
+ // the callbacks)
+ typename callback_binder_fw<TYPES>::nb_func_type m_nb_f;
+ typename callback_binder_fw<TYPES>::b_func_type m_b_f;
+ typename callback_binder_fw<TYPES>::debug_func_type m_dbg_f;
+ typename callback_binder_fw<TYPES>::dmi_func_type m_dmi_f;
+};
+
+template <typename MODULE,
+ unsigned int BUSWIDTH = 32,
+ typename TYPES = tlm::tlm_base_protocol_types,
+ unsigned int N=0>
+class multi_passthrough_target_socket_optional
+ : public multi_passthrough_target_socket<MODULE,BUSWIDTH,TYPES,N,sc_core::SC_ZERO_OR_MORE_BOUND>
+{
+ typedef multi_passthrough_target_socket<MODULE,BUSWIDTH,TYPES,N,sc_core::SC_ZERO_OR_MORE_BOUND> socket_b;
+public:
+ multi_passthrough_target_socket_optional() : socket_b() {}
+ explicit multi_passthrough_target_socket_optional(const char* name) : socket_b(name) {}
+};
+
+} // namespace tlm_utils
+#endif // TLM_UTILS_MULTI_PASSTHROUGH_TARGET_SOCKET_H_INCLUDED_
diff --git a/src/systemc/ext/tlm_utils/multi_socket_bases.h b/src/systemc/ext/tlm_utils/multi_socket_bases.h
new file mode 100644
index 000000000..d937511dc
--- /dev/null
+++ b/src/systemc/ext/tlm_utils/multi_socket_bases.h
@@ -0,0 +1,440 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+#ifndef TLM_UTILS_MULTI_SOCKET_BASES_H_INCLUDED_
+#define TLM_UTILS_MULTI_SOCKET_BASES_H_INCLUDED_
+
+#include <tlm>
+#include "tlm_utils/convenience_socket_bases.h"
+
+#include <map>
+
+namespace tlm_utils {
+
+template <typename signature>
+struct fn_container{
+ signature function;
+};
+
+#define TLM_DEFINE_FUNCTOR(name) \
+template <typename MODULE, typename TRAITS> \
+inline TLM_RET_VAL static_##name( void* mod \
+ , void* fn \
+ , int index \
+ , TLM_FULL_ARG_LIST) \
+{ \
+ typedef fn_container<TLM_RET_VAL (MODULE::*)(int, TLM_FULL_ARG_LIST)> fn_container_type; \
+ MODULE* tmp_mod=static_cast<MODULE*>(mod); \
+ fn_container_type* tmp_cb =static_cast<fn_container_type*> (fn); \
+ return (tmp_mod->*(tmp_cb->function))(index, TLM_ARG_LIST_WITHOUT_TYPES); \
+}\
+\
+template <typename MODULE, typename TRAITS> \
+inline void delete_fn_container_of_##name(void* fn) \
+{ \
+ typedef fn_container<TLM_RET_VAL (MODULE::*)(int, TLM_FULL_ARG_LIST)> fn_container_type; \
+ fn_container_type* tmp_cb =static_cast<fn_container_type*> (fn); \
+ if (tmp_cb) delete tmp_cb;\
+} \
+\
+template <typename TRAITS> \
+class name##_functor{ \
+public: \
+ typedef typename TRAITS::tlm_payload_type payload_type; \
+ typedef typename TRAITS::tlm_phase_type phase_type; \
+ typedef TLM_RET_VAL (*call_fn)(void*,void*, int, TLM_FULL_ARG_LIST); \
+ typedef void (*del_fn)(void*); \
+\
+ name##_functor(): m_fn(0), m_del_fn(0), m_mod(0), m_mem_fn(0){} \
+ ~name##_functor(){if (m_del_fn) (*m_del_fn)(m_mem_fn);} \
+\
+ template <typename MODULE> \
+ void set_function(MODULE* mod, TLM_RET_VAL (MODULE::*cb)(int, TLM_FULL_ARG_LIST)){ \
+ typedef fn_container<TLM_RET_VAL (MODULE::*)(int, TLM_FULL_ARG_LIST)> fn_container_type; \
+ m_fn=&static_##name<MODULE,TRAITS>;\
+ m_del_fn=&delete_fn_container_of_##name<MODULE,TRAITS>;\
+ m_del_fn(m_mem_fn); \
+ fn_container_type* tmp= new fn_container_type(); \
+ tmp->function=cb; \
+ m_mod=static_cast<void*>(mod); \
+ m_mem_fn=static_cast<void*>(tmp); \
+ } \
+ \
+ TLM_RET_VAL operator()(int index, TLM_FULL_ARG_LIST){ \
+ return m_fn(m_mod,m_mem_fn, index, TLM_ARG_LIST_WITHOUT_TYPES); \
+ } \
+\
+ bool is_valid(){return (m_mod!=0 && m_mem_fn!=0 && m_fn!=0);}\
+\
+protected: \
+ call_fn m_fn;\
+ del_fn m_del_fn; \
+ void* m_mod; \
+ void* m_mem_fn; \
+private: \
+ name##_functor& operator=(const name##_functor&); \
+}
+
+
+#define TLM_RET_VAL tlm::tlm_sync_enum
+#define TLM_FULL_ARG_LIST typename TRAITS::tlm_payload_type& txn, typename TRAITS::tlm_phase_type& ph, sc_core::sc_time& t
+#define TLM_ARG_LIST_WITHOUT_TYPES txn,ph,t
+TLM_DEFINE_FUNCTOR(nb_transport);
+#undef TLM_RET_VAL
+#undef TLM_FULL_ARG_LIST
+#undef TLM_ARG_LIST_WITHOUT_TYPES
+
+#define TLM_RET_VAL void
+#define TLM_FULL_ARG_LIST typename TRAITS::tlm_payload_type& txn, sc_core::sc_time& t
+#define TLM_ARG_LIST_WITHOUT_TYPES txn,t
+TLM_DEFINE_FUNCTOR(b_transport);
+#undef TLM_RET_VAL
+#undef TLM_FULL_ARG_LIST
+#undef TLM_ARG_LIST_WITHOUT_TYPES
+
+#define TLM_RET_VAL unsigned int
+#define TLM_FULL_ARG_LIST typename TRAITS::tlm_payload_type& txn
+#define TLM_ARG_LIST_WITHOUT_TYPES txn
+TLM_DEFINE_FUNCTOR(debug_transport);
+#undef TLM_RET_VAL
+#undef TLM_FULL_ARG_LIST
+#undef TLM_ARG_LIST_WITHOUT_TYPES
+
+#define TLM_RET_VAL bool
+#define TLM_FULL_ARG_LIST typename TRAITS::tlm_payload_type& txn, tlm::tlm_dmi& dmi
+#define TLM_ARG_LIST_WITHOUT_TYPES txn,dmi
+TLM_DEFINE_FUNCTOR(get_dmi_ptr);
+#undef TLM_RET_VAL
+#undef TLM_FULL_ARG_LIST
+#undef TLM_ARG_LIST_WITHOUT_TYPES
+
+#define TLM_RET_VAL void
+#define TLM_FULL_ARG_LIST sc_dt::uint64 l, sc_dt::uint64 u
+#define TLM_ARG_LIST_WITHOUT_TYPES l,u
+TLM_DEFINE_FUNCTOR(invalidate_dmi);
+#undef TLM_RET_VAL
+#undef TLM_FULL_ARG_LIST
+#undef TLM_ARG_LIST_WITHOUT_TYPES
+
+#undef TLM_DEFINE_FUNCTOR
+
+/*
+This class implements the fw interface.
+It allows to register a callback for each of the fw interface methods.
+The callbacks simply forward the fw interface call, but add the id (an int)
+of the callback binder to the signature of the call.
+*/
+template <typename TYPES>
+class callback_binder_fw
+ : public tlm::tlm_fw_transport_if<TYPES>
+ , protected convenience_socket_cb_holder
+{
+ public:
+ //typedefs according to the used TYPES class
+ typedef typename TYPES::tlm_payload_type transaction_type;
+ typedef typename TYPES::tlm_phase_type phase_type;
+ typedef tlm::tlm_sync_enum sync_enum_type;
+
+ //typedefs for the callbacks
+ typedef nb_transport_functor<TYPES> nb_func_type;
+ typedef b_transport_functor<TYPES> b_func_type;
+ typedef debug_transport_functor<TYPES> debug_func_type;
+ typedef get_dmi_ptr_functor<TYPES> dmi_func_type;
+
+ //ctor: an ID is needed to create a callback binder
+ callback_binder_fw(multi_socket_base* owner, int id)
+ : convenience_socket_cb_holder(owner), m_id(id)
+ , m_nb_f(0), m_b_f(0), m_dbg_f(0), m_dmi_f(0)
+ , m_caller_port(0)
+ {}
+
+ //the nb_transport method of the fw interface
+ sync_enum_type nb_transport_fw(transaction_type& txn,
+ phase_type& p,
+ sc_core::sc_time& t){
+ //check if a callback is registered
+ if (m_nb_f && m_nb_f->is_valid()) {
+ return (*m_nb_f)(m_id, txn, p, t); //do the callback
+ }
+
+ display_error("Call to nb_transport_fw without a registered callback for nb_transport_fw.");
+ return tlm::TLM_COMPLETED;
+ }
+
+ //the b_transport method of the fw interface
+ void b_transport(transaction_type& trans,sc_core::sc_time& t){
+ //check if a callback is registered
+ if (m_b_f && m_b_f->is_valid()) {
+ (*m_b_f)(m_id, trans,t); //do the callback
+ return;
+ }
+
+ display_error("Call to b_transport without a registered callback for b_transport.");
+ }
+
+ //the DMI method of the fw interface
+ bool get_direct_mem_ptr(transaction_type& trans, tlm::tlm_dmi& dmi_data){
+ //check if a callback is registered
+ if (m_dmi_f && m_dmi_f->is_valid()) {
+ return (*m_dmi_f)(m_id, trans,dmi_data); //do the callback
+ }
+
+ dmi_data.allow_none();
+ dmi_data.set_start_address(0x0);
+ dmi_data.set_end_address((sc_dt::uint64)-1);
+ return false;
+ }
+
+ //the debug method of the fw interface
+ unsigned int transport_dbg(transaction_type& trans){
+ //check if a callback is registered
+ if (m_dbg_f && m_dbg_f->is_valid()) {
+ return (*m_dbg_f)(m_id, trans); //do the callback
+ }
+
+ return 0;
+ }
+
+ //the SystemC standard callback register_port:
+ // - called when a port if bound to the interface
+ // - allowd to find out who is bound to that callback binder
+ void register_port(sc_core::sc_port_base& b, const char* /*name*/){
+ m_caller_port=&b;
+ }
+
+ //register callbacks for all fw interface methods at once
+ void set_callbacks(nb_func_type& cb1, b_func_type& cb2, dmi_func_type& cb3, debug_func_type& cb4){
+ m_nb_f=&cb1;
+ m_b_f=&cb2;
+ m_dmi_f=&cb3;
+ m_dbg_f=&cb4;
+ }
+
+ //getter method to get the port that is bound to that callback binder
+ // NOTE: this will only return a valid value at end of elaboration
+ // (but not before end of elaboration!)
+ sc_core::sc_port_base* get_other_side(){return m_caller_port;}
+
+ private:
+ //the ID of the callback binder
+ int m_id;
+
+ //the callbacks
+ nb_func_type* m_nb_f;
+ b_func_type* m_b_f;
+ debug_func_type* m_dbg_f;
+ dmi_func_type* m_dmi_f;
+
+ //the port bound to that callback binder
+ sc_core::sc_port_base* m_caller_port;
+};
+
+/*
+This class implements the bw interface.
+It allows to register a callback for each of the bw interface methods.
+The callbacks simply forward the bw interface call, but add the id (an int)
+of the callback binder to the signature of the call.
+*/
+template <typename TYPES>
+class callback_binder_bw
+ : public tlm::tlm_bw_transport_if<TYPES>
+ , protected convenience_socket_cb_holder
+{
+ public:
+ //typedefs according to the used TYPES class
+ typedef typename TYPES::tlm_payload_type transaction_type;
+ typedef typename TYPES::tlm_phase_type phase_type;
+ typedef tlm::tlm_sync_enum sync_enum_type;
+
+ //typedefs for the callbacks
+ typedef nb_transport_functor<TYPES> nb_func_type;
+ typedef invalidate_dmi_functor<TYPES> dmi_func_type;
+
+ //ctor: an ID is needed to create a callback binder
+ callback_binder_bw(multi_socket_base* owner, int id)
+ : convenience_socket_cb_holder(owner), m_id(id)
+ , m_nb_f(0), m_dmi_f(0) {}
+
+ //the nb_transport method of the bw interface
+ sync_enum_type nb_transport_bw(transaction_type& txn,
+ phase_type& p,
+ sc_core::sc_time& t){
+ //check if a callback is registered
+ if (m_nb_f && m_nb_f->is_valid()) {
+ return (*m_nb_f)(m_id, txn, p, t); //do the callback
+ }
+
+ display_error("Call to nb_transport_bw without a registered callback for nb_transport_bw");
+ return tlm::TLM_COMPLETED;
+ }
+
+ //the DMI method of the bw interface
+ void invalidate_direct_mem_ptr(sc_dt::uint64 l, sc_dt::uint64 u){
+ //check if a callback is registered
+ if (m_dmi_f && m_dmi_f->is_valid()) {
+ (*m_dmi_f)(m_id,l,u); //do the callback
+ }
+ }
+
+ //register callbacks for all bw interface methods at once
+ void set_callbacks(nb_func_type& cb1, dmi_func_type& cb2){
+ m_nb_f=&cb1;
+ m_dmi_f=&cb2;
+ }
+
+ private:
+ //the ID of the callback binder
+ int m_id;
+ //the callbacks
+ nb_func_type* m_nb_f;
+ dmi_func_type* m_dmi_f;
+};
+
+/*
+This class forms the base for multi initiator sockets,
+with fewer template parameters than the multi_init_base.
+This class is implementation-defined.
+*/
+template <typename TYPES = tlm::tlm_base_protocol_types>
+class multi_init_base_if {
+public:
+ //this method shall return a vector of the callback binders of multi initiator socket
+ virtual std::vector<callback_binder_bw<TYPES>* >& get_binders()=0;
+ //this method shall return a vector of all target interfaces bound to this multi init socket
+ virtual std::vector<tlm::tlm_fw_transport_if<TYPES>*>& get_sockets()=0;
+protected:
+ virtual ~multi_init_base_if() {}
+};
+
+/*
+This class forms the base for multi initiator sockets.
+It enforces a multi initiator socket to implement all functions
+needed to do hierarchical bindings.
+*/
+template <unsigned int BUSWIDTH = 32,
+ typename TYPES = tlm::tlm_base_protocol_types,
+ unsigned int N=0,
+ sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
+class multi_init_base
+ : public tlm::tlm_initiator_socket<BUSWIDTH, TYPES, N, POL>
+ , public multi_init_base_if<TYPES>
+ , protected multi_socket_base
+{
+public:
+ //typedef for the base type: the standard tlm initiator socket
+ typedef tlm::tlm_initiator_socket<BUSWIDTH, TYPES, N, POL> base_type;
+
+ //this method shall disable the code that does the callback binding
+ // that registers callbacks to binders
+ virtual void disable_cb_bind()=0;
+
+ //this method shall return the multi_init_base to which the
+ // multi_init_base is bound hierarchically
+ // If the base is not bound hierarchically it shall return a pointer to itself
+ virtual multi_init_base* get_hierarch_bind()=0;
+
+ virtual tlm::tlm_socket_category get_socket_category() const
+ {
+ return tlm::TLM_MULTI_INITIATOR_SOCKET;
+ }
+
+ //ctor and dtor
+ virtual ~multi_init_base(){}
+ multi_init_base():base_type(sc_core::sc_gen_unique_name("multi_init_base")){}
+ multi_init_base(const char* name):base_type(name){}
+
+private:
+ const sc_core::sc_object* get_socket() const { return this; }
+};
+
+/*
+This class forms the base for multi target sockets,
+with fewer template parameters than the multi_target_base.
+This class is implementation-defined.
+*/
+template <typename TYPES = tlm::tlm_base_protocol_types>
+class multi_target_base_if {
+public:
+ //this method shall return a vector of the callback binders of multi initiator socket
+ virtual std::vector<callback_binder_fw<TYPES>* >& get_binders()=0;
+
+ //this method shall return a map of all multi initiator sockets that are
+ // bound to this multi target the key of the map is the index at which the
+ // multi initiator i bound, while the value is the interface of the multi
+ // initiator socket that is bound at that index
+ virtual std::map<unsigned int, tlm::tlm_bw_transport_if<TYPES>*>& get_multi_binds()=0;
+protected:
+ virtual ~multi_target_base_if() {}
+};
+
+/*
+This class forms the base for multi target sockets.
+It enforces a multi target socket to implement all functions
+needed to do hierarchical bindings.
+*/
+template <unsigned int BUSWIDTH = 32,
+ typename TYPES = tlm::tlm_base_protocol_types,
+ unsigned int N=0,
+ sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND>
+class multi_target_base
+ : public tlm::tlm_target_socket<BUSWIDTH, TYPES, N, POL>
+ , public multi_target_base_if<TYPES>
+ , protected multi_socket_base
+{
+public:
+ //typedef for the base type: the standard tlm target socket
+ typedef tlm::tlm_target_socket<BUSWIDTH, TYPES, N, POL > base_type;
+
+ //this method shall return the multi_init_base to which the
+ // multi_init_base is bound hierarchically
+ // If the base is not bound hierarchically it shall return a pointer to itself
+ virtual multi_target_base* get_hierarch_bind()=0;
+
+ //this method shall inform the multi target socket that it is bound
+ // hierarchically and to which other multi target socket it is bound hierarchically
+ virtual void set_hierarch_bind(multi_target_base*)=0;
+
+ virtual tlm::tlm_socket_category get_socket_category() const
+ {
+ return tlm::TLM_MULTI_TARGET_SOCKET;
+ }
+
+ //ctor and dtor
+ virtual ~multi_target_base(){}
+ multi_target_base():base_type(sc_core::sc_gen_unique_name("multi_target_base")){}
+ multi_target_base(const char* name):base_type(name){}
+
+private:
+ const sc_core::sc_object* get_socket() const { return this; }
+};
+
+/*
+All multi sockets must additionally derive from this class.
+It enforces a multi socket to implement a function
+needed to do multi init to multi target bindings.
+*/
+template <typename TYPES>
+class multi_to_multi_bind_base{
+public:
+ virtual ~multi_to_multi_bind_base(){}
+ virtual tlm::tlm_fw_transport_if<TYPES>* get_last_binder(tlm::tlm_bw_transport_if<TYPES>*)=0;
+};
+
+} // namespace tlm_utils
+#endif // TLM_UTILS_MULTI_SOCKET_BASES_H_INCLUDED_
diff --git a/src/systemc/ext/tlm_utils/passthrough_target_socket.h b/src/systemc/ext/tlm_utils/passthrough_target_socket.h
new file mode 100644
index 000000000..b2c97aed5
--- /dev/null
+++ b/src/systemc/ext/tlm_utils/passthrough_target_socket.h
@@ -0,0 +1,477 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+#ifndef TLM_UTILS_PASSTHROUGH_TARGET_SOCKET_H_INCLUDED_
+#define TLM_UTILS_PASSTHROUGH_TARGET_SOCKET_H_INCLUDED_
+
+#include <tlm>
+#include "tlm_utils/convenience_socket_bases.h"
+
+namespace tlm_utils {
+
+template< typename MODULE, unsigned int BUSWIDTH, typename TYPES
+ , sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND >
+class passthrough_target_socket_b
+ : public tlm::tlm_target_socket<BUSWIDTH, TYPES, 1, POL>
+ , protected passthrough_socket_base
+{
+public:
+ typedef typename TYPES::tlm_payload_type transaction_type;
+ typedef typename TYPES::tlm_phase_type phase_type;
+ typedef tlm::tlm_sync_enum sync_enum_type;
+ typedef tlm::tlm_fw_transport_if<TYPES> fw_interface_type;
+ typedef tlm::tlm_bw_transport_if<TYPES> bw_interface_type;
+ typedef tlm::tlm_target_socket<BUSWIDTH,TYPES,1,POL> base_type;
+
+public:
+ static const char* default_name()
+ { return sc_core::sc_gen_unique_name("passthrough_target_socket"); }
+
+ explicit passthrough_target_socket_b(const char* n = default_name())
+ : base_type(n)
+ , m_process(this)
+ {
+ bind(m_process);
+ }
+
+ using base_type::bind;
+
+ // REGISTER_XXX
+ void register_nb_transport_fw(MODULE* mod,
+ sync_enum_type (MODULE::*cb)(transaction_type&,
+ phase_type&,
+ sc_core::sc_time&))
+ {
+ m_process.set_nb_transport_ptr(mod, cb);
+ }
+
+ void register_b_transport(MODULE* mod,
+ void (MODULE::*cb)(transaction_type&,
+ sc_core::sc_time&))
+ {
+ m_process.set_b_transport_ptr(mod, cb);
+ }
+
+ void register_transport_dbg(MODULE* mod,
+ unsigned int (MODULE::*cb)(transaction_type&))
+ {
+ m_process.set_transport_dbg_ptr(mod, cb);
+ }
+
+ void register_get_direct_mem_ptr(MODULE* mod,
+ bool (MODULE::*cb)(transaction_type&,
+ tlm::tlm_dmi&))
+ {
+ m_process.set_get_direct_mem_ptr(mod, cb);
+ }
+
+private:
+ class process
+ : public tlm::tlm_fw_transport_if<TYPES>
+ , protected convenience_socket_cb_holder
+ {
+ public:
+ typedef sync_enum_type (MODULE::*NBTransportPtr)(transaction_type&,
+ phase_type&,
+ sc_core::sc_time&);
+ typedef void (MODULE::*BTransportPtr)(transaction_type&,
+ sc_core::sc_time&);
+ typedef unsigned int (MODULE::*TransportDbgPtr)(transaction_type&);
+ typedef bool (MODULE::*GetDirectMem_ptr)(transaction_type&,
+ tlm::tlm_dmi&);
+
+ explicit process(passthrough_socket_base* owner)
+ : convenience_socket_cb_holder(owner), m_mod(0)
+ , m_nb_transport_ptr(0)
+ , m_b_transport_ptr(0)
+ , m_transport_dbg_ptr(0)
+ , m_get_direct_mem_ptr(0)
+ {
+ }
+
+ void set_nb_transport_ptr(MODULE* mod, NBTransportPtr p)
+ {
+ if (m_nb_transport_ptr) {
+ display_warning("non-blocking callback already registered");
+ return;
+ }
+ sc_assert(!m_mod || m_mod == mod);
+ m_mod = mod;
+ m_nb_transport_ptr = p;
+ }
+
+ void set_b_transport_ptr(MODULE* mod, BTransportPtr p)
+ {
+ if (m_b_transport_ptr) {
+ display_warning("blocking callback already registered");
+ return;
+ }
+ sc_assert(!m_mod || m_mod == mod);
+ m_mod = mod;
+ m_b_transport_ptr = p;
+ }
+
+ void set_transport_dbg_ptr(MODULE* mod, TransportDbgPtr p)
+ {
+ if (m_transport_dbg_ptr) {
+ display_warning("debug callback already registered");
+ return;
+ }
+ sc_assert(!m_mod || m_mod == mod);
+ m_mod = mod;
+ m_transport_dbg_ptr = p;
+ }
+
+ void set_get_direct_mem_ptr(MODULE* mod, GetDirectMem_ptr p)
+ {
+ if (m_get_direct_mem_ptr) {
+ display_warning("get DMI pointer callback already registered");
+ return;
+ }
+ sc_assert(!m_mod || m_mod == mod);
+ m_mod = mod;
+ m_get_direct_mem_ptr = p;
+ }
+
+ sync_enum_type nb_transport_fw(transaction_type& trans,
+ phase_type& phase,
+ sc_core::sc_time& t)
+ {
+ if (m_nb_transport_ptr) {
+ // forward call
+ sc_assert(m_mod);
+ return (m_mod->*m_nb_transport_ptr)(trans, phase, t);
+ }
+ display_error("no non-blocking callback registered");
+ return tlm::TLM_COMPLETED;
+ }
+
+ void b_transport(transaction_type& trans, sc_core::sc_time& t)
+ {
+ if (m_b_transport_ptr) {
+ // forward call
+ sc_assert(m_mod);
+ return (m_mod->*m_b_transport_ptr)(trans, t);
+ }
+ display_error("no blocking callback registered");
+ }
+
+ unsigned int transport_dbg(transaction_type& trans)
+ {
+ if (m_transport_dbg_ptr) {
+ // forward call
+ sc_assert(m_mod);
+ return (m_mod->*m_transport_dbg_ptr)(trans);
+ }
+ // No debug support
+ return 0;
+ }
+
+ bool get_direct_mem_ptr(transaction_type& trans,
+ tlm::tlm_dmi& dmi_data)
+ {
+ if (m_get_direct_mem_ptr) {
+ // forward call
+ sc_assert(m_mod);
+ return (m_mod->*m_get_direct_mem_ptr)(trans, dmi_data);
+ }
+ // No DMI support
+ dmi_data.allow_read_write();
+ dmi_data.set_start_address(0x0);
+ dmi_data.set_end_address((sc_dt::uint64)-1);
+ return false;
+ }
+
+ private:
+ MODULE* m_mod;
+ NBTransportPtr m_nb_transport_ptr;
+ BTransportPtr m_b_transport_ptr;
+ TransportDbgPtr m_transport_dbg_ptr;
+ GetDirectMem_ptr m_get_direct_mem_ptr;
+ };
+
+private:
+ const sc_core::sc_object* get_socket() const { return this; }
+private:
+ process m_process;
+};
+
+template< typename MODULE, unsigned int BUSWIDTH = 32
+ , typename TYPES = tlm::tlm_base_protocol_types >
+class passthrough_target_socket
+ : public passthrough_target_socket_b<MODULE,BUSWIDTH,TYPES>
+{
+ typedef passthrough_target_socket_b<MODULE,BUSWIDTH,TYPES> socket_b;
+public:
+ passthrough_target_socket() : socket_b() {}
+ explicit passthrough_target_socket(const char* name) : socket_b(name) {}
+};
+
+template< typename MODULE, unsigned int BUSWIDTH = 32
+ , typename TYPES = tlm::tlm_base_protocol_types >
+class passthrough_target_socket_optional
+ : public passthrough_target_socket_b<MODULE,BUSWIDTH,TYPES,sc_core::SC_ZERO_OR_MORE_BOUND>
+{
+ typedef passthrough_target_socket_b<MODULE,BUSWIDTH,TYPES,sc_core::SC_ZERO_OR_MORE_BOUND> socket_b;
+public:
+ passthrough_target_socket_optional() : socket_b() {}
+ explicit passthrough_target_socket_optional(const char* name) : socket_b(name) {}
+};
+
+//ID Tagged version
+template< typename MODULE, unsigned int BUSWIDTH, typename TYPES
+ , sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND >
+class passthrough_target_socket_tagged_b
+ : public tlm::tlm_target_socket<BUSWIDTH, TYPES, 1, POL>
+ , protected passthrough_socket_base
+{
+public:
+ typedef typename TYPES::tlm_payload_type transaction_type;
+ typedef typename TYPES::tlm_phase_type phase_type;
+ typedef tlm::tlm_sync_enum sync_enum_type;
+ typedef tlm::tlm_fw_transport_if<TYPES> fw_interface_type;
+ typedef tlm::tlm_bw_transport_if<TYPES> bw_interface_type;
+ typedef tlm::tlm_target_socket<BUSWIDTH,TYPES,1,POL> base_type;
+
+ static const char* default_name()
+ { return sc_core::sc_gen_unique_name("passthrough_target_socket_tagged"); }
+
+public:
+ explicit passthrough_target_socket_tagged_b(const char* n = default_name())
+ : base_type(n)
+ , m_process(this)
+ {
+ bind(m_process);
+ }
+
+ using base_type::bind;
+
+ // REGISTER_XXX
+ void register_nb_transport_fw(MODULE* mod,
+ sync_enum_type (MODULE::*cb)(int id,
+ transaction_type&,
+ phase_type&,
+ sc_core::sc_time&),
+ int id)
+ {
+ m_process.set_nb_transport_ptr(mod, cb);
+ m_process.set_nb_transport_user_id(id);
+ }
+
+ void register_b_transport(MODULE* mod,
+ void (MODULE::*cb)(int id,
+ transaction_type&,
+ sc_core::sc_time&),
+ int id)
+ {
+ m_process.set_b_transport_ptr(mod, cb);
+ m_process.set_b_transport_user_id(id);
+ }
+
+ void register_transport_dbg(MODULE* mod,
+ unsigned int (MODULE::*cb)(int id,
+ transaction_type&),
+ int id)
+ {
+ m_process.set_transport_dbg_ptr(mod, cb);
+ m_process.set_transport_dbg_user_id(id);
+ }
+
+ void register_get_direct_mem_ptr(MODULE* mod,
+ bool (MODULE::*cb)(int id,
+ transaction_type&,
+ tlm::tlm_dmi&),
+ int id)
+ {
+ m_process.set_get_direct_mem_ptr(mod, cb);
+ m_process.set_get_dmi_user_id(id);
+ }
+
+private:
+ class process
+ : public tlm::tlm_fw_transport_if<TYPES>
+ , protected convenience_socket_cb_holder
+ {
+ public:
+ typedef sync_enum_type (MODULE::*NBTransportPtr)(int id,
+ transaction_type&,
+ phase_type&,
+ sc_core::sc_time&);
+ typedef void (MODULE::*BTransportPtr)(int id,
+ transaction_type&,
+ sc_core::sc_time&);
+ typedef unsigned int (MODULE::*TransportDbgPtr)(int id,
+ transaction_type&);
+ typedef bool (MODULE::*GetDirectMem_ptr)(int id,
+ transaction_type&,
+ tlm::tlm_dmi&);
+
+ process(passthrough_socket_base* owner)
+ : convenience_socket_cb_holder(owner), m_mod(0)
+ , m_nb_transport_ptr(0)
+ , m_b_transport_ptr(0)
+ , m_transport_dbg_ptr(0)
+ , m_get_direct_mem_ptr(0)
+ , m_nb_transport_user_id(0)
+ , m_b_transport_user_id(0)
+ , m_transport_dbg_user_id(0)
+ , m_get_dmi_user_id(0)
+ {
+ }
+
+ void set_nb_transport_user_id(int id) { m_nb_transport_user_id = id; }
+ void set_b_transport_user_id(int id) { m_b_transport_user_id = id; }
+ void set_transport_dbg_user_id(int id) { m_transport_dbg_user_id = id; }
+ void set_get_dmi_user_id(int id) { m_get_dmi_user_id = id; }
+
+ void set_nb_transport_ptr(MODULE* mod, NBTransportPtr p)
+ {
+ if (m_nb_transport_ptr) {
+ display_warning("non-blocking callback already registered");
+ return;
+ }
+ sc_assert(!m_mod || m_mod == mod);
+ m_mod = mod;
+ m_nb_transport_ptr = p;
+ }
+
+ void set_b_transport_ptr(MODULE* mod, BTransportPtr p)
+ {
+ if (m_b_transport_ptr) {
+ display_warning("blocking callback already registered");
+ return;
+ }
+ sc_assert(!m_mod || m_mod == mod);
+ m_mod = mod;
+ m_b_transport_ptr = p;
+ }
+
+ void set_transport_dbg_ptr(MODULE* mod, TransportDbgPtr p)
+ {
+ if (m_transport_dbg_ptr) {
+ display_warning("debug callback already registered");
+ return;
+ }
+ sc_assert(!m_mod || m_mod == mod);
+ m_mod = mod;
+ m_transport_dbg_ptr = p;
+ }
+
+ void set_get_direct_mem_ptr(MODULE* mod, GetDirectMem_ptr p)
+ {
+ if (m_get_direct_mem_ptr) {
+ display_warning("get DMI pointer callback already registered");
+ return;
+ }
+ sc_assert(!m_mod || m_mod == mod);
+ m_mod = mod;
+ m_get_direct_mem_ptr = p;
+ }
+
+ sync_enum_type nb_transport_fw(transaction_type& trans,
+ phase_type& phase,
+ sc_core::sc_time& t)
+ {
+ if (m_nb_transport_ptr) {
+ // forward call
+ sc_assert(m_mod);
+ return (m_mod->*m_nb_transport_ptr)(m_nb_transport_user_id, trans, phase, t);
+ }
+ display_error("no non-blocking callback registered");
+ return tlm::TLM_COMPLETED;
+ }
+
+ void b_transport(transaction_type& trans, sc_core::sc_time& t)
+ {
+ if (m_b_transport_ptr) {
+ // forward call
+ sc_assert(m_mod);
+ return (m_mod->*m_b_transport_ptr)(m_b_transport_user_id, trans, t);
+ }
+ display_error("no blocking callback registered");
+ }
+
+ unsigned int transport_dbg(transaction_type& trans)
+ {
+ if (m_transport_dbg_ptr) {
+ // forward call
+ sc_assert(m_mod);
+ return (m_mod->*m_transport_dbg_ptr)(m_transport_dbg_user_id, trans);
+ }
+ // No debug support
+ return 0;
+ }
+
+ bool get_direct_mem_ptr(transaction_type& trans,
+ tlm::tlm_dmi& dmi_data)
+ {
+ if (m_get_direct_mem_ptr) {
+ // forward call
+ sc_assert(m_mod);
+ return (m_mod->*m_get_direct_mem_ptr)(m_get_dmi_user_id, trans, dmi_data);
+ }
+ // No DMI support
+ dmi_data.allow_read_write();
+ dmi_data.set_start_address(0x0);
+ dmi_data.set_end_address((sc_dt::uint64)-1);
+ return false;
+ }
+
+ private:
+ MODULE* m_mod;
+ NBTransportPtr m_nb_transport_ptr;
+ BTransportPtr m_b_transport_ptr;
+ TransportDbgPtr m_transport_dbg_ptr;
+ GetDirectMem_ptr m_get_direct_mem_ptr;
+ int m_nb_transport_user_id;
+ int m_b_transport_user_id;
+ int m_transport_dbg_user_id;
+ int m_get_dmi_user_id;
+ };
+
+private:
+ const sc_core::sc_object* get_socket() const { return this; }
+private:
+ process m_process;
+};
+
+template< typename MODULE, unsigned int BUSWIDTH = 32
+ , typename TYPES = tlm::tlm_base_protocol_types >
+class passthrough_target_socket_tagged
+ : public passthrough_target_socket_tagged_b<MODULE,BUSWIDTH,TYPES>
+{
+ typedef passthrough_target_socket_tagged_b<MODULE,BUSWIDTH,TYPES> socket_b;
+public:
+ passthrough_target_socket_tagged() : socket_b() {}
+ explicit passthrough_target_socket_tagged(const char* name) : socket_b(name) {}
+};
+
+template< typename MODULE, unsigned int BUSWIDTH = 32
+ , typename TYPES = tlm::tlm_base_protocol_types >
+class passthrough_target_socket_tagged_optional
+ : public passthrough_target_socket_tagged_b<MODULE,BUSWIDTH,TYPES,sc_core::SC_ZERO_OR_MORE_BOUND>
+{
+ typedef passthrough_target_socket_tagged_b<MODULE,BUSWIDTH,TYPES,sc_core::SC_ZERO_OR_MORE_BOUND> socket_b;
+public:
+ passthrough_target_socket_tagged_optional() : socket_b() {}
+ explicit passthrough_target_socket_tagged_optional(const char* name) : socket_b(name) {}
+};
+
+} // namespace tlm_utils
+#endif // TLM_UTILS_PASSTHROUGH_TARGET_SOCKET_H_INCLUDED_
diff --git a/src/systemc/ext/tlm_utils/peq_with_cb_and_phase.h b/src/systemc/ext/tlm_utils/peq_with_cb_and_phase.h
new file mode 100644
index 000000000..60f96e6bd
--- /dev/null
+++ b/src/systemc/ext/tlm_utils/peq_with_cb_and_phase.h
@@ -0,0 +1,301 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+// 12-Jan-2009 John Aynsley Bug fix. Phase argument to notify should be const
+// 20-Mar-2009 John Aynsley Add cancel_all() method
+
+
+#ifndef __PEQ_WITH_CB_AND_PHASE_H__
+#define __PEQ_WITH_CB_AND_PHASE_H__
+
+#ifndef SC_INCLUDE_DYNAMIC_PROCESSES // needed for sc_spawn
+# define SC_INCLUDE_DYNAMIC_PROCESSES
+#endif
+
+#include <vector>
+#include <systemc>
+#include <tlm>
+
+namespace tlm_utils {
+
+template <typename PAYLOAD>
+class time_ordered_list
+{
+public:
+ struct element
+ {
+ struct element *next;
+ PAYLOAD p;
+ sc_core::sc_time t;
+ sc_dt::uint64 d;
+ element(PAYLOAD& p, sc_core::sc_time t, sc_dt::uint64 d): p(p),t(t),d(d) {}
+ element(){}
+ };
+
+ element *nill;
+ element *empties;
+ element *list;
+ unsigned int size;
+
+ time_ordered_list()
+ : nill(new element()),
+ empties(NULL),
+ list(nill),
+ size(0)
+ {
+ }
+
+ ~time_ordered_list() {
+ reset();
+ while(empties){
+ struct element *e=empties->next;
+ delete empties;
+ empties=e;
+ }
+ delete nill;
+ }
+
+ void reset() {
+ while(size) {
+ delete_top();
+ }
+ }
+
+ void insert(const PAYLOAD& p, sc_core::sc_time t) {
+ if (!empties) {
+ empties=new struct element();
+ empties->next=NULL;
+ }
+
+ struct element *e=empties;
+ empties=empties->next;
+ e->p=p;
+ e->t=t;
+ e->d=sc_core::sc_delta_count();
+
+ struct element * ancestor=nill;
+ struct element * iterator=list;
+ while (iterator!=nill && iterator->t<=t){
+ ancestor=iterator;
+ iterator=iterator->next;
+ }
+ if (ancestor==nill){
+ e->next=list;
+ list=e;
+ }
+ else {
+ e->next=iterator;
+ ancestor->next=e;
+ }
+ size++;
+ }
+
+ void delete_top(){
+ if (list != nill) {
+ struct element *e=list;
+ list=list->next;
+ e->next=empties;
+ empties=e;
+ size--;
+ }
+ }
+
+ unsigned int get_size()
+ {
+ return size;
+ }
+
+ PAYLOAD &top()
+ {
+ return list->p;
+ }
+ sc_core::sc_time top_time()
+ {
+ return list->t;
+ }
+
+ sc_dt::uint64& top_delta()
+ {
+ return list->d;
+ }
+
+ sc_core::sc_time next_time()
+ {
+ return list->next->t;
+ }
+};
+
+//---------------------------------------------------------------------------
+/**
+ * An event queue that can contain any number of pending
+ * notifications. Each notification have an associate payload.
+ */
+//---------------------------------------------------------------------------
+template<typename OWNER,typename TYPES=tlm::tlm_base_protocol_types>
+class peq_with_cb_and_phase:
+ public sc_core::sc_object
+{
+
+ typedef typename TYPES::tlm_payload_type tlm_payload_type;
+ typedef typename TYPES::tlm_phase_type tlm_phase_type;
+ typedef std::pair<tlm_payload_type*, tlm_phase_type> PAYLOAD;
+ typedef void (OWNER::*cb)(tlm_payload_type&, const tlm_phase_type&);
+
+ class delta_list{
+ public:
+ delta_list(){
+ reset();
+ entries.resize(100);
+ }
+
+ inline void insert(const PAYLOAD& p){
+ if (size==entries.size()){
+ entries.resize(entries.size()*2);
+ }
+ entries[size++]=p;
+ }
+
+ inline PAYLOAD& get(){
+ return entries[out++];
+ }
+
+ inline bool next(){
+ return out<size;
+ }
+
+ inline void reset(){
+ size=0;
+ out=0;
+ }
+ public:
+ unsigned int size;
+ private:
+ std::vector<PAYLOAD> entries;
+ unsigned int out;
+ };
+
+public:
+
+ peq_with_cb_and_phase(OWNER* _owner, cb _cb)
+ :sc_core::sc_object( sc_core::sc_gen_unique_name( "peq_with_cb_and_phase" ) )
+ ,m_owner(_owner)
+ ,m_cb(_cb)
+ {
+ sc_core::sc_spawn_options opts;
+ opts.spawn_method();
+ opts.set_sensitivity(&m_e);
+ opts.dont_initialize();
+ sc_core::sc_spawn(sc_bind(&peq_with_cb_and_phase::fec, this),
+ sc_core::sc_gen_unique_name("fec"), &opts);
+ }
+
+ peq_with_cb_and_phase(const char* _name, OWNER* _owner,cb _cb)
+ : sc_core::sc_object( _name )
+ ,m_owner(_owner)
+ ,m_cb(_cb)
+ {
+ sc_core::sc_spawn_options opts;
+ opts.spawn_method();
+ opts.set_sensitivity(&m_e);
+ opts.dont_initialize();
+ sc_core::sc_spawn(sc_bind(&peq_with_cb_and_phase::fec, this),
+ sc_core::sc_gen_unique_name("fec"), &opts);
+ }
+
+ ~peq_with_cb_and_phase(){}
+
+ void notify (tlm_payload_type& t, const tlm_phase_type& p, const sc_core::sc_time& when){
+ //t.aquire();
+ if (when==sc_core::SC_ZERO_TIME) {
+ if (sc_core::sc_delta_count() & (sc_dt::uint64)0x1) //uneven delta cycle so delta delay is for even cylce
+ m_even_delta.insert(PAYLOAD(&t,p));
+ else
+ m_uneven_delta.insert(PAYLOAD(&t,p)); //even delta cycle so delta delay is for uneven delta
+ m_e.notify(sc_core::SC_ZERO_TIME);
+ }
+ else {
+ m_ppq.insert(PAYLOAD(&t,p), when + sc_core::sc_time_stamp() );
+ m_e.notify(when); // note, this will only over-right the "newest" event.
+ }
+ }
+
+ void notify (tlm_payload_type& t, const tlm_phase_type& p){
+ m_immediate_yield.insert(PAYLOAD(&t,p));
+ m_e.notify(); // immediate notification
+ }
+
+ // Cancel all events from the event queue
+ void cancel_all() {
+ m_ppq.reset();
+ m_uneven_delta.reset();
+ m_even_delta.reset();
+ m_immediate_yield.reset();
+ m_e.cancel();
+ }
+
+private:
+
+ void fec(){
+ //immediate yield notifications
+ while(m_immediate_yield.next()) {PAYLOAD& tmp=m_immediate_yield.get(); (m_owner->*m_cb)(*tmp.first, tmp.second);} //tmp.first->release();}
+ m_immediate_yield.reset();
+
+ //delta notifications
+ if (sc_core::sc_delta_count() & (sc_dt::uint64) 0x1) {//uneven delta so put out all payloads for uneven delta
+ while (m_uneven_delta.next()) {PAYLOAD& tmp=m_uneven_delta.get(); (m_owner->*m_cb)(*tmp.first, tmp.second);} //tmp.first->release();}
+ m_uneven_delta.reset();
+ if (m_even_delta.size) m_e.notify(sc_core::SC_ZERO_TIME);
+ }
+ else {
+ while (m_even_delta.next()) {PAYLOAD& tmp=m_even_delta.get(); (m_owner->*m_cb)(*tmp.first, tmp.second);} //tmp.first->release();}
+ m_even_delta.reset();
+ if (m_uneven_delta.size) m_e.notify(sc_core::SC_ZERO_TIME);
+ }
+ if (!m_ppq.get_size()) return; //there were only delta notification
+
+ //timed notifications
+ const sc_core::sc_time now=sc_core::sc_time_stamp();
+ sc_core::sc_time top=m_ppq.top_time();
+
+ while(m_ppq.get_size() && top==now) { // push all active ones into target
+ PAYLOAD& tmp=m_ppq.top();
+ (m_owner->*m_cb)(*tmp.first, tmp.second); //tmp.first->release();}
+ m_ppq.delete_top();
+ top=m_ppq.top_time();
+ }
+ if ( m_ppq.get_size()) {
+ m_e.notify( top - now) ;
+ }
+
+ }
+
+ OWNER* m_owner;
+ cb m_cb;
+
+ time_ordered_list<PAYLOAD> m_ppq;
+ delta_list m_uneven_delta;
+ delta_list m_even_delta;
+ delta_list m_immediate_yield;
+
+ sc_core::sc_event m_e; // default event
+};
+
+}
+
+#endif // __PEQ_WITH_CB_AND_PHASE_H__
diff --git a/src/systemc/ext/tlm_utils/peq_with_get.h b/src/systemc/ext/tlm_utils/peq_with_get.h
new file mode 100644
index 000000000..5c85f25d5
--- /dev/null
+++ b/src/systemc/ext/tlm_utils/peq_with_get.h
@@ -0,0 +1,94 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+// 12-Jan-2009 John Aynsley Bug fix. sc_time argument to notify should be const
+// 20-Mar-2009 John Aynsley Add cancel_all() method
+
+
+#ifndef __PEQ_WITH_GET_H__
+#define __PEQ_WITH_GET_H__
+
+#include <systemc>
+//#include <tlm>
+#include <map>
+
+namespace tlm_utils {
+
+template <class PAYLOAD>
+class peq_with_get : public sc_core::sc_object
+{
+public:
+ typedef PAYLOAD transaction_type;
+ typedef std::pair<const sc_core::sc_time, transaction_type*> pair_type;
+
+public:
+ peq_with_get(const char* name) : sc_core::sc_object(name)
+ {
+ }
+
+ void notify(transaction_type& trans, const sc_core::sc_time& t)
+ {
+ m_scheduled_events.insert(pair_type(t + sc_core::sc_time_stamp(), &trans));
+ m_event.notify(t);
+ }
+
+ void notify(transaction_type& trans)
+ {
+ m_scheduled_events.insert(pair_type(sc_core::sc_time_stamp(), &trans));
+ m_event.notify(); // immediate notification
+ }
+
+ // needs to be called until it returns 0
+ transaction_type* get_next_transaction()
+ {
+ if (m_scheduled_events.empty()) {
+ return 0;
+ }
+
+ sc_core::sc_time now = sc_core::sc_time_stamp();
+ if (m_scheduled_events.begin()->first <= now) {
+ transaction_type* trans = m_scheduled_events.begin()->second;
+ m_scheduled_events.erase(m_scheduled_events.begin());
+ return trans;
+ }
+
+ m_event.notify(m_scheduled_events.begin()->first - now);
+
+ return 0;
+ }
+
+ sc_core::sc_event& get_event()
+ {
+ return m_event;
+ }
+
+ // Cancel all events from the event queue
+ void cancel_all() {
+ m_scheduled_events.clear();
+ m_event.cancel();
+ }
+
+private:
+ std::multimap<const sc_core::sc_time, transaction_type*> m_scheduled_events;
+ sc_core::sc_event m_event;
+};
+
+}
+
+#endif
diff --git a/src/systemc/ext/tlm_utils/simple_initiator_socket.h b/src/systemc/ext/tlm_utils/simple_initiator_socket.h
new file mode 100644
index 000000000..0cf9c5649
--- /dev/null
+++ b/src/systemc/ext/tlm_utils/simple_initiator_socket.h
@@ -0,0 +1,316 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+#ifndef TLM_UTILS_SIMPLE_INITIATOR_SOCKET_H_INCLUDED_
+#define TLM_UTILS_SIMPLE_INITIATOR_SOCKET_H_INCLUDED_
+
+#include <tlm>
+#include "tlm_utils/convenience_socket_bases.h"
+
+namespace tlm_utils {
+
+template< typename MODULE, unsigned int BUSWIDTH, typename TYPES
+ , sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND >
+class simple_initiator_socket_b
+ : public tlm::tlm_initiator_socket<BUSWIDTH, TYPES, 1, POL>
+ , protected simple_socket_base
+{
+public:
+ typedef typename TYPES::tlm_payload_type transaction_type;
+ typedef typename TYPES::tlm_phase_type phase_type;
+ typedef tlm::tlm_sync_enum sync_enum_type;
+ typedef tlm::tlm_fw_transport_if<TYPES> fw_interface_type;
+ typedef tlm::tlm_bw_transport_if<TYPES> bw_interface_type;
+ typedef tlm::tlm_initiator_socket<BUSWIDTH,TYPES,1,POL> base_type;
+
+public:
+ static const char* default_name()
+ { return sc_core::sc_gen_unique_name("simple_initiator_socket"); }
+
+ explicit simple_initiator_socket_b(const char* n = default_name())
+ : base_type(n)
+ , m_process(this)
+ {
+ this->m_export.bind(m_process);
+ }
+
+ void register_nb_transport_bw(MODULE* mod,
+ sync_enum_type (MODULE::*cb)(transaction_type&,
+ phase_type&,
+ sc_core::sc_time&))
+ {
+ m_process.set_transport_ptr(mod, cb);
+ }
+
+ void register_invalidate_direct_mem_ptr(MODULE* mod,
+ void (MODULE::*cb)(sc_dt::uint64, sc_dt::uint64))
+ {
+ m_process.set_invalidate_direct_mem_ptr(mod, cb);
+ }
+
+private:
+ class process
+ : public tlm::tlm_bw_transport_if<TYPES>
+ , protected convenience_socket_cb_holder
+ {
+ public:
+ typedef sync_enum_type (MODULE::*TransportPtr)(transaction_type&,
+ phase_type&,
+ sc_core::sc_time&);
+ typedef void (MODULE::*InvalidateDirectMemPtr)(sc_dt::uint64,
+ sc_dt::uint64);
+
+ explicit process(simple_socket_base* owner)
+ : convenience_socket_cb_holder(owner), m_mod(0)
+ , m_transport_ptr(0)
+ , m_invalidate_direct_mem_ptr(0)
+ {
+ }
+
+ void set_transport_ptr(MODULE* mod, TransportPtr p)
+ {
+ if (m_transport_ptr) {
+ display_warning("non-blocking callback already registered");
+ return;
+ }
+ sc_assert(!m_mod || m_mod == mod);
+ m_mod = mod;
+ m_transport_ptr = p;
+ }
+
+ void set_invalidate_direct_mem_ptr(MODULE* mod, InvalidateDirectMemPtr p)
+ {
+ if (m_invalidate_direct_mem_ptr) {
+ display_warning("invalidate DMI callback already registered");
+ return;
+ }
+ sc_assert(!m_mod || m_mod == mod);
+ m_mod = mod;
+ m_invalidate_direct_mem_ptr = p;
+ }
+
+ sync_enum_type nb_transport_bw(transaction_type& trans, phase_type& phase, sc_core::sc_time& t)
+ {
+ if (m_transport_ptr) {
+ // forward call
+ sc_assert(m_mod);
+ return (m_mod->*m_transport_ptr)(trans, phase, t);
+ }
+ display_error("no transport callback registered");
+ return tlm::TLM_COMPLETED;
+ }
+
+ void invalidate_direct_mem_ptr(sc_dt::uint64 start_range,
+ sc_dt::uint64 end_range)
+ {
+ if (m_invalidate_direct_mem_ptr) {
+ // forward call
+ sc_assert(m_mod);
+ (m_mod->*m_invalidate_direct_mem_ptr)(start_range, end_range);
+ }
+ }
+
+ private:
+ MODULE* m_mod;
+ TransportPtr m_transport_ptr;
+ InvalidateDirectMemPtr m_invalidate_direct_mem_ptr;
+ };
+
+private:
+ const sc_core::sc_object* get_socket() const { return this; }
+private:
+ process m_process;
+};
+
+template< typename MODULE, unsigned int BUSWIDTH = 32
+ , typename TYPES = tlm::tlm_base_protocol_types >
+class simple_initiator_socket
+ : public simple_initiator_socket_b<MODULE,BUSWIDTH,TYPES>
+{
+ typedef simple_initiator_socket_b<MODULE,BUSWIDTH,TYPES> socket_b;
+public:
+ simple_initiator_socket() : socket_b() {}
+ explicit simple_initiator_socket(const char* name) : socket_b(name) {}
+};
+
+template< typename MODULE, unsigned int BUSWIDTH = 32
+ , typename TYPES = tlm::tlm_base_protocol_types >
+class simple_initiator_socket_optional
+ : public simple_initiator_socket_b<MODULE,BUSWIDTH,TYPES,sc_core::SC_ZERO_OR_MORE_BOUND>
+{
+ typedef simple_initiator_socket_b<MODULE,BUSWIDTH,TYPES,sc_core::SC_ZERO_OR_MORE_BOUND> socket_b;
+public:
+ simple_initiator_socket_optional() : socket_b() {}
+ explicit simple_initiator_socket_optional(const char* name) : socket_b(name) {}
+};
+
+
+// Tagged version
+
+template< typename MODULE, unsigned int BUSWIDTH, typename TYPES
+ , sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND >
+class simple_initiator_socket_tagged_b
+ : public tlm::tlm_initiator_socket<BUSWIDTH, TYPES, 1, POL>
+ , protected simple_socket_base
+{
+public:
+ typedef typename TYPES::tlm_payload_type transaction_type;
+ typedef typename TYPES::tlm_phase_type phase_type;
+ typedef tlm::tlm_sync_enum sync_enum_type;
+ typedef tlm::tlm_fw_transport_if<TYPES> fw_interface_type;
+ typedef tlm::tlm_bw_transport_if<TYPES> bw_interface_type;
+ typedef tlm::tlm_initiator_socket<BUSWIDTH,TYPES,1,POL> base_type;
+
+public:
+ static const char* default_name()
+ { return sc_core::sc_gen_unique_name("simple_initiator_socket_tagged"); }
+
+ explicit simple_initiator_socket_tagged_b(const char* n = default_name())
+ : base_type(n)
+ , m_process(this)
+ {
+ this->m_export.bind(m_process);
+ }
+
+ void register_nb_transport_bw(MODULE* mod,
+ sync_enum_type (MODULE::*cb)(int,
+ transaction_type&,
+ phase_type&,
+ sc_core::sc_time&),
+ int id)
+ {
+ m_process.set_transport_ptr(mod, cb);
+ m_process.set_transport_user_id(id);
+ }
+
+ void register_invalidate_direct_mem_ptr(MODULE* mod,
+ void (MODULE::*cb)(int, sc_dt::uint64, sc_dt::uint64),
+ int id)
+ {
+ m_process.set_invalidate_direct_mem_ptr(mod, cb);
+ m_process.set_invalidate_dmi_user_id(id);
+ }
+
+private:
+ class process
+ : public tlm::tlm_bw_transport_if<TYPES>
+ , protected convenience_socket_cb_holder
+ {
+ public:
+ typedef sync_enum_type (MODULE::*TransportPtr)(int,
+ transaction_type&,
+ phase_type&,
+ sc_core::sc_time&);
+ typedef void (MODULE::*InvalidateDirectMemPtr)(int,
+ sc_dt::uint64,
+ sc_dt::uint64);
+
+ explicit process(simple_socket_base* owner)
+ : convenience_socket_cb_holder(owner), m_mod(0)
+ , m_transport_ptr(0)
+ , m_invalidate_direct_mem_ptr(0)
+ , m_transport_user_id(0)
+ , m_invalidate_direct_mem_user_id(0)
+ {
+ }
+
+ void set_transport_user_id(int id) { m_transport_user_id = id; }
+ void set_invalidate_dmi_user_id(int id) { m_invalidate_direct_mem_user_id = id; }
+
+ void set_transport_ptr(MODULE* mod, TransportPtr p)
+ {
+ if (m_transport_ptr) {
+ display_warning("non-blocking callback already registered");
+ return;
+ }
+ sc_assert(!m_mod || m_mod == mod);
+ m_mod = mod;
+ m_transport_ptr = p;
+ }
+
+ void set_invalidate_direct_mem_ptr(MODULE* mod, InvalidateDirectMemPtr p)
+ {
+ if (m_invalidate_direct_mem_ptr) {
+ display_warning("invalidate DMI callback already registered");
+ return;
+ }
+ sc_assert(!m_mod || m_mod == mod);
+ m_mod = mod;
+ m_invalidate_direct_mem_ptr = p;
+ }
+
+ sync_enum_type nb_transport_bw(transaction_type& trans, phase_type& phase, sc_core::sc_time& t)
+ {
+ if (m_transport_ptr) {
+ // forward call
+ sc_assert(m_mod);
+ return (m_mod->*m_transport_ptr)(m_transport_user_id, trans, phase, t);
+ }
+ display_error("no transport callback registered");
+ return tlm::TLM_COMPLETED;
+ }
+
+ void invalidate_direct_mem_ptr(sc_dt::uint64 start_range,
+ sc_dt::uint64 end_range)
+ {
+ if (m_invalidate_direct_mem_ptr) {
+ // forward call
+ sc_assert(m_mod);
+ (m_mod->*m_invalidate_direct_mem_ptr)(m_invalidate_direct_mem_user_id, start_range, end_range);
+ }
+ }
+
+ private:
+ MODULE* m_mod;
+ TransportPtr m_transport_ptr;
+ InvalidateDirectMemPtr m_invalidate_direct_mem_ptr;
+ int m_transport_user_id;
+ int m_invalidate_direct_mem_user_id;
+ };
+
+private:
+ const sc_core::sc_object* get_socket() const { return this; }
+private:
+ process m_process;
+};
+
+template< typename MODULE, unsigned int BUSWIDTH = 32
+ , typename TYPES = tlm::tlm_base_protocol_types >
+class simple_initiator_socket_tagged
+ : public simple_initiator_socket_tagged_b<MODULE,BUSWIDTH,TYPES>
+{
+ typedef simple_initiator_socket_tagged_b<MODULE,BUSWIDTH,TYPES> socket_b;
+public:
+ simple_initiator_socket_tagged() : socket_b() {}
+ explicit simple_initiator_socket_tagged(const char* name) : socket_b(name) {}
+};
+
+template< typename MODULE, unsigned int BUSWIDTH = 32
+ , typename TYPES = tlm::tlm_base_protocol_types >
+class simple_initiator_socket_tagged_optional
+ : public simple_initiator_socket_tagged_b<MODULE,BUSWIDTH,TYPES,sc_core::SC_ZERO_OR_MORE_BOUND>
+{
+ typedef simple_initiator_socket_tagged_b<MODULE,BUSWIDTH,TYPES,sc_core::SC_ZERO_OR_MORE_BOUND> socket_b;
+public:
+ simple_initiator_socket_tagged_optional() : socket_b() {}
+ explicit simple_initiator_socket_tagged_optional(const char* name) : socket_b(name) {}
+};
+
+} // namespace tlm_utils
+#endif // TLM_UTILS_SIMPLE_INITIATOR_SOCKET_H_INCLUDED_
diff --git a/src/systemc/ext/tlm_utils/simple_target_socket.h b/src/systemc/ext/tlm_utils/simple_target_socket.h
new file mode 100644
index 000000000..7e4c3a197
--- /dev/null
+++ b/src/systemc/ext/tlm_utils/simple_target_socket.h
@@ -0,0 +1,1132 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+// *****************************************************************************
+// Modified by John Aynsley, Doulos, Feb 2009,
+// Fix a bug in simple_target_socket and simple_target_socket_tagged
+// with the addition of one new line of code in each: wait(*e);
+// *****************************************************************************
+
+// *****************************************************************************
+// Modified by John Aynsley on behalf of Robert Guenzel, May 2011,
+// Fix a bug in simple_target_socket and simple_target_socket_tagged
+// with the addition of one new line of code in each: wait(t);
+// *****************************************************************************
+
+
+#ifndef TLM_UTILS_SIMPLE_TARGET_SOCKET_H_INCLUDED_
+#define TLM_UTILS_SIMPLE_TARGET_SOCKET_H_INCLUDED_
+
+#ifndef SC_INCLUDE_DYNAMIC_PROCESSES // needed for sc_spawn
+# define SC_INCLUDE_DYNAMIC_PROCESSES
+#endif
+
+#include <systemc>
+#include <tlm>
+#include "tlm_utils/convenience_socket_bases.h"
+#include "tlm_utils/peq_with_get.h"
+
+namespace tlm_utils {
+
+template< typename MODULE, unsigned int BUSWIDTH, typename TYPES
+ , sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND >
+class simple_target_socket_b
+ : public tlm::tlm_target_socket<BUSWIDTH, TYPES, 1, POL>
+ , protected simple_socket_base
+{
+ friend class fw_process;
+ friend class bw_process;
+public:
+ typedef typename TYPES::tlm_payload_type transaction_type;
+ typedef typename TYPES::tlm_phase_type phase_type;
+ typedef tlm::tlm_sync_enum sync_enum_type;
+ typedef tlm::tlm_fw_transport_if<TYPES> fw_interface_type;
+ typedef tlm::tlm_bw_transport_if<TYPES> bw_interface_type;
+ typedef tlm::tlm_target_socket<BUSWIDTH,TYPES,1,POL> base_type;
+
+public:
+ static const char* default_name()
+ { return sc_core::sc_gen_unique_name("simple_target_socket"); }
+
+ explicit simple_target_socket_b(const char* n = default_name())
+ : base_type(n)
+ , m_fw_process(this)
+ , m_bw_process(this)
+ {
+ bind(m_fw_process);
+ }
+
+ using base_type::bind;
+
+ // bw transport must come thru us.
+ tlm::tlm_bw_transport_if<TYPES> * operator ->() {return &m_bw_process;}
+
+ // REGISTER_XXX
+ void register_nb_transport_fw(MODULE* mod,
+ sync_enum_type (MODULE::*cb)(transaction_type&,
+ phase_type&,
+ sc_core::sc_time&))
+ {
+ elaboration_check("register_nb_transport_fw");
+ m_fw_process.set_nb_transport_ptr(mod, cb);
+ }
+
+ void register_b_transport(MODULE* mod,
+ void (MODULE::*cb)(transaction_type&,
+ sc_core::sc_time&))
+ {
+ elaboration_check("register_b_transport");
+ m_fw_process.set_b_transport_ptr(mod, cb);
+ }
+
+ void register_transport_dbg(MODULE* mod,
+ unsigned int (MODULE::*cb)(transaction_type&))
+ {
+ elaboration_check("register_transport_dbg");
+ m_fw_process.set_transport_dbg_ptr(mod, cb);
+ }
+
+ void register_get_direct_mem_ptr(MODULE* mod,
+ bool (MODULE::*cb)(transaction_type&,
+ tlm::tlm_dmi&))
+ {
+ elaboration_check("register_get_direct_mem_ptr");
+ m_fw_process.set_get_direct_mem_ptr(mod, cb);
+ }
+
+protected:
+ void start_of_simulation()
+ {
+ base_type::start_of_simulation();
+ m_fw_process.start_of_simulation();
+ }
+
+private:
+ //make call on bw path.
+ sync_enum_type bw_nb_transport(transaction_type &trans, phase_type &phase, sc_core::sc_time &t)
+ {
+ return base_type::operator ->()->nb_transport_bw(trans, phase, t);
+ }
+
+ void bw_invalidate_direct_mem_ptr(sc_dt::uint64 s,sc_dt::uint64 e)
+ {
+ base_type::operator ->()->invalidate_direct_mem_ptr(s, e);
+ }
+
+ //Helper class to handle bw path calls
+ // Needed to detect transaction end when called from b_transport.
+ class bw_process : public tlm::tlm_bw_transport_if<TYPES>
+ {
+ public:
+ bw_process(simple_target_socket_b *p_own) : m_owner(p_own)
+ {
+ }
+
+ sync_enum_type nb_transport_bw(transaction_type &trans, phase_type &phase, sc_core::sc_time &t)
+ {
+ typename std::map<transaction_type*, sc_core::sc_event *>::iterator it =
+ m_owner->m_pending_trans.find(&trans);
+
+ if(it == m_owner->m_pending_trans.end()) {
+ // Not a blocking call, forward.
+ return m_owner->bw_nb_transport(trans, phase, t);
+
+ }
+
+ if (phase == tlm::END_REQ) {
+ m_owner->m_end_request.notify(sc_core::SC_ZERO_TIME);
+ return tlm::TLM_ACCEPTED;
+ }
+ if (phase == tlm::BEGIN_RESP) {
+ if (m_owner->m_current_transaction == &trans) {
+ m_owner->m_end_request.notify(sc_core::SC_ZERO_TIME);
+ }
+ //TODO: add response-accept delay?
+ it->second->notify(t);
+ m_owner->m_pending_trans.erase(it);
+ return tlm::TLM_COMPLETED;
+ }
+ m_owner->display_error("invalid phase received");
+ return tlm::TLM_COMPLETED;
+ }
+
+ void invalidate_direct_mem_ptr(sc_dt::uint64 s,sc_dt::uint64 e)
+ {
+ return m_owner->bw_invalidate_direct_mem_ptr(s, e);
+ }
+
+ private:
+ simple_target_socket_b *m_owner;
+ };
+
+ class fw_process : public tlm::tlm_fw_transport_if<TYPES>,
+ public tlm::tlm_mm_interface
+ {
+ public:
+ typedef sync_enum_type (MODULE::*NBTransportPtr)(transaction_type&,
+ phase_type&,
+ sc_core::sc_time&);
+ typedef void (MODULE::*BTransportPtr)(transaction_type&,
+ sc_core::sc_time&);
+ typedef unsigned int (MODULE::*TransportDbgPtr)(transaction_type&);
+ typedef bool (MODULE::*GetDirectMemPtr)(transaction_type&,
+ tlm::tlm_dmi&);
+
+ fw_process(simple_target_socket_b *p_own) :
+ m_owner(p_own),
+ m_mod(0),
+ m_nb_transport_ptr(0),
+ m_b_transport_ptr(0),
+ m_transport_dbg_ptr(0),
+ m_get_direct_mem_ptr(0),
+ m_peq(sc_core::sc_gen_unique_name("m_peq")),
+ m_response_in_progress(false)
+ {}
+
+ void start_of_simulation()
+ {
+ if (!m_b_transport_ptr && m_nb_transport_ptr) { // only spawn b2nb_thread, if needed
+ sc_core::sc_spawn_options opts;
+ opts.set_sensitivity(&m_peq.get_event());
+ opts.dont_initialize();
+ sc_core::sc_spawn(sc_bind(&fw_process::b2nb_thread, this),
+ sc_core::sc_gen_unique_name("b2nb_thread"), &opts);
+ }
+ }
+
+ void set_nb_transport_ptr(MODULE* mod, NBTransportPtr p)
+ {
+ if (m_nb_transport_ptr) {
+ m_owner->display_warning("non-blocking callback already registered");
+ return;
+ }
+ sc_assert(!m_mod || m_mod == mod);
+ m_mod = mod;
+ m_nb_transport_ptr = p;
+ }
+
+ void set_b_transport_ptr(MODULE* mod, BTransportPtr p)
+ {
+ if (m_b_transport_ptr) {
+ m_owner->display_warning("blocking callback already registered");
+ return;
+ }
+ sc_assert(!m_mod || m_mod == mod);
+ m_mod = mod;
+ m_b_transport_ptr = p;
+ }
+
+ void set_transport_dbg_ptr(MODULE* mod, TransportDbgPtr p)
+ {
+ if (m_transport_dbg_ptr) {
+ m_owner->display_warning("debug callback already registered");
+ return;
+ }
+ sc_assert(!m_mod || m_mod == mod);
+ m_mod = mod;
+ m_transport_dbg_ptr = p;
+ }
+
+ void set_get_direct_mem_ptr(MODULE* mod, GetDirectMemPtr p)
+ {
+ if (m_get_direct_mem_ptr) {
+ m_owner->display_warning("get DMI pointer callback already registered");
+ return;
+ }
+ sc_assert(!m_mod || m_mod == mod);
+ m_mod = mod;
+ m_get_direct_mem_ptr = p;
+ }
+// Interface implementation
+ sync_enum_type nb_transport_fw(transaction_type& trans,
+ phase_type& phase,
+ sc_core::sc_time& t)
+ {
+ if (m_nb_transport_ptr) {
+ // forward call
+ sc_assert(m_mod);
+ return (m_mod->*m_nb_transport_ptr)(trans, phase, t);
+ }
+
+ // nb->b conversion
+ if (m_b_transport_ptr) {
+ if (phase == tlm::BEGIN_REQ) {
+ // prepare thread to do blocking call
+ process_handle_class * ph = m_process_handle.get_handle(&trans);
+
+ if (!ph) { // create new dynamic process
+ ph = new process_handle_class(&trans);
+ m_process_handle.put_handle(ph);
+
+ sc_core::sc_spawn_options opts;
+ opts.dont_initialize();
+ opts.set_sensitivity(&ph->m_e);
+
+ sc_core::sc_spawn(sc_bind(&fw_process::nb2b_thread,this, ph),
+ sc_core::sc_gen_unique_name("nb2b_thread"), &opts);
+ }
+
+ ph->m_e.notify(t);
+ return tlm::TLM_ACCEPTED;
+ }
+ if (phase == tlm::END_RESP) {
+ m_response_in_progress = false;
+ m_end_response.notify(t);
+ return tlm::TLM_COMPLETED;
+ }
+ m_owner->display_error("invalid phase received");
+ return tlm::TLM_COMPLETED;
+ }
+ m_owner->display_error("no non-blocking transport callback registered");
+ return tlm::TLM_COMPLETED;
+ }
+
+ void b_transport(transaction_type& trans, sc_core::sc_time& t)
+ {
+ if (m_b_transport_ptr) {
+ // forward call
+ sc_assert(m_mod);
+ (m_mod->*m_b_transport_ptr)(trans, t);
+ return;
+ }
+
+ // b->nb conversion
+ if (m_nb_transport_ptr) {
+ m_peq.notify(trans, t);
+ t = sc_core::SC_ZERO_TIME;
+
+ mm_end_event_ext mm_ext;
+ const bool mm_added = !trans.has_mm();
+
+ if (mm_added) {
+ trans.set_mm(this);
+ trans.set_auto_extension(&mm_ext);
+ trans.acquire();
+ }
+
+ // wait until transaction is finished
+ sc_core::sc_event end_event;
+ m_owner->m_pending_trans[&trans] = &end_event;
+ sc_core::wait(end_event);
+
+ if (mm_added) {
+ // release will not delete the transaction, it will notify mm_ext.done
+ trans.release();
+ if (trans.get_ref_count()) {
+ sc_core::wait(mm_ext.done);
+ }
+ trans.set_mm(0);
+ }
+ return;
+ }
+
+ // should not be reached
+ m_owner->display_error("no blocking transport callback registered");
+ }
+
+ unsigned int transport_dbg(transaction_type& trans)
+ {
+ if (m_transport_dbg_ptr) {
+ // forward call
+ sc_assert(m_mod);
+ return (m_mod->*m_transport_dbg_ptr)(trans);
+ }
+ // No debug support
+ return 0;
+ }
+
+ bool get_direct_mem_ptr(transaction_type& trans,
+ tlm::tlm_dmi& dmi_data)
+ {
+ if (m_get_direct_mem_ptr) {
+ // forward call
+ sc_assert(m_mod);
+ return (m_mod->*m_get_direct_mem_ptr)(trans, dmi_data);
+ }
+ // No DMI support
+ dmi_data.allow_read_write();
+ dmi_data.set_start_address(0x0);
+ dmi_data.set_end_address((sc_dt::uint64)-1);
+ return false;
+ }
+
+ private:
+
+// dynamic process handler for nb2b conversion
+
+ class process_handle_class {
+ public:
+ explicit process_handle_class(transaction_type * trans)
+ : m_trans(trans),m_suspend(false) {}
+
+ transaction_type* m_trans;
+ sc_core::sc_event m_e;
+ bool m_suspend;
+ };
+
+ class process_handle_list {
+ public:
+ process_handle_list() {}
+
+ ~process_handle_list() {
+ for( typename std::vector<process_handle_class*>::iterator
+ it=v.begin(), end = v.end(); it != end; ++it )
+ delete *it;
+ }
+
+ process_handle_class* get_handle(transaction_type *trans)
+ {
+ typename std::vector<process_handle_class*>::iterator it;
+
+ for(it = v.begin(); it != v.end(); it++) {
+ if ((*it)->m_suspend) { // found suspended dynamic process, re-use it
+ (*it)->m_trans = trans; // replace to new one
+ (*it)->m_suspend = false;
+ return *it;
+ }
+ }
+ return NULL; // no suspended process
+ }
+
+ void put_handle(process_handle_class* ph)
+ {
+ v.push_back(ph);
+ }
+
+ private:
+ std::vector<process_handle_class*> v;
+ };
+
+ process_handle_list m_process_handle;
+
+
+ void nb2b_thread(process_handle_class* h)
+ {
+
+ while(1) {
+ transaction_type *trans = h->m_trans;
+ sc_core::sc_time t = sc_core::SC_ZERO_TIME;
+
+ // forward call
+ sc_assert(m_mod);
+ (m_mod->*m_b_transport_ptr)(*trans, t);
+
+ sc_core::wait(t);
+
+ // return path
+ while (m_response_in_progress) {
+ sc_core::wait(m_end_response);
+ }
+ t = sc_core::SC_ZERO_TIME;
+ phase_type phase = tlm::BEGIN_RESP;
+ sync_enum_type sync = m_owner->bw_nb_transport(*trans, phase, t);
+ if ( !(sync == tlm::TLM_COMPLETED ||
+ (sync == tlm::TLM_UPDATED && phase == tlm::END_RESP)) ) {
+ m_response_in_progress = true;
+ }
+
+ // suspend until next transaction
+ h->m_suspend = true;
+ sc_core::wait();
+ }
+ }
+
+ void b2nb_thread()
+ {
+ while (true) {
+ transaction_type* trans;
+ while ((trans = m_peq.get_next_transaction())!=0) {
+ sc_assert(m_mod);
+ sc_assert(m_nb_transport_ptr);
+ phase_type phase = tlm::BEGIN_REQ;
+ sc_core::sc_time t = sc_core::SC_ZERO_TIME;
+
+ switch ((m_mod->*m_nb_transport_ptr)(*trans, phase, t)) {
+ case tlm::TLM_COMPLETED:
+ {
+ // notify transaction is finished
+ typename std::map<transaction_type*, sc_core::sc_event *>::iterator it =
+ m_owner->m_pending_trans.find(trans);
+ sc_assert(it != m_owner->m_pending_trans.end());
+ it->second->notify(t);
+ m_owner->m_pending_trans.erase(it);
+ break;
+ }
+
+ case tlm::TLM_ACCEPTED:
+ case tlm::TLM_UPDATED:
+ switch (phase) {
+ case tlm::BEGIN_REQ:
+ m_owner->m_current_transaction = trans;
+ sc_core::wait(m_owner->m_end_request);
+ m_owner->m_current_transaction = 0;
+ break;
+
+ case tlm::END_REQ:
+ sc_core::wait(t);
+ break;
+
+ case tlm::BEGIN_RESP:
+ {
+ phase = tlm::END_RESP;
+ sc_core::wait(t); // This line is a bug fix added in TLM-2.0.2
+ t = sc_core::SC_ZERO_TIME;
+ (m_mod->*m_nb_transport_ptr)(*trans, phase, t);
+
+ // notify transaction is finished
+ typename std::map<transaction_type*, sc_core::sc_event *>::iterator it =
+ m_owner->m_pending_trans.find(trans);
+ sc_assert(it != m_owner->m_pending_trans.end());
+ it->second->notify(t);
+ m_owner->m_pending_trans.erase(it);
+ break;
+ }
+
+ default:
+ m_owner->display_error("invalid phase received");
+ }
+ break;
+
+ default:
+ m_owner->display_error("invalid sync value received");
+ }
+ }
+ sc_core::wait();
+ }
+ }
+
+ void free(tlm::tlm_generic_payload* trans)
+ {
+ mm_end_event_ext* ext = trans->template get_extension<mm_end_event_ext>();
+ sc_assert(ext);
+ // notif event first before freeing extensions (reset)
+ ext->done.notify();
+ trans->reset();
+ }
+
+ private:
+ struct mm_end_event_ext : public tlm::tlm_extension<mm_end_event_ext>
+ {
+ tlm::tlm_extension_base* clone() const { return NULL; }
+ void free() {}
+ void copy_from(tlm::tlm_extension_base const &) {}
+ sc_core::sc_event done;
+ };
+
+ private:
+ simple_target_socket_b *m_owner;
+ MODULE* m_mod;
+ NBTransportPtr m_nb_transport_ptr;
+ BTransportPtr m_b_transport_ptr;
+ TransportDbgPtr m_transport_dbg_ptr;
+ GetDirectMemPtr m_get_direct_mem_ptr;
+ peq_with_get<transaction_type> m_peq;
+ bool m_response_in_progress;
+ sc_core::sc_event m_end_response;
+ };
+
+private:
+ const sc_core::sc_object* get_socket() const { return this; }
+private:
+ fw_process m_fw_process;
+ bw_process m_bw_process;
+ std::map<transaction_type*, sc_core::sc_event *> m_pending_trans;
+ sc_core::sc_event m_end_request;
+ transaction_type* m_current_transaction;
+};
+
+template< typename MODULE, unsigned int BUSWIDTH = 32
+ , typename TYPES = tlm::tlm_base_protocol_types >
+class simple_target_socket
+ : public simple_target_socket_b<MODULE,BUSWIDTH,TYPES>
+{
+ typedef simple_target_socket_b<MODULE,BUSWIDTH,TYPES> socket_b;
+public:
+ simple_target_socket() : socket_b() {}
+ explicit simple_target_socket(const char* name) : socket_b(name) {}
+};
+
+template< typename MODULE, unsigned int BUSWIDTH = 32
+ , typename TYPES = tlm::tlm_base_protocol_types >
+class simple_target_socket_optional
+ : public simple_target_socket_b<MODULE,BUSWIDTH,TYPES,sc_core::SC_ZERO_OR_MORE_BOUND>
+{
+ typedef simple_target_socket_b<MODULE,BUSWIDTH,TYPES,sc_core::SC_ZERO_OR_MORE_BOUND> socket_b;
+public:
+ simple_target_socket_optional() : socket_b() {}
+ explicit simple_target_socket_optional(const char* name) : socket_b(name) {}
+};
+
+//ID Tagged version
+template< typename MODULE, unsigned int BUSWIDTH, typename TYPES
+ , sc_core::sc_port_policy POL = sc_core::SC_ONE_OR_MORE_BOUND >
+class simple_target_socket_tagged_b
+ : public tlm::tlm_target_socket<BUSWIDTH, TYPES, 1, POL>
+ , protected simple_socket_base
+{
+ friend class fw_process;
+ friend class bw_process;
+public:
+ typedef typename TYPES::tlm_payload_type transaction_type;
+ typedef typename TYPES::tlm_phase_type phase_type;
+ typedef tlm::tlm_sync_enum sync_enum_type;
+ typedef tlm::tlm_fw_transport_if<TYPES> fw_interface_type;
+ typedef tlm::tlm_bw_transport_if<TYPES> bw_interface_type;
+ typedef tlm::tlm_target_socket<BUSWIDTH,TYPES,1,POL> base_type;
+
+public:
+ static const char* default_name()
+ { return sc_core::sc_gen_unique_name("simple_target_socket_tagged"); }
+
+ explicit simple_target_socket_tagged_b(const char* n = default_name())
+ : base_type(n)
+ , m_fw_process(this)
+ , m_bw_process(this)
+ {
+ bind(m_fw_process);
+ }
+
+ using base_type::bind;
+
+ // bw transport must come thru us.
+ tlm::tlm_bw_transport_if<TYPES> * operator ->() {return &m_bw_process;}
+
+ // REGISTER_XXX
+ void register_nb_transport_fw(MODULE* mod,
+ sync_enum_type (MODULE::*cb)(int id,
+ transaction_type&,
+ phase_type&,
+ sc_core::sc_time&),
+ int id)
+ {
+ elaboration_check("register_nb_transport_fw");
+ m_fw_process.set_nb_transport_ptr(mod, cb);
+ m_fw_process.set_nb_transport_user_id(id);
+ }
+
+ void register_b_transport(MODULE* mod,
+ void (MODULE::*cb)(int id,
+ transaction_type&,
+ sc_core::sc_time&),
+ int id)
+ {
+ elaboration_check("register_b_transport");
+ m_fw_process.set_b_transport_ptr(mod, cb);
+ m_fw_process.set_b_transport_user_id(id);
+ }
+
+ void register_transport_dbg(MODULE* mod,
+ unsigned int (MODULE::*cb)(int id,
+ transaction_type&),
+ int id)
+ {
+ elaboration_check("register_transport_dbg");
+ m_fw_process.set_transport_dbg_ptr(mod, cb);
+ m_fw_process.set_transport_dbg_user_id(id);
+ }
+
+ void register_get_direct_mem_ptr(MODULE* mod,
+ bool (MODULE::*cb)(int id,
+ transaction_type&,
+ tlm::tlm_dmi&),
+ int id)
+ {
+ elaboration_check("register_get_direct_mem_ptr");
+ m_fw_process.set_get_direct_mem_ptr(mod, cb);
+ m_fw_process.set_get_dmi_user_id(id);
+ }
+
+protected:
+ void start_of_simulation()
+ {
+ base_type::start_of_simulation();
+ m_fw_process.start_of_simulation();
+ }
+
+private:
+ //make call on bw path.
+ sync_enum_type bw_nb_transport(transaction_type &trans, phase_type &phase, sc_core::sc_time &t)
+ {
+ return base_type::operator ->()->nb_transport_bw(trans, phase, t);
+ }
+
+ void bw_invalidate_direct_mem_ptr(sc_dt::uint64 s,sc_dt::uint64 e)
+ {
+ base_type::operator ->()->invalidate_direct_mem_ptr(s, e);
+ }
+
+ //Helper class to handle bw path calls
+ // Needed to detect transaction end when called from b_transport.
+ class bw_process : public tlm::tlm_bw_transport_if<TYPES>
+ {
+ public:
+ bw_process(simple_target_socket_tagged_b *p_own) : m_owner(p_own)
+ {
+ }
+
+ sync_enum_type nb_transport_bw(transaction_type &trans, phase_type &phase, sc_core::sc_time &t)
+ {
+ typename std::map<transaction_type*, sc_core::sc_event *>::iterator it =
+ m_owner->m_pending_trans.find(&trans);
+
+ if(it == m_owner->m_pending_trans.end()) {
+ // Not a blocking call, forward.
+ return m_owner->bw_nb_transport(trans, phase, t);
+ }
+ if (phase == tlm::END_REQ) {
+ m_owner->m_end_request.notify(sc_core::SC_ZERO_TIME);
+ return tlm::TLM_ACCEPTED;
+ }
+ if (phase == tlm::BEGIN_RESP) {
+ if (m_owner->m_current_transaction == &trans) {
+ m_owner->m_end_request.notify(sc_core::SC_ZERO_TIME);
+ }
+ //TODO: add response-accept delay?
+ it->second->notify(t);
+ m_owner->m_pending_trans.erase(it);
+ return tlm::TLM_COMPLETED;
+ }
+ m_owner->display_error("invalid phase received");
+ return tlm::TLM_COMPLETED;
+ }
+
+ void invalidate_direct_mem_ptr(sc_dt::uint64 s,sc_dt::uint64 e)
+ {
+ return m_owner->bw_invalidate_direct_mem_ptr(s, e);
+ }
+
+ private:
+ simple_target_socket_tagged_b *m_owner;
+ };
+
+ class fw_process : public tlm::tlm_fw_transport_if<TYPES>,
+ public tlm::tlm_mm_interface
+ {
+ public:
+ typedef sync_enum_type (MODULE::*NBTransportPtr)(int id,
+ transaction_type&,
+ phase_type&,
+ sc_core::sc_time&);
+ typedef void (MODULE::*BTransportPtr)(int id,
+ transaction_type&,
+ sc_core::sc_time&);
+ typedef unsigned int (MODULE::*TransportDbgPtr)(int id,
+ transaction_type&);
+ typedef bool (MODULE::*GetDirectMemPtr)(int id,
+ transaction_type&,
+ tlm::tlm_dmi&);
+
+ fw_process(simple_target_socket_tagged_b *p_own) :
+ m_owner(p_own),
+ m_mod(0),
+ m_nb_transport_ptr(0),
+ m_b_transport_ptr(0),
+ m_transport_dbg_ptr(0),
+ m_get_direct_mem_ptr(0),
+ m_nb_transport_user_id(0),
+ m_b_transport_user_id(0),
+ m_transport_dbg_user_id(0),
+ m_get_dmi_user_id(0),
+ m_peq(sc_core::sc_gen_unique_name("m_peq")),
+ m_response_in_progress(false)
+ {}
+
+ void start_of_simulation()
+ {
+ if (!m_b_transport_ptr && m_nb_transport_ptr) { // only spawn b2nb_thread, if needed
+ sc_core::sc_spawn_options opts;
+ opts.set_sensitivity(&m_peq.get_event());
+ opts.dont_initialize();
+ sc_core::sc_spawn(sc_bind(&fw_process::b2nb_thread, this),
+ sc_core::sc_gen_unique_name("b2nb_thread"), &opts);
+ }
+ }
+
+ void set_nb_transport_user_id(int id) { m_nb_transport_user_id = id; }
+ void set_b_transport_user_id(int id) { m_b_transport_user_id = id; }
+ void set_transport_dbg_user_id(int id) { m_transport_dbg_user_id = id; }
+ void set_get_dmi_user_id(int id) { m_get_dmi_user_id = id; }
+
+ void set_nb_transport_ptr(MODULE* mod, NBTransportPtr p)
+ {
+ if (m_nb_transport_ptr) {
+ m_owner->display_warning("non-blocking callback already registered");
+ return;
+ }
+ sc_assert(!m_mod || m_mod == mod);
+ m_mod = mod;
+ m_nb_transport_ptr = p;
+ }
+
+ void set_b_transport_ptr(MODULE* mod, BTransportPtr p)
+ {
+ if (m_b_transport_ptr) {
+ m_owner->display_warning("blocking callback already registered");
+ return;
+ }
+ sc_assert(!m_mod || m_mod == mod);
+ m_mod = mod;
+ m_b_transport_ptr = p;
+ }
+
+ void set_transport_dbg_ptr(MODULE* mod, TransportDbgPtr p)
+ {
+ if (m_transport_dbg_ptr) {
+ m_owner->display_warning("debug callback already registered");
+ return;
+ }
+ sc_assert(!m_mod || m_mod == mod);
+ m_mod = mod;
+ m_transport_dbg_ptr = p;
+ }
+
+ void set_get_direct_mem_ptr(MODULE* mod, GetDirectMemPtr p)
+ {
+ if (m_get_direct_mem_ptr) {
+ m_owner->display_warning("get DMI pointer callback already registered");
+ }
+ sc_assert(!m_mod || m_mod == mod);
+ m_mod = mod;
+ m_get_direct_mem_ptr = p;
+ }
+// Interface implementation
+ sync_enum_type nb_transport_fw(transaction_type& trans,
+ phase_type& phase,
+ sc_core::sc_time& t)
+ {
+ if (m_nb_transport_ptr) {
+ // forward call
+ sc_assert(m_mod);
+ return (m_mod->*m_nb_transport_ptr)(m_nb_transport_user_id, trans, phase, t);
+ }
+
+ // nb->b conversion
+ if (m_b_transport_ptr) {
+ if (phase == tlm::BEGIN_REQ) {
+
+ // prepare thread to do blocking call
+ process_handle_class * ph = m_process_handle.get_handle(&trans);
+
+ if (!ph) { // create new dynamic process
+ ph = new process_handle_class(&trans);
+ m_process_handle.put_handle(ph);
+
+ sc_core::sc_spawn_options opts;
+ opts.dont_initialize();
+ opts.set_sensitivity(&ph->m_e);
+
+ sc_core::sc_spawn(sc_bind(&fw_process::nb2b_thread, this, ph),
+ sc_core::sc_gen_unique_name("nb2b_thread"), &opts);
+ }
+
+ ph->m_e.notify(t);
+ return tlm::TLM_ACCEPTED;
+ }
+ if (phase == tlm::END_RESP) {
+ m_response_in_progress = false;
+ m_end_response.notify(t);
+ return tlm::TLM_COMPLETED;
+ }
+ m_owner->display_error("invalid phase");
+ return tlm::TLM_COMPLETED;
+ }
+
+ m_owner->display_error("no non-blocking transport callback registered");
+ return tlm::TLM_COMPLETED;
+ }
+
+ void b_transport(transaction_type& trans, sc_core::sc_time& t)
+ {
+ if (m_b_transport_ptr) {
+ // forward call
+ sc_assert(m_mod);
+ (m_mod->*m_b_transport_ptr)(m_b_transport_user_id, trans, t);
+ return;
+ }
+
+ // b->nb conversion
+ if (m_nb_transport_ptr) {
+ m_peq.notify(trans, t);
+ t = sc_core::SC_ZERO_TIME;
+
+ mm_end_event_ext mm_ext;
+ const bool mm_added = !trans.has_mm();
+
+ if (mm_added){
+ trans.set_mm(this);
+ trans.set_auto_extension(&mm_ext);
+ trans.acquire();
+ }
+
+ // wait until transaction is finished
+ sc_core::sc_event end_event;
+ m_owner->m_pending_trans[&trans] = &end_event;
+ sc_core::wait(end_event);
+
+ if (mm_added) {
+ // release will not delete the transaction, it will notify mm_ext.done
+ trans.release();
+ if (trans.get_ref_count()) {
+ sc_core::wait(mm_ext.done);
+ }
+ trans.set_mm(0);
+ }
+ return;
+ }
+
+ m_owner->display_error("no transport callback registered");
+ }
+
+ unsigned int transport_dbg(transaction_type& trans)
+ {
+ if (m_transport_dbg_ptr) {
+ // forward call
+ sc_assert(m_mod);
+ return (m_mod->*m_transport_dbg_ptr)(m_transport_dbg_user_id, trans);
+ }
+ // No debug support
+ return 0;
+ }
+
+ bool get_direct_mem_ptr(transaction_type& trans,
+ tlm::tlm_dmi& dmi_data)
+ {
+ if (m_get_direct_mem_ptr) {
+ // forward call
+ sc_assert(m_mod);
+ return (m_mod->*m_get_direct_mem_ptr)(m_get_dmi_user_id, trans, dmi_data);
+ }
+ // No DMI support
+ dmi_data.allow_read_write();
+ dmi_data.set_start_address(0x0);
+ dmi_data.set_end_address((sc_dt::uint64)-1);
+ return false;
+ }
+
+ private:
+// dynamic process handler for nb2b conversion
+
+ class process_handle_class {
+ public:
+ explicit process_handle_class(transaction_type * trans)
+ : m_trans(trans),m_suspend(false){}
+
+ transaction_type* m_trans;
+ sc_core::sc_event m_e;
+ bool m_suspend;
+ };
+
+ class process_handle_list {
+ public:
+ process_handle_list() {}
+
+ ~process_handle_list() {
+ for( typename std::vector<process_handle_class*>::iterator
+ it=v.begin(), end = v.end(); it != end; ++it )
+ delete *it;
+ }
+
+ process_handle_class* get_handle(transaction_type *trans)
+ {
+ typename std::vector<process_handle_class*>::iterator it;
+
+ for(it = v.begin(); it != v.end(); it++) {
+ if ((*it)->m_suspend) { // found suspended dynamic process, re-use it
+ (*it)->m_trans = trans; // replace to new one
+ (*it)->m_suspend = false;
+ return *it;
+ }
+ }
+ return NULL; // no suspended process
+ }
+
+ void put_handle(process_handle_class* ph)
+ {
+ v.push_back(ph);
+ }
+
+ private:
+ std::vector<process_handle_class*> v;
+ };
+
+ process_handle_list m_process_handle;
+
+ void nb2b_thread(process_handle_class* h)
+ {
+
+ while(1) {
+ transaction_type * trans = h->m_trans;
+ sc_core::sc_time t = sc_core::SC_ZERO_TIME;
+
+ // forward call
+ sc_assert(m_mod);
+ (m_mod->*m_b_transport_ptr)(m_b_transport_user_id, *trans, t);
+
+ sc_core::wait(t);
+
+ // return path
+ while (m_response_in_progress) {
+ sc_core::wait(m_end_response);
+ }
+ t = sc_core::SC_ZERO_TIME;
+ phase_type phase = tlm::BEGIN_RESP;
+ sync_enum_type sync = m_owner->bw_nb_transport(*trans, phase, t);
+ if ( !(sync == tlm::TLM_COMPLETED ||
+ (sync == tlm::TLM_UPDATED && phase == tlm::END_RESP)) ) {
+ m_response_in_progress = true;
+ }
+
+ // suspend until next transaction
+ h->m_suspend = true;
+ sc_core::wait();
+ }
+ }
+
+ void b2nb_thread()
+ {
+ while (true) {
+ transaction_type* trans;
+ while ((trans = m_peq.get_next_transaction())!=0) {
+ sc_assert(m_mod);
+ sc_assert(m_nb_transport_ptr);
+ phase_type phase = tlm::BEGIN_REQ;
+ sc_core::sc_time t = sc_core::SC_ZERO_TIME;
+
+ switch ((m_mod->*m_nb_transport_ptr)(m_nb_transport_user_id, *trans, phase, t)) {
+ case tlm::TLM_COMPLETED:
+ {
+ // notify transaction is finished
+ typename std::map<transaction_type*, sc_core::sc_event *>::iterator it =
+ m_owner->m_pending_trans.find(trans);
+ sc_assert(it != m_owner->m_pending_trans.end());
+ it->second->notify(t);
+ m_owner->m_pending_trans.erase(it);
+ break;
+ }
+
+ case tlm::TLM_ACCEPTED:
+ case tlm::TLM_UPDATED:
+ switch (phase) {
+ case tlm::BEGIN_REQ:
+ m_owner->m_current_transaction = trans;
+ sc_core::wait(m_owner->m_end_request);
+ m_owner->m_current_transaction = 0;
+ break;
+
+ case tlm::END_REQ:
+ sc_core::wait(t);
+ break;
+
+ case tlm::BEGIN_RESP:
+ {
+ phase = tlm::END_RESP;
+ sc_core::wait(t); // This line is a bug fix added in TLM-2.0.2
+ t = sc_core::SC_ZERO_TIME;
+ (m_mod->*m_nb_transport_ptr)(m_nb_transport_user_id, *trans, phase, t);
+
+ // notify transaction is finished
+ typename std::map<transaction_type*, sc_core::sc_event *>::iterator it =
+ m_owner->m_pending_trans.find(trans);
+ sc_assert(it != m_owner->m_pending_trans.end());
+ it->second->notify(t);
+ m_owner->m_pending_trans.erase(it);
+ break;
+ }
+
+ default:
+ m_owner->display_error("invalid phase received");
+ };
+ break;
+
+ default:
+ m_owner->display_error("invalid sync value received");
+ }
+ }
+ sc_core::wait();
+ }
+ }
+
+ void free(tlm::tlm_generic_payload* trans)
+ {
+ mm_end_event_ext* ext = trans->template get_extension<mm_end_event_ext>();
+ sc_assert(ext);
+ // notif event first before freeing extensions (reset)
+ ext->done.notify();
+ trans->reset();
+ }
+
+ private:
+ struct mm_end_event_ext : public tlm::tlm_extension<mm_end_event_ext>
+ {
+ tlm::tlm_extension_base* clone() const { return NULL; }
+ void free() {}
+ void copy_from(tlm::tlm_extension_base const &) {}
+ sc_core::sc_event done;
+ };
+
+ private:
+ simple_target_socket_tagged_b *m_owner;
+ MODULE* m_mod;
+ NBTransportPtr m_nb_transport_ptr;
+ BTransportPtr m_b_transport_ptr;
+ TransportDbgPtr m_transport_dbg_ptr;
+ GetDirectMemPtr m_get_direct_mem_ptr;
+ int m_nb_transport_user_id;
+ int m_b_transport_user_id;
+ int m_transport_dbg_user_id;
+ int m_get_dmi_user_id;
+ peq_with_get<transaction_type> m_peq;
+ bool m_response_in_progress;
+ sc_core::sc_event m_end_response;
+ };
+
+private:
+ const sc_core::sc_object* get_socket() const { return this; }
+private:
+ fw_process m_fw_process;
+ bw_process m_bw_process;
+ std::map<transaction_type*, sc_core::sc_event *> m_pending_trans;
+ sc_core::sc_event m_end_request;
+ transaction_type* m_current_transaction;
+};
+
+template< typename MODULE, unsigned int BUSWIDTH = 32
+ , typename TYPES = tlm::tlm_base_protocol_types >
+class simple_target_socket_tagged
+ : public simple_target_socket_tagged_b<MODULE,BUSWIDTH,TYPES>
+{
+ typedef simple_target_socket_tagged_b<MODULE,BUSWIDTH,TYPES> socket_b;
+public:
+ simple_target_socket_tagged() : socket_b() {}
+ explicit simple_target_socket_tagged(const char* name) : socket_b(name) {}
+};
+
+template< typename MODULE, unsigned int BUSWIDTH = 32
+ , typename TYPES = tlm::tlm_base_protocol_types >
+class simple_target_socket_tagged_optional
+ : public simple_target_socket_tagged_b<MODULE,BUSWIDTH,TYPES,sc_core::SC_ZERO_OR_MORE_BOUND>
+{
+ typedef simple_target_socket_tagged_b<MODULE,BUSWIDTH,TYPES,sc_core::SC_ZERO_OR_MORE_BOUND> socket_b;
+public:
+ simple_target_socket_tagged_optional() : socket_b() {}
+ explicit simple_target_socket_tagged_optional(const char* name) : socket_b(name) {}
+};
+
+} // namespace tlm_utils
+#endif // TLM_UTILS_SIMPLE_TARGET_SOCKET_H_INCLUDED_
diff --git a/src/systemc/ext/tlm_utils/tlm_quantumkeeper.h b/src/systemc/ext/tlm_utils/tlm_quantumkeeper.h
new file mode 100644
index 000000000..ed211665f
--- /dev/null
+++ b/src/systemc/ext/tlm_utils/tlm_quantumkeeper.h
@@ -0,0 +1,172 @@
+/*****************************************************************************
+
+ Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
+ more contributor license agreements. See the NOTICE file distributed
+ with this work for additional information regarding copyright ownership.
+ Accellera licenses this file to you under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied. See the License for the specific language governing
+ permissions and limitations under the License.
+
+ *****************************************************************************/
+
+// 20-Mar-2009 John Aynsley Add set_and_sync() method
+
+
+#ifndef __TLM_QUANTUMKEEPER_H__
+#define __TLM_QUANTUMKEEPER_H__
+
+#include "tlm_core/tlm_2/tlm_quantum/tlm_global_quantum.h"
+
+namespace tlm_utils {
+
+ //
+ // tlm_quantumkeeper class
+ //
+ // The tlm_quantumkeeper class is used to keep track of the local time in
+ // an initiator (how much it has run ahead of the SystemC time), to
+ // synchronize with SystemC time etc.
+ //
+ class tlm_quantumkeeper
+ {
+ public:
+ //
+ // Static setters/getters for the global quantum value.
+ //
+ // The global quantum is the maximum time an initiator can run ahead of
+ // systemC time. All initiators will synchronize on timingpoints that are
+ // multiples of the global quantum value.
+ //
+ static void set_global_quantum(const sc_core::sc_time& t)
+ {
+ tlm::tlm_global_quantum::instance().set(t);
+ }
+
+ static const sc_core::sc_time& get_global_quantum()
+ {
+ return tlm::tlm_global_quantum::instance().get();
+ }
+
+ public:
+ tlm_quantumkeeper() :
+ m_next_sync_point(sc_core::SC_ZERO_TIME),
+ m_local_time(sc_core::SC_ZERO_TIME)
+ {
+ }
+
+ virtual ~tlm_quantumkeeper() {}
+
+ //
+ // Increment the local time (the time the initiator is ahead of the
+ // systemC time) After incrementing the local time an initiator should
+ // check (with the need_sync method) if a sync is required.
+ //
+ virtual void inc(const sc_core::sc_time& t)
+ {
+ m_local_time += t;
+ }
+
+ //
+ // Sets the local time (the time the initiator is ahead of the
+ // systemC time) After changing the local time an initiator should
+ // check (with the need_sync method) if a sync is required.
+ //
+ virtual void set(const sc_core::sc_time& t)
+ {
+ m_local_time = t;
+ }
+
+ //
+ // Checks if a sync to systemC is required for this initiator. This will
+ // be the case if the local time becomes greater than the local (current)
+ // quantum value for this initiator.
+ //
+ virtual bool need_sync() const
+ {
+ return sc_core::sc_time_stamp() + m_local_time >= m_next_sync_point;
+ }
+
+ //
+ // Synchronize to systemC. This call will do a wait for the time the
+ // initiator was running ahead of systemC time and reset the
+ // tlm_quantumkeeper.
+ //
+ virtual void sync()
+ {
+ sc_core::wait(m_local_time);
+ reset();
+ }
+
+ //
+ // Non-virtual convenience method to set the local time and sync only if needed
+ //
+ void set_and_sync(const sc_core::sc_time& t)
+ {
+ set(t);
+ if (need_sync())
+ sync();
+ }
+
+ //
+ // Resets the local time to SC_ZERO_TIME and computes the value of the
+ // next local quantum. This method should be called by an initiator after
+ // a wait because of a synchronization request by a target (TLM_ACCEPTED,
+ // or TLM_UPDATED).
+ //
+ virtual void reset()
+ {
+ m_local_time = sc_core::SC_ZERO_TIME;
+ m_next_sync_point = sc_core::sc_time_stamp() + compute_local_quantum();
+ }
+
+ //
+ // Helper function to get the current systemC time, taken the local time
+ // into account. The current systemC time is calculated as the time
+ // returned by sc_time_stamp incremeneted with the time the initiator is
+ // running ahead.
+ //
+ virtual sc_core::sc_time get_current_time() const
+ {
+ return sc_core::sc_time_stamp() + m_local_time;
+ }
+
+ //
+ // Helper functions to get the time the initiator is running ahead of
+ // systenC (local time). This time should be passed to a target in the
+ // nb_transport call
+ //
+ virtual sc_core::sc_time get_local_time() const
+ {
+ return m_local_time;
+ }
+
+ protected:
+ //
+ // Calculate the next local quantum for this initiator.
+ //
+ // The method can be overloaded in a derived object if an initiator wants
+ // to use another local quantum. This derived object should also take the
+ // global quantum into account. It's local quantum should not be set to a
+ // value that is larger than the quantum returned by the
+ // compute_local_quantum of the tlm_global_quantum singleton.
+ //
+ virtual sc_core::sc_time compute_local_quantum()
+ {
+ return tlm::tlm_global_quantum::instance().compute_local_quantum();
+ }
+
+ protected:
+ sc_core::sc_time m_next_sync_point;
+ sc_core::sc_time m_local_time;
+ };
+
+} // namespace tlm
+
+#endif