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{
46 if (m_version == 0) {
47 // Combine the statistics from all controllers
48 // of this particular type.
49 Stats::registerDumpCallback(new StatsCallback(this));
50 }
51}
52
53void
54AbstractController::init()
55{
56 params()->ruby_system->registerAbstractController(this);
57 m_delayHistogram.init(10);
58 uint32_t size = Network::getNumberOfVirtualNetworks();
59 for (uint32_t i = 0; i < size; i++) {
60 m_delayVCHistogram.push_back(new Stats::Histogram());
61 m_delayVCHistogram[i]->init(10);
62 }
63 if (getMemoryQueue()) {
64 getMemoryQueue()->setSender(this);
65 }
66}
67
68void
69AbstractController::resetStats()
70{
71 m_delayHistogram.reset();
72 uint32_t size = Network::getNumberOfVirtualNetworks();
73 for (uint32_t i = 0; i < size; i++) {

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

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

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

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