Deleted Added
sdiff udiff text old ( 10986:4fbe4b0adb4d ) new ( 11021:e8a6637afa4c )
full compact
1/*
2 * Copyright (c) 2011-2014 Mark D. Hill and David A. Wood
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;

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

36
37AbstractController::AbstractController(const Params *p)
38 : MemObject(p), Consumer(this), m_version(p->version),
39 m_clusterID(p->cluster_id),
40 m_masterId(p->system->getMasterId(name())), m_is_blocking(false),
41 m_number_of_TBEs(p->number_of_TBEs),
42 m_transitions_per_cycle(p->transitions_per_cycle),
43 m_buffer_size(p->buffer_size), m_recycle_latency(p->recycle_latency),
44 memoryPort(csprintf("%s.memory", name()), this, ""),
45 m_responseFromMemory_ptr(new MessageBuffer())
46{
47 // Set the sender pointer of the response message buffer from the
48 // memory controller.
49 // This pointer is used for querying for the current time.
50 m_responseFromMemory_ptr->setSender(this);
51 m_responseFromMemory_ptr->setReceiver(this);
52 m_responseFromMemory_ptr->setOrdering(false);
53
54 if (m_version == 0) {
55 // Combine the statistics from all controllers
56 // of this particular type.
57 Stats::registerDumpCallback(new StatsCallback(this));
58 }
59}
60
61void
62AbstractController::init()
63{
64 params()->ruby_system->registerAbstractController(this);
65 m_delayHistogram.init(10);
66 uint32_t size = Network::getNumberOfVirtualNetworks();
67 for (uint32_t i = 0; i < size; i++) {
68 m_delayVCHistogram.push_back(new Stats::Histogram());
69 m_delayVCHistogram[i]->init(10);
70 }
71}
72
73void
74AbstractController::resetStats()
75{
76 m_delayHistogram.reset();
77 uint32_t size = Network::getNumberOfVirtualNetworks();
78 for (uint32_t i = 0; i < size; i++) {

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

293 memoryPort.sendFunctional(pkt);
294}
295
296int
297AbstractController::functionalMemoryWrite(PacketPtr pkt)
298{
299 int num_functional_writes = 0;
300
301 // Check the message buffer that runs from the memory to the controller.
302 num_functional_writes += m_responseFromMemory_ptr->functionalWrite(pkt);
303
304 // Check the buffer from the controller to the memory.
305 if (memoryPort.checkFunctional(pkt)) {
306 num_functional_writes++;
307 }
308
309 // Update memory itself.
310 memoryPort.sendFunctional(pkt);
311 return num_functional_writes + 1;
312}
313
314void
315AbstractController::recvTimingResp(PacketPtr pkt)
316{
317 assert(pkt->isResponse());
318
319 std::shared_ptr<MemoryMsg> msg = std::make_shared<MemoryMsg>(clockEdge());
320 (*msg).m_Addr.setAddress(pkt->getAddr());
321 (*msg).m_Sender = m_machineID;
322
323 SenderState *s = dynamic_cast<SenderState *>(pkt->senderState);
324 (*msg).m_OriginalRequestorMachId = s->id;

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

333 RubySystem::getBlockSizeBytes());
334 } else if (pkt->isWrite()) {
335 (*msg).m_Type = MemoryRequestType_MEMORY_WB;
336 (*msg).m_MessageSize = MessageSizeType_Writeback_Control;
337 } else {
338 panic("Incorrect packet type received from memory controller!");
339 }
340
341 m_responseFromMemory_ptr->enqueue(msg);
342 delete pkt;
343}
344
345bool
346AbstractController::MemoryPort::recvTimingResp(PacketPtr pkt)
347{
348 controller->recvTimingResp(pkt);
349 return true;
350}
351
352AbstractController::MemoryPort::MemoryPort(const std::string &_name,
353 AbstractController *_controller,
354 const std::string &_label)
355 : QueuedMasterPort(_name, _controller, reqQueue, snoopRespQueue),
356 reqQueue(*_controller, *this, _label),
357 snoopRespQueue(*_controller, *this, _label),
358 controller(_controller)
359{
360}