Skip to content

Commit

Permalink
force an interrupt when no cycles were seen
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertvanheusden committed May 9, 2024
1 parent 6c73bb7 commit 5b10468
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
20 changes: 14 additions & 6 deletions kw11-l.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,22 @@ void kw11_l::reset()
lf_csr = 0;
}

void kw11_l::do_interrupt()
{
set_lf_crs_b7();

if (get_lf_crs() & 64)
b->getCpu()->queue_interrupt(6, 0100);
}

void kw11_l::operator()()
{
set_thread_name("kek:kw-11l");

TRACE("Starting KW11-L thread");

uint64_t prev_cycle_count = b->getCpu()->get_instructions_executed_count();
uint64_t prev_cycle_count = b->getCpu()->get_instructions_executed_count();
uint64_t interval_prev_cycle_count = prev_cycle_count;

while(!stop_flag) {
if (*cnsl->get_running_flag()) {
Expand All @@ -77,14 +86,13 @@ void kw11_l::operator()()
uint64_t current_cycle_count = b->getCpu()->get_instructions_executed_count();
uint32_t took_ms = b->getCpu()->get_effective_run_time(current_cycle_count - prev_cycle_count);

if (took_ms >= 1000 / 50) {
set_lf_crs_b7();

if (get_lf_crs() & 64)
b->getCpu()->queue_interrupt(6, 0100);
if (took_ms >= 1000 / 50 || current_cycle_count - interval_prev_cycle_count == 0) {
do_interrupt();

prev_cycle_count = current_cycle_count;
}

interval_prev_cycle_count = current_cycle_count;
}
else {
myusleep(1000000 / 10); // 10 Hz
Expand Down
2 changes: 2 additions & 0 deletions kw11-l.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class kw11_l
uint8_t get_lf_crs();
void set_lf_crs_b7();

void do_interrupt();

public:
kw11_l(bus *const b);
virtual ~kw11_l();
Expand Down

0 comments on commit 5b10468

Please sign in to comment.