DRAMCtrl.py revision 10217:baf8754fd5be
1# Copyright (c) 2012-2014 ARM Limited 2# All rights reserved. 3# 4# The license below extends only to copyright in the software and shall 5# not be construed as granting a license to any other intellectual 6# property including but not limited to intellectual property relating 7# to a hardware implementation of the functionality of the software 8# licensed hereunder. You may use the software subject to the license 9# terms below provided that you ensure that this notice is replicated 10# unmodified and in its entirety in all distributions of the software, 11# modified or unmodified, in source code or in binary form. 12# 13# Copyright (c) 2013 Amin Farmahini-Farahani 14# All rights reserved. 15# 16# Redistribution and use in source and binary forms, with or without 17# modification, are permitted provided that the following conditions are 18# met: redistributions of source code must retain the above copyright 19# notice, this list of conditions and the following disclaimer; 20# redistributions in binary form must reproduce the above copyright 21# notice, this list of conditions and the following disclaimer in the 22# documentation and/or other materials provided with the distribution; 23# neither the name of the copyright holders nor the names of its 24# contributors may be used to endorse or promote products derived from 25# this software without specific prior written permission. 26# 27# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 30# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 31# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 32# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 33# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 34# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 35# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 36# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 37# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38# 39# Authors: Andreas Hansson 40# Ani Udipi 41 42from m5.params import * 43from AbstractMemory import * 44 45# Enum for memory scheduling algorithms, currently First-Come 46# First-Served and a First-Row Hit then First-Come First-Served 47class MemSched(Enum): vals = ['fcfs', 'frfcfs'] 48 49# Enum for the address mapping. With Ch, Ra, Ba, Ro and Co denoting 50# channel, rank, bank, row and column, respectively, and going from 51# MSB to LSB. Available are RoRaBaChCo and RoRaBaCoCh, that are 52# suitable for an open-page policy, optimising for sequential accesses 53# hitting in the open row. For a closed-page policy, RoCoRaBaCh 54# maximises parallelism. 55class AddrMap(Enum): vals = ['RoRaBaChCo', 'RoRaBaCoCh', 'RoCoRaBaCh'] 56 57# Enum for the page policy, either open, open_adaptive, close, or 58# close_adaptive. 59class PageManage(Enum): vals = ['open', 'open_adaptive', 'close', 60 'close_adaptive'] 61 62# DRAMCtrl is a single-channel single-ported DRAM controller model 63# that aims to model the most important system-level performance 64# effects of a DRAM without getting into too much detail of the DRAM 65# itself. 66class DRAMCtrl(AbstractMemory): 67 type = 'DRAMCtrl' 68 cxx_header = "mem/dram_ctrl.hh" 69 70 # single-ported on the system interface side, instantiate with a 71 # bus in front of the controller for multiple ports 72 port = SlavePort("Slave port") 73 74 # the basic configuration of the controller architecture 75 write_buffer_size = Param.Unsigned(64, "Number of write queue entries") 76 read_buffer_size = Param.Unsigned(32, "Number of read queue entries") 77 78 # threshold in percent for when to forcefully trigger writes and 79 # start emptying the write buffer 80 write_high_thresh_perc = Param.Percent(85, "Threshold to force writes") 81 82 # threshold in percentage for when to start writes if the read 83 # queue is empty 84 write_low_thresh_perc = Param.Percent(50, "Threshold to start writes") 85 86 # minimum write bursts to schedule before switching back to reads 87 min_writes_per_switch = Param.Unsigned(16, "Minimum write bursts before " 88 "switching to reads") 89 90 # scheduler, address map and page policy 91 mem_sched_policy = Param.MemSched('frfcfs', "Memory scheduling policy") 92 addr_mapping = Param.AddrMap('RoRaBaChCo', "Address mapping policy") 93 page_policy = Param.PageManage('open_adaptive', "Page management policy") 94 95 # enforce a limit on the number of accesses per row 96 max_accesses_per_row = Param.Unsigned(16, "Max accesses per row before " 97 "closing"); 98 99 # pipeline latency of the controller and PHY, split into a 100 # frontend part and a backend part, with reads and writes serviced 101 # by the queues only seeing the frontend contribution, and reads 102 # serviced by the memory seeing the sum of the two 103 static_frontend_latency = Param.Latency("10ns", "Static frontend latency") 104 static_backend_latency = Param.Latency("10ns", "Static backend latency") 105 106 # the physical organisation of the DRAM 107 device_bus_width = Param.Unsigned("data bus width in bits for each DRAM "\ 108 "device/chip") 109 burst_length = Param.Unsigned("Burst lenght (BL) in beats") 110 device_rowbuffer_size = Param.MemorySize("Page (row buffer) size per "\ 111 "device/chip") 112 devices_per_rank = Param.Unsigned("Number of devices/chips per rank") 113 ranks_per_channel = Param.Unsigned("Number of ranks per channel") 114 banks_per_rank = Param.Unsigned("Number of banks per rank") 115 # only used for the address mapping as the controller by 116 # construction is a single channel and multiple controllers have 117 # to be instantiated for a multi-channel configuration 118 channels = Param.Unsigned(1, "Number of channels") 119 120 # timing behaviour and constraints - all in nanoseconds 121 122 # the base clock period of the DRAM 123 tCK = Param.Latency("Clock period") 124 125 # the amount of time in nanoseconds from issuing an activate command 126 # to the data being available in the row buffer for a read/write 127 tRCD = Param.Latency("RAS to CAS delay") 128 129 # the time from issuing a read/write command to seeing the actual data 130 tCL = Param.Latency("CAS latency") 131 132 # minimum time between a precharge and subsequent activate 133 tRP = Param.Latency("Row precharge time") 134 135 # minimum time between an activate and a precharge to the same row 136 tRAS = Param.Latency("ACT to PRE delay") 137 138 # minimum time between a write data transfer and a precharge 139 tWR = Param.Latency("Write recovery time") 140 141 # minimum time between a read and precharge command 142 tRTP = Param.Latency("Read to precharge") 143 144 # time to complete a burst transfer, typically the burst length 145 # divided by two due to the DDR bus, but by making it a parameter 146 # it is easier to also evaluate SDR memories like WideIO. 147 # This parameter has to account for burst length. 148 # Read/Write requests with data size larger than one full burst are broken 149 # down into multiple requests in the controller 150 tBURST = Param.Latency("Burst duration (for DDR burst length / 2 cycles)") 151 152 # time taken to complete one refresh cycle (N rows in all banks) 153 tRFC = Param.Latency("Refresh cycle time") 154 155 # refresh command interval, how often a "ref" command needs 156 # to be sent. It is 7.8 us for a 64ms refresh requirement 157 tREFI = Param.Latency("Refresh command interval") 158 159 # write-to-read turn around penalty 160 tWTR = Param.Latency("Write to read switching time") 161 162 # read-to-write turn around penalty, bus turnaround delay 163 tRTW = Param.Latency("Read to write switching time") 164 165 # minimum row activate to row activate delay time 166 tRRD = Param.Latency("ACT to ACT delay") 167 168 # time window in which a maximum number of activates are allowed 169 # to take place, set to 0 to disable 170 tXAW = Param.Latency("X activation window") 171 activation_limit = Param.Unsigned("Max number of activates in window") 172 173 # Currently rolled into other params 174 ###################################################################### 175 176 # tRC - assumed to be tRAS + tRP 177 178# A single DDR3-1600 x64 channel (one command and address bus), with 179# timings based on a DDR3-1600 4 Gbit datasheet (Micron MT41J512M8) in 180# an 8x8 configuration, amounting to 4 Gbyte of memory. 181class DDR3_1600_x64(DRAMCtrl): 182 # 8x8 configuration, 8 devices each with an 8-bit interface 183 device_bus_width = 8 184 185 # DDR3 is a BL8 device 186 burst_length = 8 187 188 # Each device has a page (row buffer) size of 1 Kbyte (1K columns x8) 189 device_rowbuffer_size = '1kB' 190 191 # 8x8 configuration, so 8 devices 192 devices_per_rank = 8 193 194 # Use two ranks 195 ranks_per_channel = 2 196 197 # DDR3 has 8 banks in all configurations 198 banks_per_rank = 8 199 200 # 800 MHz 201 tCK = '1.25ns' 202 203 # 8 beats across an x64 interface translates to 4 clocks @ 800 MHz 204 tBURST = '5ns' 205 206 # DDR3-1600 11-11-11 207 tRCD = '13.75ns' 208 tCL = '13.75ns' 209 tRP = '13.75ns' 210 tRAS = '35ns' 211 tRRD = '6ns' 212 tXAW = '30ns' 213 activation_limit = 4 214 tRFC = '260ns' 215 216 tWR = '15ns' 217 218 # Greater of 4 CK or 7.5 ns 219 tWTR = '7.5ns' 220 221 # Greater of 4 CK or 7.5 ns 222 tRTP = '7.5ns' 223 224 # Default read-to-write bus around to 2 CK, @800 MHz = 2.5 ns 225 tRTW = '2.5ns' 226 227 # <=85C, half for >85C 228 tREFI = '7.8us' 229 230# A single DDR3-2133 x64 channel refining a selected subset of the 231# options for the DDR-1600 configuration, based on the same DDR3-1600 232# 4 Gbit datasheet (Micron MT41J512M8). Most parameters are kept 233# consistent across the two configurations. 234class DDR3_2133_x64(DDR3_1600_x64): 235 # 1066 MHz 236 tCK = '0.938ns' 237 238 # 8 beats across an x64 interface translates to 4 clocks @ 1066 MHz 239 tBURST = '3.752ns' 240 241 # DDR3-2133 14-14-14 242 tRCD = '13.09ns' 243 tCL = '13.09ns' 244 tRP = '13.09ns' 245 tRAS = '33ns' 246 tRRD = '5ns' 247 tXAW = '25ns' 248 249# A single DDR4-2400 x64 channel (one command and address bus), with 250# timings based on a DDR4-2400 4 Gbit datasheet (Samsung K4A4G085WD) 251# in an 8x8 configuration, amounting to 4 Gbyte of memory. 252class DDR4_2400_x64(DRAMCtrl): 253 # 8x8 configuration, 8 devices each with an 8-bit interface 254 device_bus_width = 8 255 256 # DDR4 is a BL8 device 257 burst_length = 8 258 259 # Each device has a page (row buffer) size of 1 Kbyte (1K columns x8) 260 device_rowbuffer_size = '1kB' 261 262 # 8x8 configuration, so 8 devices 263 devices_per_rank = 8 264 265 # Use a single rank 266 ranks_per_channel = 1 267 268 # DDR4 has 16 banks (4 bank groups) in all 269 # configurations. Currently we do not capture the additional 270 # constraints incurred by the bank groups 271 banks_per_rank = 16 272 273 # 1200 MHz 274 tCK = '0.833ns' 275 276 # 8 beats across an x64 interface translates to 4 clocks @ 1200 MHz 277 tBURST = '3.333ns' 278 279 # DDR4-2400 17-17-17 280 tRCD = '14.16ns' 281 tCL = '14.16ns' 282 tRP = '14.16ns' 283 tRAS = '32ns' 284 285 # Here using the average of RRD_S and RRD_L 286 tRRD = '4.1ns' 287 tXAW = '21ns' 288 activation_limit = 4 289 tRFC = '260ns' 290 291 tWR = '15ns' 292 293 # Here using the average of WTR_S and WTR_L 294 tWTR = '5ns' 295 296 # Greater of 4 CK or 7.5 ns 297 tRTP = '7.5ns' 298 299 # Default read-to-write bus around to 2 CK, @1200 MHz = 1.666 ns 300 tRTW = '1.666ns' 301 302 # <=85C, half for >85C 303 tREFI = '7.8us' 304 305# A single DDR3 x64 interface (one command and address bus), with 306# default timings based on DDR3-1333 4 Gbit parts in an 8x8 307# configuration, which would amount to 4 GByte of memory. This 308# configuration is primarily for comparing with DRAMSim2, and all the 309# parameters except ranks_per_channel are based on the DRAMSim2 config 310# file DDR3_micron_32M_8B_x8_sg15.ini. Note that ranks_per_channel has 311# to be manually set, depending on size of the memory to be 312# simulated. By default DRAMSim2 has 2048MB of memory with a single 313# rank. Therefore for 4 GByte memory, set ranks_per_channel = 2 314class DDR3_1333_x64_DRAMSim2(DRAMCtrl): 315 # 8x8 configuration, 8 devices each with an 8-bit interface 316 device_bus_width = 8 317 318 # DDR3 is a BL8 device 319 burst_length = 8 320 321 # Each device has a page (row buffer) size of 1KB 322 # (this depends on the memory density) 323 device_rowbuffer_size = '1kB' 324 325 # 8x8 configuration, so 8 devices 326 devices_per_rank = 8 327 328 # Use two ranks 329 ranks_per_channel = 2 330 331 # DDR3 has 8 banks in all configurations 332 banks_per_rank = 8 333 334 # 666 MHs 335 tCK = '1.5ns' 336 337 tRCD = '15ns' 338 tCL = '15ns' 339 tRP = '15ns' 340 tRAS = '36ns' 341 tWR = '15ns' 342 tRTP = '7.5ns' 343 344 # 8 beats across an x64 interface translates to 4 clocks @ 666.66 MHz. 345 # Note this is a BL8 DDR device. 346 tBURST = '6ns' 347 348 tRFC = '160ns' 349 350 # DDR3, <=85C, half for >85C 351 tREFI = '7.8us' 352 353 # Greater of 4 CK or 7.5 ns, 4 CK @ 666.66 MHz = 6 ns 354 tWTR = '7.5ns' 355 356 # Default read-to-write bus around to 2 CK, @666.66 MHz = 3 ns 357 tRTW = '3ns' 358 359 tRRD = '6.0ns' 360 361 tXAW = '30ns' 362 activation_limit = 4 363 364 365# A single LPDDR2-S4 x32 interface (one command/address bus), with 366# default timings based on a LPDDR2-1066 4 Gbit part in a 1x32 367# configuration. 368class LPDDR2_S4_1066_x32(DRAMCtrl): 369 # 1x32 configuration, 1 device with a 32-bit interface 370 device_bus_width = 32 371 372 # LPDDR2_S4 is a BL4 and BL8 device 373 burst_length = 8 374 375 # Each device has a page (row buffer) size of 1KB 376 # (this depends on the memory density) 377 device_rowbuffer_size = '1kB' 378 379 # 1x32 configuration, so 1 device 380 devices_per_rank = 1 381 382 # Use a single rank 383 ranks_per_channel = 1 384 385 # LPDDR2-S4 has 8 banks in all configurations 386 banks_per_rank = 8 387 388 # 533 MHz 389 tCK = '1.876ns' 390 391 # Fixed at 15 ns 392 tRCD = '15ns' 393 394 # 8 CK read latency, 4 CK write latency @ 533 MHz, 1.876 ns cycle time 395 tCL = '15ns' 396 397 # Pre-charge one bank 15 ns (all banks 18 ns) 398 tRP = '15ns' 399 400 tRAS = '42ns' 401 tWR = '15ns' 402 403 # 6 CK read to precharge delay 404 tRTP = '11.256ns' 405 406 # 8 beats across an x32 DDR interface translates to 4 clocks @ 533 MHz. 407 # Note this is a BL8 DDR device. 408 # Requests larger than 32 bytes are broken down into multiple requests 409 # in the controller 410 tBURST = '7.5ns' 411 412 # LPDDR2-S4, 4 Gbit 413 tRFC = '130ns' 414 tREFI = '3.9us' 415 416 # Irrespective of speed grade, tWTR is 7.5 ns 417 tWTR = '7.5ns' 418 419 # Default read-to-write bus around to 2 CK, @533 MHz = 3.75 ns 420 tRTW = '3.75ns' 421 422 # Activate to activate irrespective of density and speed grade 423 tRRD = '10.0ns' 424 425 # Irrespective of density, tFAW is 50 ns 426 tXAW = '50ns' 427 activation_limit = 4 428 429# A single WideIO x128 interface (one command and address bus), with 430# default timings based on an estimated WIO-200 8 Gbit part. 431class WideIO_200_x128(DRAMCtrl): 432 # 1x128 configuration, 1 device with a 128-bit interface 433 device_bus_width = 128 434 435 # This is a BL4 device 436 burst_length = 4 437 438 # Each device has a page (row buffer) size of 4KB 439 # (this depends on the memory density) 440 device_rowbuffer_size = '4kB' 441 442 # 1x128 configuration, so 1 device 443 devices_per_rank = 1 444 445 # Use one rank for a one-high die stack 446 ranks_per_channel = 1 447 448 # WideIO has 4 banks in all configurations 449 banks_per_rank = 4 450 451 # 200 MHz 452 tCK = '5ns' 453 454 # WIO-200 455 tRCD = '18ns' 456 tCL = '18ns' 457 tRP = '18ns' 458 tRAS = '42ns' 459 tWR = '15ns' 460 # Read to precharge is same as the burst 461 tRTP = '20ns' 462 463 # 4 beats across an x128 SDR interface translates to 4 clocks @ 200 MHz. 464 # Note this is a BL4 SDR device. 465 tBURST = '20ns' 466 467 # WIO 8 Gb 468 tRFC = '210ns' 469 470 # WIO 8 Gb, <=85C, half for >85C 471 tREFI = '3.9us' 472 473 # Greater of 2 CK or 15 ns, 2 CK @ 200 MHz = 10 ns 474 tWTR = '15ns' 475 476 # Default read-to-write bus around to 2 CK, @200 MHz = 10 ns 477 tRTW = '10ns' 478 479 # Activate to activate irrespective of density and speed grade 480 tRRD = '10.0ns' 481 482 # Two instead of four activation window 483 tXAW = '50ns' 484 activation_limit = 2 485 486# A single LPDDR3 x32 interface (one command/address bus), with 487# default timings based on a LPDDR3-1600 4 Gbit part in a 1x32 488# configuration 489class LPDDR3_1600_x32(DRAMCtrl): 490 # 1x32 configuration, 1 device with a 32-bit interface 491 device_bus_width = 32 492 493 # LPDDR3 is a BL8 device 494 burst_length = 8 495 496 # Each device has a page (row buffer) size of 4KB 497 device_rowbuffer_size = '4kB' 498 499 # 1x32 configuration, so 1 device 500 devices_per_rank = 1 501 502 # Use a single rank 503 ranks_per_channel = 1 504 505 # LPDDR3 has 8 banks in all configurations 506 banks_per_rank = 8 507 508 # 800 MHz 509 tCK = '1.25ns' 510 511 # Fixed at 15 ns 512 tRCD = '15ns' 513 514 # 12 CK read latency, 6 CK write latency @ 800 MHz, 1.25 ns cycle time 515 tCL = '15ns' 516 517 tRAS = '42ns' 518 tWR = '15ns' 519 520 # Greater of 4 CK or 7.5 ns, 4 CK @ 800 MHz = 5 ns 521 tRTP = '7.5ns' 522 523 # Pre-charge one bank 15 ns (all banks 18 ns) 524 tRP = '15ns' 525 526 # 8 beats across a x32 DDR interface translates to 4 clocks @ 800 MHz. 527 # Note this is a BL8 DDR device. 528 # Requests larger than 32 bytes are broken down into multiple requests 529 # in the controller 530 tBURST = '5ns' 531 532 # LPDDR3, 4 Gb 533 tRFC = '130ns' 534 tREFI = '3.9us' 535 536 # Irrespective of speed grade, tWTR is 7.5 ns 537 tWTR = '7.5ns' 538 539 # Default read-to-write bus around to 2 CK, @800 MHz = 2.5 ns 540 tRTW = '2.5ns' 541 542 # Activate to activate irrespective of density and speed grade 543 tRRD = '10.0ns' 544 545 # Irrespective of size, tFAW is 50 ns 546 tXAW = '50ns' 547 activation_limit = 4 548