WireBuffer.cc (10893:f567e80c0714) | WireBuffer.cc (10919:80069a602c83) |
---|---|
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; --- 20 unchanged lines hidden (view full) --- 29 * 30 */ 31 32#include <algorithm> 33#include <functional> 34 35#include "base/cprintf.hh" 36#include "base/stl_helpers.hh" | 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; --- 20 unchanged lines hidden (view full) --- 29 * 30 */ 31 32#include <algorithm> 33#include <functional> 34 35#include "base/cprintf.hh" 36#include "base/stl_helpers.hh" |
37#include "mem/ruby/common/Global.hh" | |
38#include "mem/ruby/structures/WireBuffer.hh" 39#include "mem/ruby/system/System.hh" 40 41using namespace std; 42 43// Output operator definition 44 45ostream& --- 7 unchanged lines hidden (view full) --- 53 54// **************************************************************** 55 56// CONSTRUCTOR 57WireBuffer::WireBuffer(const Params *p) 58 : SimObject(p) 59{ 60 m_msg_counter = 0; | 37#include "mem/ruby/structures/WireBuffer.hh" 38#include "mem/ruby/system/System.hh" 39 40using namespace std; 41 42// Output operator definition 43 44ostream& --- 7 unchanged lines hidden (view full) --- 52 53// **************************************************************** 54 55// CONSTRUCTOR 56WireBuffer::WireBuffer(const Params *p) 57 : SimObject(p) 58{ 59 m_msg_counter = 0; |
60 m_ruby_system = p->ruby_system; |
|
61} 62 63void 64WireBuffer::init() 65{ 66} 67 68WireBuffer::~WireBuffer() 69{ 70} 71 72void 73WireBuffer::enqueue(MsgPtr message, Cycles latency) 74{ 75 m_msg_counter++; | 61} 62 63void 64WireBuffer::init() 65{ 66} 67 68WireBuffer::~WireBuffer() 69{ 70} 71 72void 73WireBuffer::enqueue(MsgPtr message, Cycles latency) 74{ 75 m_msg_counter++; |
76 Cycles current_time = g_system_ptr->curCycle(); | 76 Cycles current_time = m_ruby_system->curCycle(); |
77 Cycles arrival_time = current_time + latency; 78 assert(arrival_time > current_time); 79 80 Message* msg_ptr = message.get(); 81 msg_ptr->setLastEnqueueTime(arrival_time); 82 m_message_queue.push_back(message); 83 if (m_consumer_ptr != NULL) { 84 m_consumer_ptr-> | 77 Cycles arrival_time = current_time + latency; 78 assert(arrival_time > current_time); 79 80 Message* msg_ptr = message.get(); 81 msg_ptr->setLastEnqueueTime(arrival_time); 82 m_message_queue.push_back(message); 83 if (m_consumer_ptr != NULL) { 84 m_consumer_ptr-> |
85 scheduleEventAbsolute(g_system_ptr->clockPeriod() * arrival_time); | 85 scheduleEventAbsolute(m_ruby_system->clockPeriod() * arrival_time); |
86 } else { 87 panic("No Consumer for WireBuffer! %s\n", *this); 88 } 89} 90 91void 92WireBuffer::dequeue() 93{ --- 17 unchanged lines hidden (view full) --- 111 // Because you don't want anything reordered, make sure the recycle latency 112 // is just 1 cycle. As a result, you really want to use this only in 113 // Wire-like situations because you don't want to deadlock as a result of 114 // being stuck behind something if you're not actually supposed to. 115 assert(isReady()); 116 MsgPtr node = m_message_queue.front(); 117 pop_heap(m_message_queue.begin(), m_message_queue.end(), greater<MsgPtr>()); 118 | 86 } else { 87 panic("No Consumer for WireBuffer! %s\n", *this); 88 } 89} 90 91void 92WireBuffer::dequeue() 93{ --- 17 unchanged lines hidden (view full) --- 111 // Because you don't want anything reordered, make sure the recycle latency 112 // is just 1 cycle. As a result, you really want to use this only in 113 // Wire-like situations because you don't want to deadlock as a result of 114 // being stuck behind something if you're not actually supposed to. 115 assert(isReady()); 116 MsgPtr node = m_message_queue.front(); 117 pop_heap(m_message_queue.begin(), m_message_queue.end(), greater<MsgPtr>()); 118 |
119 node->setLastEnqueueTime(g_system_ptr->curCycle() + Cycles(1)); | 119 node->setLastEnqueueTime(m_ruby_system->curCycle() + Cycles(1)); |
120 m_message_queue.back() = node; 121 push_heap(m_message_queue.begin(), m_message_queue.end(), 122 greater<MsgPtr>()); 123 m_consumer_ptr-> | 120 m_message_queue.back() = node; 121 push_heap(m_message_queue.begin(), m_message_queue.end(), 122 greater<MsgPtr>()); 123 m_consumer_ptr-> |
124 scheduleEventAbsolute(g_system_ptr->curCycle() + Cycles(1)); | 124 scheduleEventAbsolute(m_ruby_system->curCycle() + Cycles(1)); |
125} 126 127bool 128WireBuffer::isReady() 129{ 130 return ((!m_message_queue.empty()) && 131 (m_message_queue.front()->getLastEnqueueTime() <= | 125} 126 127bool 128WireBuffer::isReady() 129{ 130 return ((!m_message_queue.empty()) && 131 (m_message_queue.front()->getLastEnqueueTime() <= |
132 g_system_ptr->curCycle())); | 132 m_ruby_system->curCycle())); |
133} 134 135void 136WireBuffer::print(ostream& out) const 137{ 138} 139 140void 141WireBuffer::wakeup() 142{ 143} 144 145WireBuffer * 146RubyWireBufferParams::create() 147{ 148 return new WireBuffer(this); 149} | 133} 134 135void 136WireBuffer::print(ostream& out) const 137{ 138} 139 140void 141WireBuffer::wakeup() 142{ 143} 144 145WireBuffer * 146RubyWireBufferParams::create() 147{ 148 return new WireBuffer(this); 149} |