Skip to content

Simulator

GvsocSimulator

Bases: Simulator

Gvsoc simulator

A simulator, identified by the name gvsoc, tailored to the creation of Gvsoc simulations.

Source code in util/sim/Simulator.py
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
class GvsocSimulator(Simulator):
    """Gvsoc simulator

    A simulator, identified by the name
    `gvsoc`, tailored to the creation of
    [Gvsoc simulations][Simulation.GvsocSimulation].
    """

    def __init__(self, binary):
        """Constructor for the GvsocSimulator class.

        Arguments:
            binary: The Gvsoc simulation binary.
            kwargs: Arguments passed to the base class constructor.
        """
        super().__init__(name='gvsoc', simulation_cls=Simulation.GvsocSimulation)
        self.binary = binary

    def get_simulation(self, test):
        if 'cmd' in test:
            cmd = test['cmd']
        else:
            cmd = None
        return super().get_simulation(
            test,
            sim_bin=self.binary,
            cmd=cmd
        )

__init__(binary)

Constructor for the GvsocSimulator class.

Parameters:

Name Type Description Default
binary

The Gvsoc simulation binary.

required
kwargs

Arguments passed to the base class constructor.

required
Source code in util/sim/Simulator.py
108
109
110
111
112
113
114
115
116
def __init__(self, binary):
    """Constructor for the GvsocSimulator class.

    Arguments:
        binary: The Gvsoc simulation binary.
        kwargs: Arguments passed to the base class constructor.
    """
    super().__init__(name='gvsoc', simulation_cls=Simulation.GvsocSimulation)
    self.binary = binary

QuestaSimulator

Bases: RTLSimulator

QuestaSim simulator

An RTL simulator, identified by the name vsim, tailored to the creation of QuestaSim simulations.

Source code in util/sim/Simulator.py
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
class QuestaSimulator(RTLSimulator):
    """QuestaSim simulator

    An [RTL simulator][Simulator.RTLSimulator], identified by the name
    `vsim`, tailored to the creation of
    [QuestaSim simulations][Simulation.QuestaSimulation].
    """

    def __init__(self, binary):
        """Constructor for the QuestaSimulator class.

        Arguments:
            binary: The QuestaSim simulation binary.
        """
        super().__init__(binary, name='vsim', simulation_cls=Simulation.QuestaSimulation)

__init__(binary)

Constructor for the QuestaSimulator class.

Parameters:

Name Type Description Default
binary

The QuestaSim simulation binary.

required
Source code in util/sim/Simulator.py
155
156
157
158
159
160
161
def __init__(self, binary):
    """Constructor for the QuestaSimulator class.

    Arguments:
        binary: The QuestaSim simulation binary.
    """
    super().__init__(binary, name='vsim', simulation_cls=Simulation.QuestaSimulation)

RTLSimulator

Bases: Simulator

Base class for RTL simulators.

An RTL simulator requires a simulation binary built from an RTL design to launch a simulation.

A test may need to be run with a custom command, itself invoking the simulation binary behind the scenes, e.g. for verification purposes. Such a test carries the custom command (a list of args) under the cmd key.

Source code in util/sim/Simulator.py
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
class RTLSimulator(Simulator):
    """Base class for RTL simulators.

    An RTL simulator requires a simulation binary built from an RTL
    design to launch a simulation.

    A test may need to be run with a custom command, itself invoking
    the simulation binary behind the scenes, e.g. for verification
    purposes. Such a test carries the custom command (a list of args)
    under the `cmd` key.
    """

    def __init__(self, binary, **kwargs):
        """Constructor for the RTLSimulator class.

        Arguments:
            binary: The simulation binary.
            kwargs: Arguments passed to the base class constructor.
        """
        super().__init__(**kwargs)
        self.binary = binary

    def get_simulation(self, test):
        if 'cmd' in test:
            cmd = test['cmd']
        else:
            cmd = None
        return super().get_simulation(
            test,
            sim_bin=self.binary,
            cmd=cmd
        )

__init__(binary, **kwargs)

Constructor for the RTLSimulator class.

Parameters:

Name Type Description Default
binary

The simulation binary.

required
kwargs

Arguments passed to the base class constructor.

{}
Source code in util/sim/Simulator.py
78
79
80
81
82
83
84
85
86
def __init__(self, binary, **kwargs):
    """Constructor for the RTLSimulator class.

    Arguments:
        binary: The simulation binary.
        kwargs: Arguments passed to the base class constructor.
    """
    super().__init__(**kwargs)
    self.binary = binary

Simulator

Bases: object

An object capable of constructing Simulation objects.

A simulator constructs a Simulation object from a test object, as defined e.g. in a test suite specification file.

At minimum, a test is defined by a binary (elf) which is to be simulated and a set of simulators it can be run on. A test could be defined by a class of its own, but at the moment we assume a test to be represented by a dictionary with the elf and simulators keys at minimum.

