HMC.py revision 11183:276ad9121192
1# Copyright (c) 2012-2013 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) 2015 The University of Bologna
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: Erfan Azarkhish
40
41# A Simplified model of a complete HMC device. Based on:
42#  [1] http://www.hybridmemorycube.org/specification-download/
43#  [2] High performance AXI-4.0 based interconnect for extensible smart memory
44#      cubes(E. Azarkhish et. al)
45#  [3] Low-Power Hybrid Memory Cubes With Link Power Management and Two-Level
46#      Prefetching (J. Ahn et. al)
47#  [4] Memory-centric system interconnect design with Hybrid Memory Cubes
48#      (G. Kim et. al)
49#  [5] Near Data Processing, Are we there yet? (M. Gokhale)
50#      http://www.cs.utah.edu/wondp/gokhale.pdf
51#
52# This script builds a complete HMC device composed of vault controllers,
53# serial links, the main internal crossbar, and an external hmc controller.
54#
55# - VAULT CONTROLLERS:
56#   Instances of the HMC_2500_x32 class with their functionality specified in
57#   dram_ctrl.cc
58#
59# - THE MAIN XBAR:
60#   This component is simply an instance of the NoncoherentXBar class, and its
61#   parameters are tuned to [2].
62#
63# - SERIAL LINKS:
64#   SerialLink is a simple variation of the Bridge class, with the ability to
65#   account for the latency of packet serialization. We assume that the
66#   serializer component at the transmitter side does not need to receive the
67#   whole packet to start the serialization. But the deserializer waits for
68#   the complete packet to check its integrity first.
69#   * Bandwidth of the serial links is not modeled in the SerialLink component
70#     itself. Instead bandwidth/port of the HMCController has been adjusted to
71#     reflect the bandwidth delivered by 1 serial link.
72#
73# - HMC CONTROLLER:
74#   Contains a large buffer (modeled with Bridge) to hide the access latency
75#   of the memory cube. Plus it simply forwards the packets to the serial
76#   links in a round-robin fashion to balance load among them.
77#   * It is inferred from the standard [1] and the literature [3] that serial
78#     links share the same address range and packets can travel over any of
79#     them so a load distribution mechanism is required among them.
80
81import optparse
82
83import m5
84from m5.objects import *
85
86# A single Hybrid Memory Cube (HMC)
87class HMCSystem(SimOject):
88
89    #*****************************CROSSBAR PARAMETERS*************************
90    # Flit size of the main interconnect [1]
91    xbar_width = Param.Unsigned( 32, "Data width of the main XBar (Bytes)")
92
93    # Clock frequency of the main interconnect [1]
94    # This crossbar, is placed on the logic-based of the HMC and it has its
95    # own voltage and clock domains, different from the DRAM dies or from the
96    # host.
97    xbar_frequency = Param.Frequency('1GHz', "Clock Frequency of the main "
98        "XBar")
99
100    # Arbitration latency of the HMC XBar [1]
101    xbar_frontend_latency = Param.Cycles(1, "Arbitration latency of the XBar")
102
103    # Latency to forward a packet via the interconnect [1](two levels of FIFOs
104    # at the input and output of the inteconnect)
105    xbar_forward_latency = Param.Cycles(2, "Forward latency of the XBar")
106
107    # Latency to forward a response via the interconnect [1](two levels of
108    # FIFOs at the input and output of the inteconnect)
109    xbar_response_latency = Param.Cycles(2, "Response latency of the XBar")
110
111    #*****************************SERIAL LINK PARAMETERS**********************
112    # Number of serial links [1]
113    num_serial_links = Param.Unsigned(4, "Number of serial links")
114
115    # Number of packets (not flits) to store at the request side of the serial
116    #  link. This number should be adjusted to achive required bandwidth
117    link_buffer_size_req = Param.Unsigned( 16, "Number of packets to buffer "
118        "at the request side of the serial link")
119
120    # Number of packets (not flits) to store at the response side of the serial
121    #  link. This number should be adjusted to achive required bandwidth
122    link_buffer_size_rsp = Param.Unsigned( 16, "Number of packets to buffer "
123        "at the response side of the serial link")
124
125    # Latency of the serial link composed by SER/DES latency (1.6ns [4]) plus
126    # the PCB trace latency (3ns Estimated based on [5])
127    link_latency = Param.Latency('4.6ns', "Latency of the serial links")
128
129    # Header overhead of the serial links: Header size is 128bits in HMC [1],
130    #  and we have 16 lanes, so the overhead is 8 cycles
131    link_overhead = Param.Cycles(8, "The number of cycles required to"
132        " transmit the packet header over the serial link")
133
134    # Clock frequency of the serial links [1]
135    link_frequency = Param.Frequency('10GHz', "Clock Frequency of the serial"
136        "links")
137
138    # Number of parallel lanes in each serial link [1]
139    num_lanes_per_link =  Param.Unsigned( 16, "Number of lanes per each link")
140
141    # Number of serial links [1]
142    num_serial_links =  Param.Unsigned( 4, "Number of serial links")
143
144    #*****************************HMC CONTROLLER PARAMETERS*******************
145    # Number of packets (not flits) to store at the HMC controller. This
146    # number should be high enough to be able to hide the high latency of HMC
147    ctrl_buffer_size_req = Param.Unsigned( 256, "Number of packets to buffer "
148        "at the HMC controller (request side)")
149
150    # Number of packets (not flits) to store at the response side of the HMC
151    #  controller.
152    ctrl_buffer_size_rsp = Param.Unsigned( 256, "Number of packets to buffer "
153        "at the HMC controller (response side)")
154
155    # Latency of the HMC controller to process the packets
156    # (ClockDomain = Host clock domain)
157    ctrl_latency = Param.Cycles(4, "The number of cycles required for the "
158        " controller to process the packet")
159
160    # Wiring latency from the SoC crossbar to the HMC controller
161    ctrl_static_latency = Param.Latency('500ps', "Static latency of the HMC"
162        "controller")
163
164    #*****************************PERFORMANCE MONITORING**********************
165    # The main monitor behind the HMC Controller
166    enable_global_monitor = Param.Bool(True, "The main monitor behind the "
167        "HMC Controller")
168
169    # The link performance monitors
170    enable_link_monitor = Param.Bool(True, "The link monitors" )
171
172# Create an HMC device and attach it to the current system
173def config_hmc(options, system):
174
175    system.hmc=HMCSystem()
176
177    system.buffer = Bridge(ranges=system.mem_ranges,
178        req_size=system.hmc.ctrl_buffer_size_req,
179        resp_size=system.hmc.ctrl_buffer_size_rsp,
180        delay=system.hmc.ctrl_static_latency)
181    try:
182        system.hmc.enable_global_monitor = options.enable_global_monitor
183    except:
184        pass;
185
186    try:
187        system.hmc.enable_link_monitor = options.enable_link_monitor
188    except:
189        pass;
190
191    system.membus.master = system.buffer.slave
192
193    # The HMC controller (Clock domain is the same as the host)
194    system.hmccontroller = HMCController(width=(system.hmc.num_lanes_per_link.
195        value * system.hmc.num_serial_links/8),
196        frontend_latency=system.hmc.ctrl_latency,
197        forward_latency=system.hmc.link_overhead,
198        response_latency=system.hmc.link_overhead)
199
200    system.hmccontroller.clk_domain = SrcClockDomain(clock=system.hmc.
201        link_frequency, voltage_domain = VoltageDomain(voltage = '1V'))
202
203    # Serial Links
204    system.hmc.seriallink =[ SerialLink(ranges = system.mem_ranges,
205        req_size=system.hmc.link_buffer_size_req,
206        resp_size=system.hmc.link_buffer_size_rsp,
207        num_lanes=system.hmc.num_lanes_per_link,
208        delay=system.hmc.link_latency)
209        for i in xrange(system.hmc.num_serial_links)]
210
211    if system.hmc.enable_link_monitor:
212        system.hmc.lmonitor = [ CommMonitor()
213        for i in xrange(system.hmc.num_serial_links)]
214
215    # The HMC Crossbar located in its logic-base (LoB)
216    system.hmc.xbar = NoncoherentXBar(width = system.hmc.xbar_width,
217        frontend_latency=system.hmc.xbar_frontend_latency,
218        forward_latency=system.hmc.xbar_forward_latency,
219        response_latency=system.hmc.xbar_response_latency )
220    system.hmc.xbar.clk_domain = SrcClockDomain(clock =
221        system.hmc.xbar_frequency, voltage_domain =
222        VoltageDomain(voltage = '1V'))
223
224    if system.hmc.enable_global_monitor:
225        system.gmonitor = CommMonitor()
226        system.buffer.master = system.gmonitor.slave
227        system.gmonitor.master = system.hmccontroller.slave
228    else:
229        system.hmccontroller.slave = system.buffer.master
230
231    for i in xrange(system.hmc.num_serial_links):
232        system.hmccontroller.master = system.hmc.seriallink[i].slave
233        system.hmc.seriallink[i].clk_domain = system.hmccontroller.clk_domain;
234        if system.hmc.enable_link_monitor:
235            system.hmc.seriallink[i].master = system.hmc.lmonitor[i].slave
236            system.hmc.lmonitor[i].master = system.hmc.xbar.slave
237        else:
238            system.hmc.seriallink[i].master = system.hmc.xbar.slave
239