File memory.h
File List > bindings > simple > memory.h
Go to the documentation of this file
#pragma once
#include <sysc/kernel/sc_event.h>
#include <systemc.h>
#include <tlm.h>
#include <tlm_utils/simple_target_socket.h>
#include <elfio/elfio.hpp>
#include <sol/sol.hpp>
#include "bindings/axi/atog.h"
namespace simple {
class Memory : public sc_module {
public:
tlm_utils::simple_target_socket<Memory> port_;
Memory(const sc_module_name &name, int size, unsigned latency,
unsigned fifo_size);
~Memory();
// Callbacks for TLM transactions
virtual tlm::tlm_sync_enum nb_transport_fw(tlm::tlm_generic_payload &trans,
tlm::tlm_phase &phase, sc_time &t);
virtual unsigned int transport_dbg(tlm::tlm_generic_payload &trans);
void ProcessRequest();
void Response();
// Lua API implementations
using LuaBytes = sol::as_table_t<std::vector<uint8_t>>;
LuaBytes read_bytes(uint64_t addr, size_t size) const;
void write_bytes(uint64_t addr, const LuaBytes &data);
void set_clock(sc_clock *clock);
sc_clock *clock() const;
auto *axi_port();
size_t size() const { return size_; }
void load_elf(ELFIO::elfio &elf);
private:
size_t size_;
uint8_t *mem_;
sc_clock *clock_;
sc_in<bool> clock_i_;
unsigned latency_;
sc_fifo<tlm::tlm_generic_payload *> req_fifo_;
sc_fifo<tlm::tlm_generic_payload *> resp_fifo_;
sc_event resp_end_event_;
std::unique_ptr<AToG> atog_;
};
} // namespace simple