mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-27 06:35:04 +00:00
Switched to following the current program via address.
This commit is contained in:
parent
244b5ba3c2
commit
a0189a6fe1
@ -558,15 +558,14 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
|
|||||||
// without touching the class storage (i.e. it explicitly says they need be completely up
|
// without touching the class storage (i.e. it explicitly says they need be completely up
|
||||||
// to date in this stack frame only); which saves some complicated addressing
|
// to date in this stack frame only); which saves some complicated addressing
|
||||||
unsigned int scheduleProgramsReadPointer = schedule_programs_read_pointer_;
|
unsigned int scheduleProgramsReadPointer = schedule_programs_read_pointer_;
|
||||||
unsigned int scheduleProgramProgramCounter = schedule_program_program_counter_;
|
|
||||||
RegisterPair nextAddress = next_address_;
|
RegisterPair nextAddress = next_address_;
|
||||||
BusOperation nextBusOperation = next_bus_operation_;
|
BusOperation nextBusOperation = next_bus_operation_;
|
||||||
uint16_t busAddress = bus_address_;
|
uint16_t busAddress = bus_address_;
|
||||||
uint8_t *busValue = bus_value_;
|
uint8_t *busValue = bus_value_;
|
||||||
|
|
||||||
#define checkSchedule(op) \
|
#define checkSchedule(op) \
|
||||||
if(!scheduled_programs_[scheduleProgramsReadPointer]) {\
|
if(!scheduled_program_counter_) {\
|
||||||
scheduleProgramsReadPointer = schedule_programs_write_pointer_ = scheduleProgramProgramCounter = 0;\
|
scheduleProgramsReadPointer = schedule_programs_write_pointer_ = 0;\
|
||||||
if(interrupt_requests_) {\
|
if(interrupt_requests_) {\
|
||||||
if(interrupt_requests_ & (InterruptRequestFlags::Reset | InterruptRequestFlags::PowerOn)) {\
|
if(interrupt_requests_ & (InterruptRequestFlags::Reset | InterruptRequestFlags::PowerOn)) {\
|
||||||
interrupt_requests_ &= ~InterruptRequestFlags::PowerOn;\
|
interrupt_requests_ &= ~InterruptRequestFlags::PowerOn;\
|
||||||
@ -607,8 +606,8 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
|
|||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
|
|
||||||
const MicroOp cycle = program[scheduleProgramProgramCounter];
|
const MicroOp cycle = *scheduled_program_counter_;
|
||||||
scheduleProgramProgramCounter++;
|
scheduled_program_counter_++;
|
||||||
|
|
||||||
#define read_op(val, addr) nextBusOperation = BusOperation::ReadOpcode; busAddress = addr; busValue = &val; val = 0xff
|
#define read_op(val, addr) nextBusOperation = BusOperation::ReadOpcode; busAddress = addr; busValue = &val; val = 0xff
|
||||||
#define read_mem(val, addr) nextBusOperation = BusOperation::Read; busAddress = addr; busValue = &val; val = 0xff
|
#define read_mem(val, addr) nextBusOperation = BusOperation::Read; busAddress = addr; busValue = &val; val = 0xff
|
||||||
@ -649,7 +648,7 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
|
|||||||
case OperationMoveToNextProgram:
|
case OperationMoveToNextProgram:
|
||||||
scheduled_programs_[scheduleProgramsReadPointer] = NULL;
|
scheduled_programs_[scheduleProgramsReadPointer] = NULL;
|
||||||
scheduleProgramsReadPointer = (scheduleProgramsReadPointer+1)&3;
|
scheduleProgramsReadPointer = (scheduleProgramsReadPointer+1)&3;
|
||||||
scheduleProgramProgramCounter = 0;
|
scheduled_program_counter_ = scheduled_programs_[scheduleProgramsReadPointer];
|
||||||
checkSchedule();
|
checkSchedule();
|
||||||
program = scheduled_programs_[scheduleProgramsReadPointer];
|
program = scheduled_programs_[scheduleProgramsReadPointer];
|
||||||
continue;
|
continue;
|
||||||
@ -1083,7 +1082,6 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
|
|||||||
|
|
||||||
cycles_left_to_run_ = number_of_cycles;
|
cycles_left_to_run_ = number_of_cycles;
|
||||||
schedule_programs_read_pointer_ = scheduleProgramsReadPointer;
|
schedule_programs_read_pointer_ = scheduleProgramsReadPointer;
|
||||||
schedule_program_program_counter_ = scheduleProgramProgramCounter;
|
|
||||||
next_address_ = nextAddress;
|
next_address_ = nextAddress;
|
||||||
next_bus_operation_ = nextBusOperation;
|
next_bus_operation_ = nextBusOperation;
|
||||||
bus_address_ = busAddress;
|
bus_address_ = busAddress;
|
||||||
|
@ -17,7 +17,7 @@ template <class T> class MicroOpScheduler {
|
|||||||
scheduled_programs_{nullptr, nullptr, nullptr, nullptr},
|
scheduled_programs_{nullptr, nullptr, nullptr, nullptr},
|
||||||
schedule_programs_write_pointer_(0),
|
schedule_programs_write_pointer_(0),
|
||||||
schedule_programs_read_pointer_(0),
|
schedule_programs_read_pointer_(0),
|
||||||
schedule_program_program_counter_(0) {}
|
scheduled_program_counter_(nullptr) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/*
|
/*
|
||||||
@ -28,7 +28,8 @@ template <class T> class MicroOpScheduler {
|
|||||||
queue to take that step.
|
queue to take that step.
|
||||||
*/
|
*/
|
||||||
const T *scheduled_programs_[4];
|
const T *scheduled_programs_[4];
|
||||||
unsigned int schedule_programs_write_pointer_, schedule_programs_read_pointer_, schedule_program_program_counter_;
|
const T *scheduled_program_counter_;
|
||||||
|
unsigned int schedule_programs_write_pointer_, schedule_programs_read_pointer_;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Schedules a new program, adding it to the end of the queue. Programs should be
|
Schedules a new program, adding it to the end of the queue. Programs should be
|
||||||
@ -39,13 +40,14 @@ template <class T> class MicroOpScheduler {
|
|||||||
*/
|
*/
|
||||||
inline void schedule_program(const T *program) {
|
inline void schedule_program(const T *program) {
|
||||||
scheduled_programs_[schedule_programs_write_pointer_] = program;
|
scheduled_programs_[schedule_programs_write_pointer_] = program;
|
||||||
|
if(schedule_programs_write_pointer_ == schedule_programs_read_pointer_) scheduled_program_counter_ = program;
|
||||||
schedule_programs_write_pointer_ = (schedule_programs_write_pointer_+1)&3;
|
schedule_programs_write_pointer_ = (schedule_programs_write_pointer_+1)&3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void move_to_next_program() {
|
inline void move_to_next_program() {
|
||||||
scheduled_programs_[schedule_programs_read_pointer_] = NULL;
|
scheduled_programs_[schedule_programs_read_pointer_] = nullptr;
|
||||||
schedule_programs_read_pointer_ = (schedule_programs_read_pointer_+1)&3;
|
schedule_programs_read_pointer_ = (schedule_programs_read_pointer_+1)&3;
|
||||||
schedule_program_program_counter_ = 0;
|
scheduled_program_counter_ = scheduled_programs_[schedule_programs_read_pointer_];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -686,8 +686,8 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
|
|||||||
checkSchedule();
|
checkSchedule();
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
const MicroOp *operation = &scheduled_programs_[schedule_programs_read_pointer_][schedule_program_program_counter_];
|
const MicroOp *operation = scheduled_program_counter_;
|
||||||
schedule_program_program_counter_++;
|
scheduled_program_counter_++;
|
||||||
|
|
||||||
#define set_parity(v) \
|
#define set_parity(v) \
|
||||||
parity_overflow_result_ = v^1;\
|
parity_overflow_result_ = v^1;\
|
||||||
@ -697,7 +697,7 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
|
|||||||
|
|
||||||
switch(operation->type) {
|
switch(operation->type) {
|
||||||
case MicroOp::BusOperation:
|
case MicroOp::BusOperation:
|
||||||
if(number_of_cycles_ < operation->machine_cycle.length) { schedule_program_program_counter_--; return; }
|
if(number_of_cycles_ < operation->machine_cycle.length) { scheduled_program_counter_--; return; }
|
||||||
number_of_cycles_ -= operation->machine_cycle.length;
|
number_of_cycles_ -= operation->machine_cycle.length;
|
||||||
number_of_cycles_ -= static_cast<T *>(this)->perform_machine_cycle(&operation->machine_cycle);
|
number_of_cycles_ -= static_cast<T *>(this)->perform_machine_cycle(&operation->machine_cycle);
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user