00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef SC_SIGNAL_RV_PORTS_H
00028 #define SC_SIGNAL_RV_PORTS_H
00029
00030
00031 #include <cstdio>
00032
00033 #include "sysc/communication/sc_communication_ids.h"
00034 #include "sysc/communication/sc_signal_ports.h"
00035 #include "sysc/communication/sc_signal_rv.h"
00036 #include "sysc/datatypes/bit/sc_lv.h"
00037
00038 namespace sc_core {
00039
00040
00046 template <int W>
00047 class sc_in_rv
00048 : public sc_in<sc_dt::sc_lv<W> >
00049 {
00050 public:
00051
00052
00053
00054 typedef sc_dt::sc_lv<W> data_type;
00055
00056 typedef sc_in_rv<W> this_type;
00057 typedef sc_in<data_type> base_type;
00058
00059 typedef typename base_type::in_if_type in_if_type;
00060 typedef typename base_type::in_port_type in_port_type;
00061 typedef typename base_type::inout_port_type inout_port_type;
00062
00063 public:
00064
00065
00066
00067 sc_in_rv()
00068 : base_type()
00069 {}
00070
00071 explicit sc_in_rv( const char* name_ )
00072 : base_type( name_ )
00073 {}
00074
00075 explicit sc_in_rv( const in_if_type& interface_ )
00076 : base_type( interface_ )
00077 {}
00078
00079 sc_in_rv( const char* name_, const in_if_type& interface_ )
00080 : base_type( name_, interface_ )
00081 {}
00082
00083 explicit sc_in_rv( in_port_type& parent_ )
00084 : base_type( parent_ )
00085 {}
00086
00087 sc_in_rv( const char* name_, in_port_type& parent_ )
00088 : base_type( name_, parent_ )
00089 {}
00090
00091 explicit sc_in_rv( inout_port_type& parent_ )
00092 : base_type( parent_ )
00093 {}
00094
00095 sc_in_rv( const char* name_, inout_port_type& parent_ )
00096 : base_type( name_, parent_ )
00097 {}
00098
00099 sc_in_rv( this_type& parent_ )
00100 : base_type( parent_ )
00101 {}
00102
00103 sc_in_rv( const char* name_, this_type& parent_ )
00104 : base_type( name_, parent_ )
00105 {}
00106
00107
00108
00109
00110 virtual ~sc_in_rv()
00111 {}
00112
00113
00114
00115
00116
00117
00118 virtual void end_of_elaboration();
00119
00120 virtual const char* kind() const
00121 { return "sc_in_rv"; }
00122
00123 private:
00124
00125
00126 sc_in_rv( const this_type& );
00127 this_type& operator = ( const this_type& );
00128 };
00129
00130
00131
00132
00133
00134
00135
00136 template <int W>
00137 void
00138 sc_in_rv<W>::end_of_elaboration()
00139 {
00140 base_type::end_of_elaboration();
00141
00142 if( DCAST<sc_signal_rv<W>*>( this->get_interface() ) == 0 ) {
00143 char msg[BUFSIZ];
00144 std::sprintf( msg, "%s (%s)", this->name(), kind() );
00145 SC_REPORT_ERROR( SC_ID_RESOLVED_PORT_NOT_BOUND_, msg );
00146 }
00147 }
00148
00149
00150
00156 template <int W>
00157 class sc_inout_rv
00158 : public sc_inout<sc_dt::sc_lv<W> >
00159 {
00160 public:
00161
00162
00163
00164 typedef sc_dt::sc_lv<W> data_type;
00165
00166 typedef sc_inout_rv<W> this_type;
00167 typedef sc_inout<data_type> base_type;
00168
00169 typedef typename base_type::in_if_type in_if_type;
00170 typedef typename base_type::in_port_type in_port_type;
00171 typedef typename base_type::inout_if_type inout_if_type;
00172 typedef typename base_type::inout_port_type inout_port_type;
00173
00174 public:
00175
00176
00177
00178 sc_inout_rv()
00179 : base_type()
00180 {}
00181
00182 explicit sc_inout_rv( const char* name_ )
00183 : base_type( name_ )
00184 {}
00185
00186 explicit sc_inout_rv( inout_if_type& interface_ )
00187 : base_type( interface_ )
00188 {}
00189
00190 sc_inout_rv( const char* name_, inout_if_type& interface_ )
00191 : base_type( name_, interface_ )
00192 {}
00193
00194 explicit sc_inout_rv( inout_port_type& parent_ )
00195 : base_type( parent_ )
00196 {}
00197
00198 sc_inout_rv( const char* name_, inout_port_type& parent_ )
00199 : base_type( name_, parent_ )
00200 {}
00201
00202 sc_inout_rv( this_type& parent_ )
00203 : base_type( parent_ )
00204 {}
00205
00206 sc_inout_rv( const char* name_, this_type& parent_ )
00207 : base_type( name_, parent_ )
00208 {}
00209
00210
00211
00212
00213 virtual ~sc_inout_rv()
00214 {}
00215
00216
00217
00218
00219 this_type& operator = ( const data_type& value_ )
00220 { (*this)->write( value_ ); return *this; }
00221
00222 this_type& operator = ( const in_if_type& interface_ )
00223 { (*this)->write( interface_.read() ); return *this; }
00224
00225 this_type& operator = ( const in_port_type& port_ )
00226 { (*this)->write( port_->read() ); return *this; }
00227
00228 this_type& operator = ( const inout_port_type& port_ )
00229 { (*this)->write( port_->read() ); return *this; }
00230
00231 this_type& operator = ( const this_type& port_ )
00232 { (*this)->write( port_->read() ); return *this; }
00233
00234
00235
00236
00237
00238
00239 virtual void end_of_elaboration();
00240
00241 virtual const char* kind() const
00242 { return "sc_inout_rv"; }
00243
00244 private:
00245
00246
00247 sc_inout_rv( const this_type& );
00248 };
00249
00250
00251
00252
00253
00254
00255
00256 template <int W>
00257 void
00258 sc_inout_rv<W>::end_of_elaboration()
00259 {
00260 base_type::end_of_elaboration();
00261
00262 if( DCAST<sc_signal_rv<W>*>( this->get_interface() ) == 0 ) {
00263 char msg[BUFSIZ];
00264 std::sprintf( msg, "%s (%s)", this->name(), kind() );
00265 SC_REPORT_ERROR( SC_ID_RESOLVED_PORT_NOT_BOUND_, msg );
00266 }
00267 }
00268
00269
00270
00276
00277
00278
00279
00280 template <int W>
00281 class sc_out_rv
00282 : public sc_inout_rv<W>
00283 {
00284 public:
00285
00286
00287
00288 typedef sc_out_rv<W> this_type;
00289 typedef sc_inout_rv<W> base_type;
00290
00291 typedef typename base_type::data_type data_type;
00292
00293 typedef typename base_type::in_if_type in_if_type;
00294 typedef typename base_type::in_port_type in_port_type;
00295 typedef typename base_type::inout_if_type inout_if_type;
00296 typedef typename base_type::inout_port_type inout_port_type;
00297
00298 public:
00299
00300
00301
00302 sc_out_rv()
00303 : base_type()
00304 {}
00305
00306 explicit sc_out_rv( const char* name_ )
00307 : base_type( name_ )
00308 {}
00309
00310 explicit sc_out_rv( inout_if_type& interface_ )
00311 : base_type( interface_ )
00312 {}
00313
00314 sc_out_rv( const char* name_, inout_if_type& interface_ )
00315 : base_type( name_, interface_ )
00316 {}
00317
00318 explicit sc_out_rv( inout_port_type& parent_ )
00319 : base_type( parent_ )
00320 {}
00321
00322 sc_out_rv( const char* name_, inout_port_type& parent_ )
00323 : base_type( name_, parent_ )
00324 {}
00325
00326 sc_out_rv( this_type& parent_ )
00327 : base_type( parent_ )
00328 {}
00329
00330 sc_out_rv( const char* name_, this_type& parent_ )
00331 : base_type( name_, parent_ )
00332 {}
00333
00334
00335
00336
00337 virtual ~sc_out_rv()
00338 {}
00339
00340
00341
00342
00343 this_type& operator = ( const data_type& value_ )
00344 { (*this)->write( value_ ); return *this; }
00345
00346 this_type& operator = ( const in_if_type& interface_ )
00347 { (*this)->write( interface_.read() ); return *this; }
00348
00349 this_type& operator = ( const in_port_type& port_ )
00350 { (*this)->write( port_->read() ); return *this; }
00351
00352 this_type& operator = ( const inout_port_type& port_ )
00353 { (*this)->write( port_->read() ); return *this; }
00354
00355 this_type& operator = ( const this_type& port_ )
00356 { (*this)->write( port_->read() ); return *this; }
00357
00358 virtual const char* kind() const
00359 { return "sc_out_rv"; }
00360
00361 private:
00362
00363
00364 sc_out_rv( const this_type& );
00365 };
00366
00367
00368
00369
00370 }
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397 #endif
00398
00399