2017-05-17 01:28:17 +00:00
|
|
|
//
|
|
|
|
// AllRAMProcessor.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 16/05/2017.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2017 Thomas Harte. All rights reserved.
|
2017-05-17 01:28:17 +00:00
|
|
|
//
|
|
|
|
|
2024-01-17 04:34:46 +00:00
|
|
|
#pragma once
|
2017-05-17 01:28:17 +00:00
|
|
|
|
|
|
|
#include <cstdint>
|
2017-05-20 01:20:28 +00:00
|
|
|
#include <set>
|
2017-05-17 01:28:17 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2017-07-28 00:17:13 +00:00
|
|
|
#include "../ClockReceiver/ClockReceiver.hpp"
|
|
|
|
|
2017-05-17 01:28:17 +00:00
|
|
|
namespace CPU {
|
|
|
|
|
|
|
|
class AllRAMProcessor {
|
2024-12-05 03:29:08 +00:00
|
|
|
public:
|
|
|
|
AllRAMProcessor(std::size_t memory_size);
|
|
|
|
HalfCycles get_timestamp();
|
|
|
|
void set_data_at_address(size_t startAddress, size_t length, const uint8_t *data);
|
|
|
|
void get_data_at_address(size_t startAddress, size_t length, uint8_t *data);
|
|
|
|
|
|
|
|
class TrapHandler {
|
|
|
|
public:
|
|
|
|
virtual void processor_did_trap(AllRAMProcessor &, uint16_t address) = 0;
|
|
|
|
};
|
|
|
|
void set_trap_handler(TrapHandler *trap_handler);
|
|
|
|
void add_trap_address(uint16_t address);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
std::vector<uint8_t> memory_;
|
|
|
|
HalfCycles timestamp_;
|
|
|
|
|
|
|
|
inline void check_address_for_trap(uint16_t address) {
|
|
|
|
if(traps_[address]) {
|
|
|
|
trap_handler_->processor_did_trap(*this, address);
|
2017-06-01 22:28:34 +00:00
|
|
|
}
|
2024-12-05 03:29:08 +00:00
|
|
|
}
|
2017-05-20 01:20:28 +00:00
|
|
|
|
2024-12-05 03:29:08 +00:00
|
|
|
private:
|
|
|
|
TrapHandler *trap_handler_;
|
|
|
|
std::vector<bool> traps_;
|
2017-05-17 01:28:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|