45 lines
1.3 KiB
C++
45 lines
1.3 KiB
C++
#ifndef LIBVIO_AGENT_HH
|
|
#define LIBVIO_AGENT_HH
|
|
|
|
#include <optional>
|
|
#include <cstdint>
|
|
#include <libanemo/width.hh>
|
|
|
|
namespace libvio {
|
|
|
|
/**
|
|
* @brief Provides am MMIO interface for simulated processors.
|
|
*/
|
|
class io_agent{
|
|
public:
|
|
/**
|
|
* @brief Perform a read operation on the bus
|
|
* @param addr Target address in bus address space
|
|
* @param width Data access width
|
|
* @return std::optional<uint64_t> Read data if successful,
|
|
* std::nullopt otherwise
|
|
*/
|
|
virtual std::optional<uint64_t> read(uint64_t addr, libanemo::width_t width) = 0;
|
|
|
|
/**
|
|
* @brief Perform a write operation on the bus
|
|
* @param addr Target address in bus address space
|
|
* @param width Data access width
|
|
* @param data Data to write (least significant bits used according to width)
|
|
* @return `true` if write succeeded, `false` otherwise
|
|
*/
|
|
virtual bool write(uint64_t addr, libanemo::width_t width, uint64_t data) = 0;
|
|
|
|
/**
|
|
* @brief Tell the agent that the simulated processor that it's attached to has steped a cycle.
|
|
*
|
|
* This needs to be called by the simulated processor after completing each cycle.
|
|
*
|
|
*/
|
|
virtual void next_cycle(void) = 0;
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|