sc_signal_rv_ports.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002 
00003   The following code is derived, directly or indirectly, from the SystemC
00004   source code Copyright (c) 1996-2006 by all Contributors.
00005   All Rights reserved.
00006 
00007   The contents of this file are subject to the restrictions and limitations
00008   set forth in the SystemC Open Source License Version 2.4 (the "License");
00009   You may not use this file except in compliance with such restrictions and
00010   limitations. You may obtain instructions on how to receive a copy of the
00011   License at http://www.systemc.org/. Software distributed by Contributors
00012   under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
00013   ANY KIND, either express or implied. See the License for the specific
00014   language governing rights and limitations under the License.
00015 
00016  *****************************************************************************/
00017 
00018 /*****************************************************************************
00019 
00020   sc_signal_rv_ports.h -- The resolved vector signal ports.
00021 
00022   Original Author: Martin Janssen, Synopsys, Inc., 2001-05-21
00023 
00024  *****************************************************************************/
00025 
00026 /*****************************************************************************
00027 
00028   MODIFICATION LOG - modifiers, enter your name, affiliation, date and
00029   changes you are making here.
00030 
00031       Name, Affiliation, Date:
00032   Description of Modification:
00033     
00034  *****************************************************************************/
00035 //$Log: sc_signal_rv_ports.h,v $
00036 //Revision 1.1.1.1  2006/12/15 20:31:35  acg
00037 //SystemC 2.2
00038 //
00039 //Revision 1.2  2006/01/03 23:18:27  acg
00040 //Changed copyright to include 2006.
00041 //
00042 //Revision 1.1.1.1  2005/12/19 23:16:43  acg
00043 //First check in of SystemC 2.1 into its own archive.
00044 //
00045 //Revision 1.11  2005/09/15 23:01:52  acg
00046 //Added std:: prefix to appropriate methods and types to get around
00047 //issues with the Edison Front End.
00048 //
00049 //Revision 1.10  2005/06/10 22:43:56  acg
00050 //Added CVS change log annotation.
00051 //
00052 
00053 #ifndef SC_SIGNAL_RV_PORTS_H
00054 #define SC_SIGNAL_RV_PORTS_H
00055 
00056 
00057 #include <cstdio>
00058 
00059 #include "sysc/communication/sc_communication_ids.h"
00060 #include "sysc/communication/sc_signal_ports.h"
00061 #include "sysc/communication/sc_signal_rv.h"
00062 #include "sysc/datatypes/bit/sc_lv.h"
00063 
00064 namespace sc_core {
00065 
00066 // ----------------------------------------------------------------------------
00067 //  CLASS : sc_in_rv<W>
00068 //
00069 //  The sc_signal_rv<W> input port class.
00070 // ----------------------------------------------------------------------------
00071 
00072 template <int W>
00073 class sc_in_rv
00074     : public sc_in<sc_dt::sc_lv<W> >
00075 {
00076 public:
00077 
00078     // typedefs
00079 
00080     typedef sc_dt::sc_lv<W>                     data_type;
00081 
00082     typedef sc_in_rv<W>                         this_type;
00083     typedef sc_in<data_type>                    base_type;
00084 
00085     typedef typename base_type::in_if_type      in_if_type;
00086     typedef typename base_type::in_port_type    in_port_type;
00087     typedef typename base_type::inout_port_type inout_port_type;
00088 
00089 public:
00090 
00091     // constructors
00092 
00093     sc_in_rv()
00094     : base_type()
00095     {}
00096 
00097     explicit sc_in_rv( const char* name_ )
00098     : base_type( name_ )
00099     {}
00100 
00101     explicit sc_in_rv( const in_if_type& interface_ )
00102     : base_type( interface_ )
00103     {}
00104 
00105     sc_in_rv( const char* name_, const in_if_type& interface_ )
00106     : base_type( name_, interface_ )
00107     {}
00108 
00109     explicit sc_in_rv( in_port_type& parent_ )
00110     : base_type( parent_ )
00111     {}
00112 
00113     sc_in_rv( const char* name_, in_port_type& parent_ )
00114     : base_type( name_, parent_ )
00115     {}
00116 
00117     explicit sc_in_rv( inout_port_type& parent_ )
00118     : base_type( parent_ )
00119     {}
00120 
00121     sc_in_rv( const char* name_, inout_port_type& parent_ )
00122     : base_type( name_, parent_ )
00123     {}
00124 
00125     sc_in_rv( this_type& parent_ )
00126     : base_type( parent_ )
00127     {}
00128 
00129     sc_in_rv( const char* name_, this_type& parent_ )
00130     : base_type( name_, parent_ )
00131     {}
00132 
00133 
00134     // destructor (does nothing)
00135 
00136     virtual ~sc_in_rv()
00137     {}
00138 
00139 
00140     // called when elaboration is done
00141     /*  WHEN DEFINING THIS METHOD IN A DERIVED CLASS, */
00142     /*  MAKE SURE THAT THIS METHOD IS CALLED AS WELL. */
00143 
00144     virtual void end_of_elaboration();
00145 
00146     virtual const char* kind() const
00147         { return "sc_in_rv"; }
00148 
00149 private:
00150 
00151     // disabled
00152     sc_in_rv( const this_type& );
00153     this_type& operator = ( const this_type& );
00154 };
00155 
00156 
00157 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
00158 
00159 
00160 // called when elaboration is done
00161 
00162 template <int W>
00163 void
00164 sc_in_rv<W>::end_of_elaboration()
00165 {
00166     base_type::end_of_elaboration();
00167     // check if bound channel is a resolved signal
00168     if( DCAST<sc_signal_rv<W>*>( this->get_interface() ) == 0 ) {
00169     char msg[BUFSIZ];
00170     std::sprintf( msg, "%s (%s)", this->name(), kind() );
00171     SC_REPORT_ERROR( SC_ID_RESOLVED_PORT_NOT_BOUND_, msg );
00172     }
00173 }
00174 
00175 
00176 // ----------------------------------------------------------------------------
00177 //  CLASS : sc_inout_rv<W>
00178 //
00179 //  The sc_signal_rv<W> input/output port class.
00180 // ----------------------------------------------------------------------------
00181 
00182 template <int W>
00183 class sc_inout_rv
00184     : public sc_inout<sc_dt::sc_lv<W> >
00185 {
00186 public:
00187 
00188     // typedefs
00189 
00190     typedef sc_dt::sc_lv<W>                     data_type;
00191 
00192     typedef sc_inout_rv<W>                      this_type;
00193     typedef sc_inout<data_type>                 base_type;
00194 
00195     typedef typename base_type::in_if_type      in_if_type;
00196     typedef typename base_type::in_port_type    in_port_type;
00197     typedef typename base_type::inout_if_type   inout_if_type;
00198     typedef typename base_type::inout_port_type inout_port_type;
00199 
00200 public:
00201 
00202     // constructors
00203 
00204     sc_inout_rv()
00205     : base_type()
00206     {}
00207 
00208     explicit sc_inout_rv( const char* name_ )
00209     : base_type( name_ )
00210     {}
00211 
00212     explicit sc_inout_rv( inout_if_type& interface_ )
00213     : base_type( interface_ )
00214     {}
00215 
00216     sc_inout_rv( const char* name_, inout_if_type& interface_ )
00217     : base_type( name_, interface_ )
00218     {}
00219 
00220     explicit sc_inout_rv( inout_port_type& parent_ )
00221     : base_type( parent_ )
00222     {}
00223 
00224     sc_inout_rv( const char* name_, inout_port_type& parent_ )
00225     : base_type( name_, parent_ )
00226     {}
00227 
00228     sc_inout_rv( this_type& parent_ )
00229     : base_type( parent_ )
00230     {}
00231 
00232     sc_inout_rv( const char* name_, this_type& parent_ )
00233     : base_type( name_, parent_ )
00234     {}
00235 
00236 
00237     // destructor (does nothing)
00238 
00239     virtual ~sc_inout_rv()
00240     {}
00241 
00242 
00243     // write the new value
00244 
00245     this_type& operator = ( const data_type& value_ )
00246     { (*this)->write( value_ ); return *this; }
00247 
00248     this_type& operator = ( const in_if_type& interface_ )
00249     { (*this)->write( interface_.read() ); return *this; }
00250 
00251     this_type& operator = ( const in_port_type& port_ )
00252     { (*this)->write( port_->read() ); return *this; }
00253 
00254     this_type& operator = ( const inout_port_type& port_ )
00255     { (*this)->write( port_->read() ); return *this; }
00256 
00257     this_type& operator = ( const this_type& port_ )
00258     { (*this)->write( port_->read() ); return *this; }
00259 
00260 
00261     // called when elaboration is done
00262     /*  WHEN DEFINING THIS METHOD IN A DERIVED CLASS, */
00263     /*  MAKE SURE THAT THIS METHOD IS CALLED AS WELL. */
00264 
00265     virtual void end_of_elaboration();
00266 
00267     virtual const char* kind() const
00268         { return "sc_inout_rv"; }
00269 
00270 private:
00271 
00272     // disabled
00273     sc_inout_rv( const this_type& );
00274 };
00275 
00276 
00277 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
00278 
00279 
00280 // called when elaboration is done
00281 
00282 template <int W>
00283 void
00284 sc_inout_rv<W>::end_of_elaboration()
00285 {
00286     base_type::end_of_elaboration();
00287     // check if bound channel is a resolved signal
00288     if( DCAST<sc_signal_rv<W>*>( this->get_interface() ) == 0 ) {
00289     char msg[BUFSIZ];
00290     std::sprintf( msg, "%s (%s)", this->name(), kind() );
00291     SC_REPORT_ERROR( SC_ID_RESOLVED_PORT_NOT_BOUND_, msg );
00292     }
00293 }
00294 
00295 
00296 // ----------------------------------------------------------------------------
00297 //  CLASS : sc_out_rv<W>
00298 //
00299 //  The sc_signal_rv<W> output port class.
00300 // ----------------------------------------------------------------------------
00301 
00302 // sc_out_rv can also read from its port, hence no difference with
00303 // sc_inout_rv. For debugging reasons, a class is provided instead
00304 // of a define.
00305 
00306 template <int W>
00307 class sc_out_rv
00308     : public sc_inout_rv<W>
00309 {
00310 public:
00311 
00312     // typedefs
00313 
00314     typedef sc_out_rv<W>                        this_type;
00315     typedef sc_inout_rv<W>                      base_type;
00316 
00317     typedef typename base_type::data_type       data_type;
00318 
00319     typedef typename base_type::in_if_type      in_if_type;
00320     typedef typename base_type::in_port_type    in_port_type;
00321     typedef typename base_type::inout_if_type   inout_if_type;
00322     typedef typename base_type::inout_port_type inout_port_type;
00323 
00324 public:
00325 
00326     // constructors
00327 
00328     sc_out_rv()
00329     : base_type()
00330     {}
00331 
00332     explicit sc_out_rv( const char* name_ )
00333     : base_type( name_ )
00334     {}
00335 
00336     explicit sc_out_rv( inout_if_type& interface_ )
00337     : base_type( interface_ )
00338     {}
00339 
00340     sc_out_rv( const char* name_, inout_if_type& interface_ )
00341     : base_type( name_, interface_ )
00342     {}
00343 
00344     explicit sc_out_rv( inout_port_type& parent_ )
00345     : base_type( parent_ )
00346     {}
00347 
00348     sc_out_rv( const char* name_, inout_port_type& parent_ )
00349     : base_type( name_, parent_ )
00350     {}
00351 
00352     sc_out_rv( this_type& parent_ )
00353     : base_type( parent_ )
00354     {}
00355 
00356     sc_out_rv( const char* name_, this_type& parent_ )
00357     : base_type( name_, parent_ )
00358     {}
00359 
00360 
00361     // destructor (does nothing)
00362 
00363     virtual ~sc_out_rv()
00364     {}
00365 
00366 
00367     // write the new value
00368 
00369     this_type& operator = ( const data_type& value_ )
00370     { (*this)->write( value_ ); return *this; }
00371 
00372     this_type& operator = ( const in_if_type& interface_ )
00373     { (*this)->write( interface_.read() ); return *this; }
00374 
00375     this_type& operator = ( const in_port_type& port_ )
00376     { (*this)->write( port_->read() ); return *this; }
00377 
00378     this_type& operator = ( const inout_port_type& port_ )
00379     { (*this)->write( port_->read() ); return *this; }
00380 
00381     this_type& operator = ( const this_type& port_ )
00382     { (*this)->write( port_->read() ); return *this; }
00383 
00384     virtual const char* kind() const
00385         { return "sc_out_rv"; }
00386 
00387 private:
00388 
00389     // disabled
00390     sc_out_rv( const this_type& );
00391 };
00392 
00393 
00394 // IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
00395 
00396 } // namespace sc_core
00397 
00398 #endif
00399 
00400 // Taf!

Generated on Wed Jan 21 15:32:07 2009 for SystemC by  doxygen 1.5.5