[priv] added --slowdown flag to slow down emulated clock speed

assembly-parser-rework
Anton Lydike 3 years ago
parent cadccaef00
commit 26d0a165f7

@ -19,6 +19,7 @@ class RunConfig:
scall_input: bool = True scall_input: bool = True
scall_fs: bool = False scall_fs: bool = False
verbosity: int = 0 verbosity: int = 0
slowdown: float = 1
CONFIG = RunConfig() CONFIG = RunConfig()

@ -69,6 +69,8 @@ class PrivCPU(CPU):
# init csr # init csr
self._init_csr() self._init_csr()
self.TIME_RESOLUTION_NS = int(self.TIME_RESOLUTION_NS * conf.slowdown)
def run(self, verbose=False): def run(self, verbose=False):
if self.pc <= 0: if self.pc <= 0:
return False return False

@ -1,8 +1,6 @@
from riscemu import RunConfig from riscemu import RunConfig
from riscemu.types import Program from riscemu.types import Program
from .PrivCPU import PrivCPU from .PrivCPU import PrivCPU
from .ElfLoader import ElfBinaryFileLoader
from .ImageLoader import MemoryImageLoader
import sys import sys
@ -19,9 +17,11 @@ if __name__ == '__main__':
parser.add_argument('-v', '--verbose', help="Verbosity level (can be used multiple times)", action='count', parser.add_argument('-v', '--verbose', help="Verbosity level (can be used multiple times)", action='count',
default=0) default=0)
parser.add_argument('--slowdown', help="Slow down the emulated CPU clock by a factor", type=float, default=1)
args = parser.parse_args() args = parser.parse_args()
cpu = PrivCPU(RunConfig(verbosity=args.verbose, debug_on_exception=args.debug_exceptions)) cpu = PrivCPU(RunConfig(verbosity=args.verbose, debug_on_exception=args.debug_exceptions, slowdown=args.slowdown))
for source_path in args.source: for source_path in args.source:
loader = max((loader for loader in cpu.get_loaders()), key=lambda l: l.can_parse(source_path)) loader = max((loader for loader in cpu.get_loaders()), key=lambda l: l.can_parse(source_path))

Loading…
Cancel
Save