blob: 219ef9b63ea16e00912e977808e2459e6d93efb7 [file] [log] [blame]
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
from .sim import OTBNSim
_TEST_RND_DATA = \
0x99999999_99999999_99999999_99999999_99999999_99999999_99999999_99999999
class StandaloneSim(OTBNSim):
def run(self, verbose: bool) -> int:
'''Run until ECALL.
Return the number of cycles taken.
'''
insn_count = 0
# ISS will stall at start until URND data is valid; immediately set it
# valid when in free running mode as nothing else will.
self.state.set_urnd_reseed_complete()
while self.state.running():
self.step(verbose)
insn_count += 1
if self.state.wsrs.RND.pending_request:
# If an instruction requests RND data, make it available
# immediately.
self.state.wsrs.RND.set_unsigned(_TEST_RND_DATA)
return insn_count