Source code in util/sim/Simulator.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class Simulator(object):
    """An object capable of constructing Simulation objects.

    A simulator constructs a [Simulation][Simulation.Simulation] object
    from a test object, as defined e.g. in a test suite specification
    file.

    At minimum, a test is defined by a binary (`elf`) which is to be
    simulated and a set of simulators it can be run on. A test could be
    defined by a class of its own, but at the moment we assume a test
    to be represented by a dictionary with the `elf` and `simulators`
    keys at minimum.
    """

    def __init__(self, name, simulation_cls):
        """Constructor for the Simulator class.

        A simulator must be identifiable by a unique identifier string
        and construct at least one type of
        [Simulation][Simulation.Simulation] object.

        Arguments:
            name: The unique identifier of the simulator.
            simulation_cls: One type of
                [Simulation][Simulation.Simulation] object the
                simulator can construct.
        """
        self.name = name
        self.simulation_cls = simulation_cls

    def supports(self, test):
        """Check whether a certain test is supported by the simulator.

        Arguments:
            test: The test to check.
        """
        return 'simulators' not in test or self.name in test['simulators']

    def get_simulation(self, test, simulation_cls=None, **kwargs):
        """Construct a Simulation object from the specified test.

        Arguments:
            test: The test for which a Simulation object must be
                constructed.
            simulation_cls: Create a simulation instance of this
                Simulation subclass. Use `self.simulation_cls` by
                default.
        """
        kwargs.update({key: test[key] for key in ['elf', 'run_dir', 'retcode', 'name']
                       if key in test})
        if simulation_cls is not None:
            return simulation_cls(**kwargs)
        else:
            return self.simulation_cls(**kwargs)

__init__(name, simulation_cls)

Constructor for the Simulator class.

A simulator must be identifiable by a unique identifier string and construct at least one type of Simulation object.

Parameters:

Name Type Description Default
name

The unique identifier of the simulator.

required
simulation_cls

One type of Simulation object the simulator can construct.

required
Source code in util/sim/Simulator.py
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
def __init__(self, name, simulation_cls):
    """Constructor for the Simulator class.

    A simulator must be identifiable by a unique identifier string
    and construct at least one type of
    [Simulation][Simulation.Simulation] object.

    Arguments:
        name: The unique identifier of the simulator.
        simulation_cls: One type of
            [Simulation][Simulation.Simulation] object the
            simulator can construct.
    """
    self.name = name
    self.simulation_cls = simulation_cls

get_simulation(test, simulation_cls=None, **kwargs)

Construct a Simulation object from the specified test.

Parameters:

Name Type Description Default
test

The test for which a Simulation object must be constructed.

required
simulation_cls

Create a simulation instance of this Simulation subclass. Use self.simulation_cls by default.

None
Source code in util/sim/Simulator.py
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
def get_simulation(self, test, simulation_cls=None, **kwargs):
    """Construct a Simulation object from the specified test.

    Arguments:
        test: The test for which a Simulation object must be
            constructed.
        simulation_cls: Create a simulation instance of this
            Simulation subclass. Use `self.simulation_cls` by
            default.
    """
    kwargs.update({key: test[key] for key in ['elf', 'run_dir', 'retcode', 'name']
                   if key in test})
    if simulation_cls is not None:
        return simulation_cls(**kwargs)
    else:
        return self.simulation_cls(**kwargs)

supports(test)

Check whether a certain test is supported by the simulator.

Parameters:

Name Type Description Default
test

The test to check.

required
Source code in util/sim/Simulator.py
40
41
42
43
44
45
46
def supports(self, test):
    """Check whether a certain test is supported by the simulator.

    Arguments:
        test: The test to check.
    """
    return 'simulators' not in test or self.name in test['simulators']

VCSSimulator

Bases: RTLSimulator

VCS simulator

An RTL simulator, identified by the name vcs, tailored to the creation of VCS simulations.

Source code in util/sim/Simulator.py
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
class VCSSimulator(RTLSimulator):
    """VCS simulator

    An [RTL simulator][Simulator.RTLSimulator], identified by the name
    `vcs`, tailored to the creation of
    [VCS simulations][Simulation.VCSSimulation].
    """

    def __init__(self, binary):
        """Constructor for the VCSSimulator class.

        Arguments:
            binary: The VCS simulation binary.
        """
        super().__init__(binary, name='vcs', simulation_cls=Simulation.VCSSimulation)

__init__(binary)

Constructor for the VCSSimulator class.

Parameters:

Name Type Description Default
binary

The VCS simulation binary.

required
Source code in util/sim/Simulator.py
138
139
140
141
142
143
144
def __init__(self, binary):
    """Constructor for the VCSSimulator class.

    Arguments:
        binary: The VCS simulation binary.
    """
    super().__init__(binary, name='vcs', simulation_cls=Simulation.VCSSimulation)

VerilatorSimulator

Bases: RTLSimulator

Verilator simulator

An RTL simulator, identified by the name verilator, tailored to the creation of Verilator simulations.

Source code in util/sim/Simulator.py
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
class VerilatorSimulator(RTLSimulator):
    """Verilator simulator

    An [RTL simulator][Simulator.RTLSimulator], identified by the name
    `verilator`, tailored to the creation of
    [Verilator simulations][Simulation.VerilatorSimulation].
    """

    def __init__(self, binary):
        """Constructor for the VerilatorSimulator class.

        Arguments:
            binary: The Verilator simulation binary.
        """
        super().__init__(binary, name='verilator', simulation_cls=Simulation.VerilatorSimulation)

__init__(binary)

Constructor for the VerilatorSimulator class.

Parameters:

Name Type Description Default
binary

The Verilator simulation binary.

required
Source code in util/sim/Simulator.py
172
173
174
175
176
177
178
def __init__(self, binary):
    """Constructor for the VerilatorSimulator class.

    Arguments:
        binary: The Verilator simulation binary.
    """
    super().__init__(binary, name='verilator', simulation_cls=Simulation.VerilatorSimulation)