libriscv-0.1.0.0: A versatile, flexible and executable formal model for the RISC-V architecture.
Safe HaskellSafe-Inferred
LanguageHaskell2010

LibRISCV.Effects.Operations.Default.Machine.Register

Description

Provides a polymorphic implementation of a register file. This module is intended to be used internally by interpreters for the Operations effect. This register file implementation also provides facilities for storing a concrete program counter.

Synopsis

Documentation

data RegisterFile t a Source #

Register file addressed by RegIdx. The type is parameterized over an array implementation (such as IOUArray) and a generic value type (used to represent instruction operands).

Constructors

RegisterFile 

Fields

  • pc :: IORef Word32

    The current program counter (always concrete in this implementation).

  • regs :: t RegIdx a

    The underlying array to store the register values.

mkRegFile :: MArray t a IO => a -> IO (RegisterFile t a) Source #

Create a new register file, initializing all registers with the given default value. This value must represent the zero value in the chosen value type.

dumpRegs :: MArray t a IO => (a -> ShowS) -> RegisterFile t a -> IO String Source #

Dump the current register file state as a String.

readRegister :: MArray t a IO => RegisterFile t a -> RegIdx -> IO a Source #

Read register value at given register index. For the Zero register index, the zero/default value (as passed to mkRegFile is always returned.

writeRegister :: MArray t a IO => RegisterFile t a -> RegIdx -> a -> IO () Source #

Write register at given register index. Writes to the Zero register are ignored.

readPC :: RegisterFile t a -> IO Word32 Source #

Returs the current program counter value.

writePC :: RegisterFile t a -> Word32 -> IO () Source #

Write a new program counter value.