Deleted Added
sdiff udiff text old ( 10918:dd3ab1f109ad ) new ( 11021:e8a6637afa4c )
full compact
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}
47
48Switch::~Switch()
49{
50 delete m_perfect_switch;
51
52 // Delete throttles (one per output port)
53 deletePointers(m_throttles);
54
55 // Delete MessageBuffers
56 deletePointers(m_buffers_to_free);
57}
58
59void
60Switch::init()
61{
62 BasicRouter::init();
63 m_perfect_switch->init(m_network_ptr);
64}

--- 27 unchanged lines hidden (view full) ---

92 // Create one buffer per vnet (these are intermediaryQueues)
93 vector<MessageBuffer*> intermediateBuffers;
94
95 for (int i = 0; i < out.size(); ++i) {
96 if (out[i] != nullptr) {
97 out[i]->setSender(this);
98 }
99
100 MessageBuffer* buffer_ptr = new MessageBuffer;
101 // Make these queues ordered
102 buffer_ptr->setOrdering(true);
103 if (m_network_ptr->getBufferSize() > 0) {
104 buffer_ptr->resize(m_network_ptr->getBufferSize());
105 }
106
107 intermediateBuffers.push_back(buffer_ptr);
108 m_buffers_to_free.push_back(buffer_ptr);
109
110 buffer_ptr->setSender(this);
111 buffer_ptr->setReceiver(this);
112 }
113
114 // Hook the queues to the PerfectSwitch
115 m_perfect_switch->addOutPort(intermediateBuffers, routing_table_entry);
116

--- 66 unchanged lines hidden (view full) ---

183 // FIXME printing
184 out << "[Switch]";
185}
186
187bool
188Switch::functionalRead(Packet *pkt)
189{
190 // Access the buffers in the switch for performing a functional read
191 for (unsigned int i = 0; i < m_buffers_to_free.size(); ++i) {
192 if (m_buffers_to_free[i]->functionalRead(pkt)) {
193 return true;
194 }
195 }
196 return false;
197}
198
199uint32_t
200Switch::functionalWrite(Packet *pkt)
201{
202 // Access the buffers in the switch for performing a functional write
203 uint32_t num_functional_writes = 0;
204 for (unsigned int i = 0; i < m_buffers_to_free.size(); ++i) {
205 num_functional_writes += m_buffers_to_free[i]->functionalWrite(pkt);
206 }
207 return num_functional_writes;
208}
209
210Switch *
211SwitchParams::create()
212{
213 return new Switch(this);
214}