simuhw.memory.model package

Module contents

class simuhw.memory.model.MemorizingModel

Bases: object

The super class for all memorizing models.

abstractmethod reset() None

Resets the states.

abstractmethod read(address: bytes | type[Unknown | HighZ]) bytes | type[Unknown | HighZ]

Reads the word from the memory device.

Parameters:

address – The memory address whose word is to be read.

Returns:

The word read form the specified memory address.

abstractmethod write(address: bytes | type[Unknown | HighZ], word: bytes | type[Unknown | HighZ]) None

Writes the word to the memory device.

Parameters:
  • address – The memory address whose word is to be updated.

  • word – the word to be written to the specified memory address.

class simuhw.memory.model.MockMemorizingModel(word_func: Callable[[bytes | type[Unknown | HighZ]], bytes | type[Unknown | HighZ]] | None = None)

Bases: MemorizingModel

A mock memorizing model.

This model does not memorize any input words, and always outputs the same words at respective addresses. It is intended to be used for experiments and tests.

__init__(word_func: Callable[[bytes | type[Unknown | HighZ]], bytes | type[Unknown | HighZ]] | None = None) None

Creates a mock memorizing model.

Parameters:

word_func – The function to return a mock word according to a given address.

reset() None

Resets the states.

read(address: bytes | type[Unknown | HighZ]) bytes | type[Unknown | HighZ]

Reads the word from the memory device.

Parameters:

address – The memory address whose word is to be read.

Returns:

The word read form the specified memory address.

write(address: bytes | type[Unknown | HighZ], word: bytes | type[Unknown | HighZ]) None

Writes the word to the memory device.

Parameters:
  • address – The memory address whose word is to be updated.

  • word – the word to be written to the specified memory address.

class simuhw.memory.model.RealMemorizingModel(init_word: bytes | type[Unknown | HighZ] = <class 'simuhw._type.Unknown'>)

Bases: MemorizingModel

A memorizing model retaining actual data.

__init__(init_word: bytes | type[Unknown | HighZ] = <class 'simuhw._type.Unknown'>) None

Creates a memorizing model retaining actual data.

Parameters:

init_word – The initial word retained in all addresses.

reset() None

Resets the states.

read(address: bytes | type[Unknown | HighZ]) bytes | type[Unknown | HighZ]

Reads the word from the memory device.

Parameters:

address – The memory address whose word is to be read.

Returns:

The word read form the specified memory address.

write(address: bytes | type[Unknown | HighZ], word: bytes | type[Unknown | HighZ]) None

Writes the word to the memory device.

Parameters:
  • address – The memory address whose word is to be updated.

  • word – the word to be written to the specified memory address.