1/* 2 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 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; --- 29 unchanged lines hidden (view full) --- 38 39using namespace std; 40using m5::stl_helpers::deletePointers; 41using m5::stl_helpers::operator<<; 42 43Switch::Switch(const Params *p) : BasicRouter(p) 44{ 45 m_perfect_switch = new PerfectSwitch(m_id, this, p->virt_nets); |
46 m_port_buffers = p->port_buffers; 47 m_num_connected_buffers = 0; |
48} 49 50Switch::~Switch() 51{ 52 delete m_perfect_switch; 53 54 // Delete throttles (one per output port) 55 deletePointers(m_throttles); 56 57 // Delete MessageBuffers |
58 deletePointers(m_port_buffers); |
59} 60 61void 62Switch::init() 63{ 64 BasicRouter::init(); 65 m_perfect_switch->init(m_network_ptr); 66} --- 27 unchanged lines hidden (view full) --- 94 // Create one buffer per vnet (these are intermediaryQueues) 95 vector<MessageBuffer*> intermediateBuffers; 96 97 for (int i = 0; i < out.size(); ++i) { 98 if (out[i] != nullptr) { 99 out[i]->setSender(this); 100 } 101 |
102 assert(m_num_connected_buffers < m_port_buffers.size()); 103 MessageBuffer* buffer_ptr = m_port_buffers[m_num_connected_buffers]; 104 m_num_connected_buffers++; |
105 intermediateBuffers.push_back(buffer_ptr); |
106 107 buffer_ptr->setSender(this); 108 buffer_ptr->setReceiver(this); 109 } 110 111 // Hook the queues to the PerfectSwitch 112 m_perfect_switch->addOutPort(intermediateBuffers, routing_table_entry); 113 --- 66 unchanged lines hidden (view full) --- 180 // FIXME printing 181 out << "[Switch]"; 182} 183 184bool 185Switch::functionalRead(Packet *pkt) 186{ 187 // Access the buffers in the switch for performing a functional read |
188 for (unsigned int i = 0; i < m_port_buffers.size(); ++i) { 189 if (m_port_buffers[i]->functionalRead(pkt)) { |
190 return true; 191 } 192 } 193 return false; 194} 195 196uint32_t 197Switch::functionalWrite(Packet *pkt) 198{ 199 // Access the buffers in the switch for performing a functional write 200 uint32_t num_functional_writes = 0; |
201 for (unsigned int i = 0; i < m_port_buffers.size(); ++i) { 202 num_functional_writes += m_port_buffers[i]->functionalWrite(pkt); |
203 } 204 return num_functional_writes; 205} 206 207Switch * 208SwitchParams::create() 209{ 210 return new Switch(this); 211} |