TLM-2.0: include/tlm/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_resize.h Source File

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# include/tlm/tlm_1/tlm_req_rsp/tlm_channels/tlm_fifo/tlm_fifo_resize.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-2008 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 3.0 (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 #ifndef __TLM_FIFO_RESIZE_H__
    00019 #define __TLM_FIFO_RESIZE_H__
    00020
    00021 /******************************************************************
    00022 //
    00023 // resize interface
    00024 //
    00025 ******************************************************************/
    00026
    00027 namespace tlm {
    00028
    00029 template < typename T>
    00030 inline
    00031 void
    00032 tlm_fifo<T>::nb_expand( unsigned int n ) {
    00033
    00034   m_expand = true;
    00035   m_size += n;
    00036   request_update();
    00037
    00038 }
    00039
    00040 template < typename T>
    00041 inline
    00042 void
    00043 tlm_fifo<T>::nb_unbound( unsigned int n ) {
    00044
    00045   m_expand = true;
    00046   m_size = -n;
    00047
    00048   if( buffer->size() < static_cast<int>( n ) ) {
    00049     buffer->resize( n );
    00050   }
    00051
    00052   request_update();
    00053
    00054 }
    00055
    00056 template < typename T>
    00057 inline
    00058 bool
    00059 tlm_fifo<T>::nb_reduce( unsigned int n ) {
    00060
    00061   if( m_size < 0 ) {
    00062     return false;
    00063   }
    00064
    00065   return nb_bound( size() - n );
    00066
    00067 }
    00068
    00069 template < typename T>
    00070 inline
    00071 bool
    00072 tlm_fifo<T>::nb_bound( unsigned int new_size ) {
    00073
    00074   bool ret = true;
    00075
    00076   if( static_cast<int>( new_size ) < used() ) {
    00077
    00078     new_size = used();
    00079     ret = false;
    00080
    00081   }
    00082
    00083   m_size = new_size;
    00084   return ret;
    00085
    00086 }
    00087
    00088 } // namespace tlm
    00089
    00090 #endif