2019-04-29 20:11:01 +00:00
|
|
|
//
|
|
|
|
// Comparative68000.hpp
|
|
|
|
// Clock SignalTests
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 29/04/2019.
|
|
|
|
// Copyright © 2019 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef Comparative68000_hpp
|
|
|
|
#define Comparative68000_hpp
|
|
|
|
|
|
|
|
#include <zlib.h>
|
|
|
|
|
2022-05-25 15:32:00 +00:00
|
|
|
#include "68000Mk2.hpp"
|
2019-04-29 20:11:01 +00:00
|
|
|
|
2022-05-25 15:32:00 +00:00
|
|
|
class ComparativeBusHandler: public CPU::MC68000Mk2::BusHandler {
|
2019-04-29 20:11:01 +00:00
|
|
|
public:
|
|
|
|
ComparativeBusHandler(const char *trace_name) {
|
|
|
|
trace = gzopen(trace_name, "rt");
|
|
|
|
}
|
|
|
|
|
|
|
|
~ComparativeBusHandler() {
|
|
|
|
gzclose(trace);
|
|
|
|
}
|
|
|
|
|
2020-09-27 02:31:50 +00:00
|
|
|
void will_perform(uint32_t address, uint16_t) {
|
2019-04-29 20:11:01 +00:00
|
|
|
// Obtain the next line from the trace file.
|
|
|
|
char correct_state[300] = "\n";
|
|
|
|
gzgets(trace, correct_state, sizeof(correct_state));
|
|
|
|
++line_count;
|
|
|
|
|
|
|
|
// Generate state locally.
|
2022-05-25 15:32:00 +00:00
|
|
|
const auto state = get_state().registers;
|
2019-04-29 20:11:01 +00:00
|
|
|
char local_state[300];
|
2022-11-12 01:29:59 +00:00
|
|
|
snprintf(local_state, sizeof(local_state), "%04x: %02x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x\n",
|
2019-04-29 20:11:01 +00:00
|
|
|
address,
|
|
|
|
state.status,
|
|
|
|
state.data[0], state.data[1], state.data[2], state.data[3], state.data[4], state.data[5], state.data[6], state.data[7],
|
|
|
|
state.address[0], state.address[1], state.address[2], state.address[3], state.address[4], state.address[5], state.address[6],
|
2022-05-25 15:32:00 +00:00
|
|
|
state.stack_pointer()
|
2019-04-29 20:11:01 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// Check that the two coincide.
|
|
|
|
if(strcmp(correct_state, local_state)) {
|
|
|
|
fprintf(stderr, "Diverges at line %d\n", line_count);
|
2019-04-29 20:55:21 +00:00
|
|
|
fprintf(stderr, "Good: %s", correct_state);
|
|
|
|
fprintf(stderr, "Bad: %s", local_state);
|
2020-09-27 02:31:50 +00:00
|
|
|
throw std::exception();
|
2019-04-29 20:11:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-25 15:32:00 +00:00
|
|
|
virtual CPU::MC68000Mk2::State get_state() = 0;
|
2019-04-29 20:11:01 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
int line_count = 0;
|
|
|
|
gzFile trace;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* Comparative68000_hpp */
|