Class IO_Register
Defined in File sim_ioreg.h
Class Documentation
-
class IO_Register
Simulation model for a 8-bits I/O register that is a vehicle for data transfer between the CPU and I/O peripherals.
Peripherals can be added as handlers to a register to be notified of accesses (read or write) by the CPU.
Each bit of the register can be marked as used/unused or read-only. this is taken into account on write access for error checks.
Public Functions
-
explicit IO_Register(bool core_reg = false)
Build a register.
- Parameters:
core_reg – set to true if the register is handled by the core. The effect is to bypass read-only/use masks checks
-
IO_Register(const IO_Register &other)
-
~IO_Register()
-
inline uint8_t value() const
Simple inline interface to access the value.
-
inline void set(uint8_t value)
Simple inline interface to access the value.
-
void set_handler(IO_RegHandler &handler, uint8_t use_mask, uint8_t ro_mask)
Add a handler to this register.
Note
the bitmasks are OR’d with any pre-defined mask.
- Parameters:
handler – handler to add
use_mask – bitmask indicating the used bits (‘1’s)
ro_mask – bitmask indicating the read-only bits (‘1’s)
-
uint8_t cpu_read(reg_addr_t addr)
CPU read access to the register. The handlers’ read callbacks are called then the register value is returned.
-
bool cpu_write(reg_addr_t addr, uint8_t value)
CPU write access to the register. The handlers’ write callbacks are called.
Note
that if the register has no handler, all 8 bits are read-only except if core_reg was true at construction
- Returns:
true if the read-only rule has been violated, i.e. attempting to write a read-only or unused bit with ‘1’.(temporary removed)
-
uint8_t ioctl_read(reg_addr_t addr)
I/O peripheral interface for read/write operation on this register
-
void ioctl_write(reg_addr_t addr, uint8_t value)
I/O peripheral interface for read/write operation on this register
-
IO_Register &operator=(const IO_Register&) = delete
-
explicit IO_Register(bool core_reg = false)