gem5 v24.0.0.0
Loading...
Searching...
No Matches
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
31
33
34#include "debug/RubyNetwork.hh"
37
38namespace gem5
39{
40
41namespace ruby
42{
43
44namespace garnet
45{
46
48 : Consumer(router), m_router(router), m_num_vcs(m_router->get_num_vcs()),
49 m_crossbar_activity(0), switchBuffers(0)
50{
51}
52
53void
58
59/*
60 * The wakeup function of the CrossbarSwitch loops through all input ports,
61 * and sends the winning flit (from SA) out of its output port on to the
62 * output link. The output link is scheduled for wakeup in the next cycle.
63 */
64
65void
67{
68 DPRINTF(RubyNetwork, "CrossbarSwitch at Router %d woke up "
69 "at time: %lld\n",
71
72 for (auto& switch_buffer : switchBuffers) {
73 if (!switch_buffer.isReady(curTick())) {
74 continue;
75 }
76
77 flit *t_flit = switch_buffer.peekTopFlit();
78 if (t_flit->is_stage(ST_, curTick())) {
79 int outport = t_flit->get_outport();
80
81 // flit performs LT_ in the next cycle
83 t_flit->set_time(m_router->clockEdge(Cycles(1)));
84
85 // This will take care of waking up the Network Link
86 // in the next cycle
87 m_router->getOutputUnit(outport)->insert_flit(t_flit);
88 switch_buffer.getTopFlit();
90 }
91 }
92}
93
94bool
96{
97 bool read = false;
98 for (auto& switch_buffer : switchBuffers) {
99 if (switch_buffer.functionalRead(pkt, mask))
100 read = true;
101 }
102 return read;
103}
104
105uint32_t
107{
108 uint32_t num_functional_writes = 0;
109
110 for (auto& switch_buffer : switchBuffers) {
111 num_functional_writes += switch_buffer.functionalWrite(pkt);
112 }
113
114 return num_functional_writes;
115}
116
117void
122
123} // namespace garnet
124} // namespace ruby
125} // namespace gem5
#define DPRINTF(x,...)
Definition trace.hh:210
Cycles curCycle() const
Determine the current cycle, corresponding to a tick aligned to a clock edge.
Tick clockEdge(Cycles cycles=Cycles(0)) const
Determine the tick when a cycle begins, by default the current one, but the argument also enables the...
Cycles is a wrapper class for representing cycle counts, i.e.
Definition types.hh:79
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
uint32_t functionalWrite(Packet *pkt)
bool functionalRead(Packet *pkt, WriteMask &mask)
std::vector< flitBuffer > switchBuffers
void insert_flit(flit *t_flit)
OutputUnit * getOutputUnit(unsigned port)
Definition Router.hh:108
void set_time(Tick time)
Definition flit.hh:75
bool is_stage(flit_stage stage, Tick time)
Definition flit.hh:86
void advance_stage(flit_stage t_stage, Tick newTime)
Definition flit.hh:93
Bitfield< 3, 0 > mask
Definition pcstate.hh:63
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
Tick curTick()
The universal simulation clock.
Definition cur_tick.hh:46

Generated on Tue Jun 18 2024 16:24:05 for gem5 by doxygen 1.11.0