DRAMCtrl.py revision 12516:483fc7339fb1
110447Snilay@cs.wisc.edu# Copyright (c) 2012-2016 ARM Limited
210447Snilay@cs.wisc.edu# All rights reserved.
310447Snilay@cs.wisc.edu#
410447Snilay@cs.wisc.edu# The license below extends only to copyright in the software and shall
510447Snilay@cs.wisc.edu# not be construed as granting a license to any other intellectual
610447Snilay@cs.wisc.edu# property including but not limited to intellectual property relating
710447Snilay@cs.wisc.edu# to a hardware implementation of the functionality of the software
810447Snilay@cs.wisc.edu# licensed hereunder.  You may use the software subject to the license
910447Snilay@cs.wisc.edu# terms below provided that you ensure that this notice is replicated
1010447Snilay@cs.wisc.edu# unmodified and in its entirety in all distributions of the software,
1110447Snilay@cs.wisc.edu# modified or unmodified, in source code or in binary form.
1210447Snilay@cs.wisc.edu#
1310447Snilay@cs.wisc.edu# Copyright (c) 2013 Amin Farmahini-Farahani
1410447Snilay@cs.wisc.edu# Copyright (c) 2015 University of Kaiserslautern
1510447Snilay@cs.wisc.edu# Copyright (c) 2015 The University of Bologna
1610447Snilay@cs.wisc.edu# All rights reserved.
1710447Snilay@cs.wisc.edu#
1810447Snilay@cs.wisc.edu# Redistribution and use in source and binary forms, with or without
1910447Snilay@cs.wisc.edu# modification, are permitted provided that the following conditions are
2010447Snilay@cs.wisc.edu# met: redistributions of source code must retain the above copyright
2110447Snilay@cs.wisc.edu# notice, this list of conditions and the following disclaimer;
2210447Snilay@cs.wisc.edu# redistributions in binary form must reproduce the above copyright
2310447Snilay@cs.wisc.edu# notice, this list of conditions and the following disclaimer in the
2410447Snilay@cs.wisc.edu# documentation and/or other materials provided with the distribution;
2510447Snilay@cs.wisc.edu# neither the name of the copyright holders nor the names of its
2610447Snilay@cs.wisc.edu# contributors may be used to endorse or promote products derived from
2710447Snilay@cs.wisc.edu# this software without specific prior written permission.
2810447Snilay@cs.wisc.edu#
2910447Snilay@cs.wisc.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3010447Snilay@cs.wisc.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3110447Snilay@cs.wisc.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
3210447Snilay@cs.wisc.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3310447Snilay@cs.wisc.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
3410447Snilay@cs.wisc.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3510447Snilay@cs.wisc.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
3610447Snilay@cs.wisc.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
3710447Snilay@cs.wisc.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3810447Snilay@cs.wisc.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3910447Snilay@cs.wisc.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4010447Snilay@cs.wisc.edu#
4110447Snilay@cs.wisc.edu# Authors: Andreas Hansson
4210447Snilay@cs.wisc.edu#          Ani Udipi
4310447Snilay@cs.wisc.edu#          Omar Naji
4410447Snilay@cs.wisc.edu#          Matthias Jung
4510447Snilay@cs.wisc.edu#          Erfan Azarkhish
4610447Snilay@cs.wisc.edu
4710447Snilay@cs.wisc.edufrom m5.params import *
4810447Snilay@cs.wisc.edufrom AbstractMemory import *
4910447Snilay@cs.wisc.edu
5010447Snilay@cs.wisc.edu# Enum for memory scheduling algorithms, currently First-Come
5110447Snilay@cs.wisc.edu# First-Served and a First-Row Hit then First-Come First-Served
5210447Snilay@cs.wisc.educlass MemSched(Enum): vals = ['fcfs', 'frfcfs']
5310447Snilay@cs.wisc.edu
5410447Snilay@cs.wisc.edu# Enum for the address mapping. With Ch, Ra, Ba, Ro and Co denoting
5510447Snilay@cs.wisc.edu# channel, rank, bank, row and column, respectively, and going from
5610447Snilay@cs.wisc.edu# MSB to LSB.  Available are RoRaBaChCo and RoRaBaCoCh, that are
5710447Snilay@cs.wisc.edu# suitable for an open-page policy, optimising for sequential accesses
5810447Snilay@cs.wisc.edu# hitting in the open row. For a closed-page policy, RoCoRaBaCh
5910447Snilay@cs.wisc.edu# maximises parallelism.
6010447Snilay@cs.wisc.educlass AddrMap(Enum): vals = ['RoRaBaChCo', 'RoRaBaCoCh', 'RoCoRaBaCh']
6110447Snilay@cs.wisc.edu
6210447Snilay@cs.wisc.edu# Enum for the page policy, either open, open_adaptive, close, or
6310447Snilay@cs.wisc.edu# close_adaptive.
6410447Snilay@cs.wisc.educlass PageManage(Enum): vals = ['open', 'open_adaptive', 'close',
6510447Snilay@cs.wisc.edu                                'close_adaptive']
6610447Snilay@cs.wisc.edu
6710447Snilay@cs.wisc.edu# DRAMCtrl is a single-channel single-ported DRAM controller model
6810447Snilay@cs.wisc.edu# that aims to model the most important system-level performance
6910447Snilay@cs.wisc.edu# effects of a DRAM without getting into too much detail of the DRAM
7010447Snilay@cs.wisc.edu# itself.
7110447Snilay@cs.wisc.educlass DRAMCtrl(AbstractMemory):
7210447Snilay@cs.wisc.edu    type = 'DRAMCtrl'
7310447Snilay@cs.wisc.edu    cxx_header = "mem/dram_ctrl.hh"
7410447Snilay@cs.wisc.edu
7510447Snilay@cs.wisc.edu    # single-ported on the system interface side, instantiate with a
7610447Snilay@cs.wisc.edu    # bus in front of the controller for multiple ports
7710447Snilay@cs.wisc.edu    port = SlavePort("Slave port")
7810447Snilay@cs.wisc.edu
7910447Snilay@cs.wisc.edu    # the basic configuration of the controller architecture, note
8010447Snilay@cs.wisc.edu    # that each entry corresponds to a burst for the specific DRAM
8110447Snilay@cs.wisc.edu    # configuration (e.g. x32 with burst length 8 is 32 bytes) and not
8210447Snilay@cs.wisc.edu    # the cacheline size or request/packet size
8310447Snilay@cs.wisc.edu    write_buffer_size = Param.Unsigned(64, "Number of write queue entries")
8410447Snilay@cs.wisc.edu    read_buffer_size = Param.Unsigned(32, "Number of read queue entries")
8510447Snilay@cs.wisc.edu
8610447Snilay@cs.wisc.edu    # threshold in percent for when to forcefully trigger writes and
8710447Snilay@cs.wisc.edu    # start emptying the write buffer
8810447Snilay@cs.wisc.edu    write_high_thresh_perc = Param.Percent(85, "Threshold to force writes")
8910447Snilay@cs.wisc.edu
9010447Snilay@cs.wisc.edu    # threshold in percentage for when to start writes if the read
9110447Snilay@cs.wisc.edu    # queue is empty
9210447Snilay@cs.wisc.edu    write_low_thresh_perc = Param.Percent(50, "Threshold to start writes")
9310447Snilay@cs.wisc.edu
9410447Snilay@cs.wisc.edu    # minimum write bursts to schedule before switching back to reads
9510447Snilay@cs.wisc.edu    min_writes_per_switch = Param.Unsigned(16, "Minimum write bursts before "
9610447Snilay@cs.wisc.edu                                           "switching to reads")
9710447Snilay@cs.wisc.edu
9810447Snilay@cs.wisc.edu    # scheduler, address map and page policy
9910447Snilay@cs.wisc.edu    mem_sched_policy = Param.MemSched('frfcfs', "Memory scheduling policy")
10010447Snilay@cs.wisc.edu    addr_mapping = Param.AddrMap('RoRaBaCoCh', "Address mapping policy")
10110447Snilay@cs.wisc.edu    page_policy = Param.PageManage('open_adaptive', "Page management policy")
10210447Snilay@cs.wisc.edu
10310447Snilay@cs.wisc.edu    # enforce a limit on the number of accesses per row
10410447Snilay@cs.wisc.edu    max_accesses_per_row = Param.Unsigned(16, "Max accesses per row before "
10510447Snilay@cs.wisc.edu                                          "closing");
10610447Snilay@cs.wisc.edu
10710447Snilay@cs.wisc.edu    # size of DRAM Chip in Bytes
10810447Snilay@cs.wisc.edu    device_size = Param.MemorySize("Size of DRAM chip")
10910447Snilay@cs.wisc.edu
11010447Snilay@cs.wisc.edu    # pipeline latency of the controller and PHY, split into a
11110447Snilay@cs.wisc.edu    # frontend part and a backend part, with reads and writes serviced
11210447Snilay@cs.wisc.edu    # by the queues only seeing the frontend contribution, and reads
11310447Snilay@cs.wisc.edu    # serviced by the memory seeing the sum of the two
11410447Snilay@cs.wisc.edu    static_frontend_latency = Param.Latency("10ns", "Static frontend latency")
11510447Snilay@cs.wisc.edu    static_backend_latency = Param.Latency("10ns", "Static backend latency")
11610447Snilay@cs.wisc.edu
11710447Snilay@cs.wisc.edu    # the physical organisation of the DRAM
11810447Snilay@cs.wisc.edu    device_bus_width = Param.Unsigned("data bus width in bits for each DRAM "\
11910447Snilay@cs.wisc.edu                                      "device/chip")
12010447Snilay@cs.wisc.edu    burst_length = Param.Unsigned("Burst lenght (BL) in beats")
12110447Snilay@cs.wisc.edu    device_rowbuffer_size = Param.MemorySize("Page (row buffer) size per "\
12210447Snilay@cs.wisc.edu                                           "device/chip")
12310447Snilay@cs.wisc.edu    devices_per_rank = Param.Unsigned("Number of devices/chips per rank")
12410447Snilay@cs.wisc.edu    ranks_per_channel = Param.Unsigned("Number of ranks per channel")
12510447Snilay@cs.wisc.edu
12610447Snilay@cs.wisc.edu    # default to 0 bank groups per rank, indicating bank group architecture
12710447Snilay@cs.wisc.edu    # is not used
12810447Snilay@cs.wisc.edu    # update per memory class when bank group architecture is supported
12910447Snilay@cs.wisc.edu    bank_groups_per_rank = Param.Unsigned(0, "Number of bank groups per rank")
13010447Snilay@cs.wisc.edu    banks_per_rank = Param.Unsigned("Number of banks per rank")
13110447Snilay@cs.wisc.edu    # only used for the address mapping as the controller by
13210447Snilay@cs.wisc.edu    # construction is a single channel and multiple controllers have
13310447Snilay@cs.wisc.edu    # to be instantiated for a multi-channel configuration
13410447Snilay@cs.wisc.edu    channels = Param.Unsigned(1, "Number of channels")
13510447Snilay@cs.wisc.edu
13610447Snilay@cs.wisc.edu    # For power modelling we need to know if the DRAM has a DLL or not
13710447Snilay@cs.wisc.edu    dll = Param.Bool(True, "DRAM has DLL or not")
13810447Snilay@cs.wisc.edu
13910447Snilay@cs.wisc.edu    # DRAMPower provides in addition to the core power, the possibility to
14010447Snilay@cs.wisc.edu    # include RD/WR termination and IO power. This calculation assumes some
14110447Snilay@cs.wisc.edu    # default values. The integration of DRAMPower with gem5 does not include
14210447Snilay@cs.wisc.edu    # IO and RD/WR termination power by default. This might be added as an
14310447Snilay@cs.wisc.edu    # additional feature in the future.
14410447Snilay@cs.wisc.edu
14510447Snilay@cs.wisc.edu    # timing behaviour and constraints - all in nanoseconds
14610447Snilay@cs.wisc.edu
14710447Snilay@cs.wisc.edu    # the base clock period of the DRAM
14810447Snilay@cs.wisc.edu    tCK = Param.Latency("Clock period")
14910447Snilay@cs.wisc.edu
15010447Snilay@cs.wisc.edu    # the amount of time in nanoseconds from issuing an activate command
15110447Snilay@cs.wisc.edu    # to the data being available in the row buffer for a read/write
15210447Snilay@cs.wisc.edu    tRCD = Param.Latency("RAS to CAS delay")
15310447Snilay@cs.wisc.edu
15410447Snilay@cs.wisc.edu    # the time from issuing a read/write command to seeing the actual data
15510447Snilay@cs.wisc.edu    tCL = Param.Latency("CAS latency")
15610447Snilay@cs.wisc.edu
15710447Snilay@cs.wisc.edu    # minimum time between a precharge and subsequent activate
15810447Snilay@cs.wisc.edu    tRP = Param.Latency("Row precharge time")
15910447Snilay@cs.wisc.edu
16010447Snilay@cs.wisc.edu    # minimum time between an activate and a precharge to the same row
16110447Snilay@cs.wisc.edu    tRAS = Param.Latency("ACT to PRE delay")
16210447Snilay@cs.wisc.edu
16310447Snilay@cs.wisc.edu    # minimum time between a write data transfer and a precharge
16410447Snilay@cs.wisc.edu    tWR = Param.Latency("Write recovery time")
16510447Snilay@cs.wisc.edu
16610447Snilay@cs.wisc.edu    # minimum time between a read and precharge command
16710447Snilay@cs.wisc.edu    tRTP = Param.Latency("Read to precharge")
16810447Snilay@cs.wisc.edu
16910447Snilay@cs.wisc.edu    # time to complete a burst transfer, typically the burst length
17010447Snilay@cs.wisc.edu    # divided by two due to the DDR bus, but by making it a parameter
17110447Snilay@cs.wisc.edu    # it is easier to also evaluate SDR memories like WideIO.
17210447Snilay@cs.wisc.edu    # This parameter has to account for burst length.
17310447Snilay@cs.wisc.edu    # Read/Write requests with data size larger than one full burst are broken
17410447Snilay@cs.wisc.edu    # down into multiple requests in the controller
17510447Snilay@cs.wisc.edu    # tBURST is equivalent to the CAS-to-CAS delay (tCCD)
17610447Snilay@cs.wisc.edu    # With bank group architectures, tBURST represents the CAS-to-CAS
17710447Snilay@cs.wisc.edu    # delay for bursts to different bank groups (tCCD_S)
17810447Snilay@cs.wisc.edu    tBURST = Param.Latency("Burst duration (for DDR burst length / 2 cycles)")
17910447Snilay@cs.wisc.edu
18010447Snilay@cs.wisc.edu    # CAS-to-CAS delay for bursts to the same bank group
18110447Snilay@cs.wisc.edu    # only utilized with bank group architectures; set to 0 for default case
18210447Snilay@cs.wisc.edu    # tBURST is equivalent to tCCD_S; no explicit parameter required
18310447Snilay@cs.wisc.edu    # for CAS-to-CAS delay for bursts to different bank groups
18410447Snilay@cs.wisc.edu    tCCD_L = Param.Latency("0ns", "Same bank group CAS to CAS delay")
18510447Snilay@cs.wisc.edu
18610447Snilay@cs.wisc.edu    # time taken to complete one refresh cycle (N rows in all banks)
18710447Snilay@cs.wisc.edu    tRFC = Param.Latency("Refresh cycle time")
18810447Snilay@cs.wisc.edu
18910447Snilay@cs.wisc.edu    # refresh command interval, how often a "ref" command needs
19010447Snilay@cs.wisc.edu    # to be sent. It is 7.8 us for a 64ms refresh requirement
19110447Snilay@cs.wisc.edu    tREFI = Param.Latency("Refresh command interval")
19210447Snilay@cs.wisc.edu
19310447Snilay@cs.wisc.edu    # write-to-read, same rank turnaround penalty
19410447Snilay@cs.wisc.edu    tWTR = Param.Latency("Write to read, same rank switching time")
19510447Snilay@cs.wisc.edu
19610447Snilay@cs.wisc.edu    # read-to-write, same rank turnaround penalty
19710447Snilay@cs.wisc.edu    tRTW = Param.Latency("Read to write, same rank switching time")
19810447Snilay@cs.wisc.edu
19910447Snilay@cs.wisc.edu    # rank-to-rank bus delay penalty
20010447Snilay@cs.wisc.edu    # this does not correlate to a memory timing parameter and encompasses:
20110447Snilay@cs.wisc.edu    # 1) RD-to-RD, 2) WR-to-WR, 3) RD-to-WR, and 4) WR-to-RD
20210447Snilay@cs.wisc.edu    # different rank bus delay
20310447Snilay@cs.wisc.edu    tCS = Param.Latency("Rank to rank switching time")
20410447Snilay@cs.wisc.edu
20510447Snilay@cs.wisc.edu    # minimum row activate to row activate delay time
20610447Snilay@cs.wisc.edu    tRRD = Param.Latency("ACT to ACT delay")
20710447Snilay@cs.wisc.edu
20810447Snilay@cs.wisc.edu    # only utilized with bank group architectures; set to 0 for default case
20910447Snilay@cs.wisc.edu    tRRD_L = Param.Latency("0ns", "Same bank group ACT to ACT delay")
21010447Snilay@cs.wisc.edu
21110447Snilay@cs.wisc.edu    # time window in which a maximum number of activates are allowed
21210447Snilay@cs.wisc.edu    # to take place, set to 0 to disable
21310447Snilay@cs.wisc.edu    tXAW = Param.Latency("X activation window")
21410447Snilay@cs.wisc.edu    activation_limit = Param.Unsigned("Max number of activates in window")
21510447Snilay@cs.wisc.edu
21610447Snilay@cs.wisc.edu    # time to exit power-down mode
21710447Snilay@cs.wisc.edu    # Exit power-down to next valid command delay
21810447Snilay@cs.wisc.edu    tXP = Param.Latency("0ns", "Power-up Delay")
21910447Snilay@cs.wisc.edu
22010447Snilay@cs.wisc.edu    # Exit Powerdown to commands requiring a locked DLL
22110447Snilay@cs.wisc.edu    tXPDLL = Param.Latency("0ns", "Power-up Delay with locked DLL")
22210447Snilay@cs.wisc.edu
22310447Snilay@cs.wisc.edu    # time to exit self-refresh mode
22410447Snilay@cs.wisc.edu    tXS = Param.Latency("0ns", "Self-refresh exit latency")
22510447Snilay@cs.wisc.edu
22610447Snilay@cs.wisc.edu    # time to exit self-refresh mode with locked DLL
22710447Snilay@cs.wisc.edu    tXSDLL = Param.Latency("0ns", "Self-refresh exit latency DLL")
22810447Snilay@cs.wisc.edu
22910447Snilay@cs.wisc.edu    # Currently rolled into other params
23010447Snilay@cs.wisc.edu    ######################################################################
23110447Snilay@cs.wisc.edu
23210447Snilay@cs.wisc.edu    # tRC  - assumed to be tRAS + tRP
23310447Snilay@cs.wisc.edu
23410447Snilay@cs.wisc.edu    # Power Behaviour and Constraints
23510447Snilay@cs.wisc.edu    # DRAMs like LPDDR and WideIO have 2 external voltage domains. These are
23610447Snilay@cs.wisc.edu    # defined as VDD and VDD2. Each current is defined for each voltage domain
23710447Snilay@cs.wisc.edu    # separately. For example, current IDD0 is active-precharge current for
23810447Snilay@cs.wisc.edu    # voltage domain VDD and current IDD02 is active-precharge current for
23910447Snilay@cs.wisc.edu    # voltage domain VDD2.
24010447Snilay@cs.wisc.edu    # By default all currents are set to 0mA. Users who are only interested in
24110447Snilay@cs.wisc.edu    # the performance of DRAMs can leave them at 0.
24210447Snilay@cs.wisc.edu
24310447Snilay@cs.wisc.edu    # Operating 1 Bank Active-Precharge current
24410447Snilay@cs.wisc.edu    IDD0 = Param.Current("0mA", "Active precharge current")
24510447Snilay@cs.wisc.edu
24610447Snilay@cs.wisc.edu    # Operating 1 Bank Active-Precharge current multiple voltage Range
24710447Snilay@cs.wisc.edu    IDD02 = Param.Current("0mA", "Active precharge current VDD2")
24810447Snilay@cs.wisc.edu
24910447Snilay@cs.wisc.edu    # Precharge Power-down Current: Slow exit
25010447Snilay@cs.wisc.edu    IDD2P0 = Param.Current("0mA", "Precharge Powerdown slow")
25110447Snilay@cs.wisc.edu
25210447Snilay@cs.wisc.edu    # Precharge Power-down Current: Slow exit multiple voltage Range
25310447Snilay@cs.wisc.edu    IDD2P02 = Param.Current("0mA", "Precharge Powerdown slow VDD2")
25410447Snilay@cs.wisc.edu
25510447Snilay@cs.wisc.edu    # Precharge Power-down Current: Fast exit
25610447Snilay@cs.wisc.edu    IDD2P1 = Param.Current("0mA", "Precharge Powerdown fast")
25710447Snilay@cs.wisc.edu
25810447Snilay@cs.wisc.edu    # Precharge Power-down Current: Fast exit multiple voltage Range
25910447Snilay@cs.wisc.edu    IDD2P12 = Param.Current("0mA", "Precharge Powerdown fast VDD2")
26010447Snilay@cs.wisc.edu
26110447Snilay@cs.wisc.edu    # Precharge Standby current
26210447Snilay@cs.wisc.edu    IDD2N = Param.Current("0mA", "Precharge Standby current")
26310447Snilay@cs.wisc.edu
26410447Snilay@cs.wisc.edu    # Precharge Standby current multiple voltage range
26510447Snilay@cs.wisc.edu    IDD2N2 = Param.Current("0mA", "Precharge Standby current VDD2")
26610447Snilay@cs.wisc.edu
26710447Snilay@cs.wisc.edu    # Active Power-down current: slow exit
26810447Snilay@cs.wisc.edu    IDD3P0 = Param.Current("0mA", "Active Powerdown slow")
26910447Snilay@cs.wisc.edu
27010447Snilay@cs.wisc.edu    # Active Power-down current: slow exit multiple voltage range
27110447Snilay@cs.wisc.edu    IDD3P02 = Param.Current("0mA", "Active Powerdown slow VDD2")
27210447Snilay@cs.wisc.edu
27310447Snilay@cs.wisc.edu    # Active Power-down current : fast exit
27410447Snilay@cs.wisc.edu    IDD3P1 = Param.Current("0mA", "Active Powerdown fast")
27510447Snilay@cs.wisc.edu
27610447Snilay@cs.wisc.edu    # Active Power-down current : fast exit multiple voltage range
27710447Snilay@cs.wisc.edu    IDD3P12 = Param.Current("0mA", "Active Powerdown fast VDD2")
27810447Snilay@cs.wisc.edu
27910447Snilay@cs.wisc.edu    # Active Standby current
28010447Snilay@cs.wisc.edu    IDD3N = Param.Current("0mA", "Active Standby current")
28110447Snilay@cs.wisc.edu
28210447Snilay@cs.wisc.edu    # Active Standby current multiple voltage range
28310447Snilay@cs.wisc.edu    IDD3N2 = Param.Current("0mA", "Active Standby current VDD2")
28410447Snilay@cs.wisc.edu
28510447Snilay@cs.wisc.edu    # Burst Read Operating Current
28610447Snilay@cs.wisc.edu    IDD4R = Param.Current("0mA", "READ current")
28710447Snilay@cs.wisc.edu
28810447Snilay@cs.wisc.edu    # Burst Read Operating Current multiple voltage range
28910447Snilay@cs.wisc.edu    IDD4R2 = Param.Current("0mA", "READ current VDD2")
29010447Snilay@cs.wisc.edu
29110447Snilay@cs.wisc.edu    # Burst Write Operating Current
29210447Snilay@cs.wisc.edu    IDD4W = Param.Current("0mA", "WRITE current")
29310447Snilay@cs.wisc.edu
29410447Snilay@cs.wisc.edu    # Burst Write Operating Current multiple voltage range
29510447Snilay@cs.wisc.edu    IDD4W2 = Param.Current("0mA", "WRITE current VDD2")
29610447Snilay@cs.wisc.edu
29710447Snilay@cs.wisc.edu    # Refresh Current
29810447Snilay@cs.wisc.edu    IDD5 = Param.Current("0mA", "Refresh current")
29910447Snilay@cs.wisc.edu
30010447Snilay@cs.wisc.edu    # Refresh Current multiple voltage range
30110447Snilay@cs.wisc.edu    IDD52 = Param.Current("0mA", "Refresh current VDD2")
30210447Snilay@cs.wisc.edu
30310447Snilay@cs.wisc.edu    # Self-Refresh Current
30410447Snilay@cs.wisc.edu    IDD6 = Param.Current("0mA", "Self-refresh Current")
30510447Snilay@cs.wisc.edu
30610447Snilay@cs.wisc.edu    # Self-Refresh Current multiple voltage range
30710447Snilay@cs.wisc.edu    IDD62 = Param.Current("0mA", "Self-refresh Current VDD2")
30810447Snilay@cs.wisc.edu
30910447Snilay@cs.wisc.edu    # Main voltage range of the DRAM
31010447Snilay@cs.wisc.edu    VDD = Param.Voltage("0V", "Main Voltage Range")
31110447Snilay@cs.wisc.edu
31210447Snilay@cs.wisc.edu    # Second voltage range defined by some DRAMs
31310447Snilay@cs.wisc.edu    VDD2 = Param.Voltage("0V", "2nd Voltage Range")
31410447Snilay@cs.wisc.edu
31510447Snilay@cs.wisc.edu# A single DDR3-1600 x64 channel (one command and address bus), with
31610447Snilay@cs.wisc.edu# timings based on a DDR3-1600 4 Gbit datasheet (Micron MT41J512M8) in
31710447Snilay@cs.wisc.edu# an 8x8 configuration.
31810447Snilay@cs.wisc.educlass DDR3_1600_8x8(DRAMCtrl):
31910447Snilay@cs.wisc.edu    # size of device in bytes
32010447Snilay@cs.wisc.edu    device_size = '512MB'
32110447Snilay@cs.wisc.edu
32210447Snilay@cs.wisc.edu    # 8x8 configuration, 8 devices each with an 8-bit interface
32310447Snilay@cs.wisc.edu    device_bus_width = 8
32410447Snilay@cs.wisc.edu
32510447Snilay@cs.wisc.edu    # DDR3 is a BL8 device
32610447Snilay@cs.wisc.edu    burst_length = 8
32710447Snilay@cs.wisc.edu
32810447Snilay@cs.wisc.edu    # Each device has a page (row buffer) size of 1 Kbyte (1K columns x8)
32910447Snilay@cs.wisc.edu    device_rowbuffer_size = '1kB'
33010447Snilay@cs.wisc.edu
33110447Snilay@cs.wisc.edu    # 8x8 configuration, so 8 devices
33210447Snilay@cs.wisc.edu    devices_per_rank = 8
33310447Snilay@cs.wisc.edu
33410447Snilay@cs.wisc.edu    # Use two ranks
33510447Snilay@cs.wisc.edu    ranks_per_channel = 2
33610447Snilay@cs.wisc.edu
33710447Snilay@cs.wisc.edu    # DDR3 has 8 banks in all configurations
33810447Snilay@cs.wisc.edu    banks_per_rank = 8
33910447Snilay@cs.wisc.edu
34010447Snilay@cs.wisc.edu    # 800 MHz
34110447Snilay@cs.wisc.edu    tCK = '1.25ns'
34210447Snilay@cs.wisc.edu
34310447Snilay@cs.wisc.edu    # 8 beats across an x64 interface translates to 4 clocks @ 800 MHz
34410447Snilay@cs.wisc.edu    tBURST = '5ns'
34510447Snilay@cs.wisc.edu
34610447Snilay@cs.wisc.edu    # DDR3-1600 11-11-11
34710447Snilay@cs.wisc.edu    tRCD = '13.75ns'
34810447Snilay@cs.wisc.edu    tCL = '13.75ns'
34910447Snilay@cs.wisc.edu    tRP = '13.75ns'
35010447Snilay@cs.wisc.edu    tRAS = '35ns'
35110447Snilay@cs.wisc.edu    tRRD = '6ns'
35210447Snilay@cs.wisc.edu    tXAW = '30ns'
35310447Snilay@cs.wisc.edu    activation_limit = 4
35410447Snilay@cs.wisc.edu    tRFC = '260ns'
35510447Snilay@cs.wisc.edu
35610447Snilay@cs.wisc.edu    tWR = '15ns'
35710447Snilay@cs.wisc.edu
35810447Snilay@cs.wisc.edu    # Greater of 4 CK or 7.5 ns
35910447Snilay@cs.wisc.edu    tWTR = '7.5ns'
36010447Snilay@cs.wisc.edu
36110447Snilay@cs.wisc.edu    # Greater of 4 CK or 7.5 ns
36210447Snilay@cs.wisc.edu    tRTP = '7.5ns'
36310447Snilay@cs.wisc.edu
36410447Snilay@cs.wisc.edu    # Default same rank rd-to-wr bus turnaround to 2 CK, @800 MHz = 2.5 ns
36510447Snilay@cs.wisc.edu    tRTW = '2.5ns'
36610447Snilay@cs.wisc.edu
36710447Snilay@cs.wisc.edu    # Default different rank bus delay to 2 CK, @800 MHz = 2.5 ns
36810447Snilay@cs.wisc.edu    tCS = '2.5ns'
36910447Snilay@cs.wisc.edu
37010447Snilay@cs.wisc.edu    # <=85C, half for >85C
37110447Snilay@cs.wisc.edu    tREFI = '7.8us'
37210447Snilay@cs.wisc.edu
37310447Snilay@cs.wisc.edu    # active powerdown and precharge powerdown exit time
37410447Snilay@cs.wisc.edu    tXP = '6ns'
37510447Snilay@cs.wisc.edu
37610447Snilay@cs.wisc.edu    # self refresh exit time
37710447Snilay@cs.wisc.edu    tXS = '270ns'
37810447Snilay@cs.wisc.edu
37910447Snilay@cs.wisc.edu    # Current values from datasheet Die Rev E,J
38010447Snilay@cs.wisc.edu    IDD0 = '55mA'
381    IDD2N = '32mA'
382    IDD3N = '38mA'
383    IDD4W = '125mA'
384    IDD4R = '157mA'
385    IDD5 = '235mA'
386    IDD3P1 = '38mA'
387    IDD2P1 = '32mA'
388    IDD6 = '20mA'
389    VDD = '1.5V'
390
391# A single HMC-2500 x32 model based on:
392# [1] DRAMSpec: a high-level DRAM bank modelling tool
393# developed at the University of Kaiserslautern. This high level tool
394# uses RC (resistance-capacitance) and CV (capacitance-voltage) models to
395# estimate the DRAM bank latency and power numbers.
396# [2] High performance AXI-4.0 based interconnect for extensible smart memory
397# cubes (E. Azarkhish et. al)
398# Assumed for the HMC model is a 30 nm technology node.
399# The modelled HMC consists of 4 Gbit layers which sum up to 2GB of memory (4
400# layers).
401# Each layer has 16 vaults and each vault consists of 2 banks per layer.
402# In order to be able to use the same controller used for 2D DRAM generations
403# for HMC, the following analogy is done:
404# Channel (DDR) => Vault (HMC)
405# device_size (DDR) => size of a single layer in a vault
406# ranks per channel (DDR) => number of layers
407# banks per rank (DDR) => banks per layer
408# devices per rank (DDR) => devices per layer ( 1 for HMC).
409# The parameters for which no input is available are inherited from the DDR3
410# configuration.
411# This configuration includes the latencies from the DRAM to the logic layer
412# of the HMC
413class HMC_2500_1x32(DDR3_1600_8x8):
414    # size of device
415    # two banks per device with each bank 4MB [2]
416    device_size = '8MB'
417
418    # 1x32 configuration, 1 device with 32 TSVs [2]
419    device_bus_width = 32
420
421    # HMC is a BL8 device [2]
422    burst_length = 8
423
424    # Each device has a page (row buffer) size of 256 bytes [2]
425    device_rowbuffer_size = '256B'
426
427    # 1x32 configuration, so 1 device [2]
428    devices_per_rank = 1
429
430    # 4 layers so 4 ranks [2]
431    ranks_per_channel = 4
432
433    # HMC has 2 banks per layer [2]
434    # Each layer represents a rank. With 4 layers and 8 banks in total, each
435    # layer has 2 banks; thus 2 banks per rank.
436    banks_per_rank = 2
437
438    # 1250 MHz [2]
439    tCK = '0.8ns'
440
441    # 8 beats across an x32 interface translates to 4 clocks @ 1250 MHz
442    tBURST = '3.2ns'
443
444    # Values using DRAMSpec HMC model [1]
445    tRCD = '10.2ns'
446    tCL = '9.9ns'
447    tRP = '7.7ns'
448    tRAS = '21.6ns'
449
450    # tRRD depends on the power supply network for each vendor.
451    # We assume a tRRD of a double bank approach to be equal to 4 clock
452    # cycles (Assumption)
453    tRRD = '3.2ns'
454
455    # activation limit is set to 0 since there are only 2 banks per vault
456    # layer.
457    activation_limit = 0
458
459    # Values using DRAMSpec HMC model [1]
460    tRFC = '59ns'
461    tWR = '8ns'
462    tRTP = '4.9ns'
463
464    # Default different rank bus delay assumed to 1 CK for TSVs, @1250 MHz =
465    # 0.8 ns (Assumption)
466    tCS = '0.8ns'
467
468    # Value using DRAMSpec HMC model [1]
469    tREFI = '3.9us'
470
471    # The default page policy in the vault controllers is simple closed page
472    # [2] nevertheless 'close' policy opens and closes the row multiple times
473    # for bursts largers than 32Bytes. For this reason we use 'close_adaptive'
474    page_policy = 'close_adaptive'
475
476    # RoCoRaBaCh resembles the default address mapping in HMC
477    addr_mapping = 'RoCoRaBaCh'
478    min_writes_per_switch = 8
479
480    # These parameters do not directly correlate with buffer_size in real
481    # hardware. Nevertheless, their value has been tuned to achieve a
482    # bandwidth similar to the cycle-accurate model in [2]
483    write_buffer_size = 32
484    read_buffer_size = 32
485
486    # The static latency of the vault controllers is estimated to be smaller
487    # than a full DRAM channel controller
488    static_backend_latency='4ns'
489    static_frontend_latency='4ns'
490
491# A single DDR3-2133 x64 channel refining a selected subset of the
492# options for the DDR-1600 configuration, based on the same DDR3-1600
493# 4 Gbit datasheet (Micron MT41J512M8). Most parameters are kept
494# consistent across the two configurations.
495class DDR3_2133_8x8(DDR3_1600_8x8):
496    # 1066 MHz
497    tCK = '0.938ns'
498
499    # 8 beats across an x64 interface translates to 4 clocks @ 1066 MHz
500    tBURST = '3.752ns'
501
502    # DDR3-2133 14-14-14
503    tRCD = '13.09ns'
504    tCL = '13.09ns'
505    tRP = '13.09ns'
506    tRAS = '33ns'
507    tRRD = '5ns'
508    tXAW = '25ns'
509
510    # Current values from datasheet
511    IDD0 = '70mA'
512    IDD2N = '37mA'
513    IDD3N = '44mA'
514    IDD4W = '157mA'
515    IDD4R = '191mA'
516    IDD5 = '250mA'
517    IDD3P1 = '44mA'
518    IDD2P1 = '43mA'
519    IDD6 ='20mA'
520    VDD = '1.5V'
521
522# A single DDR4-2400 x64 channel (one command and address bus), with
523# timings based on a DDR4-2400 8 Gbit datasheet (Micron MT40A2G4)
524# in an 16x4 configuration.
525# Total channel capacity is 32GB
526# 16 devices/rank * 2 ranks/channel * 1GB/device = 32GB/channel
527class DDR4_2400_16x4(DRAMCtrl):
528    # size of device
529    device_size = '1GB'
530
531    # 16x4 configuration, 16 devices each with a 4-bit interface
532    device_bus_width = 4
533
534    # DDR4 is a BL8 device
535    burst_length = 8
536
537    # Each device has a page (row buffer) size of 512 byte (1K columns x4)
538    device_rowbuffer_size = '512B'
539
540    # 16x4 configuration, so 16 devices
541    devices_per_rank = 16
542
543    # Match our DDR3 configurations which is dual rank
544    ranks_per_channel = 2
545
546    # DDR4 has 2 (x16) or 4 (x4 and x8) bank groups
547    # Set to 4 for x4 case
548    bank_groups_per_rank = 4
549
550    # DDR4 has 16 banks(x4,x8) and 8 banks(x16) (4 bank groups in all
551    # configurations). Currently we do not capture the additional
552    # constraints incurred by the bank groups
553    banks_per_rank = 16
554
555    # override the default buffer sizes and go for something larger to
556    # accommodate the larger bank count
557    write_buffer_size = 128
558    read_buffer_size = 64
559
560    # 1200 MHz
561    tCK = '0.833ns'
562
563    # 8 beats across an x64 interface translates to 4 clocks @ 1200 MHz
564    # tBURST is equivalent to the CAS-to-CAS delay (tCCD)
565    # With bank group architectures, tBURST represents the CAS-to-CAS
566    # delay for bursts to different bank groups (tCCD_S)
567    tBURST = '3.332ns'
568
569    # @2400 data rate, tCCD_L is 6 CK
570    # CAS-to-CAS delay for bursts to the same bank group
571    # tBURST is equivalent to tCCD_S; no explicit parameter required
572    # for CAS-to-CAS delay for bursts to different bank groups
573    tCCD_L = '5ns';
574
575    # DDR4-2400 17-17-17
576    tRCD = '14.16ns'
577    tCL = '14.16ns'
578    tRP = '14.16ns'
579    tRAS = '32ns'
580
581    # RRD_S (different bank group) for 512B page is MAX(4 CK, 3.3ns)
582    tRRD = '3.332ns'
583
584    # RRD_L (same bank group) for 512B page is MAX(4 CK, 4.9ns)
585    tRRD_L = '4.9ns';
586
587    # tFAW for 512B page is MAX(16 CK, 13ns)
588    tXAW = '13.328ns'
589    activation_limit = 4
590    # tRFC is 350ns
591    tRFC = '350ns'
592
593    tWR = '15ns'
594
595    # Here using the average of WTR_S and WTR_L
596    tWTR = '5ns'
597
598    # Greater of 4 CK or 7.5 ns
599    tRTP = '7.5ns'
600
601    # Default same rank rd-to-wr bus turnaround to 2 CK, @1200 MHz = 1.666 ns
602    tRTW = '1.666ns'
603
604    # Default different rank bus delay to 2 CK, @1200 MHz = 1.666 ns
605    tCS = '1.666ns'
606
607    # <=85C, half for >85C
608    tREFI = '7.8us'
609
610    # active powerdown and precharge powerdown exit time
611    tXP = '6ns'
612
613    # self refresh exit time
614    # exit delay to ACT, PRE, PREALL, REF, SREF Enter, and PD Enter is:
615    # tRFC + 10ns = 340ns
616    tXS = '340ns'
617
618    # Current values from datasheet
619    IDD0 = '43mA'
620    IDD02 = '3mA'
621    IDD2N = '34mA'
622    IDD3N = '38mA'
623    IDD3N2 = '3mA'
624    IDD4W = '103mA'
625    IDD4R = '110mA'
626    IDD5 = '250mA'
627    IDD3P1 = '32mA'
628    IDD2P1 = '25mA'
629    IDD6 = '30mA'
630    VDD = '1.2V'
631    VDD2 = '2.5V'
632
633# A single DDR4-2400 x64 channel (one command and address bus), with
634# timings based on a DDR4-2400 8 Gbit datasheet (Micron MT40A1G8)
635# in an 8x8 configuration.
636# Total channel capacity is 16GB
637# 8 devices/rank * 2 ranks/channel * 1GB/device = 16GB/channel
638class DDR4_2400_8x8(DDR4_2400_16x4):
639    # 8x8 configuration, 8 devices each with an 8-bit interface
640    device_bus_width = 8
641
642    # Each device has a page (row buffer) size of 1 Kbyte (1K columns x8)
643    device_rowbuffer_size = '1kB'
644
645    # 8x8 configuration, so 8 devices
646    devices_per_rank = 8
647
648    # RRD_L (same bank group) for 1K page is MAX(4 CK, 4.9ns)
649    tRRD_L = '4.9ns';
650
651    tXAW = '21ns'
652
653    # Current values from datasheet
654    IDD0 = '48mA'
655    IDD3N = '43mA'
656    IDD4W = '123mA'
657    IDD4R = '135mA'
658    IDD3P1 = '37mA'
659
660# A single DDR4-2400 x64 channel (one command and address bus), with
661# timings based on a DDR4-2400 8 Gbit datasheet (Micron MT40A512M16)
662# in an 4x16 configuration.
663# Total channel capacity is 4GB
664# 4 devices/rank * 1 ranks/channel * 1GB/device = 4GB/channel
665class DDR4_2400_4x16(DDR4_2400_16x4):
666    # 4x16 configuration, 4 devices each with an 16-bit interface
667    device_bus_width = 16
668
669    # Each device has a page (row buffer) size of 2 Kbyte (1K columns x16)
670    device_rowbuffer_size = '2kB'
671
672    # 4x16 configuration, so 4 devices
673    devices_per_rank = 4
674
675    # Single rank for x16
676    ranks_per_channel = 1
677
678    # DDR4 has 2 (x16) or 4 (x4 and x8) bank groups
679    # Set to 2 for x16 case
680    bank_groups_per_rank = 2
681
682    # DDR4 has 16 banks(x4,x8) and 8 banks(x16) (4 bank groups in all
683    # configurations). Currently we do not capture the additional
684    # constraints incurred by the bank groups
685    banks_per_rank = 8
686
687    # RRD_S (different bank group) for 2K page is MAX(4 CK, 5.3ns)
688    tRRD = '5.3ns'
689
690    # RRD_L (same bank group) for 2K page is MAX(4 CK, 6.4ns)
691    tRRD_L = '6.4ns';
692
693    tXAW = '30ns'
694
695    # Current values from datasheet
696    IDD0 = '80mA'
697    IDD02 = '4mA'
698    IDD2N = '34mA'
699    IDD3N = '47mA'
700    IDD4W = '228mA'
701    IDD4R = '243mA'
702    IDD5 = '280mA'
703    IDD3P1 = '41mA'
704
705# A single LPDDR2-S4 x32 interface (one command/address bus), with
706# default timings based on a LPDDR2-1066 4 Gbit part (Micron MT42L128M32D1)
707# in a 1x32 configuration.
708class LPDDR2_S4_1066_1x32(DRAMCtrl):
709    # No DLL in LPDDR2
710    dll = False
711
712    # size of device
713    device_size = '512MB'
714
715    # 1x32 configuration, 1 device with a 32-bit interface
716    device_bus_width = 32
717
718    # LPDDR2_S4 is a BL4 and BL8 device
719    burst_length = 8
720
721    # Each device has a page (row buffer) size of 1KB
722    # (this depends on the memory density)
723    device_rowbuffer_size = '1kB'
724
725    # 1x32 configuration, so 1 device
726    devices_per_rank = 1
727
728    # Use a single rank
729    ranks_per_channel = 1
730
731    # LPDDR2-S4 has 8 banks in all configurations
732    banks_per_rank = 8
733
734    # 533 MHz
735    tCK = '1.876ns'
736
737    # Fixed at 15 ns
738    tRCD = '15ns'
739
740    # 8 CK read latency, 4 CK write latency @ 533 MHz, 1.876 ns cycle time
741    tCL = '15ns'
742
743    # Pre-charge one bank 15 ns (all banks 18 ns)
744    tRP = '15ns'
745
746    tRAS = '42ns'
747    tWR = '15ns'
748
749    tRTP = '7.5ns'
750
751    # 8 beats across an x32 DDR interface translates to 4 clocks @ 533 MHz.
752    # Note this is a BL8 DDR device.
753    # Requests larger than 32 bytes are broken down into multiple requests
754    # in the controller
755    tBURST = '7.5ns'
756
757    # LPDDR2-S4, 4 Gbit
758    tRFC = '130ns'
759    tREFI = '3.9us'
760
761    # active powerdown and precharge powerdown exit time
762    tXP = '7.5ns'
763
764    # self refresh exit time
765    tXS = '140ns'
766
767    # Irrespective of speed grade, tWTR is 7.5 ns
768    tWTR = '7.5ns'
769
770    # Default same rank rd-to-wr bus turnaround to 2 CK, @533 MHz = 3.75 ns
771    tRTW = '3.75ns'
772
773    # Default different rank bus delay to 2 CK, @533 MHz = 3.75 ns
774    tCS = '3.75ns'
775
776    # Activate to activate irrespective of density and speed grade
777    tRRD = '10.0ns'
778
779    # Irrespective of density, tFAW is 50 ns
780    tXAW = '50ns'
781    activation_limit = 4
782
783    # Current values from datasheet
784    IDD0 = '15mA'
785    IDD02 = '70mA'
786    IDD2N = '2mA'
787    IDD2N2 = '30mA'
788    IDD3N = '2.5mA'
789    IDD3N2 = '30mA'
790    IDD4W = '10mA'
791    IDD4W2 = '190mA'
792    IDD4R = '3mA'
793    IDD4R2 = '220mA'
794    IDD5 = '40mA'
795    IDD52 = '150mA'
796    IDD3P1 = '1.2mA'
797    IDD3P12 = '8mA'
798    IDD2P1 = '0.6mA'
799    IDD2P12 = '0.8mA'
800    IDD6 = '1mA'
801    IDD62 = '3.2mA'
802    VDD = '1.8V'
803    VDD2 = '1.2V'
804
805# A single WideIO x128 interface (one command and address bus), with
806# default timings based on an estimated WIO-200 8 Gbit part.
807class WideIO_200_1x128(DRAMCtrl):
808    # No DLL for WideIO
809    dll = False
810
811    # size of device
812    device_size = '1024MB'
813
814    # 1x128 configuration, 1 device with a 128-bit interface
815    device_bus_width = 128
816
817    # This is a BL4 device
818    burst_length = 4
819
820    # Each device has a page (row buffer) size of 4KB
821    # (this depends on the memory density)
822    device_rowbuffer_size = '4kB'
823
824    # 1x128 configuration, so 1 device
825    devices_per_rank = 1
826
827    # Use one rank for a one-high die stack
828    ranks_per_channel = 1
829
830    # WideIO has 4 banks in all configurations
831    banks_per_rank = 4
832
833    # 200 MHz
834    tCK = '5ns'
835
836    # WIO-200
837    tRCD = '18ns'
838    tCL = '18ns'
839    tRP = '18ns'
840    tRAS = '42ns'
841    tWR = '15ns'
842    # Read to precharge is same as the burst
843    tRTP = '20ns'
844
845    # 4 beats across an x128 SDR interface translates to 4 clocks @ 200 MHz.
846    # Note this is a BL4 SDR device.
847    tBURST = '20ns'
848
849    # WIO 8 Gb
850    tRFC = '210ns'
851
852    # WIO 8 Gb, <=85C, half for >85C
853    tREFI = '3.9us'
854
855    # Greater of 2 CK or 15 ns, 2 CK @ 200 MHz = 10 ns
856    tWTR = '15ns'
857
858    # Default same rank rd-to-wr bus turnaround to 2 CK, @200 MHz = 10 ns
859    tRTW = '10ns'
860
861    # Default different rank bus delay to 2 CK, @200 MHz = 10 ns
862    tCS = '10ns'
863
864    # Activate to activate irrespective of density and speed grade
865    tRRD = '10.0ns'
866
867    # Two instead of four activation window
868    tXAW = '50ns'
869    activation_limit = 2
870
871    # The WideIO specification does not provide current information
872
873# A single LPDDR3 x32 interface (one command/address bus), with
874# default timings based on a LPDDR3-1600 4 Gbit part (Micron
875# EDF8132A1MC) in a 1x32 configuration.
876class LPDDR3_1600_1x32(DRAMCtrl):
877    # No DLL for LPDDR3
878    dll = False
879
880    # size of device
881    device_size = '512MB'
882
883    # 1x32 configuration, 1 device with a 32-bit interface
884    device_bus_width = 32
885
886    # LPDDR3 is a BL8 device
887    burst_length = 8
888
889    # Each device has a page (row buffer) size of 4KB
890    device_rowbuffer_size = '4kB'
891
892    # 1x32 configuration, so 1 device
893    devices_per_rank = 1
894
895    # Technically the datasheet is a dual-rank package, but for
896    # comparison with the LPDDR2 config we stick to a single rank
897    ranks_per_channel = 1
898
899    # LPDDR3 has 8 banks in all configurations
900    banks_per_rank = 8
901
902    # 800 MHz
903    tCK = '1.25ns'
904
905    tRCD = '18ns'
906
907    # 12 CK read latency, 6 CK write latency @ 800 MHz, 1.25 ns cycle time
908    tCL = '15ns'
909
910    tRAS = '42ns'
911    tWR = '15ns'
912
913    # Greater of 4 CK or 7.5 ns, 4 CK @ 800 MHz = 5 ns
914    tRTP = '7.5ns'
915
916    # Pre-charge one bank 18 ns (all banks 21 ns)
917    tRP = '18ns'
918
919    # 8 beats across a x32 DDR interface translates to 4 clocks @ 800 MHz.
920    # Note this is a BL8 DDR device.
921    # Requests larger than 32 bytes are broken down into multiple requests
922    # in the controller
923    tBURST = '5ns'
924
925    # LPDDR3, 4 Gb
926    tRFC = '130ns'
927    tREFI = '3.9us'
928
929    # active powerdown and precharge powerdown exit time
930    tXP = '7.5ns'
931
932    # self refresh exit time
933    tXS = '140ns'
934
935    # Irrespective of speed grade, tWTR is 7.5 ns
936    tWTR = '7.5ns'
937
938    # Default same rank rd-to-wr bus turnaround to 2 CK, @800 MHz = 2.5 ns
939    tRTW = '2.5ns'
940
941    # Default different rank bus delay to 2 CK, @800 MHz = 2.5 ns
942    tCS = '2.5ns'
943
944    # Activate to activate irrespective of density and speed grade
945    tRRD = '10.0ns'
946
947    # Irrespective of size, tFAW is 50 ns
948    tXAW = '50ns'
949    activation_limit = 4
950
951    # Current values from datasheet
952    IDD0 = '8mA'
953    IDD02 = '60mA'
954    IDD2N = '0.8mA'
955    IDD2N2 = '26mA'
956    IDD3N = '2mA'
957    IDD3N2 = '34mA'
958    IDD4W = '2mA'
959    IDD4W2 = '190mA'
960    IDD4R = '2mA'
961    IDD4R2 = '230mA'
962    IDD5 = '28mA'
963    IDD52 = '150mA'
964    IDD3P1 = '1.4mA'
965    IDD3P12 = '11mA'
966    IDD2P1 = '0.8mA'
967    IDD2P12 = '1.8mA'
968    IDD6 = '0.5mA'
969    IDD62 = '1.8mA'
970    VDD = '1.8V'
971    VDD2 = '1.2V'
972
973# A single GDDR5 x64 interface, with
974# default timings based on a GDDR5-4000 1 Gbit part (SK Hynix
975# H5GQ1H24AFR) in a 2x32 configuration.
976class GDDR5_4000_2x32(DRAMCtrl):
977    # size of device
978    device_size = '128MB'
979
980    # 2x32 configuration, 1 device with a 32-bit interface
981    device_bus_width = 32
982
983    # GDDR5 is a BL8 device
984    burst_length = 8
985
986    # Each device has a page (row buffer) size of 2Kbits (256Bytes)
987    device_rowbuffer_size = '256B'
988
989    # 2x32 configuration, so 2 devices
990    devices_per_rank = 2
991
992    # assume single rank
993    ranks_per_channel = 1
994
995    # GDDR5 has 4 bank groups
996    bank_groups_per_rank = 4
997
998    # GDDR5 has 16 banks with 4 bank groups
999    banks_per_rank = 16
1000
1001    # 1000 MHz
1002    tCK = '1ns'
1003
1004    # 8 beats across an x64 interface translates to 2 clocks @ 1000 MHz
1005    # Data bus runs @2000 Mhz => DDR ( data runs at 4000 MHz )
1006    # 8 beats at 4000 MHz = 2 beats at 1000 MHz
1007    # tBURST is equivalent to the CAS-to-CAS delay (tCCD)
1008    # With bank group architectures, tBURST represents the CAS-to-CAS
1009    # delay for bursts to different bank groups (tCCD_S)
1010    tBURST = '2ns'
1011
1012    # @1000MHz data rate, tCCD_L is 3 CK
1013    # CAS-to-CAS delay for bursts to the same bank group
1014    # tBURST is equivalent to tCCD_S; no explicit parameter required
1015    # for CAS-to-CAS delay for bursts to different bank groups
1016    tCCD_L = '3ns';
1017
1018    tRCD = '12ns'
1019
1020    # tCL is not directly found in datasheet and assumed equal tRCD
1021    tCL = '12ns'
1022
1023    tRP = '12ns'
1024    tRAS = '28ns'
1025
1026    # RRD_S (different bank group)
1027    # RRD_S is 5.5 ns in datasheet.
1028    # rounded to the next multiple of tCK
1029    tRRD = '6ns'
1030
1031    # RRD_L (same bank group)
1032    # RRD_L is 5.5 ns in datasheet.
1033    # rounded to the next multiple of tCK
1034    tRRD_L = '6ns'
1035
1036    tXAW = '23ns'
1037
1038    # tXAW < 4 x tRRD.
1039    # Therefore, activation limit is set to 0
1040    activation_limit = 0
1041
1042    tRFC = '65ns'
1043    tWR = '12ns'
1044
1045    # Here using the average of WTR_S and WTR_L
1046    tWTR = '5ns'
1047
1048    # Read-to-Precharge 2 CK
1049    tRTP = '2ns'
1050
1051    # Assume 2 cycles
1052    tRTW = '2ns'
1053
1054# A single HBM x128 interface (one command and address bus), with
1055# default timings based on data publically released
1056# ("HBM: Memory Solution for High Performance Processors", MemCon, 2014),
1057# IDD measurement values, and by extrapolating data from other classes.
1058# Architecture values based on published HBM spec
1059# A 4H stack is defined, 2Gb per die for a total of 1GB of memory.
1060class HBM_1000_4H_1x128(DRAMCtrl):
1061    # HBM gen1 supports up to 8 128-bit physical channels
1062    # Configuration defines a single channel, with the capacity
1063    # set to (full_ stack_capacity / 8) based on 2Gb dies
1064    # To use all 8 channels, set 'channels' parameter to 8 in
1065    # system configuration
1066
1067    # 128-bit interface legacy mode
1068    device_bus_width = 128
1069
1070    # HBM supports BL4 and BL2 (legacy mode only)
1071    burst_length = 4
1072
1073    # size of channel in bytes, 4H stack of 2Gb dies is 1GB per stack;
1074    # with 8 channels, 128MB per channel
1075    device_size = '128MB'
1076
1077    device_rowbuffer_size = '2kB'
1078
1079    # 1x128 configuration
1080    devices_per_rank = 1
1081
1082    # HBM does not have a CS pin; set rank to 1
1083    ranks_per_channel = 1
1084
1085    # HBM has 8 or 16 banks depending on capacity
1086    # 2Gb dies have 8 banks
1087    banks_per_rank = 8
1088
1089    # depending on frequency, bank groups may be required
1090    # will always have 4 bank groups when enabled
1091    # current specifications do not define the minimum frequency for
1092    # bank group architecture
1093    # setting bank_groups_per_rank to 0 to disable until range is defined
1094    bank_groups_per_rank = 0
1095
1096    # 500 MHz for 1Gbps DDR data rate
1097    tCK = '2ns'
1098
1099    # use values from IDD measurement in JEDEC spec
1100    # use tRP value for tRCD and tCL similar to other classes
1101    tRP = '15ns'
1102    tRCD = '15ns'
1103    tCL = '15ns'
1104    tRAS = '33ns'
1105
1106    # BL2 and BL4 supported, default to BL4
1107    # DDR @ 500 MHz means 4 * 2ns / 2 = 4ns
1108    tBURST = '4ns'
1109
1110    # value for 2Gb device from JEDEC spec
1111    tRFC = '160ns'
1112
1113    # value for 2Gb device from JEDEC spec
1114    tREFI = '3.9us'
1115
1116    # extrapolate the following from LPDDR configs, using ns values
1117    # to minimize burst length, prefetch differences
1118    tWR = '18ns'
1119    tRTP = '7.5ns'
1120    tWTR = '10ns'
1121
1122    # start with 2 cycles turnaround, similar to other memory classes
1123    # could be more with variations across the stack
1124    tRTW = '4ns'
1125
1126    # single rank device, set to 0
1127    tCS = '0ns'
1128
1129    # from MemCon example, tRRD is 4ns with 2ns tCK
1130    tRRD = '4ns'
1131
1132    # from MemCon example, tFAW is 30ns with 2ns tCK
1133    tXAW = '30ns'
1134    activation_limit = 4
1135
1136    # 4tCK
1137    tXP = '8ns'
1138
1139    # start with tRFC + tXP -> 160ns + 8ns = 168ns
1140    tXS = '168ns'
1141
1142# A single HBM x64 interface (one command and address bus), with
1143# default timings based on HBM gen1 and data publically released
1144# A 4H stack is defined, 8Gb per die for a total of 4GB of memory.
1145# Note: This defines a pseudo-channel with a unique controller
1146# instantiated per pseudo-channel
1147# Stay at same IO rate (1Gbps) to maintain timing relationship with
1148# HBM gen1 class (HBM_1000_4H_x128) where possible
1149class HBM_1000_4H_1x64(HBM_1000_4H_1x128):
1150    # For HBM gen2 with pseudo-channel mode, configure 2X channels.
1151    # Configuration defines a single pseudo channel, with the capacity
1152    # set to (full_ stack_capacity / 16) based on 8Gb dies
1153    # To use all 16 pseudo channels, set 'channels' parameter to 16 in
1154    # system configuration
1155
1156    # 64-bit pseudo-channle interface
1157    device_bus_width = 64
1158
1159    # HBM pseudo-channel only supports BL4
1160    burst_length = 4
1161
1162    # size of channel in bytes, 4H stack of 8Gb dies is 4GB per stack;
1163    # with 16 channels, 256MB per channel
1164    device_size = '256MB'
1165
1166    # page size is halved with pseudo-channel; maintaining the same same number
1167    # of rows per pseudo-channel with 2X banks across 2 channels
1168    device_rowbuffer_size = '1kB'
1169
1170    # HBM has 8 or 16 banks depending on capacity
1171    # Starting with 4Gb dies, 16 banks are defined
1172    banks_per_rank = 16
1173
1174    # reset tRFC for larger, 8Gb device
1175    # use HBM1 4Gb value as a starting point
1176    tRFC = '260ns'
1177
1178    # start with tRFC + tXP -> 160ns + 8ns = 168ns
1179    tXS = '268ns'
1180    # Default different rank bus delay to 2 CK, @1000 MHz = 2 ns
1181    tCS = '2ns'
1182    tREFI = '3.9us'
1183
1184    # active powerdown and precharge powerdown exit time
1185    tXP = '10ns'
1186
1187    # self refresh exit time
1188    tXS = '65ns'
1189