DRAMCtrl.py revision 9488
110780SCurtis.Dunham@arm.com# Copyright (c) 2012 ARM Limited
27090SN/A# All rights reserved.
37090SN/A#
47090SN/A# The license below extends only to copyright in the software and shall
57090SN/A# not be construed as granting a license to any other intellectual
67090SN/A# property including but not limited to intellectual property relating
77090SN/A# to a hardware implementation of the functionality of the software
87090SN/A# licensed hereunder.  You may use the software subject to the license
97090SN/A# terms below provided that you ensure that this notice is replicated
107090SN/A# unmodified and in its entirety in all distributions of the software,
117090SN/A# modified or unmodified, in source code or in binary form.
127090SN/A#
134486SN/A# Redistribution and use in source and binary forms, with or without
144486SN/A# modification, are permitted provided that the following conditions are
154486SN/A# met: redistributions of source code must retain the above copyright
164486SN/A# notice, this list of conditions and the following disclaimer;
174486SN/A# redistributions in binary form must reproduce the above copyright
184486SN/A# notice, this list of conditions and the following disclaimer in the
194486SN/A# documentation and/or other materials provided with the distribution;
204486SN/A# neither the name of the copyright holders nor the names of its
214486SN/A# contributors may be used to endorse or promote products derived from
224486SN/A# this software without specific prior written permission.
234486SN/A#
244486SN/A# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
254486SN/A# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
264486SN/A# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
274486SN/A# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
284486SN/A# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
294486SN/A# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
304486SN/A# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
314486SN/A# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
324486SN/A# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
334486SN/A# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
344486SN/A# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
354486SN/A#
364486SN/A# Authors: Andreas Hansson
374486SN/A#          Ani Udipi
384486SN/A
397584SAli.Saidi@arm.comfrom m5.params import *
407584SAli.Saidi@arm.comfrom AbstractMemory import *
417754SWilliam.Wang@arm.com
424486SN/A# Enum for memory scheduling algorithms, currently First-Come
433630SN/A# First-Served and a First-Row Hit then First-Come First-Served
443630SN/Aclass MemSched(Enum): vals = ['fcfs', 'frfcfs']
4511011SAndreas.Sandberg@ARM.com
4611011SAndreas.Sandberg@ARM.com# Enum for the address mapping, currently corresponding to either
477587SAli.Saidi@arm.com# optimising for sequential accesses hitting in the open row, or
488525SAli.Saidi@ARM.com# striping across banks.
4910353SGeoffrey.Blake@arm.comclass AddrMap(Enum): vals = ['openmap', 'closemap']
508212SAli.Saidi@ARM.com
515478SN/A# Enum for the page policy, either open or close.
525478SN/Aclass PageManage(Enum): vals = ['open', 'close']
537584SAli.Saidi@arm.com
548931Sandreas.hansson@arm.com# SimpleDRAM is a single-channel single-ported DRAM controller model
559525SAndreas.Sandberg@ARM.com# that aims to model the most important system-level performance
5610397Sstephan.diestelhorst@arm.com# effects of a DRAM without getting into too much detail of the DRAM
5711090Sandreas.sandberg@arm.com# itself.
5811236Sandreas.sandberg@arm.comclass SimpleDRAM(AbstractMemory):
593630SN/A    type = 'SimpleDRAM'
609806Sstever@gmail.com    cxx_header = "mem/simple_dram.hh"
619806Sstever@gmail.com
627584SAli.Saidi@arm.com    # single-ported on the system interface side, instantiate with a
639338SAndreas.Sandberg@arm.com    # bus in front of the controller for multiple ports
647584SAli.Saidi@arm.com    port = SlavePort("Slave port")
653898SN/A
669806Sstever@gmail.com    # the physical organisation of the DRAM
677950SAli.Saidi@ARM.com    lines_per_rowbuffer = Param.Unsigned(64, "Row buffer size in cache lines")
687950SAli.Saidi@ARM.com    ranks_per_channel = Param.Unsigned(2, "Number of ranks per channel")
699338SAndreas.Sandberg@arm.com    banks_per_rank = Param.Unsigned(8, "Number of banks per rank")
709525SAndreas.Sandberg@ARM.com
717950SAli.Saidi@ARM.com    # the basic configuration of the controller architecture
727950SAli.Saidi@ARM.com    write_buffer_size = Param.Unsigned(32, "Number of read queue entries")
737950SAli.Saidi@ARM.com    read_buffer_size = Param.Unsigned(32, "Number of write queue entries")
747950SAli.Saidi@ARM.com
757587SAli.Saidi@arm.com    # threshold in percent for when to trigger writes and start
767587SAli.Saidi@arm.com    # emptying the write buffer as it starts to get full
777587SAli.Saidi@arm.com    write_thresh_perc = Param.Percent(70, "Threshold to trigger writes")
789338SAndreas.Sandberg@arm.com
797753SWilliam.Wang@arm.com    # scheduler, address map and page policy
807753SWilliam.Wang@arm.com    mem_sched_policy = Param.MemSched('fcfs', "Memory scheduling policy")
819525SAndreas.Sandberg@ARM.com    addr_mapping = Param.AddrMap('openmap', "Address mapping policy")
827753SWilliam.Wang@arm.com    page_policy = Param.PageManage('open', "Page closure management policy")
837587SAli.Saidi@arm.com
847587SAli.Saidi@arm.com    # timing behaviour and constraints - all in nanoseconds
858282SAli.Saidi@ARM.com
868282SAli.Saidi@ARM.com    # the amount of time in nanoseconds from issuing an activate command
879338SAndreas.Sandberg@arm.com    # to the data being available in the row buffer for a read/write
888282SAli.Saidi@ARM.com    tRCD = Param.Latency("14ns", "RAS to CAS delay")
897584SAli.Saidi@arm.com
907584SAli.Saidi@arm.com    # the time from issuing a read/write command to seeing the actual data
919338SAndreas.Sandberg@arm.com    tCL = Param.Latency("14ns", "CAS latency")
928524SAli.Saidi@ARM.com
938524SAli.Saidi@ARM.com    # minimum time between a precharge and subsequent activate
948299Schander.sudanthi@arm.com    tRP = Param.Latency("14ns", "Row precharge time")
957584SAli.Saidi@arm.com
9611011SAndreas.Sandberg@ARM.com    # time to complete a burst transfer, typically the burst length
9711011SAndreas.Sandberg@ARM.com    # divided by two due to the DDR bus, but by making it a parameter
9811011SAndreas.Sandberg@ARM.com    # it is easier to also evaluate SDR memories like WideIO.
9911011SAndreas.Sandberg@ARM.com    # This parameter has to account for bus width and burst length.
10011011SAndreas.Sandberg@ARM.com    # Adjustment also necessary if cache line size is greater than
10111011SAndreas.Sandberg@ARM.com    # data size read/written by one full burst.
10211011SAndreas.Sandberg@ARM.com    tBURST = Param.Latency("4ns",
10311011SAndreas.Sandberg@ARM.com                           "Burst duration (for DDR burst length / 2 cycles)")
10411011SAndreas.Sandberg@ARM.com
10511011SAndreas.Sandberg@ARM.com    # time taken to complete one refresh cycle (N rows in all banks)
10611011SAndreas.Sandberg@ARM.com    tRFC = Param.Latency("300ns", "Refresh cycle time")
10711011SAndreas.Sandberg@ARM.com
10811011SAndreas.Sandberg@ARM.com    # refresh command interval, how often a "ref" command needs
10911011SAndreas.Sandberg@ARM.com    # to be sent. It is 7.8 us for a 64ms refresh requirement
11011011SAndreas.Sandberg@ARM.com    tREFI = Param.Latency("7.8us", "Refresh command interval")
11111011SAndreas.Sandberg@ARM.com
11211011SAndreas.Sandberg@ARM.com    # write-to-read turn around penalty, assumed same as read-to-write
11311011SAndreas.Sandberg@ARM.com    tWTR = Param.Latency("1ns", "Write to read switching time")
11411011SAndreas.Sandberg@ARM.com
11511011SAndreas.Sandberg@ARM.com    # time window in which a maximum number of activates are allowed
11611011SAndreas.Sandberg@ARM.com    # to take place, set to 0 to disable
11711011SAndreas.Sandberg@ARM.com    tXAW = Param.Latency("0ns", "X activation window")
11811236Sandreas.sandberg@arm.com    activation_limit = Param.Unsigned(4, "Max number of activates in window")
11911236Sandreas.sandberg@arm.com
12011236Sandreas.sandberg@arm.com    # Currently rolled into other params
12111236Sandreas.sandberg@arm.com    ######################################################################
12211236Sandreas.sandberg@arm.com
12311236Sandreas.sandberg@arm.com    # the minimum amount of time between a row being activated, and
12411236Sandreas.sandberg@arm.com    # precharged (de-activated)
12511236Sandreas.sandberg@arm.com    # tRAS - assumed to be 3 * tRP
12611236Sandreas.sandberg@arm.com
12711011SAndreas.Sandberg@ARM.com    # tRC  - assumed to be 4 * tRP
12811011SAndreas.Sandberg@ARM.com
12911236Sandreas.sandberg@arm.com    # burst length for an access derived from peerBlockSize
13011236Sandreas.sandberg@arm.com