SystemC  Recoding Infrastructure for SystemC v0.6.2 derived from Accellera SystemC 2.3.1
Accellera SystemC proof-of-concept library
sc_signal_rv_ports.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  The following code is derived, directly or indirectly, from the SystemC
4  source code Copyright (c) 1996-2014 by all Contributors.
5  All Rights reserved.
6 
7  The contents of this file are subject to the restrictions and limitations
8  set forth in the SystemC Open Source License (the "License");
9  You may not use this file except in compliance with such restrictions and
10  limitations. You may obtain instructions on how to receive a copy of the
11  License at http://www.accellera.org/. Software distributed by Contributors
12  under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
13  ANY KIND, either express or implied. See the License for the specific
14  language governing rights and limitations under the License.
15 
16  *****************************************************************************/
17 
18 /*****************************************************************************
19 
20  sc_signal_rv_ports.h -- The resolved vector signal ports.
21 
22  Original Author: Martin Janssen, Synopsys, Inc., 2001-05-21
23 
24  CHANGE LOG IS AT THE END OF THE FILE
25  *****************************************************************************/
26 
27 #ifndef SC_SIGNAL_RV_PORTS_H
28 #define SC_SIGNAL_RV_PORTS_H
29 
30 
31 #include <cstdio>
32 
37 
38 namespace sc_core {
39 
40 /**************************************************************************/
46 template <int W>
47 class sc_in_rv
48  : public sc_in<sc_dt::sc_lv<W> >
49 {
50 public:
51 
52  // typedefs
53 
55 
58 
62 
63 public:
64 
65  // constructors
66 
68  : base_type()
69  {}
70 
71  explicit sc_in_rv( const char* name_ )
72  : base_type( name_ )
73  {}
74 
75  explicit sc_in_rv( const in_if_type& interface_ )
76  : base_type( interface_ )
77  {}
78 
79  sc_in_rv( const char* name_, const in_if_type& interface_ )
80  : base_type( name_, interface_ )
81  {}
82 
83  explicit sc_in_rv( in_port_type& parent_ )
84  : base_type( parent_ )
85  {}
86 
87  sc_in_rv( const char* name_, in_port_type& parent_ )
88  : base_type( name_, parent_ )
89  {}
90 
91  explicit sc_in_rv( inout_port_type& parent_ )
92  : base_type( parent_ )
93  {}
94 
95  sc_in_rv( const char* name_, inout_port_type& parent_ )
96  : base_type( name_, parent_ )
97  {}
98 
99  sc_in_rv( this_type& parent_ )
100  : base_type( parent_ )
101  {}
102 
103  sc_in_rv( const char* name_, this_type& parent_ )
104  : base_type( name_, parent_ )
105  {}
106 
107 
108  // destructor (does nothing)
109 
110  virtual ~sc_in_rv()
111  {}
112 
113 
114  // called when elaboration is done
115  /* WHEN DEFINING THIS METHOD IN A DERIVED CLASS, */
116  /* MAKE SURE THAT THIS METHOD IS CALLED AS WELL. */
117 
118  virtual void end_of_elaboration();
119 
120  virtual const char* kind() const
121  { return "sc_in_rv"; }
122 
123 private:
124 
125  // disabled
126  sc_in_rv( const this_type& );
127  this_type& operator = ( const this_type& );
128 };
129 
130 
131 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
132 
133 
134 // called when elaboration is done
135 
136 template <int W>
137 void
139 {
140  base_type::end_of_elaboration();
141  // check if bound channel is a resolved signal
142  if( DCAST<sc_signal_rv<W>*>( this->get_interface() ) == 0 ) {
143  char msg[BUFSIZ];
144  std::sprintf( msg, "%s (%s)", this->name(), kind() );
145  SC_REPORT_ERROR( SC_ID_RESOLVED_PORT_NOT_BOUND_, msg );
146  }
147 }
148 
149 
150 /**************************************************************************/
156 template <int W>
158  : public sc_inout<sc_dt::sc_lv<W> >
159 {
160 public:
161 
162  // typedefs
163 
165 
168 
173 
174 public:
175 
176  // constructors
177 
179  : base_type()
180  {}
181 
182  explicit sc_inout_rv( const char* name_ )
183  : base_type( name_ )
184  {}
185 
186  explicit sc_inout_rv( inout_if_type& interface_ )
187  : base_type( interface_ )
188  {}
189 
190  sc_inout_rv( const char* name_, inout_if_type& interface_ )
191  : base_type( name_, interface_ )
192  {}
193 
194  explicit sc_inout_rv( inout_port_type& parent_ )
195  : base_type( parent_ )
196  {}
197 
198  sc_inout_rv( const char* name_, inout_port_type& parent_ )
199  : base_type( name_, parent_ )
200  {}
201 
202  sc_inout_rv( this_type& parent_ )
203  : base_type( parent_ )
204  {}
205 
206  sc_inout_rv( const char* name_, this_type& parent_ )
207  : base_type( name_, parent_ )
208  {}
209 
210 
211  // destructor (does nothing)
212 
213  virtual ~sc_inout_rv()
214  {}
215 
216 
217  // write the new value
218 
219  this_type& operator = ( const data_type& value_ )
220  { (*this)->write( value_ ); return *this; }
221 
222  this_type& operator = ( const in_if_type& interface_ )
223  { (*this)->write( interface_.read() ); return *this; }
224 
226  { (*this)->write( port_->read() ); return *this; }
227 
229  { (*this)->write( port_->read() ); return *this; }
230 
231  this_type& operator = ( const this_type& port_ )
232  { (*this)->write( port_->read() ); return *this; }
233 
234 
235  // called when elaboration is done
236  /* WHEN DEFINING THIS METHOD IN A DERIVED CLASS, */
237  /* MAKE SURE THAT THIS METHOD IS CALLED AS WELL. */
238 
239  virtual void end_of_elaboration();
240 
241  virtual const char* kind() const
242  { return "sc_inout_rv"; }
243 
244 private:
245 
246  // disabled
247  sc_inout_rv( const this_type& );
248 };
249 
250 
251 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
252 
253 
254 // called when elaboration is done
255 
256 template <int W>
257 void
259 {
260  base_type::end_of_elaboration();
261  // check if bound channel is a resolved signal
262  if( DCAST<sc_signal_rv<W>*>( this->get_interface() ) == 0 ) {
263  char msg[BUFSIZ];
264  std::sprintf( msg, "%s (%s)", this->name(), kind() );
265  SC_REPORT_ERROR( SC_ID_RESOLVED_PORT_NOT_BOUND_, msg );
266  }
267 }
268 
269 
270 /**************************************************************************/
276 // sc_out_rv can also read from its port, hence no difference with
277 // sc_inout_rv. For debugging reasons, a class is provided instead
278 // of a define.
279 
280 template <int W>
282  : public sc_inout_rv<W>
283 {
284 public:
285 
286  // typedefs
287 
290 
291  typedef typename base_type::data_type data_type;
292 
293  typedef typename base_type::in_if_type in_if_type;
294  typedef typename base_type::in_port_type in_port_type;
295  typedef typename base_type::inout_if_type inout_if_type;
296  typedef typename base_type::inout_port_type inout_port_type;
297 
298 public:
299 
300  // constructors
301 
303  : base_type()
304  {}
305 
306  explicit sc_out_rv( const char* name_ )
307  : base_type( name_ )
308  {}
309 
310  explicit sc_out_rv( inout_if_type& interface_ )
311  : base_type( interface_ )
312  {}
313 
314  sc_out_rv( const char* name_, inout_if_type& interface_ )
315  : base_type( name_, interface_ )
316  {}
317 
318  explicit sc_out_rv( inout_port_type& parent_ )
319  : base_type( parent_ )
320  {}
321 
322  sc_out_rv( const char* name_, inout_port_type& parent_ )
323  : base_type( name_, parent_ )
324  {}
325 
326  sc_out_rv( this_type& parent_ )
327  : base_type( parent_ )
328  {}
329 
330  sc_out_rv( const char* name_, this_type& parent_ )
331  : base_type( name_, parent_ )
332  {}
333 
334 
335  // destructor (does nothing)
336 
337  virtual ~sc_out_rv()
338  {}
339 
340 
341  // write the new value
342 
343  this_type& operator = ( const data_type& value_ )
344  { (*this)->write( value_ ); return *this; }
345 
346  this_type& operator = ( const in_if_type& interface_ )
347  { (*this)->write( interface_.read() ); return *this; }
348 
350  { (*this)->write( port_->read() ); return *this; }
351 
353  { (*this)->write( port_->read() ); return *this; }
354 
355  this_type& operator = ( const this_type& port_ )
356  { (*this)->write( port_->read() ); return *this; }
357 
358  virtual const char* kind() const
359  { return "sc_out_rv"; }
360 
361 private:
362 
363  // disabled
364  sc_out_rv( const this_type& );
365 };
366 
367 
368 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
369 
370 } // namespace sc_core
371 
372 //$Log: sc_signal_rv_ports.h,v $
373 //Revision 1.3 2011/08/26 20:45:44 acg
374 // Andy Goodrich: moved the modification log to the end of the file to
375 // eliminate source line number skew when check-ins are done.
376 //
377 //Revision 1.2 2011/02/18 20:23:45 acg
378 // Andy Goodrich: Copyright update.
379 //
380 //Revision 1.1.1.1 2006/12/15 20:20:04 acg
381 //SystemC 2.3
382 //
383 //Revision 1.2 2006/01/03 23:18:27 acg
384 //Changed copyright to include 2006.
385 //
386 //Revision 1.1.1.1 2005/12/19 23:16:43 acg
387 //First check in of SystemC 2.1 into its own archive.
388 //
389 //Revision 1.11 2005/09/15 23:01:52 acg
390 //Added std:: prefix to appropriate methods and types to get around
391 //issues with the Edison Front End.
392 //
393 //Revision 1.10 2005/06/10 22:43:56 acg
394 //Added CVS change log annotation.
395 //
396 
397 #endif
398 
399 // Taf!
sc_inout_rv< W > base_type
sc_out_rv(const char *name_, this_type &parent_)
The sc_signal_rv&lt;W&gt; input port class.
sc_out_rv(const char *name_)
sc_in_rv(inout_port_type &parent_)
#define SC_REPORT_ERROR(msg_type, msg)
Definition: sc_report.h:213
sc_inout_rv(this_type &parent_)
base_type::in_port_type in_port_type
sc_inout< data_type > base_type
#define DCAST
Definition: sc_iostream.h:61
sc_port< in_if_type, 1, SC_ONE_OR_MORE_BOUND > in_port_type
sc_out_rv(const char *name_, inout_port_type &parent_)
sc_inout_rv< W > this_type
sc_in_rv< W > this_type
base_type::inout_if_type inout_if_type
base_type::inout_port_type inout_port_type
virtual const char * kind() const
base_type::inout_port_type inout_port_type
sc_in_rv(this_type &parent_)
sc_out_rv(inout_if_type &interface_)
virtual void end_of_elaboration()
sc_dt::sc_lv< W > data_type
The sc_signal_rv&lt;W&gt; output port class.
sc_in_rv(const char *name_, in_port_type &parent_)
sc_inout_rv(inout_if_type &interface_)
virtual const char * kind() const
The sc_signal_rv&lt;W&gt; input/output port class.
base_type::in_if_type in_if_type
base_type::in_port_type in_port_type
sc_inout_rv(const char *name_, inout_if_type &interface_)
virtual const char * kind() const
sc_out_rv< W > this_type
sc_out_rv(const char *name_, inout_if_type &interface_)
base_type::in_port_type in_port_type
this_type & operator=(const data_type &value_)
base_type::in_if_type in_if_type
sc_dt::sc_lv< W > data_type
sc_out_rv(this_type &parent_)
sc_in_rv(const char *name_, this_type &parent_)
The resolved vector signal class.
base_type::inout_port_type inout_port_type
base_type::in_if_type in_if_type
sc_in_rv(const in_if_type &interface_)
sc_port< inout_if_type, 1, SC_ONE_OR_MORE_BOUND > inout_port_type
base_type::data_type data_type
sc_in_rv(const char *name_, inout_port_type &parent_)
sc_in_rv(in_port_type &parent_)
Abstract base class for class sc_port_b.
Definition: sc_port.h:69
sc_in_rv(const char *name_)
sc_inout_rv(const char *name_)
sc_out_rv(inout_port_type &parent_)
virtual void end_of_elaboration()
sc_inout_rv(inout_port_type &parent_)
this_type & operator=(const data_type &value_)
sc_in< data_type > base_type
base_type in_port_type
sc_signal_in_if< data_type > in_if_type
sc_inout_rv(const char *name_, inout_port_type &parent_)
sc_inout_rv(const char *name_, this_type &parent_)
sc_in_rv(const char *name_, const in_if_type &interface_)
base_type::inout_if_type inout_if_type