diff --git a/ESP32/main.ino b/ESP32/main.ino index 4af7cab..440a0cf 100644 --- a/ESP32/main.ino +++ b/ESP32/main.ino @@ -50,12 +50,17 @@ void panel(void *p) { CRGB leds[1]; // FIXME 1: aantal leds, zie ook v FastLED.addLeds(leds, 1); + const CRGB run_mode_led_color[4] = { CRGB::Red, CRGB::Yellow, CRGB::Blue, CRGB::Green }; + for(;;) { vTaskDelay(100 / portTICK_RATE_MS); - uint16_t current_pc = c->getPC(); + uint16_t current_PC = c->getPC(); + uint16_t current_PSW = c->getPSW(); - leds[0] = current_pc & (1 << 5) ? CRGB::Red : CRGB::Black; + CRGB led_color = run_mode_led_color[current_PSW >> 14]; + + leds[0] = current_PC & (1 << 4) ? led_color : CRGB::Black; FastLED.show(); } @@ -126,6 +131,34 @@ void setup() { uint32_t icount = 0; +void dump_state(bus *const b) { + cpu *const c = b->getCpu(); + + uint32_t now = millis(); + uint32_t t_diff = now - start_ts; + + double mips = icount / (1000.0 * t_diff); + + // see https://retrocomputing.stackexchange.com/questions/6960/what-was-the-clock-speed-and-ips-for-the-original-pdp-11 + constexpr double pdp11_clock_cycle = 150; // ns, for the 11/70 + constexpr double pdp11_mhz = 1000.0 / pdp11_clock_cycle; + constexpr double pdp11_avg_cycles_per_instruction = (1 + 5) / 2.0; + constexpr double pdp11_estimated_mips = pdp11_mhz / pdp11_avg_cycles_per_instruction; + + Serial.print(F("MIPS: ")); + Serial.println(mips); + + Serial.print(F("emulation speed (aproximately): ")); + Serial.print(mips * 100 / pdp11_estimated_mips); + Serial.println('%'); + + Serial.print(F("PC: ")); + Serial.println(c->getPC()); + + Serial.print(F("Uptime (ms): ")); + Serial.println(t_diff); +} + void loop() { icount++; @@ -133,21 +166,17 @@ void loop() { if (Serial.available()) { char c = Serial.read(); - if (c == 5) { - Serial.print(F("Instructions per second: ")); - Serial.println(icount * 1000.0 / (millis() - start_ts)); - } - else if (c > 0 && c < 127) { + if (c == 5) + dump_state(b); + else if (c > 0 && c < 127) tty_->sendChar(c); - } } } if (c->step()) { Serial.println(F("")); Serial.println(F(" *** EMULATION STOPPED *** ")); - Serial.print(F("Instructions per second: ")); - Serial.println(icount * 1000.0 / (millis() - start_ts)); + dump_state(b); delay(3000); Serial.println(F(" *** EMULATION RESTARTING *** ")); diff --git a/cpu.cpp b/cpu.cpp index f097165..b3389d7 100644 --- a/cpu.cpp +++ b/cpu.cpp @@ -26,7 +26,7 @@ void cpu::reset() memset(sp, 0x00, sizeof sp); pc = 0; psw = fpsr = 0; - runMode = resetFlag = haltFlag = false; + resetFlag = haltFlag = false; } uint16_t cpu::getRegister(const int nr, const bool prev_mode) const diff --git a/cpu.h b/cpu.h index f7b679d..7397add 100644 --- a/cpu.h +++ b/cpu.h @@ -16,7 +16,6 @@ private: uint16_t psw { 0 }, fpsr { 0 }; uint16_t stackLimitRegister { 0 }; bool haltFlag { false }, resetFlag { false }; - bool runMode { false }; bool emulateMFPT { false }; @@ -61,8 +60,6 @@ public: void setEmulateMFPT(const bool v) { emulateMFPT = v; } - bool getRunMode() { return runMode; } - bool getPSW_c() const; bool getPSW_v() const; bool getPSW_z() const;