gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BlockBloomFilter.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met: redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer;
9  * redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution;
12  * neither the name of the copyright holders nor the names of its
13  * contributors may be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
30 
31 #include "base/intmath.hh"
32 #include "base/str.hh"
34 
35 using namespace std;
36 
38 {
39  m_filter_size = size;
40  m_filter_size_bits = floorLog2(m_filter_size);
41 
42  m_filter.resize(m_filter_size);
43 
44  clear();
45 }
46 
48 {
49 }
50 
51 void
53 {
54  for (int i = 0; i < m_filter_size; i++) {
55  m_filter[i] = 0;
56  }
57 }
58 
59 void
61 {
62  // Not used
63 }
64 
65 void
67 {
68  // Not used
69 }
70 
71 void
73 {
74  // TODO
75 }
76 
77 void
79 {
80  int i = get_index(addr);
81  m_filter[i] = 1;
82 }
83 
84 void
86 {
87  int i = get_index(addr);
88  m_filter[i] = 0;
89 }
90 
91 bool
93 {
94  int i = get_index(addr);
95  return (m_filter[i]);
96 }
97 
98 int
100 {
101  return m_filter[get_index(addr)];
102 }
103 
104 int
106 {
107  int count = 0;
108 
109  for (int i = 0; i < m_filter_size; i++) {
110  if (m_filter[i]) {
111  count++;
112  }
113  }
114  return count;
115 }
116 
117 int
119 {
120  return get_index(addr);
121 }
122 
123 void
124 BlockBloomFilter::print(ostream& out) const
125 {
126 }
127 
128 int
130 {
131  return m_filter[index];
132 }
133 
134 void
135 BlockBloomFilter::writeBit(const int index, const int value)
136 {
137  m_filter[index] = value;
138 }
139 
140 int
142 {
143  // Pull out some bit field ==> B1
144  // Pull out additional bits, not the same as B1 ==> B2
145  // XOR B1 and B2 to get hash index
146  Addr block_bits = bitSelect(addr, RubySystem::getBlockSizeBits(),
147  2 * RubySystem::getBlockSizeBits() - 1);
148  int offset = 5;
149  Addr other_bits = bitSelect(addr,
150  2 * RubySystem::getBlockSizeBits() + offset,
151  2 * RubySystem::getBlockSizeBits() + offset +
152  m_filter_size_bits - 1);
153  int index = block_bits ^ other_bits;
154  assert(index < m_filter_size);
155  return index;
156 }
157 
158 
count
Definition: misc.hh:704
Bitfield< 30, 0 > index
Addr bitSelect(Addr addr, unsigned int small, unsigned int big)
Definition: Address.cc:34
Bitfield< 7 > i
Definition: miscregs.hh:1378
void increment(Addr addr)
void decrement(Addr addr)
ip6_addr_t addr
Definition: inet.hh:335
bool isSet(Addr addr)
Bitfield< 23, 0 > offset
Definition: types.hh:149
void unset(Addr addr)
int getIndex(Addr addr)
BlockBloomFilter(int size)
void writeBit(const int index, const int value)
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
void set(Addr addr)
int floorLog2(unsigned x)
Definition: intmath.hh:100
int getCount(Addr addr)
int size()
Definition: pagetable.hh:146
int get_index(Addr addr)
void merge(AbstractBloomFilter *other_filter)
static uint32_t getBlockSizeBits()
Definition: RubySystem.hh:75
int readBit(const int index)
void print(std::ostream &out) const

Generated on Fri Jun 9 2017 13:03:49 for gem5 by doxygen 1.8.6