gem5  v20.1.0.0
NetworkLink.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Advanced Micro Devices, Inc.
3  * Copyright (c) 2020 Inria
4  * Copyright (c) 2016 Georgia Institute of Technology
5  * Copyright (c) 2008 Princeton University
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions are
10  * met: redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer;
12  * redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution;
15  * neither the name of the copyright holders nor the names of its
16  * contributors may be used to endorse or promote products derived from
17  * this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 
34 
35 #include "base/trace.hh"
36 #include "debug/RubyNetwork.hh"
38 
40  : ClockedObject(p), Consumer(this), m_id(p->link_id),
41  m_type(NUM_LINK_TYPES_),
42  m_latency(p->link_latency), m_link_utilized(0),
43  m_virt_nets(p->virt_nets), linkBuffer(),
44  link_consumer(nullptr), link_srcQueue(nullptr)
45 {
46  int num_vnets = (p->supported_vnets).size();
47  mVnets.resize(num_vnets);
48  bitWidth = p->width;
49  for (int i = 0; i < num_vnets; i++) {
50  mVnets[i] = p->supported_vnets[i];
51  }
52 }
53 
54 void
56 {
57  link_consumer = consumer;
58 }
59 
60 void
61 NetworkLink::setVcsPerVnet(uint32_t consumerVcs)
62 {
63  m_vc_load.resize(m_virt_nets * consumerVcs);
64 }
65 
66 void
68 {
69  link_srcQueue = src_queue;
70  src_object = srcClockObj;
71 }
72 
73 void
75 {
76  DPRINTF(RubyNetwork, "Woke up to transfer flits from %s\n",
77  src_object->name());
78  assert(link_srcQueue != nullptr);
79  assert(curTick() == clockEdge());
80  if (link_srcQueue->isReady(curTick())) {
81  flit *t_flit = link_srcQueue->getTopFlit();
82  DPRINTF(RubyNetwork, "Transmission will finish at %ld :%s\n",
83  clockEdge(m_latency), *t_flit);
84  if (m_type != NUM_LINK_TYPES_) {
85  // Only for assertions and debug messages
86  assert(t_flit->m_width == bitWidth);
87  assert((std::find(mVnets.begin(), mVnets.end(),
88  t_flit->get_vnet()) != mVnets.end()) ||
89  (mVnets.size() == 0));
90  }
91  t_flit->set_time(clockEdge(m_latency));
92  linkBuffer.insert(t_flit);
95  m_vc_load[t_flit->get_vc()]++;
96  }
97 
98  if (!link_srcQueue->isEmpty()) {
100  }
101 }
102 
103 void
105 {
106  for (int i = 0; i < m_vc_load.size(); i++) {
107  m_vc_load[i] = 0;
108  }
109 
110  m_link_utilized = 0;
111 }
112 
113 NetworkLink *
114 NetworkLinkParams::create()
115 {
116  return new NetworkLink(this);
117 }
118 
119 CreditLink *
120 CreditLinkParams::create()
121 {
122  return new CreditLink(this);
123 }
124 
125 uint32_t
127 {
128  return linkBuffer.functionalWrite(pkt);
129 }
flit::get_vnet
int get_vnet()
Definition: flit.hh:56
NUM_LINK_TYPES_
@ NUM_LINK_TYPES_
Definition: CommonTypes.hh:43
flitBuffer
Definition: flitBuffer.hh:41
flit
Definition: flit.hh:41
ArmISA::i
Bitfield< 7 > i
Definition: miscregs_types.hh:63
flitBuffer::getTopFlit
flit * getTopFlit()
Definition: flitBuffer.hh:55
ClockedObject
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Definition: clocked_object.hh:231
flitBuffer::functionalWrite
uint32_t functionalWrite(Packet *pkt)
Definition: flitBuffer.cc:80
flitBuffer::isEmpty
bool isEmpty()
Definition: flitBuffer.cc:45
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:234
Consumer
Definition: Consumer.hh:43
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:174
flit::set_time
void set_time(Tick time)
Definition: flit.hh:65
SimObject::name
virtual const std::string name() const
Definition: sim_object.hh:133
flitBuffer::insert
void insert(flit *flt)
Definition: flitBuffer.hh:70
flit::get_vc
int get_vc()
Definition: flit.hh:57
Consumer::scheduleEventAbsolute
void scheduleEventAbsolute(Tick timeAbs)
Definition: Consumer.cc:40
flitBuffer::isReady
bool isReady(Tick curTime)
Definition: flitBuffer.cc:51
Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:257
Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
trace.hh
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
Consumer::scheduleEvent
void scheduleEvent(Cycles timeDelta)
Definition: Consumer.cc:34
curTick
Tick curTick()
The current simulated tick.
Definition: core.hh:45
flit::m_width
uint32_t m_width
Definition: flit.hh:105

Generated on Wed Sep 30 2020 14:02:13 for gem5 by doxygen 1.8.17