RubyTester.hh (7632:acf43d6bbc18) RubyTester.hh (8090:722a0d28ee83)
1/*
2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * Copyright (c) 2009 Advanced Micro Devices, Inc.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;
10 * redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution;
13 * neither the name of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#ifndef __CPU_RUBYTEST_RUBYTESTER_HH__
31#define __CPU_RUBYTEST_RUBYTESTER_HH__
32
33#include <iostream>
34#include <vector>
35#include <string>
36
37#include "cpu/testers/rubytest/CheckTable.hh"
38#include "mem/mem_object.hh"
39#include "mem/packet.hh"
1/*
2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * Copyright (c) 2009 Advanced Micro Devices, Inc.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer;
10 * redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution;
13 * neither the name of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30#ifndef __CPU_RUBYTEST_RUBYTESTER_HH__
31#define __CPU_RUBYTEST_RUBYTESTER_HH__
32
33#include <iostream>
34#include <vector>
35#include <string>
36
37#include "cpu/testers/rubytest/CheckTable.hh"
38#include "mem/mem_object.hh"
39#include "mem/packet.hh"
40#include "mem/ruby/common/DataBlock.hh"
41#include "mem/ruby/common/Global.hh"
42#include "mem/ruby/common/SubBlock.hh"
43#include "mem/ruby/system/RubyPort.hh"
44#include "params/RubyTester.hh"
45
46class RubyTester : public MemObject
47{
48 public:
49 class CpuPort : public SimpleTimingPort
50 {
51 private:
52 RubyTester *tester;
53
54 public:
55 CpuPort(const std::string &_name, RubyTester *_tester, int _idx)
56 : SimpleTimingPort(_name, _tester), tester(_tester), idx(_idx)
57 {}
58
59 int idx;
60
61 protected:
62 virtual bool recvTiming(PacketPtr pkt);
63 virtual Tick recvAtomic(PacketPtr pkt);
64 };
65
66 struct SenderState : public Packet::SenderState
67 {
68 SubBlock* subBlock;
69 Packet::SenderState *saved;
70
71 SenderState(Address addr, int size,
72 Packet::SenderState *sender_state = NULL)
73 : saved(sender_state)
74 {
75 subBlock = new SubBlock(addr, size);
76 }
77
78 ~SenderState()
79 {
80 delete subBlock;
81 }
82 };
83
84 typedef RubyTesterParams Params;
85 RubyTester(const Params *p);
86 ~RubyTester();
87
88 virtual Port *getPort(const std::string &if_name, int idx = -1);
89
90 Port* getCpuPort(int idx);
91
92 virtual void init();
93
94 void wakeup();
95
96 void incrementCheckCompletions() { m_checks_completed++; }
97
98 void printStats(std::ostream& out) const {}
99 void clearStats() {}
100 void printConfig(std::ostream& out) const {}
101
102 void print(std::ostream& out) const;
103
104 protected:
105 class CheckStartEvent : public Event
106 {
107 private:
108 RubyTester *tester;
109
110 public:
111 CheckStartEvent(RubyTester *_tester)
112 : Event(CPU_Tick_Pri), tester(_tester)
113 {}
114 void process() { tester->wakeup(); }
115 virtual const char *description() const { return "RubyTester tick"; }
116 };
117
118 CheckStartEvent checkStartEvent;
119
120 private:
121 void hitCallback(NodeID proc, SubBlock* data);
122
123 void checkForDeadlock();
124
125 // Private copy constructor and assignment operator
126 RubyTester(const RubyTester& obj);
127 RubyTester& operator=(const RubyTester& obj);
128
129 CheckTable* m_checkTable_ptr;
130 std::vector<Time> m_last_progress_vector;
131
132 uint64 m_checks_completed;
133 std::vector<CpuPort*> ports;
134 uint64 m_checks_to_complete;
135 int m_deadlock_threshold;
136 int m_num_cpu_sequencers;
137 int m_wakeup_frequency;
138};
139
140inline std::ostream&
141operator<<(std::ostream& out, const RubyTester& obj)
142{
143 obj.print(out);
144 out << std::flush;
145 return out;
146}
147
148#endif // __CPU_RUBYTEST_RUBYTESTER_HH__
40#include "mem/ruby/common/Global.hh"
41#include "mem/ruby/common/SubBlock.hh"
42#include "mem/ruby/system/RubyPort.hh"
43#include "params/RubyTester.hh"
44
45class RubyTester : public MemObject
46{
47 public:
48 class CpuPort : public SimpleTimingPort
49 {
50 private:
51 RubyTester *tester;
52
53 public:
54 CpuPort(const std::string &_name, RubyTester *_tester, int _idx)
55 : SimpleTimingPort(_name, _tester), tester(_tester), idx(_idx)
56 {}
57
58 int idx;
59
60 protected:
61 virtual bool recvTiming(PacketPtr pkt);
62 virtual Tick recvAtomic(PacketPtr pkt);
63 };
64
65 struct SenderState : public Packet::SenderState
66 {
67 SubBlock* subBlock;
68 Packet::SenderState *saved;
69
70 SenderState(Address addr, int size,
71 Packet::SenderState *sender_state = NULL)
72 : saved(sender_state)
73 {
74 subBlock = new SubBlock(addr, size);
75 }
76
77 ~SenderState()
78 {
79 delete subBlock;
80 }
81 };
82
83 typedef RubyTesterParams Params;
84 RubyTester(const Params *p);
85 ~RubyTester();
86
87 virtual Port *getPort(const std::string &if_name, int idx = -1);
88
89 Port* getCpuPort(int idx);
90
91 virtual void init();
92
93 void wakeup();
94
95 void incrementCheckCompletions() { m_checks_completed++; }
96
97 void printStats(std::ostream& out) const {}
98 void clearStats() {}
99 void printConfig(std::ostream& out) const {}
100
101 void print(std::ostream& out) const;
102
103 protected:
104 class CheckStartEvent : public Event
105 {
106 private:
107 RubyTester *tester;
108
109 public:
110 CheckStartEvent(RubyTester *_tester)
111 : Event(CPU_Tick_Pri), tester(_tester)
112 {}
113 void process() { tester->wakeup(); }
114 virtual const char *description() const { return "RubyTester tick"; }
115 };
116
117 CheckStartEvent checkStartEvent;
118
119 private:
120 void hitCallback(NodeID proc, SubBlock* data);
121
122 void checkForDeadlock();
123
124 // Private copy constructor and assignment operator
125 RubyTester(const RubyTester& obj);
126 RubyTester& operator=(const RubyTester& obj);
127
128 CheckTable* m_checkTable_ptr;
129 std::vector<Time> m_last_progress_vector;
130
131 uint64 m_checks_completed;
132 std::vector<CpuPort*> ports;
133 uint64 m_checks_to_complete;
134 int m_deadlock_threshold;
135 int m_num_cpu_sequencers;
136 int m_wakeup_frequency;
137};
138
139inline std::ostream&
140operator<<(std::ostream& out, const RubyTester& obj)
141{
142 obj.print(out);
143 out << std::flush;
144 return out;
145}
146
147#endif // __CPU_RUBYTEST_RUBYTESTER_HH__