SystemC  2.3.2
Accellera SystemC proof-of-concept library
sc_signal_rv_ports.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 
22  sc_signal_rv_ports.h -- The resolved vector signal ports.
23 */
33 #ifndef SC_SIGNAL_RV_PORTS_H
34 #define SC_SIGNAL_RV_PORTS_H
35 
36 
37 #include <cstdio>
38 
43 
44 namespace sc_core {
45 
52 template <int W>
53 class sc_in_rv
54  : public sc_in<sc_dt::sc_lv<W> >
55 {
56 public:
57 
58  // typedefs
59 
61 
64 
68 
69 public:
70 
71  // constructors
72 
74  : base_type()
75  {}
76 
77  explicit sc_in_rv( const char* name_ )
78  : base_type( name_ )
79  {}
80 
81  explicit sc_in_rv( const in_if_type& interface_ )
82  : base_type( interface_ )
83  {}
84 
85  sc_in_rv( const char* name_, const in_if_type& interface_ )
86  : base_type( name_, interface_ )
87  {}
88 
89  explicit sc_in_rv( in_port_type& parent_ )
90  : base_type( parent_ )
91  {}
92 
93  sc_in_rv( const char* name_, in_port_type& parent_ )
94  : base_type( name_, parent_ )
95  {}
96 
97  explicit sc_in_rv( inout_port_type& parent_ )
98  : base_type( parent_ )
99  {}
100 
101  sc_in_rv( const char* name_, inout_port_type& parent_ )
102  : base_type( name_, parent_ )
103  {}
104 
105  sc_in_rv( this_type& parent_ )
106  : base_type( parent_ )
107  {}
108 
109  sc_in_rv( const char* name_, this_type& parent_ )
110  : base_type( name_, parent_ )
111  {}
112 
113 
114  // destructor (does nothing)
115 
116  virtual ~sc_in_rv()
117  {}
118 
119 
120  // called when elaboration is done
121  /* WHEN DEFINING THIS METHOD IN A DERIVED CLASS, */
122  /* MAKE SURE THAT THIS METHOD IS CALLED AS WELL. */
123 
124  virtual void end_of_elaboration();
125 
126  virtual const char* kind() const
127  { return "sc_in_rv"; }
128 
129 private:
130 
131  // disabled
132  sc_in_rv( const this_type& );
133  this_type& operator = ( const this_type& );
134 };
135 
136 
137 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
138 
139 
140 // called when elaboration is done
141 
142 template <int W>
143 void
145 {
147  // check if bound channel is a resolved signal
148  if( dynamic_cast<sc_signal_rv<W>*>( this->get_interface() ) == 0 ) {
149  this->report_error( SC_ID_RESOLVED_PORT_NOT_BOUND_, 0 );
150  }
151 }
152 
153 
160 template <int W>
162  : public sc_inout<sc_dt::sc_lv<W> >
163 {
164 public:
165 
166  // typedefs
167 
169 
172 
177 
178 public:
179 
180  // constructors
181 
183  : base_type()
184  {}
185 
186  explicit sc_inout_rv( const char* name_ )
187  : base_type( name_ )
188  {}
189 
190  explicit sc_inout_rv( inout_if_type& interface_ )
191  : base_type( interface_ )
192  {}
193 
194  sc_inout_rv( const char* name_, inout_if_type& interface_ )
195  : base_type( name_, interface_ )
196  {}
197 
198  explicit sc_inout_rv( inout_port_type& parent_ )
199  : base_type( parent_ )
200  {}
201 
202  sc_inout_rv( const char* name_, inout_port_type& parent_ )
203  : base_type( name_, parent_ )
204  {}
205 
206  sc_inout_rv( this_type& parent_ )
207  : base_type( parent_ )
208  {}
209 
210  sc_inout_rv( const char* name_, this_type& parent_ )
211  : base_type( name_, parent_ )
212  {}
213 
214 
215  // destructor (does nothing)
216 
217  virtual ~sc_inout_rv()
218  {}
219 
220 
221  // write the new value
222 
223  this_type& operator = ( const data_type& value_ )
224  { (*this)->write( value_ ); return *this; }
225 
226  this_type& operator = ( const in_if_type& interface_ )
227  { (*this)->write( interface_.read() ); return *this; }
228 
229  this_type& operator = ( const in_port_type& port_ )
230  { (*this)->write( port_->read() ); return *this; }
231 
232  this_type& operator = ( const inout_port_type& port_ )
233  { (*this)->write( port_->read() ); return *this; }
234 
235  this_type& operator = ( const this_type& port_ )
236  { (*this)->write( port_->read() ); return *this; }
237 
238 
239  // called when elaboration is done
240  /* WHEN DEFINING THIS METHOD IN A DERIVED CLASS, */
241  /* MAKE SURE THAT THIS METHOD IS CALLED AS WELL. */
242 
243  virtual void end_of_elaboration();
244 
245  virtual const char* kind() const
246  { return "sc_inout_rv"; }
247 
248 private:
249 
250  // disabled
251  sc_inout_rv( const this_type& );
252 };
253 
254 
255 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
256 
257 
258 // called when elaboration is done
259 
260 template <int W>
261 void
263 {
265  // check if bound channel is a resolved signal
266  if( dynamic_cast<sc_signal_rv<W>*>( this->get_interface() ) == 0 ) {
267  this->report_error( SC_ID_RESOLVED_PORT_NOT_BOUND_, 0 );
268  }
269 }
270 
271 
278 // sc_out_rv can also read from its port, hence no difference with
279 // sc_inout_rv. For debugging reasons, a class is provided instead
280 // of a define.
281 
282 template <int W>
284  : public sc_inout_rv<W>
285 {
286 public:
287 
288  // typedefs
289 
292 
293  typedef typename base_type::data_type data_type;
294 
299 
300 public:
301 
302  // constructors
303 
305  : base_type()
306  {}
307 
308  explicit sc_out_rv( const char* name_ )
309  : base_type( name_ )
310  {}
311 
312  explicit sc_out_rv( inout_if_type& interface_ )
313  : base_type( interface_ )
314  {}
315 
316  sc_out_rv( const char* name_, inout_if_type& interface_ )
317  : base_type( name_, interface_ )
318  {}
319 
320  explicit sc_out_rv( inout_port_type& parent_ )
321  : base_type( parent_ )
322  {}
323 
324  sc_out_rv( const char* name_, inout_port_type& parent_ )
325  : base_type( name_, parent_ )
326  {}
327 
328  sc_out_rv( this_type& parent_ )
329  : base_type( parent_ )
330  {}
331 
332  sc_out_rv( const char* name_, this_type& parent_ )
333  : base_type( name_, parent_ )
334  {}
335 
336 
337  // destructor (does nothing)
338 
339  virtual ~sc_out_rv()
340  {}
341 
342 
343  // write the new value
344 
345  this_type& operator = ( const data_type& value_ )
346  { (*this)->write( value_ ); return *this; }
347 
348  this_type& operator = ( const in_if_type& interface_ )
349  { (*this)->write( interface_.read() ); return *this; }
350 
351  this_type& operator = ( const in_port_type& port_ )
352  { (*this)->write( port_->read() ); return *this; }
353 
354  this_type& operator = ( const inout_port_type& port_ )
355  { (*this)->write( port_->read() ); return *this; }
356 
357  this_type& operator = ( const this_type& port_ )
358  { (*this)->write( port_->read() ); return *this; }
359 
360  virtual const char* kind() const
361  { return "sc_out_rv"; }
362 
363 private:
364 
365  // disabled
366  sc_out_rv( const this_type& );
367 };
368 
369 
370 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
371 
372 } // namespace sc_core
373 
374 //$Log: sc_signal_rv_ports.h,v $
375 //Revision 1.3 2011/08/26 20:45:44 acg
376 // Andy Goodrich: moved the modification log to the end of the file to
377 // eliminate source line number skew when check-ins are done.
378 //
379 //Revision 1.2 2011/02/18 20:23:45 acg
380 // Andy Goodrich: Copyright update.
381 //
382 //Revision 1.1.1.1 2006/12/15 20:20:04 acg
383 //SystemC 2.3
384 //
385 //Revision 1.2 2006/01/03 23:18:27 acg
386 //Changed copyright to include 2006.
387 //
388 //Revision 1.1.1.1 2005/12/19 23:16:43 acg
389 //First check in of SystemC 2.1 into its own archive.
390 //
391 //Revision 1.11 2005/09/15 23:01:52 acg
392 //Added std:: prefix to appropriate methods and types to get around
393 //issues with the Edison Front End.
394 //
395 //Revision 1.10 2005/06/10 22:43:56 acg
396 //Added CVS change log annotation.
397 //
398 
399 #endif
400 
401 // Taf!
sc_inout_rv(this_type &parent_)
base_type::in_port_type in_port_type
sc_dt::sc_lv< W > data_type
base_type::inout_if_type inout_if_type
sc_in_rv(this_type &parent_)
base_type::in_if_type in_if_type
base_type::inout_port_type inout_port_type
sc_in_rv(const char *name_, const in_if_type &interface_)
sc_inout_rv(const char *name_, inout_port_type &parent_)
sc_in_rv(const char *name_, this_type &parent_)
Arbitrary size logic vector class.
sc_out_rv(const char *name_)
virtual void end_of_elaboration()
sc_out_rv(const char *name_, inout_if_type &interface_)
The sc_signal_rv<W> output port class.
void report_error(const char *id, const char *add_msg=0) const
sc_in_rv(const char *name_, inout_port_type &parent_)
sc_inout_rv< W > base_type
sc_out_rv(const char *name_, inout_port_type &parent_)
sc_signal_inout_if< data_type > inout_if_type
sc_inout< data_type > base_type
base_type in_port_type
sc_inout_rv(inout_port_type &parent_)
base_type::in_if_type in_if_type
sc_out_rv(inout_if_type &interface_)
sc_port< inout_if_type, 1, SC_ONE_OR_MORE_BOUND > inout_port_type
sc_out_rv(inout_port_type &parent_)
base_type::in_if_type in_if_type
The resolved vector signal class.
sc_inout_rv(const char *name_, inout_if_type &interface_)
sc_dt::sc_lv< W > data_type
sc_inout_rv< W > this_type
sc_out_rv< W > this_type
base_type::in_port_type in_port_type
virtual void end_of_elaboration()
The sc_signal_rv<W> input/output port class.
sc_in_rv(const char *name_, in_port_type &parent_)
sc_inout_rv(const char *name_)
sc_in_rv(const in_if_type &interface_)
sc_inout_rv(inout_if_type &interface_)
virtual const char * kind() const
virtual const char * kind() const
sc_in_rv(inout_port_type &parent_)
base_type::in_port_type in_port_type
The sc_signal_rv<W> input port class.
Report ids for the communication code.
sc_in_rv(const char *name_)
base_type::inout_port_type inout_port_type
The resolved vector signal class.
sc_in_rv(in_port_type &parent_)
virtual void end_of_elaboration()
virtual const char * kind() const
sc_out_rv(this_type &parent_)
The sc_signal<T> port classes.
base_type::data_type data_type
base_type::inout_if_type inout_if_type
sc_in< data_type > base_type
sc_in_rv< W > this_type
virtual sc_interface * get_interface()
Definition: sc_port.h:324
sc_out_rv(const char *name_, this_type &parent_)
sc_inout_rv(const char *name_, this_type &parent_)
base_type::inout_port_type inout_port_type