Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / model / vendor / TLM-2006-11-29 / tlm / tlm_core / tlm_fifo / tlm_fifo_resize.h
CommitLineData
86530b38
AT
1\r
2/*****************************************************************************\r
3\r
4 The following code is derived, directly or indirectly, from the SystemC\r
5 source code Copyright (c) 1996-2004 by all Contributors.\r
6 All Rights reserved.\r
7\r
8 The contents of this file are subject to the restrictions and limitations\r
9 set forth in the SystemC Open Source License Version 2.4 (the "License");\r
10 You may not use this file except in compliance with such restrictions and\r
11 limitations. You may obtain instructions on how to receive a copy of the\r
12 License at http://www.systemc.org/. Software distributed by Contributors\r
13 under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF\r
14 ANY KIND, either express or implied. See the License for the specific\r
15 language governing rights and limitations under the License.\r
16\r
17 *****************************************************************************/\r
18\r
19\r
20#ifndef TLM_FIFO_RESIZE_HEADER\r
21#define TLM_FIFO_RESIZE_HEADER\r
22\r
23#ifndef TLM_FIFO_HEADER\r
24#include "tlm_core/tlm_fifo/tlm_fifo.h"\r
25#endif\r
26\r
27/******************************************************************\r
28//\r
29// resize interface\r
30//\r
31******************************************************************/\r
32\r
33template < typename T>\r
34inline\r
35void\r
36tlm_fifo<T>::nb_expand( unsigned int n ) {\r
37\r
38 m_expand = true;\r
39 m_size += n;\r
40 request_update();\r
41\r
42}\r
43\r
44template < typename T>\r
45inline\r
46void\r
47tlm_fifo<T>::nb_unbound( unsigned int n ) {\r
48\r
49 m_expand = true;\r
50 m_size = -n;\r
51\r
52 if( buffer->size() < static_cast<int>( n ) ) {\r
53 buffer->resize( n );\r
54 }\r
55\r
56 request_update();\r
57\r
58}\r
59\r
60template < typename T>\r
61inline\r
62bool\r
63tlm_fifo<T>::nb_reduce( unsigned int n ) {\r
64\r
65 if( m_size < 0 ) {\r
66 return false;\r
67 }\r
68\r
69 return nb_bound( size() - n );\r
70 \r
71}\r
72\r
73template < typename T>\r
74inline\r
75bool\r
76tlm_fifo<T>::nb_bound( unsigned int new_size ) {\r
77 \r
78 bool ret = true;\r
79 \r
80 if( static_cast<int>( new_size ) < used() ) {\r
81\r
82 new_size = used();\r
83 ret = false;\r
84\r
85 }\r
86\r
87 m_size = new_size;\r
88 return ret;\r
89\r
90}\r
91\r
92#endif\r