1 # Copyright 2019 Google, Inc.
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are
5 # met: redistributions of source code must retain the above copyright
6 # notice, this list of conditions and the following disclaimer;
7 # redistributions in binary form must reproduce the above copyright
8 # notice, this list of conditions and the following disclaimer in the
9 # documentation and/or other materials provided with the distribution;
10 # neither the name of the copyright holders nor the names of its
11 # contributors may be used to endorse or promote products derived from
12 # this software without specific prior written permission.
14 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
18 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
20 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 from m5
.defines
import buildEnv
31 import _m5
.arm_fast_model
33 def set_armlmd_license_file(force
=False):
34 '''Set the ARMLMD_LICENSE_FILE environment variable. If "force" is
35 False, then it will only be set if it wasn't already set in the
36 environment. The value it's set to is the one gem5 was built with.
38 key
= 'ARMLMD_LICENSE_FILE'
39 license_file
= buildEnv
[key
]
40 if force
or key
not in os
.environ
:
41 os
.environ
[key
] = license_file
43 # These methods wrap much of the SystemC Export API described in section
44 # 7.6 of the Fast Models User Guide.
46 def scx_initialize(id):
47 # Change our working directory to where the simulation engine library
48 # is so that the fast model code can find it. It looks in the binary
49 # directory and in the current working directory, and we can change
50 # the later. This avoids having to make copies of that library all
53 os
.chdir(os
.path
.join(buildEnv
['PVLIB_HOME'], 'lib',
54 buildEnv
['PVLIB_FLAVOR']))
56 # Actually run scx_initialize.
57 _m5
.arm_fast_model
.scx_initialize(id)
59 # Restore the previous working directory.
62 def scx_load_application(instance
, application
):
63 _m5
.arm_fast_model
.scx_load_application(instance
, application
)
65 def scx_load_application_all(application
):
66 _m5
.arm_fast_model
.scx_load_application_all(application
)
68 def scx_load_data(instance
, data
, address
):
69 _m5
.arm_fast_model
.scx_load_data(instance
, data
, address
)
71 def scx_load_data_all(data
, address
):
72 _m5
.arm_fast_model
.scx_load_data_all(data
, address
)
74 def scx_set_parameter(name
, value
):
75 _m5
.arm_fast_model
.scx_set_parameter(name
, value
)
77 def scx_get_parameter(name
):
79 _m5
.arm_fast_model
.scx_get_parameter(name
, value
)
82 def scx_get_parameter_list(self
):
83 return _m5
.arm_fast_model
.scx_get_parameter_list()
85 def scx_set_cpi_file(cpi_file_path
):
86 _m5
.arm_fast_model
.scx_set_cpi_file(cpi_file_path
)
89 _m5
.arm_fast_model
.scx_cpulimit(t
)
92 _m5
.arm_fast_model
.scx_timelimit(t
)
95 _m5
.arm_fast_model
.scx_simlimit(t
)
97 def scx_parse_and_configure(
98 self
, argc
, argv
, trailer
=None, sig_handler
=True):
99 _m5
.arm_fast_model
.scx_parse_and_configure(
100 argc
, argv
, trailer
, sig_handler
)
102 def scx_start_cadi_server(start
=True, run
=True, debug
=False):
103 _m5
.arm_fast_model
.scx_start_cadi_server(start
, run
, debug
)
105 def scx_enable_cadi_log(log
=True):
106 _m5
.arm_fast_model
.scx_enable_cadi_log(log
)
108 def scx_prefix_appli_output(prefix
=True):
109 _m5
.arm_fast_model
.scx_prefix_appli_output(prefix
)
111 def scx_print_port_number(print_
=True):
112 _m5
.arm_fast_model
.scx_print_port_number(print_
)
114 def scx_print_statistics(print_
=True):
115 _m5
.arm_fast_model
.scx_print_statistics(print_
)
117 def scx_load_plugin(file_
):
118 _m5
.arm_fast_model
.scx_load_plugin(file_
)
120 def scx_sync(sync_time
):
121 _m5
.arm_fast_model
.scx_sync(sync_time
)
123 def scx_set_min_sync_latency(latency
):
124 _m5
.arm_fast_model
.scx_set_min_sync_latency(latency
)
126 def scx_get_min_sync_latency(arg
=None):
128 return _m5
.arm_fast_model
.scx_get_min_sync_latency(arg
)
130 return _m5
.arm_fast_model
.scx_get_min_sync_latency()
132 # This should be called once per simulation
133 def setup_simulation(sim_name
, min_sync_latency
=100.0 / 100000000):
134 set_armlmd_license_file()
135 scx_initialize(sim_name
)
136 scx_set_min_sync_latency(min_sync_latency
)