diff --git a/materials/complete/hello-world.py b/materials/complete/hello-world.py index b8c153e..2444d3f 100644 --- a/materials/complete/hello-world.py +++ b/materials/complete/hello-world.py @@ -1,15 +1,16 @@ from gem5.components.boards.simple_board import SimpleBoard from gem5.components.cachehierarchies.classic.no_cache import NoCache -from gem5.components.memory.single_channel import SingleChannelDDR_1600 +from gem5.components.memory import SingleChannelDDR3_1600 from gem5.components.processors.simple_processor import SimpleProcessor from gem5.components.processors.cpu_types import CPUTypes from gem5.resources.resource import obtain_resource from gem5.simulate.simulator import Simulator +from gem5.isas import ISA # Obtain the components. -cache_hierarchy = NoCache -memory = SingleChannelDDR_1600("1GiB") -processor = SimpleProcessor(cpu_type=CPUTypes.Atomic, num_cores=1) +cache_hierarchy = NoCache() +memory = SingleChannelDDR3_1600("1GiB") +processor = SimpleProcessor(cpu_type=CPUTypes.ATOMIC, num_cores=1, isa=ISA.X86) # Add them to the board. board = SimpleBoard( diff --git a/materials/complete/traffic-generator-hbm2stack.py b/materials/complete/traffic-generator-hbm2stack.py index d3c7fa7..165dc35 100644 --- a/materials/complete/traffic-generator-hbm2stack.py +++ b/materials/complete/traffic-generator-hbm2stack.py @@ -1,25 +1,29 @@ from gem5.components.boards.test_board import TestBoard from gem5.components.memory import HBM2Stack from gem5.components.processors.random_generator import RandomGenerator +from gem5.components.boards.test_board import TestBoard +from gem5.components.processors.random_generator import RandomGenerator +from gem5.components.cachehierarchies.classic.no_cache import NoCache import m5 from m5.objects import Root -# Obtain the compinents -mem_size = "1GiB" -memory = HBM2Stack(mem_size) +# Setup the components. +memory = HBM2Stack("1GiB") generator = RandomGenerator( duration="250us", rate="40GB/s", num_cores=1, - max_addr=mem_size, + max_addr=memory.get_size(), ) +cache_hierarchy = NoCache() # Add them to the Test board. board = TestBoard( clk_freq="3GHz", generator=generator, memory=memory, + cache_hierarchy=cache_hierarchy, ) # Setup the root and instantiate the simulation. @@ -29,5 +33,5 @@ m5.instantiate() # Start the traffic generator. -board.start_traffic() +generator.start_traffic() exit_event = m5.simulate() diff --git a/materials/complete/x86-full-system-complete.py b/materials/complete/x86-full-system-complete.py index e24ed24..289ad51 100644 --- a/materials/complete/x86-full-system-complete.py +++ b/materials/complete/x86-full-system-complete.py @@ -10,7 +10,7 @@ from gem5.coherence_protocol import CoherenceProtocol from gem5.isas import ISA from gem5.components.processors.cpu_types import CPUTypes -from gem5.resources.resource import Resource +from gem5.resources.workload import Workload from gem5.simulate.simulator import Simulator from gem5.simulate.exit_event import ExitEvent @@ -48,6 +48,7 @@ starting_core_type=CPUTypes.TIMING, switch_core_type=CPUTypes.O3, num_cores=2, + isa=ISA.X86, ) # Here we setup the board. The X86Board allows for Full-System X86 simulations. @@ -71,19 +72,47 @@ + "m5 exit;" ) -# Here we set the Full System workload. -# The `set_workload` function for the X86Board takes a kernel, a disk image, -# and, optionally, a the contents of the "readfile". In the case of the -# "x86-ubuntu-18.04-img", a file to be executed as a script after booting the -# system. -board.set_kernel_disk_workload( - kernel=Resource( - "x86-linux-kernel-5.4.49", - ), - disk_image=Resource("x86-ubuntu-18.04-img"), - readfile_contents=command, +# Here we set the workload. If we look up +# http://resources.gem5.org/resources.json we can see the following entry for +# the workload "x86-ubuntu-18.04-boot": +# ``` +# { +# "type" : "workload", +# "name" : "x86-ubuntu-18.04-boot", +# "documentation" : "A full boot of Ubuntu 18.04 with Linux 5.4.49 for +# X86. It runs an `m5 exit` command when the boot is +# completed unless the readfile is specified. If +# specified the readfile will be executed after +# booting.", +# "function": "set_kernel_disk_workload", +# "resources" : { +# "kernel" : "x86-linux-kernel-5.4.49", +# "disk_image":"x86-ubuntu-18.04-img" +# }, +# "additional_params" : {} +# }, +# ``` +workload = Workload("x86-ubuntu-18.04-boot") + +# We want to ammend this workload slightly to carry out a script when the OS +# boot is complete. The script immediately exits the simulation loop then, +# when re-entered, will print "This is running on Timing CPU cores." before +# sleeping for 1 simulated second then exiting the simulation loop again. +# +# We set this to the "readfile_contents" parameter. This parameter allows for +# the setting of the contents of the readfile. The readfile is executed by this +# resource when the OS is booted. +command = ( + "m5 exit;" + + "echo 'This is running on Timing CPU cores.';" + + "sleep 1;" + + "m5 exit;" ) +workload.set_parameter("readfile_contents", command) + +board.set_workload(workload) + simulator = Simulator( board=board, on_exit_event={ diff --git a/materials/hello-world.py b/materials/hello-world.py index 3f82644..306039a 100644 --- a/materials/hello-world.py +++ b/materials/hello-world.py @@ -1,7 +1,8 @@ from gem5.components.boards.simple_board import SimpleBoard from gem5.components.cachehierarchies.classic.no_cache import NoCache -from gem5.components.memory.single_channel import SingleChannelDDR3_1600 +from gem5.components.memory import SingleChannelDDR3_1600 from gem5.components.processors.simple_processor import SimpleProcessor from gem5.components.processors.cpu_types import CPUTypes -from gem5.resources.resource import Resource +from gem5.resources.resource import obtain_resource from gem5.simulate.simulator import Simulator +from gem5.isas import ISA diff --git a/materials/x86-full-system.py b/materials/x86-full-system.py index 28ebb15..9a9257a 100644 --- a/materials/x86-full-system.py +++ b/materials/x86-full-system.py @@ -10,6 +10,6 @@ from gem5.coherence_protocol import CoherenceProtocol from gem5.isas import ISA from gem5.components.processors.cpu_types import CPUTypes -from gem5.resources.resource import Resource +from gem5.resources.workload import Workload from gem5.simulate.simulator import Simulator from gem5.simulate.exit_event import ExitEvent