RubySlicc_Util.hh (8608:02d7ac5fb855) RubySlicc_Util.hh (9116:9171e26543fa)
1/*
2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 21 unchanged lines hidden (view full) ---

30 * These are the functions that exported to slicc from ruby.
31 */
32
33#ifndef __MEM_RUBY_SLICC_INTERFACE_RUBYSLICCUTIL_HH__
34#define __MEM_RUBY_SLICC_INTERFACE_RUBYSLICCUTIL_HH__
35
36#include <cassert>
37
1/*
2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 21 unchanged lines hidden (view full) ---

30 * These are the functions that exported to slicc from ruby.
31 */
32
33#ifndef __MEM_RUBY_SLICC_INTERFACE_RUBYSLICCUTIL_HH__
34#define __MEM_RUBY_SLICC_INTERFACE_RUBYSLICCUTIL_HH__
35
36#include <cassert>
37
38#include "mem/protocol/AccessType.hh"
39#include "mem/protocol/GenericRequestType.hh"
40#include "mem/protocol/MachineType.hh"
41#include "mem/protocol/MessageSizeType.hh"
42#include "mem/protocol/PrefetchBit.hh"
43#include "mem/ruby/common/Address.hh"
44#include "mem/ruby/common/Global.hh"
38#include "mem/ruby/common/Address.hh"
39#include "mem/ruby/common/Global.hh"
45#include "mem/ruby/network/Network.hh"
46#include "mem/ruby/slicc_interface/RubySlicc_ComponentMapping.hh"
40#include "mem/ruby/slicc_interface/RubySlicc_ComponentMapping.hh"
47#include "mem/ruby/system/MachineID.hh"
48#include "mem/ruby/system/System.hh"
49
41#include "mem/ruby/system/System.hh"
42
50class Set;
51class NetDest;
52
53inline int
54random(int n)
55{
56 return random() % n;
57}
58
43inline int
44random(int n)
45{
46 return random() % n;
47}
48
59inline bool
60multicast_retry()
61{
62 if (RubySystem::getRandomization()) {
63 return (random() & 0x1);
64 } else {
65 return true;
66 }
67}
68
69inline Time
70get_time()
71{
72 return g_eventQueue_ptr->getTime();
73}
74
75inline Time
76zero_time()

--- 10 unchanged lines hidden (view full) ---

87
88inline int
89IDToInt(NodeID id)
90{
91 int nodenum = id;
92 return nodenum;
93}
94
49inline Time
50get_time()
51{
52 return g_eventQueue_ptr->getTime();
53}
54
55inline Time
56zero_time()

--- 10 unchanged lines hidden (view full) ---

67
68inline int
69IDToInt(NodeID id)
70{
71 int nodenum = id;
72 return nodenum;
73}
74
95inline int
96addressToInt(Address addr)
97{
98 return (int)addr.getLineAddress();
99}
100
101inline bool
102long_enough_ago(Time event)
103{
104 return ((get_time() - event) > 200);
105}
106
107inline int
108getAddThenMod(int addend1, int addend2, int modulus)
109{
110 return (addend1 + addend2) % modulus;
111}
112
113inline Time
114getTimeModInt(Time time, int modulus)
115{
116 return time % modulus;
117}
118
119inline Time
120getTimePlusInt(Time addend1, int addend2)
121{
122 return (Time) addend1 + addend2;
123}
124
125inline Time
126getTimeMinusTime(Time t1, Time t2)
127{
128 assert(t1 >= t2);
129 return t1 - t2;
130}
131
75inline Time
76getTimeModInt(Time time, int modulus)
77{
78 return time % modulus;
79}
80
81inline Time
82getTimePlusInt(Time addend1, int addend2)
83{
84 return (Time) addend1 + addend2;
85}
86
87inline Time
88getTimeMinusTime(Time t1, Time t2)
89{
90 assert(t1 >= t2);
91 return t1 - t2;
92}
93
132inline Time
133getPreviousDelayedCycles(Time t1, Time t2)
134{
135 if (RubySystem::getRandomization()) { // when randomizing delayed
136 return 0;
137 } else {
138 return getTimeMinusTime(t1, t2);
139 }
140}
141
142// Return type for time_to_int is "Time" and not "int" so we get a
143// 64-bit integer
144inline Time
145time_to_int(Time time)
146{
147 return time;
148}
149

--- 31 unchanged lines hidden ---
94// Return type for time_to_int is "Time" and not "int" so we get a
95// 64-bit integer
96inline Time
97time_to_int(Time time)
98{
99 return time;
100}
101

--- 31 unchanged lines hidden ---