RubyPort.hh (6844:b8421af116e5) | RubyPort.hh (6876:a658c315512c) |
---|---|
1 2/* 3 * Copyright (c) 2009 Advanced Micro Devices, Inc. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer; 10 * redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution; 13 * neither the name of the copyright holders nor the names of its 14 * contributors may be used to endorse or promote products derived from 15 * this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 |
|
1#ifndef RUBYPORT_H 2#define RUBYPORT_H 3 4#include "mem/ruby/libruby.hh" 5#include <string> 6#include <assert.h> 7 | 30#ifndef RUBYPORT_H 31#define RUBYPORT_H 32 33#include "mem/ruby/libruby.hh" 34#include <string> 35#include <assert.h> 36 |
37#include "mem/mem_object.hh" 38#include "mem/tport.hh" 39 40#include "params/RubyPort.hh" 41 |
|
8using namespace std; 9 | 42using namespace std; 43 |
10class RubyPort { | 44class MessageBuffer; 45class AbstractController; 46 47class RubyPort : public MemObject { |
11public: | 48public: |
12 RubyPort(const string & name) 13 : m_name(name) 14 { 15 m_port_id = m_num_ports++; 16 m_request_cnt = 0; 17 m_hit_callback = NULL; 18 assert(m_num_ports <= 2048); // see below for reason 19 } | 49 typedef RubyPortParams Params; 50 RubyPort(const Params *p); |
20 virtual ~RubyPort() {} 21 | 51 virtual ~RubyPort() {} 52 |
53 Port *getPort(const std::string &if_name, int idx); 54 |
|
22 virtual int64_t makeRequest(const RubyRequest & request) = 0; 23 24 void registerHitCallback(void (*hit_callback)(int64_t request_id)) { 25 assert(m_hit_callback == NULL); // can't assign hit_callback twice 26 m_hit_callback = hit_callback; 27 } 28 29protected: --- 16 unchanged lines hidden (view full) --- 46 // and 2^48 ~= 3x10^14 requests per component 47 48 int64_t id = (static_cast<uint64_t>(m_port_id) << 48) | m_request_cnt; 49 m_request_cnt++; 50 // assert((m_request_cnt & (1<<48)) == 0); 51 return id; 52 } 53 | 55 virtual int64_t makeRequest(const RubyRequest & request) = 0; 56 57 void registerHitCallback(void (*hit_callback)(int64_t request_id)) { 58 assert(m_hit_callback == NULL); // can't assign hit_callback twice 59 m_hit_callback = hit_callback; 60 } 61 62protected: --- 16 unchanged lines hidden (view full) --- 79 // and 2^48 ~= 3x10^14 requests per component 80 81 int64_t id = (static_cast<uint64_t>(m_port_id) << 48) | m_request_cnt; 82 m_request_cnt++; 83 // assert((m_request_cnt & (1<<48)) == 0); 84 return id; 85 } 86 |
87 int m_version; 88 AbstractController* m_controller; 89 MessageBuffer* m_mandatory_q_ptr; 90 |
|
54private: 55 static uint16_t m_num_ports; 56 uint16_t m_port_id; 57 uint64_t m_request_cnt; 58}; 59 60#endif | 91private: 92 static uint16_t m_num_ports; 93 uint16_t m_port_id; 94 uint64_t m_request_cnt; 95}; 96 97#endif |