Deleted Added
sdiff udiff text old ( 10301:44839e8febbd ) new ( 10893:f567e80c0714 )
full compact
1/*
2 * Copyright (c) 2010 Advanced Micro Devices, Inc.
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;

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

72void
73WireBuffer::enqueue(MsgPtr message, Cycles latency)
74{
75 m_msg_counter++;
76 Cycles current_time = g_system_ptr->curCycle();
77 Cycles arrival_time = current_time + latency;
78 assert(arrival_time > current_time);
79
80 MessageBufferNode thisNode(arrival_time, m_msg_counter, message);
81 m_message_queue.push_back(thisNode);
82 if (m_consumer_ptr != NULL) {
83 m_consumer_ptr->
84 scheduleEventAbsolute(g_system_ptr->clockPeriod() * arrival_time);
85 } else {
86 panic("No Consumer for WireBuffer! %s\n", *this);
87 }
88}
89
90void
91WireBuffer::dequeue()
92{
93 assert(isReady());
94 pop_heap(m_message_queue.begin(), m_message_queue.end(),
95 greater<MessageBufferNode>());
96 m_message_queue.pop_back();
97}
98
99const Message*
100WireBuffer::peek()
101{
102 MessageBufferNode node = peekNode();
103 Message* msg_ptr = node.m_msgptr.get();
104 assert(msg_ptr != NULL);
105 return msg_ptr;
106}
107
108MessageBufferNode
109WireBuffer::peekNode()
110{
111 assert(isReady());
112 MessageBufferNode req = m_message_queue.front();
113 return req;
114}
115
116void
117WireBuffer::recycle()
118{
119 // Because you don't want anything reordered, make sure the recycle latency
120 // is just 1 cycle. As a result, you really want to use this only in
121 // Wire-like situations because you don't want to deadlock as a result of
122 // being stuck behind something if you're not actually supposed to.
123 assert(isReady());
124 MessageBufferNode node = m_message_queue.front();
125 pop_heap(m_message_queue.begin(), m_message_queue.end(),
126 greater<MessageBufferNode>());
127
128 node.m_time = g_system_ptr->curCycle() + Cycles(1);
129 m_message_queue.back() = node;
130 push_heap(m_message_queue.begin(), m_message_queue.end(),
131 greater<MessageBufferNode>());
132 m_consumer_ptr->
133 scheduleEventAbsolute(g_system_ptr->clockPeriod() * node.m_time);
134}
135
136bool
137WireBuffer::isReady()
138{
139 return ((!m_message_queue.empty()) &&
140 (m_message_queue.front().m_time <= g_system_ptr->curCycle()));
141}
142
143void
144WireBuffer::print(ostream& out) const
145{
146}
147
148void
149WireBuffer::wakeup()
150{
151}
152
153WireBuffer *
154RubyWireBufferParams::create()
155{
156 return new WireBuffer(this);
157}
158