5 from pprint
import pprint
8 from m5
.objects
import *
13 from common
import MemConfig
14 from common
import HMC
17 def add_options(parser
):
18 parser
.add_argument("--external-memory-system", default
=0, action
="store",
19 type=int, help="External memory system")
20 # TLM related options, currently optional in configs/common/MemConfig.py
21 parser
.add_argument("--tlm-memory", action
="store_true", help="use\
22 external port for SystemC TLM co-simulation. Default:\
24 # Elastic traces related options, currently optional in
25 # configs/common/MemConfig.py
26 parser
.add_argument("--elastic-trace-en", action
="store_true",
27 help="enable capture of data dependency and\
28 instruction fetch traces using elastic trace\
30 # Options related to traffic generation
31 parser
.add_argument("--num-tgen", default
=4, action
="store", type=int,
32 choices
=[4], help="number of traffic generators.\
33 Right now this script supports only 4.\nDefault: 4")
34 parser
.add_argument("--tgen-cfg-file",
35 default
="./configs/example/hmc_tgen.cfg",
36 type=str, help="Traffic generator(s) configuration\
37 file. Note: this script uses the same configuration\
38 file for all traffic generators")
41 # considering 4GB HMC device with following parameters
42 # hmc_device_size = '4GB'
43 # hmc_vault_size = '256MB'
45 # hmc_bank_in_stack = 2
46 # hmc_bank_size = '16MB'
47 # hmc_bank_in_vault = 16
48 def build_system(options
):
49 # create the system we are going to simulate
51 # use timing mode for the interaction between master-slave ports
52 system
.mem_mode
= 'timing'
53 # set the clock fequency of the system
55 vd
= VoltageDomain(voltage
='1V')
56 system
.clk_domain
= SrcClockDomain(clock
=clk
, voltage_domain
=vd
)
57 # add traffic generators to the system
58 system
.tgen
= [TrafficGen(config_file
=options
.tgen_cfg_file
) for i
in
59 range(options
.num_tgen
)]
60 # Config memory system with given HMC arch
61 MemConfig
.config_mem(options
, system
)
62 # Connect the traffic generatiors
63 if options
.arch
== "distributed":
64 for i
in range(options
.num_tgen
):
65 system
.tgen
[i
].port
= system
.membus
.slave
66 # connect the system port even if it is not used in this example
67 system
.system_port
= system
.membus
.slave
68 if options
.arch
== "mixed":
69 for i
in range(int(options
.num_tgen
/2)):
70 system
.tgen
[i
].port
= system
.membus
.slave
72 if options
.enable_global_monitor
:
73 system
.tgen
[2].port
= hh
.lmonitor
[2].slave
74 hh
.lmonitor
[2].master
= hh
.seriallink
[2].slave
75 system
.tgen
[3].port
= hh
.lmonitor
[3].slave
76 hh
.lmonitor
[3].master
= hh
.seriallink
[3].slave
78 system
.tgen
[2].port
= hh
.seriallink
[2].slave
79 system
.tgen
[3].port
= hh
.seriallink
[3].slave
80 # connect the system port even if it is not used in this example
81 system
.system_port
= system
.membus
.slave
82 if options
.arch
== "same":
84 for i
in range(options
.num_links_controllers
):
85 if options
.enable_global_monitor
:
86 system
.tgen
[i
].port
= hh
.lmonitor
[i
].slave
88 system
.tgen
[i
].port
= hh
.seriallink
[i
].slave
89 # set up the root SimObject
90 root
= Root(full_system
=False, system
=system
)
95 parser
= argparse
.ArgumentParser(description
="Simple system using HMC as\
97 HMC
.add_options(parser
)
99 options
= parser
.parse_args()
101 root
= build_system(options
)
102 # instantiate all of the objects we've created so far
104 print("Beginning simulation!")
105 event
= m5
.simulate(10000000000)
107 print('Exiting @ tick %i because %s (exit code is %i)' % (m5
.curTick(),
113 if __name__
== "__m5_main__":