Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mem: Add an update simple.py #10

Open
wants to merge 1 commit into
base: dcache_orb
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 68 additions & 15 deletions simple.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,52 @@
from m5.objects import *
import m5
import argparse

args = argparse.ArgumentParser()

# This scipt takes these arguments [traffic mode] [address range]
# [rd percentage] [duration of simulation in ticks]
# [request injection period in ticks] [device model for dram cache]

# sample cmd: gem5.opt simple.py linear 4GB 70 1000000000 10000 DDR3_1600_8x8

args.add_argument(
"traffic_mode",
type = str,
help = "Traffic type to use"
)

args.add_argument(
"address",
type=str,
help="End address of the range to be accessed",
)

args.add_argument(
"rd_prct",
type=int,
help="Read Percentage",
)

args.add_argument(
"duration",
type = int,
help = "Duration of simulation"
)

args.add_argument(
"inj_period",
type = int,
help = "Period to inject reqs"
)

args.add_argument(
"device",
type = str,
help = "Memory device to use as a dram cache"
)

options = args.parse_args()

system = System()
system.clk_domain = SrcClockDomain()
Expand All @@ -10,10 +57,8 @@
system.generator = PyTrafficGen()

system.mem_ctrl = DcacheCtrl()
system.mem_ctrl.dram = DDR3_1600_8x8(range=AddrRange('8GB'),
#system.mem_ctrl.dram = DDR4_2400_16x4(range=AddrRange('32GB'),
#system.mem_ctrl.dram = HBM_1000_4H_1x128(range=AddrRange('128MiB'),
in_addr_map=False)
system.mem_ctrl.dram = eval(options.device)(range=AddrRange('8GB'),
in_addr_map=False)
system.mem_ctrl.nvm = NVM_2400_1x64(range=AddrRange('8GB'))

system.mem_ctrl.dram.tREFI = "200"
Expand All @@ -25,30 +70,38 @@
system.generator.port = system.mem_ctrl.port

def createRandomTraffic(tgen):
yield tgen.createRandom(100000000000, # duration
yield tgen.createRandom(options.duration, # duration
0, # min_addr
16700000, # max_adr
AddrRange(options.address).end, # max_adr
64, # block_size
10000, # min_period
10000, # max_period
70, # rd_perc
options.inj_period, # min_period
options.inj_period, # max_period
options.rd_prct, # rd_perc
0) # data_limit
yield tgen.createExit(0)

def createLinearTraffic(tgen):
yield tgen.createLinear(10000000000, # duration
yield tgen.createLinear(options.duration, # duration
0, # min_addr
AddrRange('8GB').end, # max_adr
AddrRange(options.address).end, # max_adr
64, # block_size
1000, # min_period
1000, # max_period
70, # rd_perc
options.inj_period, # min_period
options.inj_period, # max_period
options.rd_prct, # rd_perc
0) # data_limit
yield tgen.createExit(0)


root = Root(full_system=False, system=system)

m5.instantiate()
system.generator.start(createRandomTraffic(system.generator))

if options.traffic_mode == 'linear':
system.generator.start(createLinearTraffic(system.generator))
elif options.traffic_mode == 'random':
system.generator.start(createRandomTraffic(system.generator))
else:
print('Wrong traffic type! Exiting!')
exit()

exit_event = m5.simulate()