nonblocking_port.hh revision 13586:008fe87c1ad4
1/*****************************************************************************
2
3  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4  more contributor license agreements.  See the NOTICE file distributed
5  with this work for additional information regarding copyright ownership.
6  Accellera licenses this file to you under the Apache License, Version 2.0
7  (the "License"); you may not use this file except in compliance with the
8  License.  You may obtain a copy of the License at
9
10    http://www.apache.org/licenses/LICENSE-2.0
11
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15  implied.  See the License for the specific language governing
16  permissions and limitations under the License.
17
18 *****************************************************************************/
19
20#ifndef __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_PORTS_NONBLOCKING_PORT_HH__
21#define __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_PORTS_NONBLOCKING_PORT_HH__
22
23#include "../interfaces/core_ifs.hh"
24#include "event_finder.hh"
25
26namespace tlm
27{
28
29template <typename T>
30class tlm_nonblocking_get_port :
31    public sc_core::sc_port<tlm_nonblocking_get_if<T>, 1>
32{
33  public:
34    typedef tlm_nonblocking_get_if<T> get_if_type;
35
36    tlm_nonblocking_get_port(const char *port_name) :
37        sc_core::sc_port<tlm_nonblocking_get_if<T>, 1>(port_name)
38    {}
39
40    sc_core::sc_event_finder &
41    ok_to_get() const
42    {
43        return *new tlm_event_finder_t<get_if_type, T >(
44                *this, &get_if_type::ok_to_get);
45    }
46};
47
48template <typename T>
49class tlm_nonblocking_peek_port :
50    public sc_core::sc_port<tlm_nonblocking_peek_if<T>, 1>
51{
52  public:
53    typedef tlm_nonblocking_peek_if<T> peek_if_type;
54
55    tlm_nonblocking_peek_port(const char *port_name) :
56        sc_core::sc_port<tlm_nonblocking_peek_if<T>, 1>(port_name)
57    {}
58
59    sc_core::sc_event_finder &
60    ok_to_peek() const
61    {
62        return *new tlm_event_finder_t<peek_if_type, T>(
63                *this, &peek_if_type::ok_to_peek);
64    }
65};
66
67template <typename T>
68class tlm_nonblocking_put_port :
69    public sc_core::sc_port<tlm_nonblocking_put_if<T>, 1>
70{
71  public:
72    typedef tlm_nonblocking_put_if<T> put_if_type;
73
74    tlm_nonblocking_put_port(const char *port_name) :
75        sc_core::sc_port<tlm_nonblocking_put_if<T>, 1>(port_name)
76    {}
77
78    sc_core::sc_event_finder &
79    ok_to_put() const
80    {
81        return *new tlm_event_finder_t<put_if_type, T>(
82                *this, &put_if_type::ok_to_put);
83    }
84};
85
86} // namespace tlm
87
88#endif /* __SYSTEMC_EXT_TLM_CORE_1_REQ_RSP_PORTS_NONBLOCKING_PORT_HH__ */
89