gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CrossbarSwitch.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008 Princeton University
3  * Copyright (c) 2016 Georgia Institute of Technology
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  * Authors: Niket Agarwal
30  * Tushar Krishna
31  */
32 
33 
35 
36 #include "base/stl_helpers.hh"
37 #include "debug/RubyNetwork.hh"
40 
42 
44  : Consumer(router)
45 {
46  m_router = router;
49 }
50 
52 {
54 }
55 
56 void
58 {
60 
63  for (int i = 0; i < m_num_inports; i++) {
64  m_switch_buffer[i] = new flitBuffer();
65  }
66 }
67 
68 /*
69  * The wakeup function of the CrossbarSwitch loops through all input ports,
70  * and sends the winning flit (from SA) out of its output port on to the
71  * output link. The output link is scheduled for wakeup in the next cycle.
72  */
73 
74 void
76 {
77  DPRINTF(RubyNetwork, "CrossbarSwitch at Router %d woke up "
78  "at time: %lld\n",
80 
81  for (int inport = 0; inport < m_num_inports; inport++) {
82  if (!m_switch_buffer[inport]->isReady(m_router->curCycle()))
83  continue;
84 
85  flit *t_flit = m_switch_buffer[inport]->peekTopFlit();
86  if (t_flit->is_stage(ST_, m_router->curCycle())) {
87  int outport = t_flit->get_outport();
88 
89  // flit performs LT_ in the next cycle
90  t_flit->advance_stage(LT_, m_router->curCycle() + Cycles(1));
91  t_flit->set_time(m_router->curCycle() + Cycles(1));
92 
93  // This will take care of waking up the Network Link
94  // in the next cycle
95  m_output_unit[outport]->insert_flit(t_flit);
96  m_switch_buffer[inport]->getTopFlit();
98  }
99  }
100 }
101 
102 uint32_t
104 {
105  uint32_t num_functional_writes = 0;
106 
107  for (uint32_t i = 0; i < m_switch_buffer.size(); ++i) {
108  num_functional_writes += m_switch_buffer[i]->functionalWrite(pkt);
109  }
110 
111  return num_functional_writes;
112 }
#define DPRINTF(x,...)
Definition: trace.hh:212
void set_time(Cycles time)
Definition: flit.hh:66
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
Bitfield< 7 > i
Definition: miscregs.hh:1378
int get_outport()
Definition: flit.hh:51
uint32_t functionalWrite(Packet *pkt)
int get_id()
Definition: Router.hh:81
Cycles curCycle() const
Determine the current cycle, corresponding to a tick aligned to a clock edge.
double m_crossbar_activity
Definition: flit.hh:44
std::vector< flitBuffer * > m_switch_buffer
void deletePointers(C< T, A > &container)
Definition: stl_helpers.hh:77
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:245
bool is_stage(flit_stage stage, Cycles time)
Definition: flit.hh:76
Definition: Router.hh:57
std::vector< OutputUnit * > m_output_unit
int get_num_vcs()
Definition: Router.hh:76
int get_num_inports()
Definition: Router.hh:79
void advance_stage(flit_stage t_stage, Cycles newTime)
Definition: flit.hh:83
CrossbarSwitch(Router *router)
std::vector< OutputUnit * > & get_outputUnit_ref()
Definition: Router.hh:90

Generated on Fri Jun 9 2017 13:03:49 for gem5 by doxygen 1.8.6