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
24  Original Author: Martin Janssen, Synopsys, Inc., 2001-05-21
25
26  CHANGE LOG IS AT THE END OF THE FILE
27 *****************************************************************************/
28
29#ifndef SC_SIGNAL_RV_PORTS_H
30#define SC_SIGNAL_RV_PORTS_H
31
32
33#include <cstdio>
34
35#include "sysc/communication/sc_communication_ids.h"
36#include "sysc/communication/sc_signal_ports.h"
37#include "sysc/communication/sc_signal_rv.h"
38#include "sysc/datatypes/bit/sc_lv.h"
39
40namespace sc_core {
41
42// ----------------------------------------------------------------------------
43//  CLASS : sc_in_rv<W>
44//
45//  The sc_signal_rv<W> input port class.
46// ----------------------------------------------------------------------------
47
48template <int W>
49class sc_in_rv
50    : public sc_in<sc_dt::sc_lv<W> >
51{
52public:
53
54    // typedefs
55
56    typedef sc_dt::sc_lv<W>                     data_type;
57
58    typedef sc_in_rv<W>                         this_type;
59    typedef sc_in<data_type>                    base_type;
60
61    typedef typename base_type::in_if_type      in_if_type;
62    typedef typename base_type::in_port_type    in_port_type;
63    typedef typename base_type::inout_port_type inout_port_type;
64
65public:
66
67    // constructors
68
69    sc_in_rv()
70	: base_type()
71	{}
72
73    explicit sc_in_rv( const char* name_ )
74	: base_type( name_ )
75	{}
76
77    explicit sc_in_rv( const in_if_type& interface_ )
78	: base_type( interface_ )
79	{}
80
81    sc_in_rv( const char* name_, const in_if_type& interface_ )
82	: base_type( name_, interface_ )
83	{}
84
85    explicit sc_in_rv( in_port_type& parent_ )
86	: base_type( parent_ )
87	{}
88
89    sc_in_rv( const char* name_, in_port_type& parent_ )
90	: base_type( name_, parent_ )
91	{}
92
93    explicit sc_in_rv( inout_port_type& parent_ )
94	: base_type( parent_ )
95	{}
96
97    sc_in_rv( const char* name_, inout_port_type& parent_ )
98	: base_type( name_, parent_ )
99	{}
100
101    sc_in_rv( this_type& parent_ )
102	: base_type( parent_ )
103	{}
104
105    sc_in_rv( const char* name_, this_type& parent_ )
106	: base_type( name_, parent_ )
107	{}
108
109
110    // destructor (does nothing)
111
112    virtual ~sc_in_rv()
113	{}
114
115
116    // called when elaboration is done
117    /*  WHEN DEFINING THIS METHOD IN A DERIVED CLASS, */
118    /*  MAKE SURE THAT THIS METHOD IS CALLED AS WELL. */
119
120    virtual void end_of_elaboration();
121
122    virtual const char* kind() const
123        { return "sc_in_rv"; }
124
125private:
126
127    // disabled
128    sc_in_rv( const this_type& );
129    this_type& operator = ( const this_type& );
130};
131
132
133// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
134
135
136// called when elaboration is done
137
138template <int W>
139void
140sc_in_rv<W>::end_of_elaboration()
141{
142    base_type::end_of_elaboration();
143    // check if bound channel is a resolved signal
144    if( DCAST<sc_signal_rv<W>*>( this->get_interface() ) == 0 ) {
145	char msg[BUFSIZ];
146	std::sprintf( msg, "%s (%s)", this->name(), kind() );
147	SC_REPORT_ERROR( SC_ID_RESOLVED_PORT_NOT_BOUND_, msg );
148    }
149}
150
151
152// ----------------------------------------------------------------------------
153//  CLASS : sc_inout_rv<W>
154//
155//  The sc_signal_rv<W> input/output port class.
156// ----------------------------------------------------------------------------
157
158template <int W>
159class sc_inout_rv
160    : public sc_inout<sc_dt::sc_lv<W> >
161{
162public:
163
164    // typedefs
165
166    typedef sc_dt::sc_lv<W>                     data_type;
167
168    typedef sc_inout_rv<W>                      this_type;
169    typedef sc_inout<data_type>                 base_type;
170
171    typedef typename base_type::in_if_type      in_if_type;
172    typedef typename base_type::in_port_type    in_port_type;
173    typedef typename base_type::inout_if_type   inout_if_type;
174    typedef typename base_type::inout_port_type inout_port_type;
175
176public:
177
178    // constructors
179
180    sc_inout_rv()
181	: base_type()
182	{}
183
184    explicit sc_inout_rv( const char* name_ )
185	: base_type( name_ )
186	{}
187
188    explicit sc_inout_rv( inout_if_type& interface_ )
189	: base_type( interface_ )
190	{}
191
192    sc_inout_rv( const char* name_, inout_if_type& interface_ )
193	: base_type( name_, interface_ )
194	{}
195
196    explicit sc_inout_rv( inout_port_type& parent_ )
197	: base_type( parent_ )
198	{}
199
200    sc_inout_rv( const char* name_, inout_port_type& parent_ )
201	: base_type( name_, parent_ )
202	{}
203
204    sc_inout_rv( this_type& parent_ )
205	: base_type( parent_ )
206	{}
207
208    sc_inout_rv( const char* name_, this_type& parent_ )
209	: base_type( name_, parent_ )
210	{}
211
212
213    // destructor (does nothing)
214
215    virtual ~sc_inout_rv()
216	{}
217
218
219    // write the new value
220
221    this_type& operator = ( const data_type& value_ )
222	{ (*this)->write( value_ ); return *this; }
223
224    this_type& operator = ( const in_if_type& interface_ )
225	{ (*this)->write( interface_.read() ); return *this; }
226
227    this_type& operator = ( const in_port_type& port_ )
228	{ (*this)->write( port_->read() ); return *this; }
229
230    this_type& operator = ( const inout_port_type& port_ )
231	{ (*this)->write( port_->read() ); return *this; }
232
233    this_type& operator = ( const this_type& port_ )
234	{ (*this)->write( port_->read() ); return *this; }
235
236
237    // called when elaboration is done
238    /*  WHEN DEFINING THIS METHOD IN A DERIVED CLASS, */
239    /*  MAKE SURE THAT THIS METHOD IS CALLED AS WELL. */
240
241    virtual void end_of_elaboration();
242
243    virtual const char* kind() const
244        { return "sc_inout_rv"; }
245
246private:
247
248    // disabled
249    sc_inout_rv( const this_type& );
250};
251
252
253// IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
254
255
256// called when elaboration is done
257
258template <int W>
259void
260sc_inout_rv<W>::end_of_elaboration()
261{
262    base_type::end_of_elaboration();
263    // check if bound channel is a resolved signal
264    if( DCAST<sc_signal_rv<W>*>( this->get_interface() ) == 0 ) {
265	char msg[BUFSIZ];
266	std::sprintf( msg, "%s (%s)", this->name(), kind() );
267	SC_REPORT_ERROR( SC_ID_RESOLVED_PORT_NOT_BOUND_, msg );
268    }
269}
270
271
272// ----------------------------------------------------------------------------
273//  CLASS : sc_out_rv<W>
274//
275//  The sc_signal_rv<W> output port class.
276// ----------------------------------------------------------------------------
277
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
282template <int W>
283class sc_out_rv
284    : public sc_inout_rv<W>
285{
286public:
287
288    // typedefs
289
290    typedef sc_out_rv<W>                        this_type;
291    typedef sc_inout_rv<W>                      base_type;
292
293    typedef typename base_type::data_type       data_type;
294
295    typedef typename base_type::in_if_type      in_if_type;
296    typedef typename base_type::in_port_type    in_port_type;
297    typedef typename base_type::inout_if_type   inout_if_type;
298    typedef typename base_type::inout_port_type inout_port_type;
299
300public:
301
302    // constructors
303
304    sc_out_rv()
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
363private:
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!
402