gem5  v21.1.0.2
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 
39 namespace gem5
40 {
41 
42 namespace ruby
43 {
44 
45 namespace garnet
46 {
47 
49  : ClockedObject(p), Consumer(this), m_id(p.link_id),
50  m_type(NUM_LINK_TYPES_),
51  m_latency(p.link_latency), m_link_utilized(0),
52  m_virt_nets(p.virt_nets), linkBuffer(),
53  link_consumer(nullptr), link_srcQueue(nullptr)
54 {
55  int num_vnets = (p.supported_vnets).size();
56  mVnets.resize(num_vnets);
57  bitWidth = p.width;
58  for (int i = 0; i < num_vnets; i++) {
59  mVnets[i] = p.supported_vnets[i];
60  }
61 }
62 
63 void
65 {
66  link_consumer = consumer;
67 }
68 
69 void
70 NetworkLink::setVcsPerVnet(uint32_t consumerVcs)
71 {
72  m_vc_load.resize(m_virt_nets * consumerVcs);
73 }
74 
75 void
77 {
78  link_srcQueue = src_queue;
79  src_object = srcClockObj;
80 }
81 
82 void
84 {
85  DPRINTF(RubyNetwork, "Woke up to transfer flits from %s\n",
86  src_object->name());
87  assert(link_srcQueue != nullptr);
88  assert(curTick() == clockEdge());
89  if (link_srcQueue->isReady(curTick())) {
90  flit *t_flit = link_srcQueue->getTopFlit();
91  DPRINTF(RubyNetwork, "Transmission will finish at %ld :%s\n",
92  clockEdge(m_latency), *t_flit);
93  if (m_type != NUM_LINK_TYPES_) {
94  // Only for assertions and debug messages
95  assert(t_flit->m_width == bitWidth);
96  assert((std::find(mVnets.begin(), mVnets.end(),
97  t_flit->get_vnet()) != mVnets.end()) ||
98  (mVnets.size() == 0));
99  }
100  t_flit->set_time(clockEdge(m_latency));
101  linkBuffer.insert(t_flit);
103  m_link_utilized++;
104  m_vc_load[t_flit->get_vc()]++;
105  }
106 
107  if (!link_srcQueue->isEmpty()) {
108  scheduleEvent(Cycles(1));
109  }
110 }
111 
112 void
114 {
115  for (int i = 0; i < m_vc_load.size(); i++) {
116  m_vc_load[i] = 0;
117  }
118 
119  m_link_utilized = 0;
120 }
121 
122 uint32_t
124 {
125  return linkBuffer.functionalWrite(pkt);
126 }
127 
128 } // namespace garnet
129 } // namespace ruby
130 } // 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::flit::get_vnet
int get_vnet()
Definition: flit.hh:65
gem5::ruby::garnet::flit::set_time
void set_time(Tick time)
Definition: flit.hh:74
gem5::ruby::garnet::flitBuffer::isReady
bool isReady(Tick curTime)
Definition: flitBuffer.cc:60
gem5::ruby::Consumer
Definition: Consumer.hh:61
gem5::ArmISA::i
Bitfield< 7 > i
Definition: misc_types.hh:66
gem5::Cycles
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:78
gem5::ruby::garnet::NUM_LINK_TYPES_
@ NUM_LINK_TYPES_
Definition: CommonTypes.hh:52
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::flitBuffer::getTopFlit
flit * getTopFlit()
Definition: flitBuffer.hh:64
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
gem5::ruby::garnet::flitBuffer::insert
void insert(flit *flt)
Definition: flitBuffer.hh:78
gem5::ClockedObject
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Definition: clocked_object.hh:234
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::flitBuffer::functionalWrite
uint32_t functionalWrite(Packet *pkt)
Definition: flitBuffer.cc:89
gem5::ruby::garnet::flitBuffer
Definition: flitBuffer.hh:50
trace.hh
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::ruby::garnet::flit::m_width
uint32_t m_width
Definition: flit.hh:114
gem5::ruby::garnet::flitBuffer::isEmpty
bool isEmpty()
Definition: flitBuffer.cc:54
gem5::ruby::Consumer::scheduleEventAbsolute
void scheduleEventAbsolute(Tick timeAbs)
Definition: Consumer.cc:63

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