mirror of
https://github.com/TomHarte/CLK.git
synced 2024-07-05 10:28:58 +00:00
Added bus request/acknowledge logic.
This commit is contained in:
parent
7bd45d308a
commit
7898f643ac
@ -195,13 +195,13 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
|
||||
enum Interrupt: uint8_t {
|
||||
IRQ = 0x01,
|
||||
NMI = 0x02,
|
||||
BUSREQ = 0x04,
|
||||
Reset = 0x08,
|
||||
PowerOn = 0x10
|
||||
Reset = 0x04,
|
||||
PowerOn = 0x08
|
||||
};
|
||||
uint8_t request_status_;
|
||||
uint8_t last_request_status_;
|
||||
bool irq_line_;
|
||||
bool bus_request_line_;
|
||||
|
||||
uint8_t operation_;
|
||||
RegisterPair temp16_;
|
||||
@ -667,16 +667,11 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
|
||||
public:
|
||||
Processor() : MicroOpScheduler(),
|
||||
halt_mask_(0xff),
|
||||
sp_(0xffff),
|
||||
pc_(0x0000),
|
||||
a_(0xff),
|
||||
interrupt_mode_(0),
|
||||
iff1_(false),
|
||||
iff2_(false),
|
||||
number_of_cycles_(0),
|
||||
request_status_(Interrupt::PowerOn),
|
||||
last_request_status_(Interrupt::PowerOn),
|
||||
irq_line_(false),
|
||||
bus_request_line_(false),
|
||||
pc_increment_(1) {
|
||||
set_flags(0xff);
|
||||
|
||||
@ -768,6 +763,14 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
|
||||
}
|
||||
|
||||
while(1) {
|
||||
|
||||
while(bus_request_line_) {
|
||||
static MachineCycle bus_acknowledge_cycle = {BusOperation::BusAcknowledge, 1};
|
||||
number_of_cycles_ -= static_cast<T *>(this)->perform_machine_cycle(bus_acknowledge_cycle) + 1;
|
||||
if(!number_of_cycles_) return;
|
||||
}
|
||||
|
||||
while(!bus_request_line_) {
|
||||
const MicroOp *operation = scheduled_program_counter_;
|
||||
scheduled_program_counter_++;
|
||||
|
||||
@ -1494,14 +1497,13 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
|
||||
#pragma mark - Interrupt handling
|
||||
|
||||
case MicroOp::Reset:
|
||||
// TODO
|
||||
// iff1_ = iff2_ = false;
|
||||
// interrupt_mode_ = 0;
|
||||
// pc_.full = 0;
|
||||
// sp_.full = 0xffff;
|
||||
// a_ = 0xff;
|
||||
// set_flags(0xff);
|
||||
// i_ = r_ = 0;
|
||||
iff1_ = iff2_ = false;
|
||||
interrupt_mode_ = 0;
|
||||
pc_.full = 0;
|
||||
sp_.full = 0xffff;
|
||||
a_ = 0xff;
|
||||
set_flags(0xff);
|
||||
i_ = r_ = 0;
|
||||
break;
|
||||
|
||||
#pragma mark - Internal bookkeeping
|
||||
@ -1520,6 +1522,7 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
|
||||
return;
|
||||
}
|
||||
#undef set_parity
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -1718,9 +1721,7 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
|
||||
Sets the logical value of the bus request line.
|
||||
*/
|
||||
void set_bus_request_line(bool value) {
|
||||
// Bus requests are level triggered and cannot be masked.
|
||||
if(value) request_status_ |= Interrupt::BUSREQ;
|
||||
else request_status_ &= ~Interrupt::BUSREQ;
|
||||
bus_request_line_ = value;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
Loading…
Reference in New Issue
Block a user