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; --- 50 unchanged lines hidden (view full) --- 59void 60Switch::init() 61{ 62 BasicRouter::init(); 63 m_perfect_switch->init(m_network_ptr); 64} 65 66void |
67Switch::addInPort(const vector<MessageBuffer*>& in) |
68{ 69 m_perfect_switch->addInPort(in); 70 71 for (auto& it : in) { |
72 if (it != nullptr) { 73 it->setReceiver(this); 74 } |
75 } 76} 77 78void |
79Switch::addOutPort(const vector<MessageBuffer*>& out, |
80 const NetDest& routing_table_entry, 81 Cycles link_latency, int bw_multiplier) 82{ 83 // Create a throttle 84 Throttle* throttle_ptr = new Throttle(m_id, m_throttles.size(), 85 link_latency, bw_multiplier, 86 m_network_ptr->getEndpointBandwidth(), 87 this); 88 89 m_throttles.push_back(throttle_ptr); 90 91 // Create one buffer per vnet (these are intermediaryQueues) |
92 vector<MessageBuffer*> intermediateBuffers; |
93 |
94 for (int i = 0; i < out.size(); ++i) { 95 if (out[i] != nullptr) { 96 out[i]->setSender(this); 97 } |
98 99 MessageBuffer* buffer_ptr = new MessageBuffer; 100 // Make these queues ordered 101 buffer_ptr->setOrdering(true); 102 if (m_network_ptr->getBufferSize() > 0) { 103 buffer_ptr->resize(m_network_ptr->getBufferSize()); 104 } 105 |
106 intermediateBuffers.push_back(buffer_ptr); |
107 m_buffers_to_free.push_back(buffer_ptr); 108 109 buffer_ptr->setSender(this); 110 buffer_ptr->setReceiver(this); 111 } 112 113 // Hook the queues to the PerfectSwitch 114 m_perfect_switch->addOutPort(intermediateBuffers, routing_table_entry); --- 99 unchanged lines hidden --- |