gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
CrossbarSwitch.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Inria
3  * Copyright (c) 2016 Georgia Institute of Technology
4  * Copyright (c) 2008 Princeton University
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are
9  * met: redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer;
11  * redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution;
14  * neither the name of the copyright holders nor the names of its
15  * contributors may be used to endorse or promote products derived from
16  * this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  *
30  * Authors: Niket Agarwal
31  * Tushar Krishna
32  */
33 
34 
36 
37 #include "debug/RubyNetwork.hh"
40 
42  : Consumer(router)
43 {
44  m_router = router;
47 }
48 
49 void
51 {
53 
56  for (int i = 0; i < m_num_inports; i++) {
57  m_switch_buffer[i].reset(new flitBuffer());
58  }
59 }
60 
61 /*
62  * The wakeup function of the CrossbarSwitch loops through all input ports,
63  * and sends the winning flit (from SA) out of its output port on to the
64  * output link. The output link is scheduled for wakeup in the next cycle.
65  */
66 
67 void
69 {
70  DPRINTF(RubyNetwork, "CrossbarSwitch at Router %d woke up "
71  "at time: %lld\n",
73 
74  for (int inport = 0; inport < m_num_inports; inport++) {
75  if (!m_switch_buffer[inport]->isReady(m_router->curCycle()))
76  continue;
77 
78  flit *t_flit = m_switch_buffer[inport]->peekTopFlit();
79  if (t_flit->is_stage(ST_, m_router->curCycle())) {
80  int outport = t_flit->get_outport();
81 
82  // flit performs LT_ in the next cycle
83  t_flit->advance_stage(LT_, m_router->curCycle() + Cycles(1));
84  t_flit->set_time(m_router->curCycle() + Cycles(1));
85 
86  // This will take care of waking up the Network Link
87  // in the next cycle
88  m_output_unit[outport]->insert_flit(t_flit);
89  m_switch_buffer[inport]->getTopFlit();
91  }
92  }
93 }
94 
95 uint32_t
97 {
98  uint32_t num_functional_writes = 0;
99 
100  for (uint32_t i = 0; i < m_switch_buffer.size(); ++i) {
101  num_functional_writes += m_switch_buffer[i]->functionalWrite(pkt);
102  }
103 
104  return num_functional_writes;
105 }
106 
107 void
109 {
111 }
#define DPRINTF(x,...)
Definition: trace.hh:229
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
int get_outport()
Definition: flit.hh:51
uint32_t functionalWrite(Packet *pkt)
int get_id()
Definition: Router.hh:81
double m_crossbar_activity
Definition: flit.hh:44
Cycles curCycle() const
Determine the current cycle, corresponding to a tick aligned to a clock edge.
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:255
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< std::unique_ptr< flitBuffer > > m_switch_buffer
std::vector< OutputUnit * > & get_outputUnit_ref()
Definition: Router.hh:90

Generated on Fri Feb 28 2020 16:27:02 for gem5 by doxygen 1.8.13