summaryrefslogtreecommitdiff
path: root/src/mem/ruby/tester/XactRequestGenerator.hh
blob: 826a257ce7b9b9b91ec966cbac9ed07cb8247ae4 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
 * Copyright (c) 1999 by Mark Hill and David Wood for the Wisconsin
 * Multifacet Project.  ALL RIGHTS RESERVED.
 *
 * ##HEADER##
 *
 * This software is furnished under a license and may be used and
 * copied only in accordance with the terms of such license and the
 * inclusion of the above copyright notice.  This software or any
 * other copies thereof or any derivative works may not be provided or
 * otherwise made available to any other persons.  Title to and
 * ownership of the software is retained by Mark Hill and David Wood.
 * Any use of this software must include the above copyright notice.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS".  THE LICENSOR MAKES NO
 * WARRANTIES ABOUT ITS CORRECTNESS OR PERFORMANCE.
 * */

/*
 * $Id: XactRequestGenerator.h 1.4 05/07/07 10:35:32-05:00 kmoore@s0-30.cs.wisc.edu $
 *
 * Description:
 *
 */

#ifndef XACTREQUESTGENERATOR_H
#define XACTREQUESTGENERATOR_H

#include "global.hh"
#include "RequestGenerator.hh"
#include "Consumer.hh"
#include "NodeID.hh"
#include "Address.hh"
#include "TransactionManager.hh"

class Sequencer;
class SubBlock;
class SyntheticDriver;
class Instruction;
class TransactionManager;

#define MAX_ADDRESS 16777216
const int TESTER_MAX_DEPTH = 16;

enum XactRequestGeneratorStatus {
  XactRequestGeneratorStatus_Waiting,
  XactRequestGeneratorStatus_Ready,
  XactRequestGeneratorStatus_Blocked,
  XactRequestGeneratorStatus_Aborted,
  XactRequestGeneratorStatus_Done
};

class XactRequestGenerator : public RequestGenerator {
public:
  // Constructors
  XactRequestGenerator(NodeID node, SyntheticDriver& driver);

  // Destructor
  ~XactRequestGenerator();

  // Public Methods
  void wakeup();
  void performCallback(NodeID proc, SubBlock& data);
  void abortTransaction();

  void print(ostream& out) const;

  // For dealing with NACKs/retries
  void notifySendNack(const Address & addr, uint64 remote_timestamp, const MachineID & remote_id);
  void notifyReceiveNack(const Address & addr, uint64 remote_timestamp, const MachineID & remote_id);
  void notifyReceiveNackFinal(const Address & addr);
private:
  // Private Methods
  int thinkTime() const;
  int waitTime() const;
  int holdTime() const;
  void initiateBeginTransaction();
  void initiateStore(Address a);
  void initiateCommit();
  void initiateInc(Address a);
  void initiateLoad(Address a);
  void initiateDone();
  void pickAddress();
  Sequencer* sequencer() const;
  TransactionManager* transactionManager() const;
  void execute();
  void scheduleEvent(int time);
  void checkCorrectness();

  // Private copy constructor and assignment operator
  XactRequestGenerator(const XactRequestGenerator& obj);
  XactRequestGenerator& operator=(const XactRequestGenerator& obj);

  void newTransaction(bool init);
  void printPcStack(int depth);

  // Data Members (m_ prefix)
  SyntheticDriver& m_driver;
  NodeID m_node;
  XactRequestGeneratorStatus m_status;
  int m_counter;
  int m_size;
  Time m_last_transition;
  Address m_address;

  Instruction *m_instructions;
  int m_pc;
  int pc_stack[TESTER_MAX_DEPTH];
  bool m_transaction;
  uint8 m_register;
  uint8 * testArray;
  //static uint8 dataArray[];
  bool m_eventPending;

  // for pending aborts
  bool m_abortPending;
};

// Output operator declaration
ostream& operator<<(ostream& out, const XactRequestGenerator& obj);

// ******************* Definitions *******************

// Output operator definition
extern inline
ostream& operator<<(ostream& out, const XactRequestGenerator& obj)
{
  obj.print(out);
  out << flush;
  return out;
}

#endif //XACTREQUESTGENERATOR_H