AbstractController.hh revision 10522
18999Suri.wiener@arm.com/* 28999Suri.wiener@arm.com * Copyright (c) 2009 Mark D. Hill and David A. Wood 38999Suri.wiener@arm.com * All rights reserved. 48999Suri.wiener@arm.com * 58999Suri.wiener@arm.com * Redistribution and use in source and binary forms, with or without 68999Suri.wiener@arm.com * modification, are permitted provided that the following conditions are 78999Suri.wiener@arm.com * met: redistributions of source code must retain the above copyright 88999Suri.wiener@arm.com * notice, this list of conditions and the following disclaimer; 98999Suri.wiener@arm.com * redistributions in binary form must reproduce the above copyright 108999Suri.wiener@arm.com * notice, this list of conditions and the following disclaimer in the 118999Suri.wiener@arm.com * documentation and/or other materials provided with the distribution; 128999Suri.wiener@arm.com * neither the name of the copyright holders nor the names of its 134762Snate@binkert.org * contributors may be used to endorse or promote products derived from 147534Ssteve.reinhardt@amd.com * this software without specific prior written permission. 154762Snate@binkert.org * 164762Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 174762Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 184762Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 194762Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 204762Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 214762Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 224762Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 234762Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 244762Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 254762Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 264762Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 274762Snate@binkert.org */ 284762Snate@binkert.org 294762Snate@binkert.org#ifndef __MEM_RUBY_SLICC_INTERFACE_ABSTRACTCONTROLLER_HH__ 304762Snate@binkert.org#define __MEM_RUBY_SLICC_INTERFACE_ABSTRACTCONTROLLER_HH__ 314762Snate@binkert.org 324762Snate@binkert.org#include <iostream> 334762Snate@binkert.org#include <string> 344762Snate@binkert.org 354762Snate@binkert.org#include "base/callback.hh" 364762Snate@binkert.org#include "mem/protocol/AccessPermission.hh" 374762Snate@binkert.org#include "mem/ruby/common/Address.hh" 384762Snate@binkert.org#include "mem/ruby/common/Consumer.hh" 394762Snate@binkert.org#include "mem/ruby/common/DataBlock.hh" 404762Snate@binkert.org#include "mem/ruby/common/Histogram.hh" 414762Snate@binkert.org#include "mem/ruby/common/MachineID.hh" 424762Snate@binkert.org#include "mem/ruby/network/MessageBuffer.hh" 434762Snate@binkert.org#include "mem/ruby/network/Network.hh" 444762Snate@binkert.org#include "mem/ruby/system/CacheRecorder.hh" 454762Snate@binkert.org#include "mem/packet.hh" 464762Snate@binkert.org#include "params/RubyController.hh" 4711991Sandreas.sandberg@arm.com#include "sim/clocked_object.hh" 4811802Sandreas.sandberg@arm.com 4911802Sandreas.sandberg@arm.comclass Network; 5011802Sandreas.sandberg@arm.com 5111802Sandreas.sandberg@arm.comclass AbstractController : public ClockedObject, public Consumer 526001Snate@binkert.org{ 534762Snate@binkert.org public: 544762Snate@binkert.org typedef RubyControllerParams Params; 554851Snate@binkert.org AbstractController(const Params *p); 5611418Ssascha.bischoff@arm.com void init(); 578999Suri.wiener@arm.com const Params *params() const { return (const Params *)_params; } 587525Ssteve.reinhardt@amd.com 598664SAli.Saidi@ARM.com const NodeID getVersion() const { return m_machineID.getNum(); } 604762Snate@binkert.org const MachineType getType() const { return m_machineID.getType(); } 619811Sandreas.hansson@arm.com 629811Sandreas.hansson@arm.com void initNetworkPtr(Network* net_ptr) { m_net_ptr = net_ptr; } 636654Snate@binkert.org 649521SAndreas.Sandberg@ARM.com // return instance name 659521SAndreas.Sandberg@ARM.com void blockOnQueue(Address, MessageBuffer*); 669521SAndreas.Sandberg@ARM.com void unblock(Address); 679524SAndreas.Sandberg@ARM.com 689521SAndreas.Sandberg@ARM.com virtual MessageBuffer* getMandatoryQueue() const = 0; 699521SAndreas.Sandberg@ARM.com virtual AccessPermission getAccessPermission(const Address& addr) = 0; 7011802Sandreas.sandberg@arm.com 7110912Sandreas.sandberg@arm.com virtual void print(std::ostream & out) const = 0; 724762Snate@binkert.org virtual void wakeup() = 0; 734762Snate@binkert.org virtual void resetStats() = 0; 747531Ssteve.reinhardt@amd.com virtual void regStats(); 758245Snate@binkert.org 768234Snate@binkert.org virtual void recordCacheTrace(int cntrl, CacheRecorder* tr) = 0; 777525Ssteve.reinhardt@amd.com virtual Sequencer* getSequencer() const = 0; 787525Ssteve.reinhardt@amd.com 797525Ssteve.reinhardt@amd.com //! These functions are used by ruby system to read/write the message 807525Ssteve.reinhardt@amd.com //! queues that exist with in the controller. 817525Ssteve.reinhardt@amd.com //! The boolean return value indicates if the read was performed 824762Snate@binkert.org //! successfully. 834762Snate@binkert.org virtual bool functionalReadBuffers(PacketPtr&) = 0; 844762Snate@binkert.org virtual void functionalRead(const Address &addr, PacketPtr) = 0; 857528Ssteve.reinhardt@amd.com //! The return value indicates the number of messages written with the 867528Ssteve.reinhardt@amd.com //! data from the packet. 877528Ssteve.reinhardt@amd.com virtual uint32_t functionalWriteBuffers(PacketPtr&) = 0; 887528Ssteve.reinhardt@amd.com virtual int functionalWrite(const Address &addr, PacketPtr) = 0; 897527Ssteve.reinhardt@amd.com 907527Ssteve.reinhardt@amd.com //! Function for enqueuing a prefetch request 915037Smilesck@eecs.umich.edu virtual void enqueuePrefetch(const Address&, const RubyRequestType&) 925773Snate@binkert.org { fatal("Prefetches not implemented!");} 935773Snate@binkert.org 947527Ssteve.reinhardt@amd.com //! Function for collating statistics from all the controllers of this 957527Ssteve.reinhardt@amd.com //! particular type. This function should only be called from the 967527Ssteve.reinhardt@amd.com //! version 0 of this controller type. 975773Snate@binkert.org virtual void collateStats() 984762Snate@binkert.org {fatal("collateStats() should be overridden!");} 998664SAli.Saidi@ARM.com 1008675SAli.Saidi@ARM.com //! Set the message buffer with given name. 1018675SAli.Saidi@ARM.com virtual void setNetQueue(const std::string& name, MessageBuffer *b) = 0; 1028675SAli.Saidi@ARM.com 1038675SAli.Saidi@ARM.com public: 1048675SAli.Saidi@ARM.com MachineID getMachineID() const { return m_machineID; } 1058675SAli.Saidi@ARM.com 1068675SAli.Saidi@ARM.com Stats::Histogram& getDelayHist() { return m_delayHistogram; } 1078675SAli.Saidi@ARM.com Stats::Histogram& getDelayVCHist(uint32_t index) 1088664SAli.Saidi@ARM.com { return *(m_delayVCHistogram[index]); } 1098999Suri.wiener@arm.com 1108664SAli.Saidi@ARM.com protected: 1114762Snate@binkert.org //! Profiles original cache requests including PUTs 1126001Snate@binkert.org void profileRequest(const std::string &request); 1134762Snate@binkert.org //! Profiles the delay associated with messages. 1144762Snate@binkert.org void profileMsgDelay(uint32_t virtualNetwork, Cycles delay); 1157527Ssteve.reinhardt@amd.com 1167527Ssteve.reinhardt@amd.com void stallBuffer(MessageBuffer* buf, Address addr); 1174762Snate@binkert.org void wakeUpBuffers(Address addr); 1184762Snate@binkert.org void wakeUpAllBuffers(Address addr); 1197527Ssteve.reinhardt@amd.com void wakeUpAllBuffers(); 1204762Snate@binkert.org 1214762Snate@binkert.org protected: 1227527Ssteve.reinhardt@amd.com NodeID m_version; 1234762Snate@binkert.org MachineID m_machineID; 12410023Smatt.horsnell@ARM.com NodeID m_clusterID; 12510023Smatt.horsnell@ARM.com 12610023Smatt.horsnell@ARM.com Network* m_net_ptr; 12710023Smatt.horsnell@ARM.com bool m_is_blocking; 12810023Smatt.horsnell@ARM.com std::map<Address, MessageBuffer*> m_block_map; 12910023Smatt.horsnell@ARM.com 13011418Ssascha.bischoff@arm.com typedef std::vector<MessageBuffer*> MsgVecType; 13111418Ssascha.bischoff@arm.com typedef std::map< Address, MsgVecType* > WaitingBufType; 13211418Ssascha.bischoff@arm.com WaitingBufType m_waiting_buffers; 13311431Ssascha.bischoff@arm.com 13411431Ssascha.bischoff@arm.com unsigned int m_in_ports; 13511418Ssascha.bischoff@arm.com unsigned int m_cur_in_port; 1366001Snate@binkert.org int m_number_of_TBEs; 1376001Snate@binkert.org int m_transitions_per_cycle; 1384762Snate@binkert.org unsigned int m_buffer_size; 1397531Ssteve.reinhardt@amd.com Cycles m_recycle_latency; 1407531Ssteve.reinhardt@amd.com 14110912Sandreas.sandberg@arm.com //! Counter for the number of cycles when the transitions carried out 14211802Sandreas.sandberg@arm.com //! were equal to the maximum allowed 14311802Sandreas.sandberg@arm.com Stats::Scalar m_fully_busy_cycles; 1447532Ssteve.reinhardt@amd.com 1457532Ssteve.reinhardt@amd.com //! Histogram for profiling delay for the messages this controller 1467532Ssteve.reinhardt@amd.com //! cares for 1477531Ssteve.reinhardt@amd.com Stats::Histogram m_delayHistogram; 1489262Ssascha.bischoff@arm.com std::vector<Stats::Histogram *> m_delayVCHistogram; 1499262Ssascha.bischoff@arm.com 1509262Ssascha.bischoff@arm.com //! Callback class used for collating statistics from all the 1519262Ssascha.bischoff@arm.com //! controller of this type. 1524762Snate@binkert.org class StatsCallback : public Callback 1534762Snate@binkert.org { 15410912Sandreas.sandberg@arm.com private: 1554762Snate@binkert.org AbstractController *ctr; 1564762Snate@binkert.org 1577527Ssteve.reinhardt@amd.com public: 1587527Ssteve.reinhardt@amd.com virtual ~StatsCallback() {} 1594762Snate@binkert.org StatsCallback(AbstractController *_ctr) : ctr(_ctr) {} 1604762Snate@binkert.org void process() {ctr->collateStats();} 1619983Sstever@gmail.com }; 1629983Sstever@gmail.com}; 1639983Sstever@gmail.com 1649983Sstever@gmail.com#endif // __MEM_RUBY_SLICC_INTERFACE_ABSTRACTCONTROLLER_HH__ 1659983Sstever@gmail.com