WireBuffer.hh revision 9499
17404SAli.Saidi@ARM.com/* 212709Sgiacomo.travaglini@arm.com * Copyright (c) 2010 Advanced Micro Devices, Inc. 37404SAli.Saidi@ARM.com * All rights reserved. 47404SAli.Saidi@ARM.com * 57404SAli.Saidi@ARM.com * Redistribution and use in source and binary forms, with or without 67404SAli.Saidi@ARM.com * modification, are permitted provided that the following conditions are 77404SAli.Saidi@ARM.com * met: redistributions of source code must retain the above copyright 87404SAli.Saidi@ARM.com * notice, this list of conditions and the following disclaimer; 97404SAli.Saidi@ARM.com * redistributions in binary form must reproduce the above copyright 107404SAli.Saidi@ARM.com * notice, this list of conditions and the following disclaimer in the 117404SAli.Saidi@ARM.com * documentation and/or other materials provided with the distribution; 127404SAli.Saidi@ARM.com * neither the name of the copyright holders nor the names of its 137404SAli.Saidi@ARM.com * contributors may be used to endorse or promote products derived from 147404SAli.Saidi@ARM.com * this software without specific prior written permission. 157404SAli.Saidi@ARM.com * 167404SAli.Saidi@ARM.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 177404SAli.Saidi@ARM.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 187404SAli.Saidi@ARM.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 197404SAli.Saidi@ARM.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 207404SAli.Saidi@ARM.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 217404SAli.Saidi@ARM.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 227404SAli.Saidi@ARM.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 237404SAli.Saidi@ARM.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 247404SAli.Saidi@ARM.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 257404SAli.Saidi@ARM.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 267404SAli.Saidi@ARM.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 277404SAli.Saidi@ARM.com * 287404SAli.Saidi@ARM.com * Author: Lisa Hsu 297404SAli.Saidi@ARM.com * 307404SAli.Saidi@ARM.com */ 317404SAli.Saidi@ARM.com 327404SAli.Saidi@ARM.com#ifndef __MEM_RUBY_SYSTEM_WIREBUFFER_HH__ 337404SAli.Saidi@ARM.com#define __MEM_RUBY_SYSTEM_WIREBUFFER_HH__ 347404SAli.Saidi@ARM.com 357404SAli.Saidi@ARM.com#include <iostream> 367404SAli.Saidi@ARM.com#include <string> 377404SAli.Saidi@ARM.com#include <vector> 3810037SARM gem5 Developers 397404SAli.Saidi@ARM.com#include "mem/ruby/buffers/MessageBufferNode.hh" 4010873Sandreas.sandberg@arm.com#include "mem/ruby/common/Consumer.hh" 417404SAli.Saidi@ARM.com#include "params/RubyWireBuffer.hh" 4210474Sandreas.hansson@arm.com#include "sim/sim_object.hh" 4310474Sandreas.hansson@arm.com 447404SAli.Saidi@ARM.com////////////////////////////////////////////////////////////////////////////// 4510037SARM gem5 Developers// This object was written to literally mimic a Wire in Ruby, in the sense 4610037SARM gem5 Developers// that there is no way for messages to get reordered en route on the WireBuffer. 477404SAli.Saidi@ARM.com// With Message Buffers, even if randomization is off and ordered is on, 487728SAli.Saidi@ARM.com// messages can arrive in different orders than they were sent because of 497404SAli.Saidi@ARM.com// network issues. This mimics a Wire, such that that is not possible. This can 508245Snate@binkert.org// allow for messages between closely coupled controllers that are not actually 519152Satgutier@umich.edu// separated by a network in real systems to simplify coherence. 528245Snate@binkert.org///////////////////////////////////////////////////////////////////////////// 538245Snate@binkert.org 5410873Sandreas.sandberg@arm.comclass Message; 557748SAli.Saidi@ARM.com 567404SAli.Saidi@ARM.comclass WireBuffer : public SimObject 577404SAli.Saidi@ARM.com{ 587404SAli.Saidi@ARM.com public: 597404SAli.Saidi@ARM.com typedef RubyWireBufferParams Params; 6010913Sandreas.sandberg@arm.com WireBuffer(const Params *p); 6110717Sandreas.hansson@arm.com void init(); 6210717Sandreas.hansson@arm.com 6310717Sandreas.hansson@arm.com ~WireBuffer(); 649258SAli.Saidi@ARM.com 6510621SCurtis.Dunham@arm.com void wakeup(); 6610621SCurtis.Dunham@arm.com 6712086Sspwilson2@wisc.edu void setConsumer(Consumer* consumer_ptr) 6812086Sspwilson2@wisc.edu { 6912086Sspwilson2@wisc.edu m_consumer_ptr = consumer_ptr; 7012086Sspwilson2@wisc.edu } 7112086Sspwilson2@wisc.edu Consumer* getConsumer() { return m_consumer_ptr; }; 7212086Sspwilson2@wisc.edu void setDescription(const std::string& name) { m_description = name; }; 7311588SCurtis.Dunham@arm.com std::string getDescription() { return m_description; }; 7411588SCurtis.Dunham@arm.com 7512086Sspwilson2@wisc.edu void enqueue(MsgPtr message, Cycles latency); 767439Sdam.sunwoo@arm.com void dequeue(); 777576SAli.Saidi@ARM.com const Message* peek(); 7810037SARM gem5 Developers MessageBufferNode peekNode(); 7910037SARM gem5 Developers void recycle(); 8010037SARM gem5 Developers bool isReady(); 8110717Sandreas.hansson@arm.com bool areNSlotsAvailable(int n) { return true; }; // infinite queue length 8210037SARM gem5 Developers 8310037SARM gem5 Developers void print(std::ostream& out) const; 8410037SARM gem5 Developers void clearStats() const; 8510037SARM gem5 Developers void printStats(std::ostream& out) const; 8610037SARM gem5 Developers 8710037SARM gem5 Developers uint64_t m_msg_counter; 8810037SARM gem5 Developers 8910037SARM gem5 Developers private: 9010037SARM gem5 Developers // Private copy constructor and assignment operator 9110037SARM gem5 Developers WireBuffer (const WireBuffer& obj); 9210037SARM gem5 Developers WireBuffer& operator=(const WireBuffer& obj); 9310037SARM gem5 Developers 947439Sdam.sunwoo@arm.com // data members 957404SAli.Saidi@ARM.com Consumer* m_consumer_ptr; // Consumer to signal a wakeup() 967404SAli.Saidi@ARM.com std::string m_description; 977404SAli.Saidi@ARM.com 987404SAli.Saidi@ARM.com // queues where memory requests live 997404SAli.Saidi@ARM.com std::vector<MessageBufferNode> m_message_queue; 1007404SAli.Saidi@ARM.com 10110717Sandreas.hansson@arm.com}; 10210717Sandreas.hansson@arm.com 10310717Sandreas.hansson@arm.com#endif // __MEM_RUBY_SYSTEM_WireBuffer_HH__ 10410717Sandreas.hansson@arm.com