tport.cc (2914:2c524dc023d2) tport.cc (3091:dba513d68c16)
1/*
2 * Copyright (c) 2006 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 17 unchanged lines hidden (view full) ---

26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Authors: Ali Saidi
29 */
30
31#include "mem/tport.hh"
32
33void
1/*
2 * Copyright (c) 2006 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 17 unchanged lines hidden (view full) ---

26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Authors: Ali Saidi
29 */
30
31#include "mem/tport.hh"
32
33void
34SimpleTimingPort::recvFunctional(Packet *pkt)
35{
36 // just do an atomic access and throw away the returned latency
37 recvAtomic(pkt);
38}
39
40bool
41SimpleTimingPort::recvTiming(Packet *pkt)
42{
43 // If the device is only a slave, it should only be sending
44 // responses, which should never get nacked. There used to be
45 // code to hanldle nacks here, but I'm pretty sure it didn't work
46 // correctly with the drain code, so that would need to be fixed
47 // if we ever added it back.
48 assert(pkt->result != Packet::Nacked);
49 Tick latency = recvAtomic(pkt);
50 // turn packet around to go back to requester
51 pkt->makeTimingResponse();
52 sendTimingLater(pkt, latency);
53 return true;
54}
55
56void
34SimpleTimingPort::recvRetry()
35{
36 bool result = true;
37 while (result && transmitList.size()) {
57SimpleTimingPort::recvRetry()
58{
59 bool result = true;
60 while (result && transmitList.size()) {
38 result = Port::sendTiming(transmitList.front());
61 result = sendTiming(transmitList.front());
39 if (result)
40 transmitList.pop_front();
41 }
62 if (result)
63 transmitList.pop_front();
64 }
42 if (transmitList.size() == 0 && drainEvent) {
43 drainEvent->process();
44 drainEvent = NULL;
45 }
65 if (transmitList.size() == 0 && drainEvent) {
66 drainEvent->process();
67 drainEvent = NULL;
68 }
46}
47
48void
49SimpleTimingPort::SendEvent::process()
50{
51 port->outTiming--;
52 assert(port->outTiming >= 0);
69}
70
71void
72SimpleTimingPort::SendEvent::process()
73{
74 port->outTiming--;
75 assert(port->outTiming >= 0);
53 if (port->Port::sendTiming(packet))
54 if (port->transmitList.size() == 0 && port->drainEvent) {
55 port->drainEvent->process();
56 port->drainEvent = NULL;
57 }
58 return;
59
60 port->transmitList.push_back(packet);
61}
62
63void
64SimpleTimingPort::resendNacked(Packet *pkt) {
65 pkt->reinitNacked();
66 if (transmitList.size()) {
67 transmitList.push_front(pkt);
76 if (port->sendTiming(packet)) {
77 // send successfule
78 if (port->transmitList.size() == 0 && port->drainEvent) {
79 port->drainEvent->process();
80 port->drainEvent = NULL;
81 }
68 } else {
82 } else {
69 if (!Port::sendTiming(pkt))
70 transmitList.push_front(pkt);
83 // send unsuccessful (due to flow control). Will get retry
84 // callback later; save for then.
85 port->transmitList.push_back(packet);
71 }
86 }
72};
87}
73
74
75unsigned int
76SimpleTimingPort::drain(Event *de)
77{
78 if (outTiming == 0 && transmitList.size() == 0)
79 return 0;
80 drainEvent = de;
81 return 1;
82}
88
89
90unsigned int
91SimpleTimingPort::drain(Event *de)
92{
93 if (outTiming == 0 && transmitList.size() == 0)
94 return 0;
95 drainEvent = de;
96 return 1;
97}