summaryrefslogtreecommitdiff
path: root/src/mem/ruby/tester/XactAbortRequestGenerator.hh
blob: 90ec1bf1b254c854f9ca33e001972564c468beb4 (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
/*
 * 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$
 *
 * Description:
 *
 */

#ifndef XACTABORTREQUESTGENERATOR_H
#define XACTABORTREQUESTGENERATOR_H

#ifdef XACT_MEM

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

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

#define MAX_ADDRESS 16777216

enum XactAbortRequestGeneratorStatus {
  XactAbortRequestGeneratorStatus_Waiting,
  XactAbortRequestGeneratorStatus_Ready,
  XactAbortRequestGeneratorStatus_Blocked,
  XactAbortRequestGeneratorStatus_Aborted,
  XactAbortRequestGeneratorStatus_Done
};

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

  // Destructor
  ~XactAbortRequestGenerator();

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

  void print(ostream& out) const;
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 pickAddress();
  Sequencer* sequencer() const;
  TransactionManager* transactionManager() const;
  void execute();

  void checkCorrectness();

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

  void newTransaction();

  // Data Members (m_ prefix)
  SyntheticDriver& m_driver;
  NodeID m_node;
  XactAbortRequestGeneratorStatus m_xact_status;
  int m_counter;
  Time m_last_transition;
  Address m_address;

  Instruction *m_instructions;
  int m_pc;
  uint8 m_register;
  static Vector<uint8> testArray;
  //static uint8 dataArray[];
};

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

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

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

#endif //XACT_MEM

#endif //REQUESTGENERATOR_H