BankedArray.hh revision 9105
1
2#ifndef __MEM_RUBY_SYSTEM_BANKEDARRAY_HH__
3#define __MEM_RUBY_SYSTEM_BANKEDARRAY_HH__
4
5#include <vector>
6
7#include "mem/ruby/common/TypeDefines.hh"
8#include "sim/eventq.hh"
9
10
11
12class BankedArray : public EventManager
13{
14private:
15    unsigned int banks;
16    unsigned int accessLatency;
17    unsigned int bankBits;
18    unsigned int startIndexBit;
19
20    //std::vector<bool> busyBanks;
21
22    class TickEvent : public Event
23    {
24    public:
25        TickEvent() : Event() {}
26        void process() {}
27        Index idx;
28        Tick startAccess;
29    };
30    friend class TickEvent;
31
32    // If the tick event is scheduled then the bank is busy
33    // otherwise, schedule the event and wait for it to complete
34    std::vector<TickEvent> busyBanks;
35
36    unsigned int mapIndexToBank(Index idx);
37
38public:
39    BankedArray(unsigned int banks, unsigned int accessLatency, unsigned int startIndexBit);
40
41    // Note: We try the access based on the cache index, not the address
42    // This is so we don't get aliasing on blocks being replaced
43    bool tryAccess(Index idx);
44
45};
46
47#endif
48