summaryrefslogtreecommitdiff
path: root/src/intersim/buffer_state.hpp
blob: 8418f02471e4c2c8662a6efd64def64f57cd48b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef _BUFFER_STATE_HPP_
#define _BUFFER_STATE_HPP_

#include "module.hpp"
#include "flit.hpp"
#include "credit.hpp"
#include "config_utils.hpp"

class BufferState : public Module {

   int  _wait_for_tail_credit;
   int  _buf_size;
   int  _vcs;

   int  _last_avail;

   bool *_in_use;
   bool *_tail_sent;
   int  *_cur_occupied;

   void _Init( const Configuration& config );

public:
    BufferState() : Module( ) {}
   void init( const Configuration& config );
   BufferState( const Configuration& config, 
                Module *parent, const string& name );
   ~BufferState( );

   void ProcessCredit( Credit *c );
   void SendingFlit( Flit *f );

   void TakeBuffer( int vc = 0 );

   bool IsFullFor( int vc = 0 ) const;
   bool IsAvailableFor( int vc = 0 ) const;

   int FindAvailable( );

   void Display( ) const;
};

#endif