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