<commit_before>#=========================================================================
# machine.py
#=========================================================================

from pydgin.storage import RegisterFile
from pydgin.utils import specialize
from utils import trim_64

#-------------------------------------------------------------------------
# State
#-------------------------------------------------------------------------
class State( object ):
  # TODO: add virtualizables
  _virtualizable_ = ['pc', 'num_insts']

  def __init__( self, memory, debug, reset_addr=0x400 ):
    self.pc       = reset_addr

    # TODO: don't know what this is:
    self.xlen     = 64

    self.rf       = RiscVRegisterFile()
    self.mem      = memory

    self    .debug = debug
    self.rf .debug = debug
    self.mem.debug = debug

    # coprocessor registers
    self.status          = 0
    self.stats_en        = 0
    self.num_insts       = 0
    self.stat_num_insts  = 0

    # we need a dedicated running flag bacase status could be 0 on a
    # syscall_exit
    self.running       = True

    # indicate if this is running a self-checking test
    self.testbin  = False

    # executable name
    self.exe_name = ""

    # syscall stuff... TODO: should this be here?
    self.breakpoint = 0

  def fetch_pc( self ):
    return self.pc

class RiscVRegisterFile( RegisterFile ):
  def __init__( self ):
    return RegisterFile.__init__( self, nbits=64 )

  @specialize.argtype(2)
  def __setitem__( self, idx, value ):
    return RegisterFile.__setitem__( self, idx, trim_64( value ) )<commit_msg>[riscv] add floating-point register file, cleanup RiscV RF init<commit_after>#=========================================================================
# machine.py
#=========================================================================

from pydgin.storage import RegisterFile
from pydgin.utils import specialize
from utils import trim_64

#-------------------------------------------------------------------------
# State
#-------------------------------------------------------------------------
class State( object ):
  # TODO: add virtualizables
  _virtualizable_ = ['pc', 'num_insts']

  def __init__( self, memory, debug, reset_addr=0x400 ):
    self.pc       = reset_addr

    # TODO: don't know what this is:
    self.xlen     = 64

    self.rf       = RiscVRegisterFile()
    self.fp       = RiscVFPRegisterFile()
    self.mem      = memory

    self    .debug = debug
    self.rf .debug = debug
    self.fp .debug = debug
    self.mem.debug = debug

    # coprocessor registers
    self.status          = 0
    self.stats_en        = 0
    self.num_insts       = 0
    self.stat_num_insts  = 0

    # we need a dedicated running flag bacase status could be 0 on a
    # syscall_exit
    self.running       = True

    # indicate if this is running a self-checking test
    self.testbin  = False

    # executable name
    self.exe_name = ""

    # syscall stuff... TODO: should this be here?
    self.breakpoint = 0

  def fetch_pc( self ):
    return self.pc

class RiscVRegisterFile( RegisterFile ):
  def __init__( self ):
    RegisterFile.__init__( self,
      constant_zero=True,
      num_regs=32,
      nbits=64
    )

  @specialize.argtype(2)
  def __setitem__( self, idx, value ):
    return RegisterFile.__setitem__( self, idx, trim_64( value ) )

class RiscVFPRegisterFile( RegisterFile ):
  def __init__( self ):
    RegisterFile.__init__( self,
      constant_zero=False,
      num_regs=32,
      nbits=64
    )

  @specialize.argtype(2)
  def __setitem__( self, idx, value ):
    return RegisterFile.__setitem__( self, idx, value )
{'fraction_non_alphanumeric': 0.2342981977061715, 'fraction_numerical': 0.012288367012561441, 'mean_word_length': 2.138817480719794, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7272824', 'n_tokens_mistral': 1077, 'n_tokens_neox': 994, 'n_words': 290}