From a60868f5d5ddf565ddb8ce340ad6f1509f3cdf41 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Tue, 8 May 2018 19:01:17 -0700 Subject: systemc: Seperate the "external" header interface. Most (but not all) of the SystemC headers are part of the "external" interface that an existing, standard compliant module would include through or . Since those follow slightly different rules (relative includes, no gem5 includes), this change separates them out so that they're easier to identify. Also, this change moves the other files into a "core" subdirectory, with the intention to add a "dt", aka data type, directory some time in the future when those standard defined types are implemented. Change-Id: Ida63f9cc0bc0431024d4dd691cc5b22b944a99a8 Reviewed-on: https://gem5-review.googlesource.com/10835 Reviewed-by: Jason Lowe-Power Maintainer: Gabe Black --- src/systemc/ext/core/sc_attr.hh | 98 +++++++++++++ src/systemc/ext/core/sc_event.hh | 151 ++++++++++++++++++++ src/systemc/ext/core/sc_export.hh | 101 ++++++++++++++ src/systemc/ext/core/sc_interface.hh | 57 ++++++++ src/systemc/ext/core/sc_main.hh | 44 ++++++ src/systemc/ext/core/sc_module.hh | 246 +++++++++++++++++++++++++++++++++ src/systemc/ext/core/sc_module_name.hh | 56 ++++++++ src/systemc/ext/core/sc_object.hh | 80 +++++++++++ src/systemc/ext/core/sc_port.hh | 192 +++++++++++++++++++++++++ src/systemc/ext/core/sc_prim.hh | 97 +++++++++++++ src/systemc/ext/core/sc_sensitive.hh | 52 +++++++ src/systemc/ext/core/sc_time.hh | 98 +++++++++++++ 12 files changed, 1272 insertions(+) create mode 100644 src/systemc/ext/core/sc_attr.hh create mode 100644 src/systemc/ext/core/sc_event.hh create mode 100644 src/systemc/ext/core/sc_export.hh create mode 100644 src/systemc/ext/core/sc_interface.hh create mode 100644 src/systemc/ext/core/sc_main.hh create mode 100644 src/systemc/ext/core/sc_module.hh create mode 100644 src/systemc/ext/core/sc_module_name.hh create mode 100644 src/systemc/ext/core/sc_object.hh create mode 100644 src/systemc/ext/core/sc_port.hh create mode 100644 src/systemc/ext/core/sc_prim.hh create mode 100644 src/systemc/ext/core/sc_sensitive.hh create mode 100644 src/systemc/ext/core/sc_time.hh (limited to 'src/systemc/ext/core') diff --git a/src/systemc/ext/core/sc_attr.hh b/src/systemc/ext/core/sc_attr.hh new file mode 100644 index 000000000..d7baa149d --- /dev/null +++ b/src/systemc/ext/core/sc_attr.hh @@ -0,0 +1,98 @@ +/* + * Copyright 2018 Google, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer; + * redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution; + * neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Authors: Gabe Black + */ + +#ifndef __SYSTEMC_EXT_CORE_SC_ATTR_HH__ +#define __SYSTEMC_EXT_CORE_SC_ATTR_HH__ + +#include + +namespace sc_core +{ + +class sc_attr_base +{ + public: + sc_attr_base(const std::string &); + sc_attr_base(const sc_attr_base &); + virtual ~sc_attr_base(); + + const std::string &name() const; + + protected: + void warn_unimpl(const char *func); + + private: + // Disabled + sc_attr_base(); + sc_attr_base &operator = (const sc_attr_base &); +}; + +template +class sc_attribute : public sc_attr_base +{ + public: + sc_attribute(const std::string &_name) : sc_attr_base(_name) + { + warn_unimpl(__PRETTY_FUNCTION__); + } + sc_attribute(const std::string &_name, const T &t) : + sc_attr_base(_name), value(t) + { + warn_unimpl(__PRETTY_FUNCTION__); + } + sc_attribute(const sc_attribute &other) : + sc_attr_base(other.name()), value(other.value) + { + warn_unimpl(__PRETTY_FUNCTION__); + } + virtual ~sc_attribute() { warn_unimpl(__PRETTY_FUNCTION__); } + T value; + + private: + // Disabled + sc_attribute() {} + sc_attribute &operator = (const sc_attribute &) { return *this; } +}; + +class sc_attr_cltn +{ + public: + typedef sc_attr_base *elem_type; + typedef elem_type *iterator; + typedef const elem_type *const_iterator; + + iterator begin(); + const_iterator begin() const; + iterator end(); + const_iterator end() const; +}; + +} // namespace sc_core + +#endif //__SYSTEMC_EXT_CORE_SC_ATTR_HH__ diff --git a/src/systemc/ext/core/sc_event.hh b/src/systemc/ext/core/sc_event.hh new file mode 100644 index 000000000..d4d719b95 --- /dev/null +++ b/src/systemc/ext/core/sc_event.hh @@ -0,0 +1,151 @@ +/* + * Copyright 2018 Google, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer; + * redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution; + * neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Authors: Gabe Black + */ + +#ifndef __SYSTEMC_EXT_CORE_SC_EVENT_HH__ +#define __SYSTEMC_EXT_CORE_SC_EVENT_HH__ + +#include + +#include "sc_time.hh" + +namespace sc_core +{ + +class sc_event; +class sc_event_and_expr; +class sc_event_or_expr; +class sc_object; +class sc_port_base; + +class sc_event_finder +{ + protected: + void warn_unimpl(const char *func) const; +}; + +template +class sc_event_finder_t : public sc_event_finder +{ + public: + sc_event_finder_t(const sc_port_base &, + const sc_event & (IF::*event_method)() const) + { + warn_unimpl(__PRETTY_FUNCTION__); + } +}; + +class sc_event_and_list +{ + public: + sc_event_and_list(); + sc_event_and_list(const sc_event_and_list &); + sc_event_and_list(const sc_event &); + sc_event_and_list &operator = (const sc_event_and_list &); + + int size() const; + void swap(sc_event_and_list &); + + sc_event_and_list &operator &= (const sc_event &); + sc_event_and_list &operator &= (const sc_event_and_list &); + + sc_event_and_expr operator & (const sc_event &) const; + sc_event_and_expr operator & (const sc_event_and_list &); +}; + +class sc_event_or_list +{ + public: + sc_event_or_list(); + sc_event_or_list(const sc_event_or_list &); + sc_event_or_list(const sc_event &); + sc_event_or_list& operator = (const sc_event_or_list &); + ~sc_event_or_list(); + + int size() const; + void swap(sc_event_or_list &); + + sc_event_or_list &operator |= (const sc_event &); + sc_event_or_list &operator |= (const sc_event_or_list &); + + sc_event_or_expr operator | (const sc_event &) const; + sc_event_or_expr operator | (const sc_event_or_list &) const; +}; + +class sc_event_and_expr +{ + public: + operator const sc_event_and_list &() const; +}; + +sc_event_and_expr operator & (sc_event_and_expr, sc_event const &); +sc_event_and_expr operator & (sc_event_and_expr, sc_event_and_list const &); + +class sc_event_or_expr +{ + public: + operator const sc_event_or_list &() const; +}; + +sc_event_or_expr operator | (sc_event_or_expr, sc_event const &); +sc_event_or_expr operator | (sc_event_or_expr, sc_event_or_list const &); + +class sc_event +{ + public: + sc_event(); + explicit sc_event(const char *); + ~sc_event(); + + const char *name() const; + const char *basename() const; + bool in_hierarchy() const; + sc_object *get_parent_object() const; + + void notify(); + void notify(const sc_time &); + void notify(double, sc_time_unit); + void cancel(); + + sc_event_and_expr operator & (const sc_event &) const; + sc_event_and_expr operator & (const sc_event_and_list &) const; + sc_event_or_expr operator | (const sc_event &) const; + sc_event_or_expr operator | (const sc_event_or_list &) const; + + private: + // Disabled + sc_event(const sc_event &) {} + sc_event &operator = (const sc_event &) { return *this; } +}; + +const std::vector &sc_get_top_level_events(); +sc_event *sc_find_event(const char *); + +} // namespace sc_core + +#endif //__SYSTEMC_EXT_CORE_SC_INTERFACE_HH__ diff --git a/src/systemc/ext/core/sc_export.hh b/src/systemc/ext/core/sc_export.hh new file mode 100644 index 000000000..dc2176492 --- /dev/null +++ b/src/systemc/ext/core/sc_export.hh @@ -0,0 +1,101 @@ +/* + * Copyright 2018 Google, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer; + * redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution; + * neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Authors: Gabe Black + */ + +#ifndef __SYSTEMC_EXT_CORE_SC_EXPORT_HH__ +#define __SYSTEMC_EXT_CORE_SC_EXPORT_HH__ + +#include "sc_object.hh" + +namespace sc_core +{ + +class sc_interface; + +class sc_export_base : public sc_object +{ + public: + void warn_unimpl(const char *func) const; +}; + +template +class sc_export : public sc_export_base +{ + public: + sc_export() { warn_unimpl(__PRETTY_FUNCTION__); } + explicit sc_export(const char *) { warn_unimpl(__PRETTY_FUNCTION__); } + virtual ~sc_export() { warn_unimpl(__PRETTY_FUNCTION__); }; + + virtual const char *kind() const { return "sc_export"; } + + void operator () (IF &) { warn_unimpl(__PRETTY_FUNCTION__); }; + virtual void bind(IF &) { warn_unimpl(__PRETTY_FUNCTION__); }; + operator IF & () { warn_unimpl(__PRETTY_FUNCTION__); }; + operator const IF & () const { warn_unimpl(__PRETTY_FUNCTION__); }; + + IF * + operator -> () + { + warn_unimpl(__PRETTY_FUNCTION__); + return nullptr; + } + const IF * + operator -> () const + { + warn_unimpl(__PRETTY_FUNCTION__); + return nullptr; + } + + virtual sc_interface * + get_iterface() + { + warn_unimpl(__PRETTY_FUNCTION__); + return nullptr; + } + virtual const sc_interface * + get_interface() const + { + warn_unimpl(__PRETTY_FUNCTION__); + return nullptr; + } + + protected: + virtual void before_end_of_elaboration() {} + virtual void end_of_elaboration() {} + virtual void start_of_simulation() {} + virtual void end_of_simulation() {} + + private: + // Disabled + sc_export(const sc_export &); + sc_export &operator = (const sc_export &); +}; + +} // namespace sc_core + +#endif //__SYSTEMC_EXT_CORE_SC_EXPORT_HH__ diff --git a/src/systemc/ext/core/sc_interface.hh b/src/systemc/ext/core/sc_interface.hh new file mode 100644 index 000000000..2073f5362 --- /dev/null +++ b/src/systemc/ext/core/sc_interface.hh @@ -0,0 +1,57 @@ +/* + * Copyright 2018 Google, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer; + * redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution; + * neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Authors: Gabe Black + */ + +#ifndef __SYSTEMC_EXT_CORE_SC_INTERFACE_HH__ +#define __SYSTEMC_EXT_CORE_SC_INTERFACE_HH__ + +namespace sc_core +{ + +class sc_port_base; +class sc_event; + +class sc_interface +{ + public: + virtual void register_port(sc_port_base &, const char *); + virtual const sc_event &default_event() const; + virtual ~sc_interface(); + + protected: + sc_interface(); + + private: + // Disabled + sc_interface(const sc_interface &) {} + sc_interface &operator = (const sc_interface &) { return *this; } +}; + +} // namespace sc_core + +#endif //__SYSTEMC_EXT_CORE_SC_INTERFACE_HH__ diff --git a/src/systemc/ext/core/sc_main.hh b/src/systemc/ext/core/sc_main.hh new file mode 100644 index 000000000..9bf0d0aae --- /dev/null +++ b/src/systemc/ext/core/sc_main.hh @@ -0,0 +1,44 @@ +/* + * Copyright 2018 Google, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer; + * redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution; + * neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Authors: Gabe Black + */ + +#ifndef __SYSTEMC_EXT_CORE_SC_MAIN_HH__ +#define __SYSTEMC_EXT_CORE_SC_MAIN_HH__ + +extern "C" int sc_main(int argc, char *argv[]); + +namespace sc_core +{ + extern "C" int sc_argc(); + + // The standard version of this function doesn't have these "const" + // qualifiers, but the canonical SystemC implementation does. + extern "C" const char *const *sc_argv(); +} // namespace sc_core + +#endif //__SYSTEMC_EXT_CORE_SC_MAIN_HH__ diff --git a/src/systemc/ext/core/sc_module.hh b/src/systemc/ext/core/sc_module.hh new file mode 100644 index 000000000..4c4ebb269 --- /dev/null +++ b/src/systemc/ext/core/sc_module.hh @@ -0,0 +1,246 @@ +/* + * Copyright 2018 Google, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer; + * redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution; + * neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Authors: Gabe Black + */ + +#ifndef __SYSTEMC_CORE_EXT_SC_MODULE_HH__ +#define __SYSTEMC_CORE_EXT_SC_MODULE_HH__ + +#include + +#include "sc_object.hh" +#include "sc_sensitive.hh" +#include "sc_time.hh" + +namespace sc_core +{ + +template +class sc_in; +template +class sc_out; +template +class sc_inout; +template +class sc_signal_in_if; + +class sc_event; +class sc_event_and_list; +class sc_event_or_list; +class sc_module_name; + +class sc_bind_proxy +{ + public: + sc_bind_proxy(const sc_interface &interface); + sc_bind_proxy(const sc_port_base &port); +}; + +extern const sc_bind_proxy SC_BIND_PROXY_NIL; + +class sc_module : public sc_object +{ + public: + virtual ~sc_module(); + + virtual const char *kind() const; + + void operator () (const sc_bind_proxy &p001, + const sc_bind_proxy &p002 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p003 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p004 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p005 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p006 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p007 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p008 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p009 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p010 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p011 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p012 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p013 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p014 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p015 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p016 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p017 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p018 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p019 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p020 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p021 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p022 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p023 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p024 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p025 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p026 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p027 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p028 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p029 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p030 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p031 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p032 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p033 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p034 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p035 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p036 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p037 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p038 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p039 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p040 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p041 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p042 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p043 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p044 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p045 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p046 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p047 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p048 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p049 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p050 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p051 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p052 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p053 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p054 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p055 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p056 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p057 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p058 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p059 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p060 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p061 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p062 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p063 = SC_BIND_PROXY_NIL, + const sc_bind_proxy &p064 = SC_BIND_PROXY_NIL); + + virtual const std::vector &get_child_objects() const; + virtual const std::vector &get_child_events() const; + + protected: + sc_module(const sc_module_name &); + sc_module(); + + void reset_signal_is(const sc_in &, bool); + void reset_signal_is(const sc_inout &, bool); + void reset_signal_is(const sc_out &, bool); + void reset_signal_is(const sc_signal_in_if &, bool); + + void async_reset_signal_is(const sc_in &, bool); + void async_reset_signal_is(const sc_inout &, bool); + void async_reset_signal_is(const sc_out &, bool); + void async_reset_signal_is(const sc_signal_in_if &, bool); + + sc_sensitive sensitive; + + void dont_initialize(); + void set_stack_size(size_t); + + void next_trigger(); + void next_trigger(const sc_event &); + void next_trigger(const sc_event_or_list &); + void next_trigger(const sc_event_and_list &); + void next_trigger(const sc_time &); + void next_trigger(double, sc_time_unit); + void next_trigger(const sc_time &, const sc_event &); + void next_trigger(double, sc_time_unit, const sc_event &); + void next_trigger(const sc_time &, const sc_event_or_list &); + void next_trigger(double, sc_time_unit, const sc_event_or_list &); + void next_trigger(const sc_time &, const sc_event_and_list &); + void next_trigger(double, sc_time_unit, const sc_event_and_list &); + + void wait(); + void wait(int); + void wait(const sc_event &); + void wait(const sc_event_or_list &); + void wait(const sc_event_and_list &); + void wait(const sc_time &); + void wait(double, sc_time_unit); + void wait(const sc_time &, const sc_event &); + void wait(double, sc_time_unit, const sc_event &); + void wait(const sc_time &, const sc_event_or_list &); + void wait(double, sc_time_unit, const sc_event_or_list &); + void wait(const sc_time &, const sc_event_and_list &); + void wait(double, sc_time_unit, const sc_event_and_list &); + + virtual void before_end_of_elaboration() {} + virtual void end_of_elaboration() {} + virtual void start_of_simulation() {} + virtual void end_of_simulation() {} + + private: + // Disabled + sc_module(const sc_module &) : sc_object() {}; + sc_module &operator = (const sc_module &) { return *this; } +}; + +void next_trigger(); +void next_trigger(const sc_event &); +void next_trigger(const sc_event_or_list &); +void next_trigger(const sc_event_and_list &); +void next_trigger(const sc_time &); +void next_trigger(double, sc_time_unit); +void next_trigger(const sc_time &, const sc_event &); +void next_trigger(double, sc_time_unit, const sc_event &); +void next_trigger(const sc_time &, const sc_event_or_list &); +void next_trigger(double, sc_time_unit, const sc_event_or_list &); +void next_trigger(const sc_time &, const sc_event_and_list &); +void next_trigger(double, sc_time_unit, const sc_event_and_list &); + +void wait(); +void wait(int); +void wait(const sc_event &); +void wait(const sc_event_or_list &); +void wait(const sc_event_and_list &); +void wait(const sc_time &); +void wait(double, sc_time_unit); +void wait(const sc_time &, const sc_event &); +void wait(double, sc_time_unit, const sc_event &); +void wait(const sc_time &, const sc_event_or_list &); +void wait(double, sc_time_unit, const sc_event_or_list &); +void wait(const sc_time &, const sc_event_and_list &); +void wait(double, sc_time_unit, const sc_event_and_list &); + +#define SC_MODULE(name) struct name : ::sc_core::sc_module + +#define SC_CTOR(name) \ + typedef name SC_CURRENT_USER_MODULE; \ + name(::sc_core::sc_module_name) + +#define SC_HAS_PROCESS(name) typedef name SC_CURRENT_USER_MODULE + +#define SC_METHOD(name) /* Implementation defined */ +#define SC_THREAD(name) /* Implementation defined */ +#define SC_CTHREAD(name, clk) /* Implementation defined */ + +const char *sc_gen_unique_name(const char *); + +typedef sc_module sc_behavior; +typedef sc_module sc_channel; + +bool sc_start_of_simulation_invoked(); +bool sc_end_of_simulation_invoked(); + +} // namespace sc_core + +#endif //__SYSTEMC_EXT_CORE_SC_MODULE_HH__ diff --git a/src/systemc/ext/core/sc_module_name.hh b/src/systemc/ext/core/sc_module_name.hh new file mode 100644 index 000000000..7ae2fd689 --- /dev/null +++ b/src/systemc/ext/core/sc_module_name.hh @@ -0,0 +1,56 @@ +/* + * Copyright 2018 Google, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer; + * redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution; + * neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Authors: Gabe Black + */ + +#ifndef __SYSTEMC_EXT_CORE_SC_MODULE_NAME_HH__ +#define __SYSTEMC_EXT_CORE_SC_MODULE_NAME_HH__ + +namespace sc_core +{ + +class sc_module_name +{ + public: + sc_module_name(const char *); + sc_module_name(const sc_module_name &); + ~sc_module_name(); + + operator const char *() const; + + private: + const char *_name; + bool _on_the_stack; + + // Disabled + sc_module_name() {} + sc_module_name &operator = (const sc_module_name &) { return *this; } +}; + +} // namespace sc_core + +#endif //__SYSTEMC_EXT_CORE_SC_MODULE_NAME_HH__ diff --git a/src/systemc/ext/core/sc_object.hh b/src/systemc/ext/core/sc_object.hh new file mode 100644 index 000000000..0e975814f --- /dev/null +++ b/src/systemc/ext/core/sc_object.hh @@ -0,0 +1,80 @@ +/* + * Copyright 2018 Google, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer; + * redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution; + * neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Authors: Gabe Black + */ + +#ifndef __SYSTEMC_EXT_CORE_SC_OBJECT_HH__ +#define __SYSTEMC_EXT_CORE_SC_OBJECT_HH__ + +#include +#include +#include + +namespace sc_core +{ + +class sc_event; +class sc_attr_base; +class sc_attr_cltn; + +class sc_object +{ + public: + const char *name() const; + const char *basename() const; + + virtual const char *kind() const; + + virtual void print(std::ostream & =std::cout) const; + virtual void dump(std::ostream & =std::cout) const; + + virtual const std::vector &get_child_objects() const; + virtual const std::vector &get_child_events() const; + sc_object *get_parent_object() const; + + bool add_attribute(sc_attr_base &); + sc_attr_base *get_attribute(const std::string &); + sc_attr_base *remove_attribute(const std::string &); + void remove_all_attributes(); + int num_attributes() const; + sc_attr_cltn &attr_cltn(); + const sc_attr_cltn &attr_cltn() const; + + protected: + sc_object(); + sc_object(const char *); + sc_object(const sc_object &); + sc_object &operator = (const sc_object &); + virtual ~sc_object(); +}; + +const std::vector &sc_get_top_level_objects(); +sc_object *sc_find_object(const char *); + +} // namespace sc_core + +#endif //__SYSTEMC_EXT_CORE_SC_OBJECT_HH__ diff --git a/src/systemc/ext/core/sc_port.hh b/src/systemc/ext/core/sc_port.hh new file mode 100644 index 000000000..1d32422a5 --- /dev/null +++ b/src/systemc/ext/core/sc_port.hh @@ -0,0 +1,192 @@ +/* + * Copyright 2018 Google, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer; + * redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution; + * neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Authors: Gabe Black + */ + +#ifndef __SYSTEMC_EXT_CORE_SC_PORT_HH__ +#define __SYSTEMC_EXT_CORE_SC_PORT_HH__ + +#include "sc_object.hh" + +namespace sc_core +{ + +class sc_interface; + +enum sc_port_policy +{ + SC_ONE_OR_MORE_BOUND, // Default + SC_ZERO_OR_MORE_BOUND, + SC_ALL_BOUND +}; + +class sc_port_base : public sc_object +{ + public: + void warn_unimpl(const char *func); +}; + +template +class sc_port_b : public sc_port_base +{ + public: + void + operator () (IF &) + { + warn_unimpl(__PRETTY_FUNCTION__); + } + + void + operator () (sc_port_b &) + { + warn_unimpl(__PRETTY_FUNCTION__); + } + + virtual void + bind(IF &) + { + warn_unimpl(__PRETTY_FUNCTION__); + } + + virtual void + bind(sc_port_b &) + { + warn_unimpl(__PRETTY_FUNCTION__); + } + + int + size() const + { + warn_unimpl(__PRETTY_FUNCTION__); + return 0; + } + + IF * + operator -> () + { + warn_unimpl(__PRETTY_FUNCTION__); + return (IF *)nullptr; + } + + const IF * + operator -> () const + { + warn_unimpl(__PRETTY_FUNCTION__); + return (IF *)nullptr; + } + + IF * + operator [] (int) + { + warn_unimpl(__PRETTY_FUNCTION__); + return (IF *)nullptr; + } + + const IF * + operator [] (int) const + { + warn_unimpl(__PRETTY_FUNCTION__); + return (IF *)nullptr; + } + + virtual sc_interface * + get_interface() + { + warn_unimpl(__PRETTY_FUNCTION__); + return (sc_interface *)nullptr; + } + + virtual const sc_interface * + get_interface() const + { + warn_unimpl(__PRETTY_FUNCTION__); + return (sc_interface *)nullptr; + } + + protected: + virtual void before_end_of_elaboration() {} + virtual void end_of_elaboration() {} + virtual void start_of_elaboration() {} + virtual void end_of_simulation() {} + + explicit sc_port_b(int, sc_port_policy) + { + warn_unimpl(__PRETTY_FUNCTION__); + } + + sc_port_b(const char *, int, sc_port_policy) + { + warn_unimpl(__PRETTY_FUNCTION__); + } + + virtual ~sc_port_b() + { + warn_unimpl(__PRETTY_FUNCTION__); + } + + private: + // Disabled + sc_port_b() {} + sc_port_b(const sc_port_b &) {} + sc_port_b &operator = (const sc_port_b &) { return *this; } +}; + +template +class sc_port : public sc_port_b +{ + public: + sc_port() + { + warn_unimpl(__PRETTY_FUNCTION__); + } + + explicit sc_port(const char *) + { + warn_unimpl(__PRETTY_FUNCTION__); + } + + virtual ~sc_port() + { + warn_unimpl(__PRETTY_FUNCTION__); + } + + virtual const char * + kind() const + { + warn_unimpl(__PRETTY_FUNCTION__); + return ""; + } + + private: + // Disabled + sc_port(const sc_port &) {} + sc_port &operator = (const sc_port &) { return *this; } +}; + +} // namespace sc_core + +#endif //__SYSTEMC_EXT_CORE_SC_PORT_HH__ diff --git a/src/systemc/ext/core/sc_prim.hh b/src/systemc/ext/core/sc_prim.hh new file mode 100644 index 000000000..d6265cb56 --- /dev/null +++ b/src/systemc/ext/core/sc_prim.hh @@ -0,0 +1,97 @@ +/* + * Copyright 2018 Google, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer; + * redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution; + * neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Authors: Gabe Black + */ + +#ifndef __SYSTEMC_EXT_CORE_SC_PRIM_HH__ +#define __SYSTEMC_EXT_CORE_SC_PRIM_HH__ + +#include "sc_object.hh" +#include "sc_time.hh" + +namespace sc_core +{ + +class sc_event; +class sc_event_and_list; +class sc_event_or_list; + +class sc_prim_channel : public sc_object +{ + public: + virtual const char *kind() const; + + protected: + sc_prim_channel(); + explicit sc_prim_channel(const char *); + virtual ~sc_prim_channel() {} + + void request_update(); + void async_request_update(); + virtual void update() {} + + void next_trigger(); + void next_trigger(const sc_event &); + void next_trigger(const sc_event_or_list &); + void next_trigger(const sc_event_and_list &); + void next_trigger(const sc_time &); + void next_trigger(double, sc_time_unit); + void next_trigger(const sc_time &, const sc_event &); + void next_trigger(double, sc_time_unit, const sc_event &); + void next_trigger(const sc_time &, const sc_event_or_list &); + void next_trigger(double, sc_time_unit, const sc_event_or_list &); + void next_trigger(const sc_time &, const sc_event_and_list &); + void next_trigger(double, sc_time_unit, const sc_event_and_list &); + + void wait(); + void wait(int); + void wait(const sc_event &); + void wait(const sc_event_or_list &); + void wait(const sc_event_and_list &); + void wait(const sc_time &); + void wait(double, sc_time_unit); + void wait(const sc_time &, const sc_event &); + void wait(double, sc_time_unit, const sc_event &); + void wait(const sc_time &, const sc_event_or_list &); + void wait(double, sc_time_unit, const sc_event_or_list &); + void wait(const sc_time &, const sc_event_and_list &); + void wait(double, sc_time_unit, const sc_event_and_list &); + + virtual void before_end_of_elaboration() {} + virtual void end_of_elaboration() {} + virtual void start_of_simulation() {} + virtual void end_of_simulation() {} + + private: + // Disabled + sc_prim_channel(const sc_prim_channel &); + sc_prim_channel &operator = (const sc_prim_channel &); +}; + +} // namespace sc_core + +#endif //__SYSTEMC_EXT_CORE_SC_PRIM_HH__ diff --git a/src/systemc/ext/core/sc_sensitive.hh b/src/systemc/ext/core/sc_sensitive.hh new file mode 100644 index 000000000..62f18b6d2 --- /dev/null +++ b/src/systemc/ext/core/sc_sensitive.hh @@ -0,0 +1,52 @@ +/* + * Copyright 2018 Google, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer; + * redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution; + * neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Authors: Gabe Black + */ + +#ifndef __SYSTEMC_EXT_CORE_SC_SENSITIVE_HH__ +#define __SYSTEMC_EXT_CORE_SC_SENSITIVE_HH__ + +namespace sc_core +{ + +class sc_event; +class sc_event_finder; +class sc_interface; +class sc_port_base; + +class sc_sensitive +{ + public: + sc_sensitive &operator << (const sc_event &); + sc_sensitive &operator << (const sc_interface &); + sc_sensitive &operator << (const sc_port_base &); + sc_sensitive &operator << (sc_event_finder &); +}; + +} // namespace sc_core + +#endif //__SYSTEMC_EXT_CORE_SC_SENSITIVE_HH__ diff --git a/src/systemc/ext/core/sc_time.hh b/src/systemc/ext/core/sc_time.hh new file mode 100644 index 000000000..456d59e02 --- /dev/null +++ b/src/systemc/ext/core/sc_time.hh @@ -0,0 +1,98 @@ +/* + * Copyright 2018 Google, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer; + * redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution; + * neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Authors: Gabe Black + */ + +#ifndef __SYSTEMC_EXT_CORE_SC_TIME_HH__ +#define __SYSTEMC_EXT_CORE_SC_TIME_HH__ + +#include + +#include + +#include "../dt/int/sc_nbdefs.hh" + +namespace sc_core +{ + +enum sc_time_unit { + SC_FS = 0, + SC_PS, + SC_NS, + SC_US, + SC_MS, + SC_SEC +}; + +class sc_time +{ + public: + sc_time(); + sc_time(double, sc_time_unit); + sc_time(const sc_time &); + + sc_time &operator = (const sc_time &); + + sc_dt::uint64 value() const; + double to_double() const; + double to_seconds() const; + const std::string to_string() const; + + bool operator == (const sc_time &) const; + bool operator != (const sc_time &) const; + bool operator < (const sc_time &) const; + bool operator <= (const sc_time &) const; + bool operator > (const sc_time &) const; + bool operator >= (const sc_time &) const; + + sc_time &operator += (const sc_time &); + sc_time &operator -= (const sc_time &); + sc_time &operator *= (double); + sc_time &operator /= (double); + + void print(std::ostream & =std::cout) const; +}; + +const sc_time operator + (const sc_time &, const sc_time &); +const sc_time operator - (const sc_time &, const sc_time &); + +const sc_time operator * (const sc_time &, double); +const sc_time operator * (double, const sc_time &); +const sc_time operator / (const sc_time &, double); +double operator / (const sc_time &, const sc_time &); + +std::ostream &operator << (std::ostream &, const sc_time &); + +extern const sc_time SC_ZERO_TIME; + +void sc_set_time_resolution(double, sc_time_unit); +sc_time sc_get_time_resolution(); +const sc_time &sc_max_time(); + +} // namespace sc_core + +#endif //__SYSTEMC_EXT_CORE_SC_TIME_HH__ -- cgit v1.2.3