2017-05-17 01:28:17 +00:00
|
|
|
//
|
|
|
|
// AllRAMProcessor.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 16/05/2017.
|
|
|
|
// Copyright © 2017 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef AllRAMProcessor_hpp
|
|
|
|
#define AllRAMProcessor_hpp
|
|
|
|
|
|
|
|
#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 {
|
|
|
|
public:
|
|
|
|
AllRAMProcessor(size_t memory_size);
|
2017-07-28 00:17:13 +00:00
|
|
|
HalfCycles get_timestamp();
|
2017-05-17 01:28:17 +00:00
|
|
|
void set_data_at_address(uint16_t startAddress, size_t length, const uint8_t *data);
|
2017-05-20 01:53:39 +00:00
|
|
|
void get_data_at_address(uint16_t startAddress, size_t length, uint8_t *data);
|
2017-05-17 01:28:17 +00:00
|
|
|
|
2017-05-20 01:20:28 +00:00
|
|
|
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);
|
|
|
|
|
2017-05-17 01:28:17 +00:00
|
|
|
protected:
|
|
|
|
std::vector<uint8_t> memory_;
|
2017-07-28 00:17:13 +00:00
|
|
|
HalfCycles timestamp_;
|
2017-05-20 01:20:28 +00:00
|
|
|
|
2017-06-01 22:28:34 +00:00
|
|
|
inline void check_address_for_trap(uint16_t address) {
|
2017-06-04 01:54:42 +00:00
|
|
|
if(traps_[address]) {
|
2017-06-01 22:28:34 +00:00
|
|
|
trap_handler_->processor_did_trap(*this, address);
|
|
|
|
}
|
|
|
|
}
|
2017-05-20 01:20:28 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
TrapHandler *trap_handler_;
|
2017-06-04 01:54:42 +00:00
|
|
|
std::vector<bool> traps_;
|
2017-05-17 01:28:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* AllRAMProcessor_hpp */
|