TLM-2.0  2.0.4
Accellera TLM-2.0 proof-of-concept library
tlm_core_ifs.h
Go to the documentation of this file.
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 //
21 // Note to the LRM writer : This is the core of the TLM standard
22 //
23 
24 
25 #ifndef __TLM_CORE_IFS_H__
26 #define __TLM_CORE_IFS_H__
27 
28 //#include <systemc>
29 
31 
32 namespace tlm {
33 
34 // bidirectional blocking interfaces
35 
36 template < typename REQ , typename RSP >
38 {
39 public:
40  virtual RSP transport( const REQ & ) = 0;
41 
42  virtual void transport( const REQ &req , RSP &rsp ) {
43  rsp = transport( req );
44  }
45 
46 };
47 
48 
49 // uni-directional blocking interfaces
50 
51 template < typename T >
53 {
54 public:
55  virtual T get( tlm_tag<T> *t = 0 ) = 0;
56  virtual void get( T &t ) { t = get(); }
57 
58 };
59 
60 template < typename T >
62 {
63 public:
64  virtual void put( const T &t ) = 0;
65 };
66 
67 // uni-directional non blocking interfaces
68 
69 template < typename T >
71 {
72 public:
73  virtual bool nb_get( T &t ) = 0;
74  virtual bool nb_can_get( tlm_tag<T> *t = 0 ) const = 0;
75  virtual const sc_core::sc_event &ok_to_get( tlm_tag<T> *t = 0 ) const = 0;
76 };
77 
78 template < typename T >
80 {
81 public:
82  virtual bool nb_put( const T &t ) = 0;
83  virtual bool nb_can_put( tlm_tag<T> *t = 0 ) const = 0;
84  virtual const sc_core::sc_event &ok_to_put( tlm_tag<T> *t = 0 ) const = 0;
85 };
86 
87 
88 // combined uni-directional blocking and non blocking
89 
90 template < typename T >
91 class tlm_get_if :
92  public virtual tlm_blocking_get_if< T > ,
93  public virtual tlm_nonblocking_get_if< T > {};
94 
95 template < typename T >
96 class tlm_put_if :
97  public virtual tlm_blocking_put_if< T > ,
98  public virtual tlm_nonblocking_put_if< T > {};
99 
100 
101 // peek interfaces
102 
103 template < typename T >
105 {
106 public:
107  virtual T peek( tlm_tag<T> *t = 0 ) const = 0;
108  virtual void peek( T &t ) const { t = peek(); }
109 
110 };
111 
112 template < typename T >
114 {
115 public:
116  virtual bool nb_peek( T &t ) const = 0;
117  virtual bool nb_can_peek( tlm_tag<T> *t = 0 ) const = 0;
118  virtual const sc_core::sc_event &ok_to_peek( tlm_tag<T> *t = 0 ) const = 0;
119 };
120 
121 template < typename T >
122 class tlm_peek_if :
123  public virtual tlm_blocking_peek_if< T > ,
124  public virtual tlm_nonblocking_peek_if< T > {};
125 
126 // get_peek interfaces
127 
128 template < typename T >
130  public virtual tlm_blocking_get_if<T> ,
131  public virtual tlm_blocking_peek_if<T> {};
132 
133 template < typename T >
135  public virtual tlm_nonblocking_get_if<T> ,
136  public virtual tlm_nonblocking_peek_if<T> {};
137 
138 
139 template < typename T >
141  public virtual tlm_get_if<T> ,
142  public virtual tlm_peek_if<T> ,
143  public virtual tlm_blocking_get_peek_if<T> ,
144  public virtual tlm_nonblocking_get_peek_if<T>
145  {};
146 
147 } // namespace tlm
148 
149 #endif
virtual void peek(T &t) const
Definition: tlm_core_ifs.h:108
virtual void transport(const REQ &req, RSP &rsp)
Definition: tlm_core_ifs.h:42
virtual RSP transport(const REQ &)=0