<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>gem5: mem/dramsim2.cc Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.7 -->
<div class="tabs">
  <ul>
    <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
    <li><a href="modules.html"><span>Modules</span></a></li>
    <li><a href="namespaces.html"><span>Namespaces</span></a></li>
    <li><a href="classes.html"><span>Classes</span></a></li>
    <li id="current"><a href="files.html"><span>Files</span></a></li>
    <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
    <li>
      <form action="search.php" method="get">
        <table cellspacing="0" cellpadding="0" border="0">
          <tr>
            <td><label>&nbsp;<u>S</u>earch&nbsp;for&nbsp;</label></td>
            <td><input type="text" name="query" value="" size="20" accesskey="s"/></td>
          </tr>
        </table>
      </form>
    </li>
  </ul></div>
<div class="tabs">
  <ul>
    <li><a href="files.html"><span>File&nbsp;List</span></a></li>
    <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
  </ul></div>
<h1>mem/dramsim2.cc</h1><a href="dramsim2_8cc.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * Copyright (c) 2013 ARM Limited</span>
<a name="l00003"></a>00003 <span class="comment"> * All rights reserved</span>
<a name="l00004"></a>00004 <span class="comment"> *</span>
<a name="l00005"></a>00005 <span class="comment"> * The license below extends only to copyright in the software and shall</span>
<a name="l00006"></a>00006 <span class="comment"> * not be construed as granting a license to any other intellectual</span>
<a name="l00007"></a>00007 <span class="comment"> * property including but not limited to intellectual property relating</span>
<a name="l00008"></a>00008 <span class="comment"> * to a hardware implementation of the functionality of the software</span>
<a name="l00009"></a>00009 <span class="comment"> * licensed hereunder.  You may use the software subject to the license</span>
<a name="l00010"></a>00010 <span class="comment"> * terms below provided that you ensure that this notice is replicated</span>
<a name="l00011"></a>00011 <span class="comment"> * unmodified and in its entirety in all distributions of the software,</span>
<a name="l00012"></a>00012 <span class="comment"> * modified or unmodified, in source code or in binary form.</span>
<a name="l00013"></a>00013 <span class="comment"> *</span>
<a name="l00014"></a>00014 <span class="comment"> * Redistribution and use in source and binary forms, with or without</span>
<a name="l00015"></a>00015 <span class="comment"> * modification, are permitted provided that the following conditions are</span>
<a name="l00016"></a>00016 <span class="comment"> * met: redistributions of source code must retain the above copyright</span>
<a name="l00017"></a>00017 <span class="comment"> * notice, this list of conditions and the following disclaimer;</span>
<a name="l00018"></a>00018 <span class="comment"> * redistributions in binary form must reproduce the above copyright</span>
<a name="l00019"></a>00019 <span class="comment"> * notice, this list of conditions and the following disclaimer in the</span>
<a name="l00020"></a>00020 <span class="comment"> * documentation and/or other materials provided with the distribution;</span>
<a name="l00021"></a>00021 <span class="comment"> * neither the name of the copyright holders nor the names of its</span>
<a name="l00022"></a>00022 <span class="comment"> * contributors may be used to endorse or promote products derived from</span>
<a name="l00023"></a>00023 <span class="comment"> * this software without specific prior written permission.</span>
<a name="l00024"></a>00024 <span class="comment"> *</span>
<a name="l00025"></a>00025 <span class="comment"> * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS</span>
<a name="l00026"></a>00026 <span class="comment"> * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT</span>
<a name="l00027"></a>00027 <span class="comment"> * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR</span>
<a name="l00028"></a>00028 <span class="comment"> * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT</span>
<a name="l00029"></a>00029 <span class="comment"> * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</span>
<a name="l00030"></a>00030 <span class="comment"> * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</span>
<a name="l00031"></a>00031 <span class="comment"> * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,</span>
<a name="l00032"></a>00032 <span class="comment"> * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY</span>
<a name="l00033"></a>00033 <span class="comment"> * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</span>
<a name="l00034"></a>00034 <span class="comment"> * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE</span>
<a name="l00035"></a>00035 <span class="comment"> * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span>
<a name="l00036"></a>00036 <span class="comment"> *</span>
<a name="l00037"></a>00037 <span class="comment"> * Authors: Andreas Hansson</span>
<a name="l00038"></a>00038 <span class="comment"> */</span>
<a name="l00039"></a>00039 
<a name="l00040"></a>00040 <span class="preprocessor">#include "DRAMSim2/Callback.h"</span>
<a name="l00041"></a>00041 <span class="preprocessor">#include "<a class="code" href="callback_8hh.html">base/callback.hh</a>"</span>
<a name="l00042"></a>00042 <span class="preprocessor">#include "<a class="code" href="base_2trace_8hh.html">base/trace.hh</a>"</span>
<a name="l00043"></a>00043 <span class="preprocessor">#include "debug/DRAMSim2.hh"</span>
<a name="l00044"></a>00044 <span class="preprocessor">#include "debug/Drain.hh"</span>
<a name="l00045"></a>00045 <span class="preprocessor">#include "<a class="code" href="dramsim2_8hh.html">mem/dramsim2.hh</a>"</span>
<a name="l00046"></a>00046 <span class="preprocessor">#include "<a class="code" href="sim_2system_8hh.html">sim/system.hh</a>"</span>
<a name="l00047"></a>00047 
<a name="l00048"></a><a class="code" href="classDRAMSim2.html#21e1afbc6afe80fe3f73deea1abfb4e5">00048</a> <a class="code" href="classDRAMSim2.html#21e1afbc6afe80fe3f73deea1abfb4e5">DRAMSim2::DRAMSim2</a>(<span class="keyword">const</span> <a class="code" href="namespaceThePipeline.html#a93998cbab17d7a8eb0acb0c9153b70a">Params</a>* <a class="code" href="namespaceMipsISA.html#e12ae9e12fab22594609e2fefce7f7c2">p</a>) :
<a name="l00049"></a>00049     <a class="code" href="classAbstractMemory.html">AbstractMemory</a>(p),
<a name="l00050"></a>00050     port(<a class="code" href="base_2trace_8hh.html#166fa10b86d8faa127fb7c78191e3e60">name</a>() + <span class="stringliteral">".port"</span>, *this),
<a name="l00051"></a>00051     wrapper(p-&gt;deviceConfigFile, p-&gt;systemConfigFile, p-&gt;filePath,
<a name="l00052"></a>00052             p-&gt;traceFile, p-&gt;range.size() / 1024 / 1024, p-&gt;enableDebug),
<a name="l00053"></a>00053     retryReq(false), retryResp(false), <a class="code" href="namespaceStats.html#88520e9336021114e0c4883083f1249a">startTick</a>(0),
<a name="l00054"></a>00054     nbrOutstandingReads(0), nbrOutstandingWrites(0),
<a name="l00055"></a>00055     drainManager(NULL),
<a name="l00056"></a>00056     sendResponseEvent(this), tickEvent(this)
<a name="l00057"></a>00057 {
<a name="l00058"></a>00058     <a class="code" href="base_2trace_8hh.html#2df3201419df2f91d2b34b10ba16b944">DPRINTF</a>(<a class="code" href="classDRAMSim2.html">DRAMSim2</a>,
<a name="l00059"></a>00059             <span class="stringliteral">"Instantiated DRAMSim2 with clock %d ns and queue size %d\n"</span>,
<a name="l00060"></a>00060             <a class="code" href="classDRAMSim2.html#7061a99095aac016b28064e9be76689f">wrapper</a>.<a class="code" href="classDRAMSim2Wrapper.html#d28147010efa982850edd2646f11bac4">clockPeriod</a>(), <a class="code" href="classDRAMSim2.html#7061a99095aac016b28064e9be76689f">wrapper</a>.<a class="code" href="classDRAMSim2Wrapper.html#63b145879760ad6eba4cdfaaf59f3faa">queueSize</a>());
<a name="l00061"></a>00061 
<a name="l00062"></a>00062     DRAMSim::TransactionCompleteCB* read_cb =
<a name="l00063"></a>00063         <span class="keyword">new</span> DRAMSim::Callback&lt;DRAMSim2, void, unsigned, uint64_t, uint64_t&gt;(
<a name="l00064"></a>00064             <span class="keyword">this</span>, &amp;<a class="code" href="classDRAMSim2.html#d9b10d15bec0f7a5abdb785ba181d7fc">DRAMSim2::readComplete</a>);
<a name="l00065"></a>00065     DRAMSim::TransactionCompleteCB* write_cb =
<a name="l00066"></a>00066         <span class="keyword">new</span> DRAMSim::Callback&lt;DRAMSim2, void, unsigned, uint64_t, uint64_t&gt;(
<a name="l00067"></a>00067             <span class="keyword">this</span>, &amp;<a class="code" href="classDRAMSim2.html#999e258fdf8d670938c4bd1ef89665e6">DRAMSim2::writeComplete</a>);
<a name="l00068"></a>00068     <a class="code" href="classDRAMSim2.html#7061a99095aac016b28064e9be76689f">wrapper</a>.<a class="code" href="classDRAMSim2Wrapper.html#208562d4fbeed63de25c7e6f3c5f0bc8">setCallbacks</a>(read_cb, write_cb);
<a name="l00069"></a>00069 
<a name="l00070"></a>00070     <span class="comment">// Register a callback to compensate for the destructor not</span>
<a name="l00071"></a>00071     <span class="comment">// being called. The callback prints the DRAMSim2 stats.</span>
<a name="l00072"></a>00072     <a class="code" href="classCallback.html">Callback</a>* cb = <span class="keyword">new</span> <a class="code" href="classMakeCallback.html">MakeCallback</a>&lt;<a class="code" href="classDRAMSim2Wrapper.html">DRAMSim2Wrapper</a>,
<a name="l00073"></a>00073         &amp;<a class="code" href="classDRAMSim2Wrapper.html#c12f6260d525980554fd91799db9e0e8">DRAMSim2Wrapper::printStats</a>&gt;(<a class="code" href="classDRAMSim2.html#7061a99095aac016b28064e9be76689f">wrapper</a>);
<a name="l00074"></a>00074     <a class="code" href="core_8cc.html#cbc78ce26c7964097d562909c589d585">registerExitCallback</a>(cb);
<a name="l00075"></a>00075 }
<a name="l00076"></a>00076 
<a name="l00077"></a>00077 <span class="keywordtype">void</span>
<a name="l00078"></a><a class="code" href="classDRAMSim2.html#2540edfb0a236a7e3504d816f84c2a7a">00078</a> <a class="code" href="classDRAMSim2.html#2540edfb0a236a7e3504d816f84c2a7a">DRAMSim2::init</a>()
<a name="l00079"></a>00079 {
<a name="l00080"></a>00080     <span class="keywordflow">if</span> (!<a class="code" href="classDRAMSim2.html#edcda98c55f56487a40a10f21dcd5a0c">port</a>.<a class="code" href="classBaseSlavePort.html#bcc0500ed927088c400b25abecae5c8c">isConnected</a>()) {
<a name="l00081"></a>00081         <a class="code" href="base_2misc_8hh.html#7ffb0b9e78348b242fbb6f491ea80eb5">fatal</a>(<span class="stringliteral">"DRAMSim2 %s is unconnected!\n"</span>, <a class="code" href="classSimObject.html#96c36bff06d98deb79d09e93652667ae">name</a>());
<a name="l00082"></a>00082     } <span class="keywordflow">else</span> {
<a name="l00083"></a>00083         <a class="code" href="classDRAMSim2.html#edcda98c55f56487a40a10f21dcd5a0c">port</a>.<a class="code" href="classSlavePort.html#335e5649623f9976259f34aa10bbebdd">sendRangeChange</a>();
<a name="l00084"></a>00084     }
<a name="l00085"></a>00085 
<a name="l00086"></a>00086     <span class="keywordflow">if</span> (<a class="code" href="classAbstractMemory.html#3982da9ac617ec2f310f4d4740615804">system</a>()-&gt;cacheLineSize() != <a class="code" href="classDRAMSim2.html#7061a99095aac016b28064e9be76689f">wrapper</a>.<a class="code" href="classDRAMSim2Wrapper.html#1d6741bb12c0171b6df2d6e12ca7440e">burstSize</a>())
<a name="l00087"></a>00087         <a class="code" href="base_2misc_8hh.html#7ffb0b9e78348b242fbb6f491ea80eb5">fatal</a>(<span class="stringliteral">"DRAMSim2 burst size %d does not match cache line size %d\n"</span>,
<a name="l00088"></a>00088               <a class="code" href="classDRAMSim2.html#7061a99095aac016b28064e9be76689f">wrapper</a>.<a class="code" href="classDRAMSim2Wrapper.html#1d6741bb12c0171b6df2d6e12ca7440e">burstSize</a>(), <a class="code" href="classAbstractMemory.html#3982da9ac617ec2f310f4d4740615804">system</a>()-&gt;<a class="code" href="classSystem.html#66b0c4a8be53793ead2007ea4aa7ea70">cacheLineSize</a>());
<a name="l00089"></a>00089 }
<a name="l00090"></a>00090 
<a name="l00091"></a>00091 <span class="keywordtype">void</span>
<a name="l00092"></a><a class="code" href="classDRAMSim2.html#1677e103319b45487be197e4bcd0ce54">00092</a> <a class="code" href="classDRAMSim2.html#1677e103319b45487be197e4bcd0ce54">DRAMSim2::startup</a>()
<a name="l00093"></a>00093 {
<a name="l00094"></a>00094     <a class="code" href="classDRAMSim2.html#89a4221dd722901a8cfbd3cd094e9e9d">startTick</a> = <a class="code" href="statistics_8hh.html#7acdccbf0d35ce0c159c0cdd36371b22">curTick</a>();
<a name="l00095"></a>00095 
<a name="l00096"></a>00096     <span class="comment">// kick off the clock ticks</span>
<a name="l00097"></a>00097     <a class="code" href="classEventManager.html#749a10828b2dd5017a2582960d04e400">schedule</a>(<a class="code" href="classDRAMSim2.html#c033fb1c7a85b58db1e8459d453f85e7">tickEvent</a>, <a class="code" href="classClockedObject.html#7c1f64c925f158530be84323a503dbb7">clockEdge</a>());
<a name="l00098"></a>00098 }
<a name="l00099"></a>00099 
<a name="l00100"></a>00100 <span class="keywordtype">void</span>
<a name="l00101"></a><a class="code" href="classDRAMSim2.html#f544f16396df691d0149a3f1644b54a3">00101</a> <a class="code" href="classDRAMSim2.html#f544f16396df691d0149a3f1644b54a3">DRAMSim2::sendResponse</a>()
<a name="l00102"></a>00102 {
<a name="l00103"></a>00103     assert(!<a class="code" href="classDRAMSim2.html#6591cc4df13b088bf6351ca0593a920c">retryResp</a>);
<a name="l00104"></a>00104     assert(!<a class="code" href="classDRAMSim2.html#4595448d1d2600a24e1903bad690d032">responseQueue</a>.empty());
<a name="l00105"></a>00105 
<a name="l00106"></a>00106     <a class="code" href="base_2trace_8hh.html#2df3201419df2f91d2b34b10ba16b944">DPRINTF</a>(<a class="code" href="classDRAMSim2.html">DRAMSim2</a>, <span class="stringliteral">"Attempting to send response\n"</span>);
<a name="l00107"></a>00107 
<a name="l00108"></a>00108     <span class="keywordtype">bool</span> success = <a class="code" href="classDRAMSim2.html#edcda98c55f56487a40a10f21dcd5a0c">port</a>.<a class="code" href="classSlavePort.html#d0eff9b8440219fef370496812b53211">sendTimingResp</a>(<a class="code" href="classDRAMSim2.html#4595448d1d2600a24e1903bad690d032">responseQueue</a>.front());
<a name="l00109"></a>00109     <span class="keywordflow">if</span> (success) {
<a name="l00110"></a>00110         <a class="code" href="classDRAMSim2.html#4595448d1d2600a24e1903bad690d032">responseQueue</a>.pop_front();
<a name="l00111"></a>00111 
<a name="l00112"></a>00112         <a class="code" href="base_2trace_8hh.html#2df3201419df2f91d2b34b10ba16b944">DPRINTF</a>(<a class="code" href="classDRAMSim2.html">DRAMSim2</a>, <span class="stringliteral">"Have %d read, %d write, %d responses outstanding\n"</span>,
<a name="l00113"></a>00113                 <a class="code" href="classDRAMSim2.html#cd81d26cd475997c138e00adc20ff745">nbrOutstandingReads</a>, <a class="code" href="classDRAMSim2.html#bcbf63a24a30af8f4bf250a8970b96cd">nbrOutstandingWrites</a>,
<a name="l00114"></a>00114                 <a class="code" href="classDRAMSim2.html#4595448d1d2600a24e1903bad690d032">responseQueue</a>.size());
<a name="l00115"></a>00115 
<a name="l00116"></a>00116         <span class="keywordflow">if</span> (!<a class="code" href="classDRAMSim2.html#4595448d1d2600a24e1903bad690d032">responseQueue</a>.empty() &amp;&amp; !<a class="code" href="classDRAMSim2.html#150c765739098813208004cf797e48dc">sendResponseEvent</a>.<a class="code" href="classEvent.html#36bdc2ee73215ed7670a7bfc0f25ab8b">scheduled</a>())
<a name="l00117"></a>00117             <a class="code" href="classEventManager.html#749a10828b2dd5017a2582960d04e400">schedule</a>(<a class="code" href="classDRAMSim2.html#150c765739098813208004cf797e48dc">sendResponseEvent</a>, <a class="code" href="statistics_8hh.html#7acdccbf0d35ce0c159c0cdd36371b22">curTick</a>());
<a name="l00118"></a>00118 
<a name="l00119"></a>00119         <span class="comment">// check if we were asked to drain and if we are now done</span>
<a name="l00120"></a>00120         <span class="keywordflow">if</span> (<a class="code" href="classDRAMSim2.html#428f47fc69ebee8db2340ae018ca34bb">drainManager</a> &amp;&amp; <a class="code" href="classDRAMSim2.html#64013900343814092c8b20dda3ec1e1d">nbrOutstanding</a>() == 0) {
<a name="l00121"></a>00121             <a class="code" href="classDRAMSim2.html#428f47fc69ebee8db2340ae018ca34bb">drainManager</a>-&gt;<a class="code" href="classDrainManager.html#bd134e8277be09e702b63f36f6ee31d0">signalDrainDone</a>();
<a name="l00122"></a>00122             <a class="code" href="classDRAMSim2.html#428f47fc69ebee8db2340ae018ca34bb">drainManager</a> = NULL;
<a name="l00123"></a>00123         }
<a name="l00124"></a>00124     } <span class="keywordflow">else</span> {
<a name="l00125"></a>00125         <a class="code" href="classDRAMSim2.html#6591cc4df13b088bf6351ca0593a920c">retryResp</a> = <span class="keyword">true</span>;
<a name="l00126"></a>00126 
<a name="l00127"></a>00127         <a class="code" href="base_2trace_8hh.html#2df3201419df2f91d2b34b10ba16b944">DPRINTF</a>(<a class="code" href="classDRAMSim2.html">DRAMSim2</a>, <span class="stringliteral">"Waiting for response retry\n"</span>);
<a name="l00128"></a>00128 
<a name="l00129"></a>00129         assert(!<a class="code" href="classDRAMSim2.html#150c765739098813208004cf797e48dc">sendResponseEvent</a>.<a class="code" href="classEvent.html#36bdc2ee73215ed7670a7bfc0f25ab8b">scheduled</a>());
<a name="l00130"></a>00130     }
<a name="l00131"></a>00131 }
<a name="l00132"></a>00132 
<a name="l00133"></a>00133 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>
<a name="l00134"></a><a class="code" href="classDRAMSim2.html#64013900343814092c8b20dda3ec1e1d">00134</a> <a class="code" href="classDRAMSim2.html#64013900343814092c8b20dda3ec1e1d">DRAMSim2::nbrOutstanding</a>()<span class="keyword"> const</span>
<a name="l00135"></a>00135 <span class="keyword"></span>{
<a name="l00136"></a>00136     <span class="keywordflow">return</span> <a class="code" href="classDRAMSim2.html#cd81d26cd475997c138e00adc20ff745">nbrOutstandingReads</a> + <a class="code" href="classDRAMSim2.html#bcbf63a24a30af8f4bf250a8970b96cd">nbrOutstandingWrites</a> + <a class="code" href="classDRAMSim2.html#4595448d1d2600a24e1903bad690d032">responseQueue</a>.size();
<a name="l00137"></a>00137 }
<a name="l00138"></a>00138 
<a name="l00139"></a>00139 <span class="keywordtype">void</span>
<a name="l00140"></a><a class="code" href="classDRAMSim2.html#f94a749ab9c6568addac0ffda5a07c7b">00140</a> <a class="code" href="classDRAMSim2.html#f94a749ab9c6568addac0ffda5a07c7b">DRAMSim2::tick</a>()
<a name="l00141"></a>00141 {
<a name="l00142"></a>00142     <a class="code" href="classDRAMSim2.html#7061a99095aac016b28064e9be76689f">wrapper</a>.<a class="code" href="classDRAMSim2Wrapper.html#98cf53189771a54a06df9a842ebec244">tick</a>();
<a name="l00143"></a>00143 
<a name="l00144"></a>00144     <span class="comment">// is the connected port waiting for a retry, if so check the</span>
<a name="l00145"></a>00145     <span class="comment">// state and send a retry if conditions have changed</span>
<a name="l00146"></a>00146     <span class="keywordflow">if</span> (<a class="code" href="classDRAMSim2.html#4cfb5e7563234044797c4d2b3dcf479c">retryReq</a> &amp;&amp; <a class="code" href="classDRAMSim2.html#64013900343814092c8b20dda3ec1e1d">nbrOutstanding</a>() &lt; <a class="code" href="classDRAMSim2.html#7061a99095aac016b28064e9be76689f">wrapper</a>.<a class="code" href="classDRAMSim2Wrapper.html#63b145879760ad6eba4cdfaaf59f3faa">queueSize</a>()) {
<a name="l00147"></a>00147         <a class="code" href="classDRAMSim2.html#4cfb5e7563234044797c4d2b3dcf479c">retryReq</a> = <span class="keyword">false</span>;
<a name="l00148"></a>00148         <a class="code" href="classDRAMSim2.html#edcda98c55f56487a40a10f21dcd5a0c">port</a>.<a class="code" href="classSlavePort.html#e8927738694b0576ee6a37c73d2fafb9">sendRetry</a>();
<a name="l00149"></a>00149     }
<a name="l00150"></a>00150 
<a name="l00151"></a>00151     <a class="code" href="classEventManager.html#749a10828b2dd5017a2582960d04e400">schedule</a>(<a class="code" href="classDRAMSim2.html#c033fb1c7a85b58db1e8459d453f85e7">tickEvent</a>, <a class="code" href="statistics_8hh.html#7acdccbf0d35ce0c159c0cdd36371b22">curTick</a>() + <a class="code" href="classDRAMSim2.html#7061a99095aac016b28064e9be76689f">wrapper</a>.<a class="code" href="classDRAMSim2Wrapper.html#d28147010efa982850edd2646f11bac4">clockPeriod</a>() * <a class="code" href="namespaceSimClock_1_1Int.html#2a3db53e965de92179c7e876f9316d74">SimClock::Int::ns</a>);
<a name="l00152"></a>00152 }
<a name="l00153"></a>00153 
<a name="l00154"></a>00154 <a class="code" href="base_2types_8hh.html#5c8ed81b7d238c9083e1037ba6d61643">Tick</a>
<a name="l00155"></a><a class="code" href="classDRAMSim2.html#36e7ecd234d840073007289c267a3594">00155</a> <a class="code" href="classDRAMSim2.html#36e7ecd234d840073007289c267a3594">DRAMSim2::recvAtomic</a>(<a class="code" href="classPacket.html">PacketPtr</a> pkt)
<a name="l00156"></a>00156 {
<a name="l00157"></a>00157     <a class="code" href="classAbstractMemory.html#4f8bf048c846bef573325f47a0603b09">access</a>(pkt);
<a name="l00158"></a>00158 
<a name="l00159"></a>00159     <span class="comment">// 50 ns is just an arbitrary value at this point</span>
<a name="l00160"></a>00160     <span class="keywordflow">return</span> pkt-&gt;<a class="code" href="classPacket.html#3e04f59de35e82a50c48e0ca903a64cb">memInhibitAsserted</a>() ? 0 : 50000;
<a name="l00161"></a>00161 }
<a name="l00162"></a>00162 
<a name="l00163"></a>00163 <span class="keywordtype">void</span>
<a name="l00164"></a><a class="code" href="classDRAMSim2.html#5cb12a2b69508fe2b6cca9da1fac2f7a">00164</a> <a class="code" href="classDRAMSim2.html#5cb12a2b69508fe2b6cca9da1fac2f7a">DRAMSim2::recvFunctional</a>(<a class="code" href="classPacket.html">PacketPtr</a> pkt)
<a name="l00165"></a>00165 {
<a name="l00166"></a>00166     pkt-&gt;<a class="code" href="classPacket.html#bf1a177ee6ddce59da49869cfeecc7bc">pushLabel</a>(<a class="code" href="classSimObject.html#96c36bff06d98deb79d09e93652667ae">name</a>());
<a name="l00167"></a>00167 
<a name="l00168"></a>00168     <a class="code" href="classAbstractMemory.html#cb2ca48dbe8f541907b3827feeb292d5">functionalAccess</a>(pkt);
<a name="l00169"></a>00169 
<a name="l00170"></a>00170     <span class="comment">// potentially update the packets in our response queue as well</span>
<a name="l00171"></a>00171     <span class="keywordflow">for</span> (<span class="keyword">auto</span> <a class="code" href="namespaceArmISA.html#718defda84c16589694d68fe7689a803">i</a> = <a class="code" href="classDRAMSim2.html#4595448d1d2600a24e1903bad690d032">responseQueue</a>.begin(); <a class="code" href="namespaceArmISA.html#718defda84c16589694d68fe7689a803">i</a> != <a class="code" href="classDRAMSim2.html#4595448d1d2600a24e1903bad690d032">responseQueue</a>.end(); ++<a class="code" href="namespaceArmISA.html#718defda84c16589694d68fe7689a803">i</a>)
<a name="l00172"></a>00172         pkt-&gt;<a class="code" href="classPacket.html#58f7268060dfd15d3807d5f3173362fc">checkFunctional</a>(*<a class="code" href="namespaceArmISA.html#718defda84c16589694d68fe7689a803">i</a>);
<a name="l00173"></a>00173 
<a name="l00174"></a>00174     pkt-&gt;<a class="code" href="classPacket.html#d28d4bd566aee12a370dc9180e064bea">popLabel</a>();
<a name="l00175"></a>00175 }
<a name="l00176"></a>00176 
<a name="l00177"></a>00177 <span class="keywordtype">bool</span>
<a name="l00178"></a><a class="code" href="classDRAMSim2.html#cdafcd36516384830d0b0d373e2dfeb1">00178</a> <a class="code" href="classDRAMSim2.html#cdafcd36516384830d0b0d373e2dfeb1">DRAMSim2::recvTimingReq</a>(<a class="code" href="classPacket.html">PacketPtr</a> pkt)
<a name="l00179"></a>00179 {
<a name="l00180"></a>00180     <span class="comment">// we should never see a new request while in retry</span>
<a name="l00181"></a>00181     assert(!<a class="code" href="classDRAMSim2.html#4cfb5e7563234044797c4d2b3dcf479c">retryReq</a>);
<a name="l00182"></a>00182 
<a name="l00183"></a>00183     <span class="comment">// @todo temporary hack to deal with memory corruption issues until</span>
<a name="l00184"></a>00184     <span class="comment">// 4-phase transactions are complete</span>
<a name="l00185"></a>00185     <span class="keywordflow">for</span> (<span class="keywordtype">int</span> <a class="code" href="namespaceX86ISA.html#7329cbd3da39e27c5b311899bac95a04">x</a> = 0; <a class="code" href="namespaceX86ISA.html#7329cbd3da39e27c5b311899bac95a04">x</a> &lt; <a class="code" href="classDRAMSim2.html#63b84408cc9b592d983165f8d3ac24c4">pendingDelete</a>.size(); <a class="code" href="namespaceX86ISA.html#7329cbd3da39e27c5b311899bac95a04">x</a>++)
<a name="l00186"></a>00186         <span class="keyword">delete</span> <a class="code" href="classDRAMSim2.html#63b84408cc9b592d983165f8d3ac24c4">pendingDelete</a>[<a class="code" href="namespaceX86ISA.html#7329cbd3da39e27c5b311899bac95a04">x</a>];
<a name="l00187"></a>00187     <a class="code" href="classDRAMSim2.html#63b84408cc9b592d983165f8d3ac24c4">pendingDelete</a>.clear();
<a name="l00188"></a>00188 
<a name="l00189"></a>00189     <span class="keywordflow">if</span> (pkt-&gt;<a class="code" href="classPacket.html#3e04f59de35e82a50c48e0ca903a64cb">memInhibitAsserted</a>()) {
<a name="l00190"></a>00190         <span class="comment">// snooper will supply based on copy of packet</span>
<a name="l00191"></a>00191         <span class="comment">// still target's responsibility to delete packet</span>
<a name="l00192"></a>00192         <a class="code" href="classDRAMSim2.html#63b84408cc9b592d983165f8d3ac24c4">pendingDelete</a>.push_back(pkt);
<a name="l00193"></a>00193         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00194"></a>00194     }
<a name="l00195"></a>00195 
<a name="l00196"></a>00196     <span class="comment">// if we cannot accept we need to send a retry once progress can</span>
<a name="l00197"></a>00197     <span class="comment">// be made</span>
<a name="l00198"></a>00198     <span class="keywordtype">bool</span> can_accept = <a class="code" href="classDRAMSim2.html#64013900343814092c8b20dda3ec1e1d">nbrOutstanding</a>() &lt; <a class="code" href="classDRAMSim2.html#7061a99095aac016b28064e9be76689f">wrapper</a>.<a class="code" href="classDRAMSim2Wrapper.html#63b145879760ad6eba4cdfaaf59f3faa">queueSize</a>();
<a name="l00199"></a>00199 
<a name="l00200"></a>00200     <span class="comment">// keep track of the transaction</span>
<a name="l00201"></a>00201     <span class="keywordflow">if</span> (pkt-&gt;<a class="code" href="classPacket.html#d7fd7ab0e95007d1c6232b231482c6fa">isRead</a>()) {
<a name="l00202"></a>00202         <span class="keywordflow">if</span> (can_accept) {
<a name="l00203"></a>00203             <a class="code" href="classDRAMSim2.html#39c6f83c109245e47097b0b5f635548f">outstandingReads</a>[pkt-&gt;<a class="code" href="classPacket.html#1c04785186ba5aa70a40cac9b2bfc86e">getAddr</a>()].push(pkt);
<a name="l00204"></a>00204 
<a name="l00205"></a>00205             <span class="comment">// we count a transaction as outstanding until it has left the</span>
<a name="l00206"></a>00206             <span class="comment">// queue in the controller, and the response has been sent</span>
<a name="l00207"></a>00207             <span class="comment">// back, note that this will differ for reads and writes</span>
<a name="l00208"></a>00208             ++<a class="code" href="classDRAMSim2.html#cd81d26cd475997c138e00adc20ff745">nbrOutstandingReads</a>;
<a name="l00209"></a>00209         }
<a name="l00210"></a>00210     } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (pkt-&gt;<a class="code" href="classPacket.html#2bfee2cdcdfd22a227f0254b7dd56249">isWrite</a>()) {
<a name="l00211"></a>00211         <span class="keywordflow">if</span> (can_accept) {
<a name="l00212"></a>00212             <a class="code" href="classDRAMSim2.html#ff23d875d83642f5ad005ce35a24cedd">outstandingWrites</a>[pkt-&gt;<a class="code" href="classPacket.html#1c04785186ba5aa70a40cac9b2bfc86e">getAddr</a>()].push(pkt);
<a name="l00213"></a>00213 
<a name="l00214"></a>00214             ++<a class="code" href="classDRAMSim2.html#bcbf63a24a30af8f4bf250a8970b96cd">nbrOutstandingWrites</a>;
<a name="l00215"></a>00215 
<a name="l00216"></a>00216             <span class="comment">// perform the access for writes</span>
<a name="l00217"></a>00217             <a class="code" href="classDRAMSim2.html#2bbc2b424f246730dbe38abfee93ccef">accessAndRespond</a>(pkt);
<a name="l00218"></a>00218         }
<a name="l00219"></a>00219     } <span class="keywordflow">else</span> {
<a name="l00220"></a>00220         <span class="comment">// keep it simple and just respond if necessary</span>
<a name="l00221"></a>00221         <a class="code" href="classDRAMSim2.html#2bbc2b424f246730dbe38abfee93ccef">accessAndRespond</a>(pkt);
<a name="l00222"></a>00222         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00223"></a>00223     }
<a name="l00224"></a>00224 
<a name="l00225"></a>00225     <span class="keywordflow">if</span> (can_accept) {
<a name="l00226"></a>00226         <span class="comment">// we should never have a situation when we think there is space,</span>
<a name="l00227"></a>00227         <span class="comment">// and there isn't</span>
<a name="l00228"></a>00228         assert(<a class="code" href="classDRAMSim2.html#7061a99095aac016b28064e9be76689f">wrapper</a>.<a class="code" href="classDRAMSim2Wrapper.html#c62a81406057faef1915f67927a4e215">canAccept</a>());
<a name="l00229"></a>00229 
<a name="l00230"></a>00230         <a class="code" href="base_2trace_8hh.html#2df3201419df2f91d2b34b10ba16b944">DPRINTF</a>(<a class="code" href="classDRAMSim2.html">DRAMSim2</a>, <span class="stringliteral">"Enqueueing address %lld\n"</span>, pkt-&gt;<a class="code" href="classPacket.html#1c04785186ba5aa70a40cac9b2bfc86e">getAddr</a>());
<a name="l00231"></a>00231 
<a name="l00232"></a>00232         <span class="comment">// @todo what about the granularity here, implicit assumption that</span>
<a name="l00233"></a>00233         <span class="comment">// a transaction matches the burst size of the memory (which we</span>
<a name="l00234"></a>00234         <span class="comment">// cannot determine without parsing the ini file ourselves)</span>
<a name="l00235"></a>00235         <a class="code" href="classDRAMSim2.html#7061a99095aac016b28064e9be76689f">wrapper</a>.<a class="code" href="classDRAMSim2Wrapper.html#5087853a0eaf0f28417020d5197bda66">enqueue</a>(pkt-&gt;<a class="code" href="classPacket.html#2bfee2cdcdfd22a227f0254b7dd56249">isWrite</a>(), pkt-&gt;<a class="code" href="classPacket.html#1c04785186ba5aa70a40cac9b2bfc86e">getAddr</a>());
<a name="l00236"></a>00236 
<a name="l00237"></a>00237         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00238"></a>00238     } <span class="keywordflow">else</span> {
<a name="l00239"></a>00239         <a class="code" href="classDRAMSim2.html#4cfb5e7563234044797c4d2b3dcf479c">retryReq</a> = <span class="keyword">true</span>;
<a name="l00240"></a>00240         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00241"></a>00241     }
<a name="l00242"></a>00242 }
<a name="l00243"></a>00243 
<a name="l00244"></a>00244 <span class="keywordtype">void</span>
<a name="l00245"></a><a class="code" href="classDRAMSim2.html#6a260883a3ac4966d65d30ce6e7eb726">00245</a> <a class="code" href="classDRAMSim2.html#6a260883a3ac4966d65d30ce6e7eb726">DRAMSim2::recvRetry</a>()
<a name="l00246"></a>00246 {
<a name="l00247"></a>00247     <a class="code" href="base_2trace_8hh.html#2df3201419df2f91d2b34b10ba16b944">DPRINTF</a>(<a class="code" href="classDRAMSim2.html">DRAMSim2</a>, <span class="stringliteral">"Retrying\n"</span>);
<a name="l00248"></a>00248 
<a name="l00249"></a>00249     assert(<a class="code" href="classDRAMSim2.html#6591cc4df13b088bf6351ca0593a920c">retryResp</a>);
<a name="l00250"></a>00250     <a class="code" href="classDRAMSim2.html#6591cc4df13b088bf6351ca0593a920c">retryResp</a> = <span class="keyword">false</span>;
<a name="l00251"></a>00251     <a class="code" href="classDRAMSim2.html#f544f16396df691d0149a3f1644b54a3">sendResponse</a>();
<a name="l00252"></a>00252 }
<a name="l00253"></a>00253 
<a name="l00254"></a>00254 <span class="keywordtype">void</span>
<a name="l00255"></a><a class="code" href="classDRAMSim2.html#2bbc2b424f246730dbe38abfee93ccef">00255</a> <a class="code" href="classDRAMSim2.html#2bbc2b424f246730dbe38abfee93ccef">DRAMSim2::accessAndRespond</a>(<a class="code" href="classPacket.html">PacketPtr</a> pkt)
<a name="l00256"></a>00256 {
<a name="l00257"></a>00257     <a class="code" href="base_2trace_8hh.html#2df3201419df2f91d2b34b10ba16b944">DPRINTF</a>(<a class="code" href="classDRAMSim2.html">DRAMSim2</a>, <span class="stringliteral">"Access for address %lld\n"</span>, pkt-&gt;<a class="code" href="classPacket.html#1c04785186ba5aa70a40cac9b2bfc86e">getAddr</a>());
<a name="l00258"></a>00258 
<a name="l00259"></a>00259     <span class="keywordtype">bool</span> needsResponse = pkt-&gt;<a class="code" href="classPacket.html#3eafb3dde5f57c16f684862aff8da0b3">needsResponse</a>();
<a name="l00260"></a>00260 
<a name="l00261"></a>00261     <span class="comment">// do the actual memory access which also turns the packet into a</span>
<a name="l00262"></a>00262     <span class="comment">// response</span>
<a name="l00263"></a>00263     <a class="code" href="classAbstractMemory.html#4f8bf048c846bef573325f47a0603b09">access</a>(pkt);
<a name="l00264"></a>00264 
<a name="l00265"></a>00265     <span class="comment">// turn packet around to go back to requester if response expected</span>
<a name="l00266"></a>00266     <span class="keywordflow">if</span> (needsResponse) {
<a name="l00267"></a>00267         <span class="comment">// access already turned the packet into a response</span>
<a name="l00268"></a>00268         assert(pkt-&gt;<a class="code" href="classPacket.html#e55f4c38bf6367f308c935cb833027ee">isResponse</a>());
<a name="l00269"></a>00269 
<a name="l00270"></a>00270         <span class="comment">// @todo someone should pay for this</span>
<a name="l00271"></a>00271         pkt-&gt;<a class="code" href="classPacket.html#7053c19502272d13cfe6472a44cc5afb">firstWordDelay</a> = pkt-&gt;<a class="code" href="classPacket.html#ea3c353a92e3971a18b1c619a7f8e8c6">lastWordDelay</a> = 0;
<a name="l00272"></a>00272 
<a name="l00273"></a>00273         <a class="code" href="base_2trace_8hh.html#2df3201419df2f91d2b34b10ba16b944">DPRINTF</a>(<a class="code" href="classDRAMSim2.html">DRAMSim2</a>, <span class="stringliteral">"Queuing response for address %lld\n"</span>,
<a name="l00274"></a>00274                 pkt-&gt;<a class="code" href="classPacket.html#1c04785186ba5aa70a40cac9b2bfc86e">getAddr</a>());
<a name="l00275"></a>00275 
<a name="l00276"></a>00276         <span class="comment">// queue it to be sent back</span>
<a name="l00277"></a>00277         <a class="code" href="classDRAMSim2.html#4595448d1d2600a24e1903bad690d032">responseQueue</a>.push_back(pkt);
<a name="l00278"></a>00278 
<a name="l00279"></a>00279         <span class="comment">// if we are not already waiting for a retry, or are scheduled</span>
<a name="l00280"></a>00280         <span class="comment">// to send a response, schedule an event</span>
<a name="l00281"></a>00281         <span class="keywordflow">if</span> (!<a class="code" href="classDRAMSim2.html#6591cc4df13b088bf6351ca0593a920c">retryResp</a> &amp;&amp; !<a class="code" href="classDRAMSim2.html#150c765739098813208004cf797e48dc">sendResponseEvent</a>.<a class="code" href="classEvent.html#36bdc2ee73215ed7670a7bfc0f25ab8b">scheduled</a>())
<a name="l00282"></a>00282             <a class="code" href="classEventManager.html#749a10828b2dd5017a2582960d04e400">schedule</a>(<a class="code" href="classDRAMSim2.html#150c765739098813208004cf797e48dc">sendResponseEvent</a>, <a class="code" href="statistics_8hh.html#7acdccbf0d35ce0c159c0cdd36371b22">curTick</a>());
<a name="l00283"></a>00283     } <span class="keywordflow">else</span> {
<a name="l00284"></a>00284         <span class="comment">// @todo the packet is going to be deleted, and the DRAMPacket</span>
<a name="l00285"></a>00285         <span class="comment">// is still having a pointer to it</span>
<a name="l00286"></a>00286         <a class="code" href="classDRAMSim2.html#63b84408cc9b592d983165f8d3ac24c4">pendingDelete</a>.push_back(pkt);
<a name="l00287"></a>00287     }
<a name="l00288"></a>00288 }
<a name="l00289"></a>00289 
<a name="l00290"></a><a class="code" href="classDRAMSim2.html#d9b10d15bec0f7a5abdb785ba181d7fc">00290</a> <span class="keywordtype">void</span> <a class="code" href="classDRAMSim2.html#d9b10d15bec0f7a5abdb785ba181d7fc">DRAMSim2::readComplete</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">id</span>, uint64_t <a class="code" href="namespaceX86ISA.html#79b5c08c190167d17c9b9b3fd40112f6">addr</a>, uint64_t cycle)
<a name="l00291"></a>00291 {
<a name="l00292"></a>00292     assert(cycle == <a class="code" href="intmath_8hh.html#e842b412d3570df97a944085b8f85850">divCeil</a>(<a class="code" href="statistics_8hh.html#7acdccbf0d35ce0c159c0cdd36371b22">curTick</a>() - <a class="code" href="classDRAMSim2.html#89a4221dd722901a8cfbd3cd094e9e9d">startTick</a>,
<a name="l00293"></a>00293                             <a class="code" href="classDRAMSim2.html#7061a99095aac016b28064e9be76689f">wrapper</a>.<a class="code" href="classDRAMSim2Wrapper.html#d28147010efa982850edd2646f11bac4">clockPeriod</a>() * <a class="code" href="namespaceSimClock_1_1Int.html#2a3db53e965de92179c7e876f9316d74">SimClock::Int::ns</a>));
<a name="l00294"></a>00294 
<a name="l00295"></a>00295     <a class="code" href="base_2trace_8hh.html#2df3201419df2f91d2b34b10ba16b944">DPRINTF</a>(<a class="code" href="classDRAMSim2.html">DRAMSim2</a>, <span class="stringliteral">"Read to address %lld complete\n"</span>, addr);
<a name="l00296"></a>00296 
<a name="l00297"></a>00297     <span class="comment">// get the outstanding reads for the address in question</span>
<a name="l00298"></a>00298     <span class="keyword">auto</span> <a class="code" href="namespaceMipsISA.html#e12ae9e12fab22594609e2fefce7f7c2">p</a> = <a class="code" href="classDRAMSim2.html#39c6f83c109245e47097b0b5f635548f">outstandingReads</a>.find(addr);
<a name="l00299"></a>00299     assert(<a class="code" href="namespaceMipsISA.html#e12ae9e12fab22594609e2fefce7f7c2">p</a> != <a class="code" href="classDRAMSim2.html#39c6f83c109245e47097b0b5f635548f">outstandingReads</a>.end());
<a name="l00300"></a>00300 
<a name="l00301"></a>00301     <span class="comment">// first in first out, which is not necessarily true, but it is</span>
<a name="l00302"></a>00302     <span class="comment">// the best we can do at this point</span>
<a name="l00303"></a>00303     <a class="code" href="classPacket.html">PacketPtr</a> pkt = <a class="code" href="namespaceMipsISA.html#e12ae9e12fab22594609e2fefce7f7c2">p</a>-&gt;second.front();
<a name="l00304"></a>00304     <a class="code" href="namespaceMipsISA.html#e12ae9e12fab22594609e2fefce7f7c2">p</a>-&gt;second.pop();
<a name="l00305"></a>00305 
<a name="l00306"></a>00306     <span class="keywordflow">if</span> (<a class="code" href="namespaceMipsISA.html#e12ae9e12fab22594609e2fefce7f7c2">p</a>-&gt;second.empty())
<a name="l00307"></a>00307         <a class="code" href="classDRAMSim2.html#39c6f83c109245e47097b0b5f635548f">outstandingReads</a>.erase(<a class="code" href="namespaceMipsISA.html#e12ae9e12fab22594609e2fefce7f7c2">p</a>);
<a name="l00308"></a>00308 
<a name="l00309"></a>00309     <span class="comment">// no need to check for drain here as the next call will add a</span>
<a name="l00310"></a>00310     <span class="comment">// response to the response queue straight away</span>
<a name="l00311"></a>00311     assert(<a class="code" href="classDRAMSim2.html#cd81d26cd475997c138e00adc20ff745">nbrOutstandingReads</a> != 0);
<a name="l00312"></a>00312     --<a class="code" href="classDRAMSim2.html#cd81d26cd475997c138e00adc20ff745">nbrOutstandingReads</a>;
<a name="l00313"></a>00313 
<a name="l00314"></a>00314     <span class="comment">// perform the actual memory access</span>
<a name="l00315"></a>00315     <a class="code" href="classDRAMSim2.html#2bbc2b424f246730dbe38abfee93ccef">accessAndRespond</a>(pkt);
<a name="l00316"></a>00316 }
<a name="l00317"></a>00317 
<a name="l00318"></a><a class="code" href="classDRAMSim2.html#999e258fdf8d670938c4bd1ef89665e6">00318</a> <span class="keywordtype">void</span> <a class="code" href="classDRAMSim2.html#999e258fdf8d670938c4bd1ef89665e6">DRAMSim2::writeComplete</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">id</span>, uint64_t <a class="code" href="namespaceX86ISA.html#79b5c08c190167d17c9b9b3fd40112f6">addr</a>, uint64_t cycle)
<a name="l00319"></a>00319 {
<a name="l00320"></a>00320     assert(cycle == <a class="code" href="intmath_8hh.html#e842b412d3570df97a944085b8f85850">divCeil</a>(<a class="code" href="statistics_8hh.html#7acdccbf0d35ce0c159c0cdd36371b22">curTick</a>() - <a class="code" href="classDRAMSim2.html#89a4221dd722901a8cfbd3cd094e9e9d">startTick</a>,
<a name="l00321"></a>00321                             <a class="code" href="classDRAMSim2.html#7061a99095aac016b28064e9be76689f">wrapper</a>.<a class="code" href="classDRAMSim2Wrapper.html#d28147010efa982850edd2646f11bac4">clockPeriod</a>() * <a class="code" href="namespaceSimClock_1_1Int.html#2a3db53e965de92179c7e876f9316d74">SimClock::Int::ns</a>));
<a name="l00322"></a>00322 
<a name="l00323"></a>00323     <a class="code" href="base_2trace_8hh.html#2df3201419df2f91d2b34b10ba16b944">DPRINTF</a>(<a class="code" href="classDRAMSim2.html">DRAMSim2</a>, <span class="stringliteral">"Write to address %lld complete\n"</span>, addr);
<a name="l00324"></a>00324 
<a name="l00325"></a>00325     <span class="comment">// get the outstanding reads for the address in question</span>
<a name="l00326"></a>00326     <span class="keyword">auto</span> <a class="code" href="namespaceMipsISA.html#e12ae9e12fab22594609e2fefce7f7c2">p</a> = <a class="code" href="classDRAMSim2.html#ff23d875d83642f5ad005ce35a24cedd">outstandingWrites</a>.find(addr);
<a name="l00327"></a>00327     assert(<a class="code" href="namespaceMipsISA.html#e12ae9e12fab22594609e2fefce7f7c2">p</a> != <a class="code" href="classDRAMSim2.html#ff23d875d83642f5ad005ce35a24cedd">outstandingWrites</a>.end());
<a name="l00328"></a>00328 
<a name="l00329"></a>00329     <span class="comment">// we have already responded, and this is only to keep track of</span>
<a name="l00330"></a>00330     <span class="comment">// what is outstanding</span>
<a name="l00331"></a>00331     <a class="code" href="namespaceMipsISA.html#e12ae9e12fab22594609e2fefce7f7c2">p</a>-&gt;second.pop();
<a name="l00332"></a>00332     <span class="keywordflow">if</span> (<a class="code" href="namespaceMipsISA.html#e12ae9e12fab22594609e2fefce7f7c2">p</a>-&gt;second.empty())
<a name="l00333"></a>00333         <a class="code" href="classDRAMSim2.html#ff23d875d83642f5ad005ce35a24cedd">outstandingWrites</a>.erase(<a class="code" href="namespaceMipsISA.html#e12ae9e12fab22594609e2fefce7f7c2">p</a>);
<a name="l00334"></a>00334 
<a name="l00335"></a>00335     assert(<a class="code" href="classDRAMSim2.html#bcbf63a24a30af8f4bf250a8970b96cd">nbrOutstandingWrites</a> != 0);
<a name="l00336"></a>00336     --<a class="code" href="classDRAMSim2.html#bcbf63a24a30af8f4bf250a8970b96cd">nbrOutstandingWrites</a>;
<a name="l00337"></a>00337 
<a name="l00338"></a>00338     <span class="comment">// check if we were asked to drain and if we are now done</span>
<a name="l00339"></a>00339     <span class="keywordflow">if</span> (<a class="code" href="classDRAMSim2.html#428f47fc69ebee8db2340ae018ca34bb">drainManager</a> &amp;&amp; <a class="code" href="classDRAMSim2.html#64013900343814092c8b20dda3ec1e1d">nbrOutstanding</a>() == 0) {
<a name="l00340"></a>00340         <a class="code" href="classDRAMSim2.html#428f47fc69ebee8db2340ae018ca34bb">drainManager</a>-&gt;<a class="code" href="classDrainManager.html#bd134e8277be09e702b63f36f6ee31d0">signalDrainDone</a>();
<a name="l00341"></a>00341         <a class="code" href="classDRAMSim2.html#428f47fc69ebee8db2340ae018ca34bb">drainManager</a> = NULL;
<a name="l00342"></a>00342     }
<a name="l00343"></a>00343 }
<a name="l00344"></a>00344 
<a name="l00345"></a>00345 <a class="code" href="classBaseSlavePort.html">BaseSlavePort</a>&amp;
<a name="l00346"></a><a class="code" href="classDRAMSim2.html#f29084d94bafef2f72d626d17cecd73e">00346</a> <a class="code" href="classDRAMSim2.html#f29084d94bafef2f72d626d17cecd73e">DRAMSim2::getSlavePort</a>(<span class="keyword">const</span> std::string &amp;if_name, <a class="code" href="base_2types_8hh.html#cef4d7d41cb21fdc252e20c04cd7bb8e">PortID</a> idx)
<a name="l00347"></a>00347 {
<a name="l00348"></a>00348     <span class="keywordflow">if</span> (if_name != <span class="stringliteral">"port"</span>) {
<a name="l00349"></a>00349         <span class="keywordflow">return</span> <a class="code" href="classMemObject.html#51d400deb86bb1f483ca6b5525070c23">MemObject::getSlavePort</a>(if_name, idx);
<a name="l00350"></a>00350     } <span class="keywordflow">else</span> {
<a name="l00351"></a>00351         <span class="keywordflow">return</span> <a class="code" href="classDRAMSim2.html#edcda98c55f56487a40a10f21dcd5a0c">port</a>;
<a name="l00352"></a>00352     }
<a name="l00353"></a>00353 }
<a name="l00354"></a>00354 
<a name="l00355"></a>00355 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span>
<a name="l00356"></a><a class="code" href="classDRAMSim2.html#28a5cfdf1de57b407fea9bb158217fbb">00356</a> <a class="code" href="classDRAMSim2.html#28a5cfdf1de57b407fea9bb158217fbb">DRAMSim2::drain</a>(<a class="code" href="classDrainManager.html">DrainManager</a>* <a class="code" href="namespaceMipsISA.html#fed89bf85db8c823833a4921f0b24ac8">dm</a>)
<a name="l00357"></a>00357 {
<a name="l00358"></a>00358     <span class="comment">// check our outstanding reads and writes and if any they need to</span>
<a name="l00359"></a>00359     <span class="comment">// drain</span>
<a name="l00360"></a>00360     <span class="keywordflow">if</span> (<a class="code" href="classDRAMSim2.html#64013900343814092c8b20dda3ec1e1d">nbrOutstanding</a>() != 0) {
<a name="l00361"></a>00361         <a class="code" href="classDrainable.html#fce7a34e1fcacc71267a947a3feb941b">setDrainState</a>(<a class="code" href="classDrainable.html#6173416423af6af1bfe17262be40b5ffbd11bb9d2e9941029e08925c2a151162">Drainable::Draining</a>);
<a name="l00362"></a>00362         <a class="code" href="classDRAMSim2.html#428f47fc69ebee8db2340ae018ca34bb">drainManager</a> = <a class="code" href="namespaceMipsISA.html#fed89bf85db8c823833a4921f0b24ac8">dm</a>;
<a name="l00363"></a>00363         <span class="keywordflow">return</span> 1;
<a name="l00364"></a>00364     } <span class="keywordflow">else</span> {
<a name="l00365"></a>00365         <a class="code" href="classDrainable.html#fce7a34e1fcacc71267a947a3feb941b">setDrainState</a>(<a class="code" href="classDrainable.html#6173416423af6af1bfe17262be40b5ffd08d746efca2f68aeb28f73f94237603">Drainable::Drained</a>);
<a name="l00366"></a>00366         <span class="keywordflow">return</span> 0;
<a name="l00367"></a>00367     }
<a name="l00368"></a>00368 }
<a name="l00369"></a>00369 
<a name="l00370"></a><a class="code" href="classDRAMSim2_1_1MemoryPort.html#fac3e5e8ead18bf2fd6da92960f2eaa9">00370</a> <a class="code" href="classDRAMSim2_1_1MemoryPort.html#fac3e5e8ead18bf2fd6da92960f2eaa9">DRAMSim2::MemoryPort::MemoryPort</a>(<span class="keyword">const</span> std::string&amp; _name,
<a name="l00371"></a>00371                                  <a class="code" href="classDRAMSim2.html">DRAMSim2</a>&amp; _memory)
<a name="l00372"></a>00372     : <a class="code" href="classSlavePort.html">SlavePort</a>(_name, &amp;_memory), memory(_memory)
<a name="l00373"></a>00373 { }
<a name="l00374"></a>00374 
<a name="l00375"></a>00375 <a class="code" href="classstd_1_1list.html">AddrRangeList</a>
<a name="l00376"></a><a class="code" href="classDRAMSim2_1_1MemoryPort.html#0928cb300ff18b7a55f5bb3444e05672">00376</a> <a class="code" href="classDRAMSim2_1_1MemoryPort.html#0928cb300ff18b7a55f5bb3444e05672">DRAMSim2::MemoryPort::getAddrRanges</a>()<span class="keyword"> const</span>
<a name="l00377"></a>00377 <span class="keyword"></span>{
<a name="l00378"></a>00378     <a class="code" href="classstd_1_1list.html">AddrRangeList</a> ranges;
<a name="l00379"></a>00379     ranges.push_back(<a class="code" href="classDRAMSim2_1_1MemoryPort.html#d5899554b88d500ea424d10efcdffd6f">memory</a>.<a class="code" href="classAbstractMemory.html#8cc7718cf94a14b1bad6ae24d7859cd8">getAddrRange</a>());
<a name="l00380"></a>00380     <span class="keywordflow">return</span> ranges;
<a name="l00381"></a>00381 }
<a name="l00382"></a>00382 
<a name="l00383"></a>00383 <a class="code" href="base_2types_8hh.html#5c8ed81b7d238c9083e1037ba6d61643">Tick</a>
<a name="l00384"></a><a class="code" href="classDRAMSim2_1_1MemoryPort.html#8cf77d86654517ea6fb946cce4b6a867">00384</a> <a class="code" href="classDRAMSim2_1_1MemoryPort.html#8cf77d86654517ea6fb946cce4b6a867">DRAMSim2::MemoryPort::recvAtomic</a>(<a class="code" href="classPacket.html">PacketPtr</a> pkt)
<a name="l00385"></a>00385 {
<a name="l00386"></a>00386     <span class="keywordflow">return</span> <a class="code" href="classDRAMSim2_1_1MemoryPort.html#d5899554b88d500ea424d10efcdffd6f">memory</a>.<a class="code" href="classDRAMSim2.html#36e7ecd234d840073007289c267a3594">recvAtomic</a>(pkt);
<a name="l00387"></a>00387 }
<a name="l00388"></a>00388 
<a name="l00389"></a>00389 <span class="keywordtype">void</span>
<a name="l00390"></a><a class="code" href="classDRAMSim2_1_1MemoryPort.html#ccbaa5f806c65223466b6d96d5be927d">00390</a> <a class="code" href="classDRAMSim2_1_1MemoryPort.html#ccbaa5f806c65223466b6d96d5be927d">DRAMSim2::MemoryPort::recvFunctional</a>(<a class="code" href="classPacket.html">PacketPtr</a> pkt)
<a name="l00391"></a>00391 {
<a name="l00392"></a>00392     <a class="code" href="classDRAMSim2_1_1MemoryPort.html#d5899554b88d500ea424d10efcdffd6f">memory</a>.<a class="code" href="classDRAMSim2.html#5cb12a2b69508fe2b6cca9da1fac2f7a">recvFunctional</a>(pkt);
<a name="l00393"></a>00393 }
<a name="l00394"></a>00394 
<a name="l00395"></a>00395 <span class="keywordtype">bool</span>
<a name="l00396"></a><a class="code" href="classDRAMSim2_1_1MemoryPort.html#faa58c9d4f03fc752aaa81399029413c">00396</a> <a class="code" href="classDRAMSim2_1_1MemoryPort.html#faa58c9d4f03fc752aaa81399029413c">DRAMSim2::MemoryPort::recvTimingReq</a>(<a class="code" href="classPacket.html">PacketPtr</a> pkt)
<a name="l00397"></a>00397 {
<a name="l00398"></a>00398     <span class="comment">// pass it to the memory controller</span>
<a name="l00399"></a>00399     <span class="keywordflow">return</span> <a class="code" href="classDRAMSim2_1_1MemoryPort.html#d5899554b88d500ea424d10efcdffd6f">memory</a>.<a class="code" href="classDRAMSim2.html#cdafcd36516384830d0b0d373e2dfeb1">recvTimingReq</a>(pkt);
<a name="l00400"></a>00400 }
<a name="l00401"></a>00401 
<a name="l00402"></a>00402 <span class="keywordtype">void</span>
<a name="l00403"></a><a class="code" href="classDRAMSim2_1_1MemoryPort.html#4760aece9fddb2b56029e12129adfcb5">00403</a> <a class="code" href="classDRAMSim2_1_1MemoryPort.html#4760aece9fddb2b56029e12129adfcb5">DRAMSim2::MemoryPort::recvRetry</a>()
<a name="l00404"></a>00404 {
<a name="l00405"></a>00405     <a class="code" href="classDRAMSim2_1_1MemoryPort.html#d5899554b88d500ea424d10efcdffd6f">memory</a>.<a class="code" href="classDRAMSim2.html#6a260883a3ac4966d65d30ce6e7eb726">recvRetry</a>();
<a name="l00406"></a>00406 }
<a name="l00407"></a>00407 
<a name="l00408"></a>00408 <a class="code" href="classDRAMSim2.html">DRAMSim2</a>*
<a name="l00409"></a>00409 DRAMSim2Params::create()
<a name="l00410"></a>00410 {
<a name="l00411"></a>00411     <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="classDRAMSim2.html#21e1afbc6afe80fe3f73deea1abfb4e5">DRAMSim2</a>(<span class="keyword">this</span>);
<a name="l00412"></a>00412 }
</pre></div><hr size="1"><address style="align: right;"><small>
Generated on Fri Apr 17 12:38:52 2015 for gem5 by <a href="http://www.doxygen.org/index.html"> doxygen</a> 1.4.7</small></address>

</body>
</html>
