gem5  v21.1.0.2
OutputUnit.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"
39 
40 namespace gem5
41 {
42 
43 namespace ruby
44 {
45 
46 namespace garnet
47 {
48 
49 OutputUnit::OutputUnit(int id, PortDirection direction, Router *router,
50  uint32_t consumerVcs)
51  : Consumer(router), m_router(router), m_id(id), m_direction(direction),
52  m_vc_per_vnet(consumerVcs)
53 {
54  const int m_num_vcs = consumerVcs * m_router->get_num_vnets();
55  outVcState.reserve(m_num_vcs);
56  for (int i = 0; i < m_num_vcs; i++) {
57  outVcState.emplace_back(i, m_router->get_net_ptr(), consumerVcs);
58  }
59 }
60 
61 void
63 {
64  DPRINTF(RubyNetwork, "Router %d OutputUnit %s decrementing credit:%d for "
65  "outvc %d at time: %lld for %s\n", m_router->get_id(),
67  outVcState[out_vc].get_credit_count(),
68  out_vc, m_router->curCycle(), m_credit_link->name());
69 
70  outVcState[out_vc].decrement_credit();
71 }
72 
73 void
75 {
76  DPRINTF(RubyNetwork, "Router %d OutputUnit %s incrementing credit:%d for "
77  "outvc %d at time: %lld from:%s\n", m_router->get_id(),
79  outVcState[out_vc].get_credit_count(),
80  out_vc, m_router->curCycle(), m_credit_link->name());
81 
82  outVcState[out_vc].increment_credit();
83 }
84 
85 // Check if the output VC (i.e., input VC at next router)
86 // has free credits (i..e, buffer slots).
87 // This is tracked by OutVcState
88 bool
90 {
91  assert(outVcState[out_vc].isInState(ACTIVE_, curTick()));
92  return outVcState[out_vc].has_credit();
93 }
94 
95 
96 // Check if the output port (i.e., input port at next router) has free VCs.
97 bool
99 {
100  int vc_base = vnet*m_vc_per_vnet;
101  for (int vc = vc_base; vc < vc_base + m_vc_per_vnet; vc++) {
102  if (is_vc_idle(vc, curTick()))
103  return true;
104  }
105 
106  return false;
107 }
108 
109 // Assign a free output VC to the winner of Switch Allocation
110 int
112 {
113  int vc_base = vnet*m_vc_per_vnet;
114  for (int vc = vc_base; vc < vc_base + m_vc_per_vnet; vc++) {
115  if (is_vc_idle(vc, curTick())) {
116  outVcState[vc].setState(ACTIVE_, curTick());
117  return vc;
118  }
119  }
120 
121  return -1;
122 }
123 
124 /*
125  * The wakeup function of the OutputUnit reads the credit signal from the
126  * downstream router for the output VC (i.e., input VC at downstream router).
127  * It increments the credit count in the appropriate output VC state.
128  * If the credit carries is_free_signal as true,
129  * the output VC is marked IDLE.
130  */
131 
132 void
134 {
135  if (m_credit_link->isReady(curTick())) {
136  Credit *t_credit = (Credit*) m_credit_link->consumeLink();
137  increment_credit(t_credit->get_vc());
138 
139  if (t_credit->is_free_signal())
140  set_vc_state(IDLE_, t_credit->get_vc(), curTick());
141 
142  delete t_credit;
143 
144  if (m_credit_link->isReady(curTick())) {
145  scheduleEvent(Cycles(1));
146  }
147  }
148 }
149 
150 flitBuffer*
152 {
153  return &outBuffer;
154 }
155 
156 void
158 {
159  m_out_link = link;
160 }
161 
162 void
164 {
165  m_credit_link = credit_link;
166 }
167 
168 void
170 {
171  outBuffer.insert(t_flit);
173 }
174 
175 uint32_t
177 {
178  return outBuffer.functionalWrite(pkt);
179 }
180 
181 } // namespace garnet
182 } // namespace ruby
183 } // namespace gem5
gem5::curTick
Tick curTick()
The universal simulation clock.
Definition: cur_tick.hh:46
gem5::ruby::garnet::flit
Definition: flit.hh:50
gem5::ruby::garnet::OutputUnit::functionalWrite
uint32_t functionalWrite(Packet *pkt)
Definition: OutputUnit.cc:176
gem5::ruby::garnet::Router::get_net_ptr
GarnetNetwork * get_net_ptr()
Definition: Router.hh:98
gem5::ruby::garnet::OutputUnit::get_credit_count
int get_credit_count(int vc)
Definition: OutputUnit.hh:76
gem5::ruby::PortDirection
std::string PortDirection
Definition: Topology.hh:68
gem5::Clocked::curCycle
Cycles curCycle() const
Determine the current cycle, corresponding to a tick aligned to a clock edge.
Definition: clocked_object.hh:195
gem5::ruby::garnet::OutputUnit::m_router
Router * m_router
Definition: OutputUnit.hh:110
gem5::ruby::garnet::Credit
Definition: Credit.hh:54
gem5::ruby::garnet::Router
Definition: Router.hh:66
gem5::ruby::garnet::OutputUnit::outVcState
std::vector< OutVcState > outVcState
Definition: OutputUnit.hh:120
gem5::ruby::garnet::OutputUnit::has_free_vc
bool has_free_vc(int vnet)
Definition: OutputUnit.cc:98
gem5::ruby::Consumer
Definition: Consumer.hh:61
gem5::ruby::garnet::Router::get_num_vnets
uint32_t get_num_vnets()
Definition: Router.hh:87
gem5::ArmISA::i
Bitfield< 7 > i
Definition: misc_types.hh:66
flitBuffer.hh
gem5::ruby::garnet::OutputUnit::decrement_credit
void decrement_credit(int out_vc)
Definition: OutputUnit.cc:62
gem5::ruby::garnet::OutputUnit::insert_flit
void insert_flit(flit *t_flit)
Definition: OutputUnit.cc:169
gem5::Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:78
gem5::ruby::garnet::flit::get_vc
int get_vc()
Definition: flit.hh:66
gem5::Named::name
virtual std::string name() const
Definition: named.hh:47
gem5::ruby::Consumer::scheduleEvent
void scheduleEvent(Cycles timeDelta)
Definition: Consumer.cc:56
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:186
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:283
gem5::ruby::garnet::OutputUnit::has_credit
bool has_credit(int out_vc)
Definition: OutputUnit.cc:89
gem5::ruby::garnet::OutputUnit::set_out_link
void set_out_link(NetworkLink *link)
Definition: OutputUnit.cc:157
gem5::ruby::garnet::OutputUnit::m_out_link
NetworkLink * m_out_link
Definition: OutputUnit.hh:114
gem5::ruby::garnet::OutputUnit::getOutQueue
flitBuffer * getOutQueue()
Definition: OutputUnit.cc:151
gem5::ruby::garnet::OutputUnit::set_credit_link
void set_credit_link(CreditLink *credit_link)
Definition: OutputUnit.cc:163
gem5::ruby::garnet::flitBuffer::insert
void insert(flit *flt)
Definition: flitBuffer.hh:78
gem5::ruby::garnet::OutputUnit::increment_credit
void increment_credit(int out_vc)
Definition: OutputUnit.cc:74
gem5::ruby::garnet::IDLE_
@ IDLE_
Definition: CommonTypes.hh:49
gem5::Clocked::clockEdge
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...
Definition: clocked_object.hh:177
gem5::ruby::garnet::Credit::is_free_signal
bool is_free_signal()
Definition: Credit.hh:67
OutputUnit.hh
gem5::ruby::garnet::flitBuffer::functionalWrite
uint32_t functionalWrite(Packet *pkt)
Definition: flitBuffer.cc:89
gem5::ruby::garnet::OutputUnit::wakeup
void wakeup()
Definition: OutputUnit.cc:133
Credit.hh
gem5::ruby::garnet::OutputUnit::OutputUnit
OutputUnit(int id, PortDirection direction, Router *router, uint32_t consumerVcs)
Definition: OutputUnit.cc:49
gem5::ruby::garnet::OutputUnit::m_vc_per_vnet
int m_vc_per_vnet
Definition: OutputUnit.hh:113
gem5::ruby::garnet::OutputUnit::m_credit_link
CreditLink * m_credit_link
Definition: OutputUnit.hh:115
gem5::ruby::garnet::flitBuffer
Definition: flitBuffer.hh:50
gem5::ArmISA::id
Bitfield< 33 > id
Definition: misc_types.hh:250
gem5::ruby::garnet::Router::getPortDirectionName
std::string getPortDirectionName(PortDirection direction)
Definition: Router.cc:181
gem5::ruby::garnet::ACTIVE_
@ ACTIVE_
Definition: CommonTypes.hh:49
gem5::ruby::garnet::Router::get_id
int get_id()
Definition: Router.hh:91
gem5::ruby::garnet::OutputUnit::set_vc_state
void set_vc_state(VC_state_type state, int vc, Tick curTime)
Definition: OutputUnit.hh:88
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::ruby::garnet::OutputUnit::get_direction
PortDirection get_direction()
Definition: OutputUnit.hh:73
gem5::ruby::garnet::OutputUnit::select_free_vc
int select_free_vc(int vnet)
Definition: OutputUnit.cc:111
gem5::ruby::Consumer::scheduleEventAbsolute
void scheduleEventAbsolute(Tick timeAbs)
Definition: Consumer.cc:63
gem5::ruby::garnet::OutputUnit::outBuffer
flitBuffer outBuffer
Definition: OutputUnit.hh:118
gem5::ruby::garnet::OutputUnit::is_vc_idle
bool is_vc_idle(int vc, Tick curTime)
Definition: OutputUnit.hh:94
Router.hh

Generated on Tue Sep 21 2021 12:25:41 for gem5 by doxygen 1.8.17