led color now depends on run-mode

This commit is contained in:
folkert van heusden 2022-03-17 23:23:53 +01:00
parent ab1584d73f
commit a8d62a5426
3 changed files with 40 additions and 14 deletions

View file

@ -50,12 +50,17 @@ void panel(void *p) {
CRGB leds[1]; // FIXME 1: aantal leds, zie ook v CRGB leds[1]; // FIXME 1: aantal leds, zie ook v
FastLED.addLeds<NEOPIXEL, NEOPIXELS_PIN>(leds, 1); FastLED.addLeds<NEOPIXEL, NEOPIXELS_PIN>(leds, 1);
const CRGB run_mode_led_color[4] = { CRGB::Red, CRGB::Yellow, CRGB::Blue, CRGB::Green };
for(;;) { for(;;) {
vTaskDelay(100 / portTICK_RATE_MS); 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(); FastLED.show();
} }
@ -126,6 +131,34 @@ void setup() {
uint32_t icount = 0; 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() { void loop() {
icount++; icount++;
@ -133,21 +166,17 @@ void loop() {
if (Serial.available()) { if (Serial.available()) {
char c = Serial.read(); char c = Serial.read();
if (c == 5) { if (c == 5)
Serial.print(F("Instructions per second: ")); dump_state(b);
Serial.println(icount * 1000.0 / (millis() - start_ts)); else if (c > 0 && c < 127)
}
else if (c > 0 && c < 127) {
tty_->sendChar(c); tty_->sendChar(c);
} }
} }
}
if (c->step()) { if (c->step()) {
Serial.println(F("")); Serial.println(F(""));
Serial.println(F(" *** EMULATION STOPPED *** ")); Serial.println(F(" *** EMULATION STOPPED *** "));
Serial.print(F("Instructions per second: ")); dump_state(b);
Serial.println(icount * 1000.0 / (millis() - start_ts));
delay(3000); delay(3000);
Serial.println(F(" *** EMULATION RESTARTING *** ")); Serial.println(F(" *** EMULATION RESTARTING *** "));

View file

@ -26,7 +26,7 @@ void cpu::reset()
memset(sp, 0x00, sizeof sp); memset(sp, 0x00, sizeof sp);
pc = 0; pc = 0;
psw = fpsr = 0; psw = fpsr = 0;
runMode = resetFlag = haltFlag = false; resetFlag = haltFlag = false;
} }
uint16_t cpu::getRegister(const int nr, const bool prev_mode) const uint16_t cpu::getRegister(const int nr, const bool prev_mode) const

3
cpu.h
View file

@ -16,7 +16,6 @@ private:
uint16_t psw { 0 }, fpsr { 0 }; uint16_t psw { 0 }, fpsr { 0 };
uint16_t stackLimitRegister { 0 }; uint16_t stackLimitRegister { 0 };
bool haltFlag { false }, resetFlag { false }; bool haltFlag { false }, resetFlag { false };
bool runMode { false };
bool emulateMFPT { false }; bool emulateMFPT { false };
@ -61,8 +60,6 @@ public:
void setEmulateMFPT(const bool v) { emulateMFPT = v; } void setEmulateMFPT(const bool v) { emulateMFPT = v; }
bool getRunMode() { return runMode; }
bool getPSW_c() const; bool getPSW_c() const;
bool getPSW_v() const; bool getPSW_v() const;
bool getPSW_z() const; bool getPSW_z() const;