///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
//
|
//
|
// Filename: zipdbg.cpp
|
// Filename: zipdbg.cpp
|
//
|
//
|
// Project: Zip CPU -- a small, lightweight, RISC CPU soft core
|
// Project: Zip CPU -- a small, lightweight, RISC CPU soft core
|
//
|
//
|
// Purpose:
|
// Purpose:
|
//
|
//
|
//
|
//
|
// Creator: Dan Gisselquist, Ph.D.
|
// Creator: Dan Gisselquist, Ph.D.
|
// Gisselquist Tecnology, LLC
|
// Gisselquist Tecnology, LLC
|
//
|
//
|
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
//
|
//
|
// Copyright (C) 2015, Gisselquist Technology, LLC
|
// Copyright (C) 2015, Gisselquist Technology, LLC
|
//
|
//
|
// This program is free software (firmware): you can redistribute it and/or
|
// This program is free software (firmware): you can redistribute it and/or
|
// modify it under the terms of the GNU General Public License as published
|
// modify it under the terms of the GNU General Public License as published
|
// by the Free Software Foundation, either version 3 of the License, or (at
|
// by the Free Software Foundation, either version 3 of the License, or (at
|
// your option) any later version.
|
// your option) any later version.
|
//
|
//
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
|
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
// for more details.
|
// for more details.
|
//
|
//
|
// License: GPL, v3, as defined and found on www.gnu.org,
|
// License: GPL, v3, as defined and found on www.gnu.org,
|
// http://www.gnu.org/licenses/gpl.html
|
// http://www.gnu.org/licenses/gpl.html
|
//
|
//
|
//
|
//
|
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
//
|
//
|
//
|
//
|
//
|
//
|
// BUGS:
|
// BUGS:
|
// - No ability to verify CPU functionality (3rd party simulator)
|
// - No ability to verify CPU functionality (3rd party simulator)
|
// - No ability to set/clear breakpoints
|
// - No ability to set/clear breakpoints
|
//
|
//
|
//
|
//
|
//
|
//
|
#include <stdlib.h>
|
#include <stdlib.h>
|
#include <signal.h>
|
#include <signal.h>
|
#include <time.h>
|
#include <time.h>
|
#include <unistd.h>
|
#include <unistd.h>
|
#include <string.h>
|
#include <string.h>
|
|
|
#include <ctype.h>
|
#include <ctype.h>
|
#include <ncurses.h>
|
#include <ncurses.h>
|
|
|
#include "zopcodes.h"
|
#include "zopcodes.h"
|
#include "zparser.h"
|
#include "zparser.h"
|
#include "devbus.h"
|
#include "devbus.h"
|
#include "regdefs.h"
|
#include "regdefs.h"
|
|
|
#include "usbi.h"
|
#include "usbi.h"
|
#include "port.h"
|
#include "port.h"
|
|
|
#define CMD_REG 0
|
#define CMD_REG 0
|
#define CMD_DATA 1
|
#define CMD_DATA 1
|
#define CMD_HALT (1<<10)
|
#define CMD_HALT (1<<10)
|
#define CMD_STALL (1<<9)
|
#define CMD_STALL (1<<9)
|
#define CMD_STEP (1<<8)
|
#define CMD_STEP (1<<8)
|
#define CMD_INT (1<<7)
|
#define CMD_INT (1<<7)
|
#define CMD_RESET (1<<6)
|
#define CMD_RESET (1<<6)
|
|
|
#define KEY_ESCAPE 27
|
#define KEY_ESCAPE 27
|
#define KEY_RETURN 10
|
#define KEY_RETURN 10
|
#define CTRL(X) ((X)&0x01f)
|
#define CTRL(X) ((X)&0x01f)
|
|
|
class SPARSEMEM {
|
class SPARSEMEM {
|
public:
|
public:
|
bool m_valid;
|
bool m_valid;
|
unsigned int m_a, m_d;
|
unsigned int m_a, m_d;
|
};
|
};
|
|
|
bool gbl_err = false;
|
bool gbl_err = false;
|
class ZIPSTATE {
|
class ZIPSTATE {
|
public:
|
public:
|
bool m_valid, m_gie, m_last_pc_valid;
|
bool m_valid, m_gie, m_last_pc_valid;
|
unsigned int m_sR[16], m_uR[16];
|
unsigned int m_sR[16], m_uR[16];
|
unsigned int m_p[20];
|
unsigned int m_p[20];
|
unsigned int m_last_pc, m_pc, m_sp;
|
unsigned int m_last_pc, m_pc, m_sp;
|
SPARSEMEM m_smem[5];
|
SPARSEMEM m_smem[5];
|
SPARSEMEM m_imem[5];
|
SPARSEMEM m_imem[5];
|
ZIPSTATE(void) : m_valid(false), m_last_pc_valid(false) {}
|
ZIPSTATE(void) : m_valid(false), m_last_pc_valid(false) {}
|
|
|
void step(void) {
|
void step(void) {
|
m_last_pc_valid = true;
|
m_last_pc_valid = true;
|
m_last_pc = m_pc;
|
m_last_pc = m_pc;
|
}
|
}
|
};
|
};
|
|
|
// No particular "parameters" need definition or redefinition here.
|
// No particular "parameters" need definition or redefinition here.
|
class ZIPPY : public DEVBUS {
|
class ZIPPY : public DEVBUS {
|
static const int MAXERR;
|
static const int MAXERR;
|
typedef DEVBUS::BUSW BUSW;
|
typedef DEVBUS::BUSW BUSW;
|
DEVBUS *m_fpga;
|
DEVBUS *m_fpga;
|
int m_cursor;
|
int m_cursor;
|
ZIPSTATE m_state;
|
ZIPSTATE m_state;
|
bool m_user_break, m_show_users_timers;
|
bool m_user_break, m_show_users_timers;
|
public:
|
public:
|
ZIPPY(DEVBUS *fpga) : m_fpga(fpga), m_cursor(0), m_user_break(false),
|
ZIPPY(DEVBUS *fpga) : m_fpga(fpga), m_cursor(0), m_user_break(false),
|
m_show_users_timers(false) {}
|
m_show_users_timers(false) {}
|
|
|
void read_raw_state(void) {
|
void read_raw_state(void) {
|
m_state.m_valid = false;
|
m_state.m_valid = false;
|
for(int i=0; i<16; i++)
|
for(int i=0; i<16; i++)
|
m_state.m_sR[i] = cmd_read(i);
|
m_state.m_sR[i] = cmd_read(i);
|
for(int i=0; i<16; i++)
|
for(int i=0; i<16; i++)
|
m_state.m_uR[i] = cmd_read(i+16);
|
m_state.m_uR[i] = cmd_read(i+16);
|
for(int i=0; i<20; i++)
|
for(int i=0; i<20; i++)
|
m_state.m_p[i] = cmd_read(i+32);
|
m_state.m_p[i] = cmd_read(i+32);
|
|
|
m_state.m_gie = (m_state.m_sR[14] & 0x020);
|
m_state.m_gie = (m_state.m_sR[14] & 0x020);
|
m_state.m_pc = (m_state.m_gie) ? (m_state.m_uR[15]):(m_state.m_sR[15]);
|
m_state.m_pc = (m_state.m_gie) ? (m_state.m_uR[15]):(m_state.m_sR[15]);
|
m_state.m_sp = (m_state.m_gie) ? (m_state.m_uR[13]):(m_state.m_sR[13]);
|
m_state.m_sp = (m_state.m_gie) ? (m_state.m_uR[13]):(m_state.m_sR[13]);
|
|
|
if (m_state.m_last_pc_valid)
|
if (m_state.m_last_pc_valid)
|
m_state.m_imem[0].m_a = m_state.m_last_pc;
|
m_state.m_imem[0].m_a = m_state.m_last_pc;
|
else
|
else
|
m_state.m_imem[0].m_a = m_state.m_pc - 1;
|
m_state.m_imem[0].m_a = m_state.m_pc - 1;
|
try {
|
try {
|
m_state.m_imem[0].m_d = readio(m_state.m_imem[0].m_a);
|
m_state.m_imem[0].m_d = readio(m_state.m_imem[0].m_a);
|
m_state.m_imem[0].m_valid = true;
|
m_state.m_imem[0].m_valid = true;
|
} catch(BUSERR be) {
|
} catch(BUSERR be) {
|
m_state.m_imem[0].m_valid = false;
|
m_state.m_imem[0].m_valid = false;
|
}
|
}
|
m_state.m_imem[1].m_a = m_state.m_pc;
|
m_state.m_imem[1].m_a = m_state.m_pc;
|
try {
|
try {
|
m_state.m_imem[1].m_d = readio(m_state.m_imem[1].m_a);
|
m_state.m_imem[1].m_d = readio(m_state.m_imem[1].m_a);
|
m_state.m_imem[1].m_valid = true;
|
m_state.m_imem[1].m_valid = true;
|
} catch(BUSERR be) {
|
} catch(BUSERR be) {
|
m_state.m_imem[1].m_valid = false;
|
m_state.m_imem[1].m_valid = false;
|
}
|
}
|
|
|
for(int i=1; i<4; i++) {
|
for(int i=1; i<4; i++) {
|
if (!m_state.m_imem[i].m_valid) {
|
if (!m_state.m_imem[i].m_valid) {
|
m_state.m_imem[i+1].m_valid = false;
|
m_state.m_imem[i+1].m_valid = false;
|
m_state.m_imem[i+1].m_a = m_state.m_imem[i].m_a+1;
|
m_state.m_imem[i+1].m_a = m_state.m_imem[i].m_a+1;
|
continue;
|
continue;
|
}
|
}
|
m_state.m_imem[i+1].m_a = zop_early_branch(
|
m_state.m_imem[i+1].m_a = zop_early_branch(
|
m_state.m_imem[i].m_a,
|
m_state.m_imem[i].m_a,
|
m_state.m_imem[i].m_d);
|
m_state.m_imem[i].m_d);
|
try {
|
try {
|
m_state.m_imem[i+1].m_d = readio(m_state.m_imem[i+1].m_a);
|
m_state.m_imem[i+1].m_d = readio(m_state.m_imem[i+1].m_a);
|
m_state.m_imem[i+1].m_valid = true;
|
m_state.m_imem[i+1].m_valid = true;
|
} catch(BUSERR be) {
|
} catch(BUSERR be) {
|
m_state.m_imem[i+1].m_valid = false;
|
m_state.m_imem[i+1].m_valid = false;
|
}
|
}
|
}
|
}
|
|
|
m_state.m_smem[0].m_a = m_state.m_sp;
|
m_state.m_smem[0].m_a = m_state.m_sp;
|
for(int i=1; i<5; i++)
|
for(int i=1; i<5; i++)
|
m_state.m_smem[i].m_a = m_state.m_smem[i-1].m_a+1;
|
m_state.m_smem[i].m_a = m_state.m_smem[i-1].m_a+1;
|
for(int i=0; i<5; i++) {
|
for(int i=0; i<5; i++) {
|
try {
|
try {
|
m_state.m_smem[i].m_d = readio(m_state.m_smem[i].m_a);
|
m_state.m_smem[i].m_d = readio(m_state.m_smem[i].m_a);
|
m_state.m_smem[i].m_valid = true;
|
m_state.m_smem[i].m_valid = true;
|
} catch(BUSERR be) {
|
} catch(BUSERR be) {
|
m_state.m_smem[i].m_valid = false;
|
m_state.m_smem[i].m_valid = false;
|
}
|
}
|
}
|
}
|
m_state.m_valid = true;
|
m_state.m_valid = true;
|
}
|
}
|
|
|
void kill(void) { m_fpga->kill(); }
|
void kill(void) { m_fpga->kill(); }
|
void close(void) { m_fpga->close(); }
|
void close(void) { m_fpga->close(); }
|
void writeio(const BUSW a, const BUSW v) { m_fpga->writeio(a, v); }
|
void writeio(const BUSW a, const BUSW v) { m_fpga->writeio(a, v); }
|
BUSW readio(const BUSW a) { return m_fpga->readio(a); }
|
BUSW readio(const BUSW a) { return m_fpga->readio(a); }
|
void readi(const BUSW a, const int len, BUSW *buf) {
|
void readi(const BUSW a, const int len, BUSW *buf) {
|
return m_fpga->readi(a, len, buf); }
|
return m_fpga->readi(a, len, buf); }
|
void readz(const BUSW a, const int len, BUSW *buf) {
|
void readz(const BUSW a, const int len, BUSW *buf) {
|
return m_fpga->readz(a, len, buf); }
|
return m_fpga->readz(a, len, buf); }
|
void writei(const BUSW a, const int len, const BUSW *buf) {
|
void writei(const BUSW a, const int len, const BUSW *buf) {
|
return m_fpga->writei(a, len, buf); }
|
return m_fpga->writei(a, len, buf); }
|
void writez(const BUSW a, const int len, const BUSW *buf) {
|
void writez(const BUSW a, const int len, const BUSW *buf) {
|
return m_fpga->writez(a, len, buf); }
|
return m_fpga->writez(a, len, buf); }
|
bool poll(void) { return m_fpga->poll(); }
|
bool poll(void) { return m_fpga->poll(); }
|
void usleep(unsigned ms) { m_fpga->usleep(ms); }
|
void usleep(unsigned ms) { m_fpga->usleep(ms); }
|
void wait(void) { m_fpga->wait(); }
|
void wait(void) { m_fpga->wait(); }
|
bool bus_err(void) const { return m_fpga->bus_err(); }
|
bool bus_err(void) const { return m_fpga->bus_err(); }
|
void reset_err(void) { m_fpga->reset_err(); }
|
void reset_err(void) { m_fpga->reset_err(); }
|
void clear(void) { m_fpga->clear(); }
|
void clear(void) { m_fpga->clear(); }
|
|
|
void reset(void) { writeio(R_ZIPCTRL, CPU_RESET|CPU_HALT); }
|
void reset(void) { writeio(R_ZIPCTRL, CPU_RESET|CPU_HALT); }
|
void step(void) { writeio(R_ZIPCTRL, CPU_STEP); m_state.step(); }
|
void step(void) { writeio(R_ZIPCTRL, CPU_STEP); m_state.step(); }
|
void go(void) { writeio(R_ZIPCTRL, CPU_GO); }
|
void go(void) { writeio(R_ZIPCTRL, CPU_GO); }
|
void halt(void) { writeio(R_ZIPCTRL, CPU_HALT); }
|
void halt(void) { writeio(R_ZIPCTRL, CPU_HALT); }
|
bool stalled(void) { return ((readio(R_ZIPCTRL)&CPU_STALL)==0); }
|
bool stalled(void) { return ((readio(R_ZIPCTRL)&CPU_STALL)==0); }
|
|
|
void show_user_timers(bool v) {
|
void show_user_timers(bool v) {
|
m_show_users_timers = v;
|
m_show_users_timers = v;
|
}
|
}
|
|
|
void showval(int y, int x, const char *lbl, unsigned int v, bool c) {
|
void showval(int y, int x, const char *lbl, unsigned int v, bool c) {
|
if (c)
|
if (c)
|
mvprintw(y,x, ">%s> 0x%08x<", lbl, v);
|
mvprintw(y,x, ">%s> 0x%08x<", lbl, v);
|
else
|
else
|
mvprintw(y,x, " %s: 0x%08x ", lbl, v);
|
mvprintw(y,x, " %s: 0x%08x ", lbl, v);
|
}
|
}
|
|
|
void dispreg(int y, int x, const char *n, unsigned int v, bool c) {
|
void dispreg(int y, int x, const char *n, unsigned int v, bool c) {
|
// 4,4,8,1 = 17 of 20, +2 = 18
|
// 4,4,8,1 = 17 of 20, +2 = 18
|
if (c)
|
if (c)
|
mvprintw(y, x, ">%s> 0x%08x<", n, v);
|
mvprintw(y, x, ">%s> 0x%08x<", n, v);
|
else
|
else
|
mvprintw(y, x, " %s: 0x%08x ", n, v);
|
mvprintw(y, x, " %s: 0x%08x ", n, v);
|
}
|
}
|
|
|
int showins(int y, const char *lbl, const unsigned int pcidx) {
|
int showins(int y, const char *lbl, const unsigned int pcidx) {
|
char la[80], lb[80];
|
char la[80], lb[80];
|
int r = y-1;
|
int r = y-1;
|
|
|
mvprintw(y, 0, "%s0x%08x", lbl, m_state.m_imem[pcidx].m_a);
|
mvprintw(y, 0, "%s0x%08x", lbl, m_state.m_imem[pcidx].m_a);
|
|
|
if (m_state.m_gie) attroff(A_BOLD);
|
if (m_state.m_gie) attroff(A_BOLD);
|
else attron(A_BOLD);
|
else attron(A_BOLD);
|
|
|
la[0] = '\0';
|
la[0] = '\0';
|
lb[0] = '\0';
|
lb[0] = '\0';
|
if (m_state.m_imem[pcidx].m_valid) {
|
if (m_state.m_imem[pcidx].m_valid) {
|
zipi_to_string(m_state.m_imem[pcidx].m_d, la, lb);
|
zipi_to_string(m_state.m_imem[pcidx].m_d, la, lb);
|
printw(" 0x%08x", m_state.m_imem[pcidx].m_d);
|
printw(" 0x%08x", m_state.m_imem[pcidx].m_d);
|
printw(" %-25s", la);
|
printw(" %-25s", la);
|
if (lb[0]) {
|
if (lb[0]) {
|
mvprintw(y-1, 0, "%s", lbl);
|
mvprintw(y-1, 0, "%s", lbl);
|
mvprintw(y-1, strlen(lbl)+10+3+8+2, "%-25s", lb);
|
mvprintw(y-1, strlen(lbl)+10+3+8+2, "%-25s", lb);
|
r--;
|
r--;
|
}
|
}
|
} else {
|
} else {
|
printw(" 0x-------- %-25s", "(Bus Error)");
|
printw(" 0x-------- %-25s", "(Bus Error)");
|
}
|
}
|
attroff(A_BOLD);
|
attroff(A_BOLD);
|
|
|
return r;
|
return r;
|
}
|
}
|
|
|
void showstack(int y, const char *lbl, const unsigned int idx) {
|
void showstack(int y, const char *lbl, const unsigned int idx) {
|
mvprintw(y, 27+26, "%s%08x ", lbl, m_state.m_smem[idx].m_a);
|
mvprintw(y, 27+26, "%s%08x ", lbl, m_state.m_smem[idx].m_a);
|
|
|
if (m_state.m_gie) attroff(A_BOLD);
|
if (m_state.m_gie) attroff(A_BOLD);
|
else attron(A_BOLD);
|
else attron(A_BOLD);
|
|
|
if (m_state.m_smem[idx].m_valid)
|
if (m_state.m_smem[idx].m_valid)
|
printw("0x%08x", m_state.m_smem[idx].m_d);
|
printw("0x%08x", m_state.m_smem[idx].m_d);
|
else
|
else
|
printw("(Bus Err)");
|
printw("(Bus Err)");
|
attroff(A_BOLD);
|
attroff(A_BOLD);
|
}
|
}
|
|
|
unsigned int cmd_read(unsigned int a) {
|
unsigned int cmd_read(unsigned int a) {
|
int errcount = 0;
|
int errcount = 0;
|
unsigned int s;
|
unsigned int s;
|
|
|
writeio(R_ZIPCTRL, CMD_HALT|(a&0x3f));
|
writeio(R_ZIPCTRL, CMD_HALT|(a&0x3f));
|
while((((s=readio(R_ZIPCTRL))&CPU_STALL)== 0)&&(errcount<MAXERR)
|
while((((s=readio(R_ZIPCTRL))&CPU_STALL)== 0)&&(errcount<MAXERR)
|
&&(!m_user_break))
|
&&(!m_user_break))
|
errcount++;
|
errcount++;
|
if (m_user_break) {
|
if (m_user_break) {
|
endwin();
|
endwin();
|
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
} else if (errcount >= MAXERR) {
|
} else if (errcount >= MAXERR) {
|
endwin();
|
endwin();
|
printf("ERR: errcount(%d) >= MAXERR on cmd_read(a=%2x)\n", errcount, a);
|
printf("ERR: errcount(%d) >= MAXERR on cmd_read(a=%2x)\n", errcount, a);
|
printf("ZIPCTRL = 0x%08x", s);
|
printf("ZIPCTRL = 0x%08x", s);
|
if ((s & 0x0200)==0) printf(" STALL");
|
if ((s & 0x0200)==0) printf(" STALL");
|
if (s & 0x0400) printf(" HALTED");
|
if (s & 0x0400) printf(" HALTED");
|
if ((s & 0x03000)==0x01000)
|
if ((s & 0x03000)==0x01000)
|
printf(" SW-HALT");
|
printf(" SW-HALT");
|
else {
|
else {
|
if (s & 0x01000) printf(" SLEEPING");
|
if (s & 0x01000) printf(" SLEEPING");
|
if (s & 0x02000) printf(" GIE(UsrMode)");
|
if (s & 0x02000) printf(" GIE(UsrMode)");
|
} printf("\n");
|
} printf("\n");
|
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
}
|
}
|
return readio(R_ZIPDATA);
|
return readio(R_ZIPDATA);
|
}
|
}
|
|
|
void cmd_write(unsigned int a, int v) {
|
void cmd_write(unsigned int a, int v) {
|
int errcount = 0;
|
int errcount = 0;
|
unsigned int s;
|
unsigned int s;
|
|
|
writeio(R_ZIPCTRL, CMD_HALT|(a&0x3f));
|
writeio(R_ZIPCTRL, CMD_HALT|(a&0x3f));
|
while((((s=readio(R_ZIPCTRL))&CPU_STALL)== 0)&&(errcount<MAXERR)
|
while((((s=readio(R_ZIPCTRL))&CPU_STALL)== 0)&&(errcount<MAXERR)
|
&&(!m_user_break))
|
&&(!m_user_break))
|
errcount++;
|
errcount++;
|
if (m_user_break) {
|
if (m_user_break) {
|
endwin();
|
endwin();
|
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
} else if (errcount >= MAXERR) {
|
} else if (errcount >= MAXERR) {
|
endwin();
|
endwin();
|
printf("ERR: errcount(%d) >= MAXERR on cmd_read(a=%2x)\n", errcount, a);
|
printf("ERR: errcount(%d) >= MAXERR on cmd_read(a=%2x)\n", errcount, a);
|
printf("ZIPCTRL = 0x%08x", s);
|
printf("ZIPCTRL = 0x%08x", s);
|
if ((s & 0x0200)==0) printf(" STALL");
|
if ((s & 0x0200)==0) printf(" STALL");
|
if (s & 0x0400) printf(" HALTED");
|
if (s & 0x0400) printf(" HALTED");
|
if ((s & 0x03000)==0x01000)
|
if ((s & 0x03000)==0x01000)
|
printf(" SW-HALT");
|
printf(" SW-HALT");
|
else {
|
else {
|
if (s & 0x01000) printf(" SLEEPING");
|
if (s & 0x01000) printf(" SLEEPING");
|
if (s & 0x02000) printf(" GIE(UsrMode)");
|
if (s & 0x02000) printf(" GIE(UsrMode)");
|
} printf("\n");
|
} printf("\n");
|
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
}
|
}
|
|
|
writeio(R_ZIPDATA, (unsigned int)v);
|
writeio(R_ZIPDATA, (unsigned int)v);
|
}
|
}
|
|
|
void read_state(void) {
|
void read_state(void) {
|
int ln= 0;
|
int ln= 0;
|
bool gie;
|
bool gie;
|
|
|
read_raw_state();
|
read_raw_state();
|
|
|
if (m_cursor < 0)
|
if (m_cursor < 0)
|
m_cursor = 0;
|
m_cursor = 0;
|
else if (m_cursor >= 44)
|
else if (m_cursor >= 44)
|
m_cursor = 43;
|
m_cursor = 43;
|
|
|
mvprintw(ln,0, "Peripherals");
|
mvprintw(ln,0, "Peripherals");
|
mvprintw(ln,30,"%-50s", "CPU State: ");
|
mvprintw(ln,30,"%-50s", "CPU State: ");
|
{
|
{
|
unsigned int v = readio(R_ZIPCTRL);
|
unsigned int v = readio(R_ZIPCTRL);
|
mvprintw(ln,41, "0x%08x ", v);
|
mvprintw(ln,41, "0x%08x ", v);
|
// if (v & 0x010000)
|
// if (v & 0x010000)
|
// printw("INT ");
|
// printw("INT ");
|
if ((v & 0x003000) == 0x03000)
|
if ((v & 0x003000) == 0x03000)
|
printw("Sleeping ");
|
printw("Sleeping ");
|
else if (v & 0x001000)
|
else if (v & 0x001000)
|
printw("Halted ");
|
printw("Halted ");
|
else if (v & 0x002000)
|
else if (v & 0x002000)
|
printw("User Mode ");
|
printw("User Mode ");
|
else
|
else
|
printw("Supervisor mode ");
|
printw("Supervisor mode ");
|
if (v& 0x0200) {
|
if (v& 0x0200) {
|
v = m_state.m_sR[15];
|
v = m_state.m_sR[15];
|
|
|
} else printw("Stalled ");
|
} else printw("Stalled ");
|
// if (v & 0x008000)
|
// if (v & 0x008000)
|
// printw("Break-Enabled ");
|
// printw("Break-Enabled ");
|
// if (v & 0x000080)
|
// if (v & 0x000080)
|
// printw("PIC Enabled ");
|
// printw("PIC Enabled ");
|
} ln++;
|
} ln++;
|
showval(ln, 0, "PIC ", m_state.m_p[0], (m_cursor==0));
|
showval(ln, 0, "PIC ", m_state.m_p[0], (m_cursor==0));
|
showval(ln,20, "WDT ", m_state.m_p[1], (m_cursor==1));
|
showval(ln,20, "WDT ", m_state.m_p[1], (m_cursor==1));
|
showval(ln,40, "WBUS", m_state.m_p[2], (m_cursor==2));
|
showval(ln,40, "WBUS", m_state.m_p[2], (m_cursor==2));
|
showval(ln,60, "PIC2", m_state.m_p[3], (m_cursor==3));
|
showval(ln,60, "PIC2", m_state.m_p[3], (m_cursor==3));
|
ln++;
|
ln++;
|
showval(ln, 0, "TMRA", m_state.m_p[4], (m_cursor==4));
|
showval(ln, 0, "TMRA", m_state.m_p[4], (m_cursor==4));
|
showval(ln,20, "TMRB", m_state.m_p[5], (m_cursor==5));
|
showval(ln,20, "TMRB", m_state.m_p[5], (m_cursor==5));
|
showval(ln,40, "TMRC", m_state.m_p[6], (m_cursor==6));
|
showval(ln,40, "TMRC", m_state.m_p[6], (m_cursor==6));
|
showval(ln,60, "JIF ", m_state.m_p[7], (m_cursor==7));
|
showval(ln,60, "JIF ", m_state.m_p[7], (m_cursor==7));
|
|
|
ln++;
|
ln++;
|
if (!m_show_users_timers) {
|
if (!m_show_users_timers) {
|
showval(ln, 0, "MTSK", m_state.m_p[12], (m_cursor==8));
|
showval(ln, 0, "MTSK", m_state.m_p[12], (m_cursor==8));
|
showval(ln,20, "MOST", m_state.m_p[13], (m_cursor==9));
|
showval(ln,20, "MOST", m_state.m_p[13], (m_cursor==9));
|
showval(ln,40, "MPST", m_state.m_p[14], (m_cursor==10));
|
showval(ln,40, "MPST", m_state.m_p[14], (m_cursor==10));
|
showval(ln,60, "MICT", m_state.m_p[15], (m_cursor==11));
|
showval(ln,60, "MICT", m_state.m_p[15], (m_cursor==11));
|
} else {
|
} else {
|
showval(ln, 0, "UTSK", m_state.m_p[ 8], (m_cursor==8));
|
showval(ln, 0, "UTSK", m_state.m_p[ 8], (m_cursor==8));
|
showval(ln,20, "UMST", m_state.m_p[ 9], (m_cursor==9));
|
showval(ln,20, "UMST", m_state.m_p[ 9], (m_cursor==9));
|
showval(ln,40, "UPST", m_state.m_p[10], (m_cursor==10));
|
showval(ln,40, "UPST", m_state.m_p[10], (m_cursor==10));
|
showval(ln,60, "UICT", m_state.m_p[11], (m_cursor==11));
|
showval(ln,60, "UICT", m_state.m_p[11], (m_cursor==11));
|
}
|
}
|
|
|
ln++;
|
ln++;
|
ln++;
|
ln++;
|
unsigned int cc = m_state.m_sR[14];
|
unsigned int cc = m_state.m_sR[14];
|
gie = (cc & 0x020);
|
gie = (cc & 0x020);
|
if (gie)
|
if (gie)
|
attroff(A_BOLD);
|
attroff(A_BOLD);
|
else
|
else
|
attron(A_BOLD);
|
attron(A_BOLD);
|
mvprintw(ln, 0, "Supervisor Registers");
|
mvprintw(ln, 0, "Supervisor Registers");
|
ln++;
|
ln++;
|
|
|
dispreg(ln, 0, "sR0 ", m_state.m_sR[0], (m_cursor==12));
|
dispreg(ln, 0, "sR0 ", m_state.m_sR[0], (m_cursor==12));
|
dispreg(ln,20, "sR1 ", m_state.m_sR[1], (m_cursor==13));
|
dispreg(ln,20, "sR1 ", m_state.m_sR[1], (m_cursor==13));
|
dispreg(ln,40, "sR2 ", m_state.m_sR[2], (m_cursor==14));
|
dispreg(ln,40, "sR2 ", m_state.m_sR[2], (m_cursor==14));
|
dispreg(ln,60, "sR3 ", m_state.m_sR[3], (m_cursor==15)); ln++;
|
dispreg(ln,60, "sR3 ", m_state.m_sR[3], (m_cursor==15)); ln++;
|
|
|
dispreg(ln, 0, "sR4 ", m_state.m_sR[4], (m_cursor==16));
|
dispreg(ln, 0, "sR4 ", m_state.m_sR[4], (m_cursor==16));
|
dispreg(ln,20, "sR5 ", m_state.m_sR[5], (m_cursor==17));
|
dispreg(ln,20, "sR5 ", m_state.m_sR[5], (m_cursor==17));
|
dispreg(ln,40, "sR6 ", m_state.m_sR[6], (m_cursor==18));
|
dispreg(ln,40, "sR6 ", m_state.m_sR[6], (m_cursor==18));
|
dispreg(ln,60, "sR7 ", m_state.m_sR[7], (m_cursor==19)); ln++;
|
dispreg(ln,60, "sR7 ", m_state.m_sR[7], (m_cursor==19)); ln++;
|
|
|
dispreg(ln, 0, "sR8 ", m_state.m_sR[ 8], (m_cursor==20));
|
dispreg(ln, 0, "sR8 ", m_state.m_sR[ 8], (m_cursor==20));
|
dispreg(ln,20, "sR9 ", m_state.m_sR[ 9], (m_cursor==21));
|
dispreg(ln,20, "sR9 ", m_state.m_sR[ 9], (m_cursor==21));
|
dispreg(ln,40, "sR10", m_state.m_sR[10], (m_cursor==22));
|
dispreg(ln,40, "sR10", m_state.m_sR[10], (m_cursor==22));
|
dispreg(ln,60, "sR11", m_state.m_sR[11], (m_cursor==23)); ln++;
|
dispreg(ln,60, "sR11", m_state.m_sR[11], (m_cursor==23)); ln++;
|
|
|
dispreg(ln, 0, "sR12", m_state.m_sR[12], (m_cursor==24));
|
dispreg(ln, 0, "sR12", m_state.m_sR[12], (m_cursor==24));
|
dispreg(ln,20, "sSP ", m_state.m_sR[13], (m_cursor==25));
|
dispreg(ln,20, "sSP ", m_state.m_sR[13], (m_cursor==25));
|
|
|
mvprintw(ln,40, "%ssCC :%s%s%s%s%s%s%s",
|
mvprintw(ln,40, "%ssCC :%s%s%s%s%s%s%s",
|
(m_cursor == 26)?">":" ",
|
(m_cursor == 26)?">":" ",
|
(cc&0x1000)?"FE":"",
|
(cc&0x1000)?"FE":"", // Floating point exception
|
(cc&0x0800)?"DE":"",
|
(cc&0x0800)?"DV":"", // Division by zero
|
(cc&0x0400)?"BE":"",
|
(cc&0x0400)?"BE":"", // Bus Error
|
(cc&0x0200)?"TP":"",
|
(cc&0x0200)?"TP":"", // Trap
|
(cc&0x0100)?"IL":"",
|
(cc&0x0100)?"IL":"", // Illegal instruction
|
(cc&0x0080)?"BK":"",
|
(cc&0x0080)?"BK":"", // Break
|
((gie==0)&&(cc&0x0010))?"HLT":"");
|
((gie==0)&&(cc&0x0010))?"HLT":""); // Halted
|
mvprintw(ln,54,"%s%s%s%s",
|
mvprintw(ln,54,"%s%s%s%s",
|
(cc&8)?"V":" ",
|
(cc&8)?"V":" ",
|
(cc&4)?"N":" ",
|
(cc&4)?"N":" ",
|
(cc&2)?"C":" ",
|
(cc&2)?"C":" ",
|
(cc&1)?"Z":" ");
|
(cc&1)?"Z":" ");
|
dispreg(ln,60, "sPC ", m_state.m_sR[15], (m_cursor==27));
|
dispreg(ln,60, "sPC ", m_state.m_sR[15], (m_cursor==27));
|
ln++;
|
ln++;
|
|
|
if (gie)
|
if (gie)
|
attron(A_BOLD);
|
attron(A_BOLD);
|
else
|
else
|
attroff(A_BOLD);
|
attroff(A_BOLD);
|
mvprintw(ln, 0, "User Registers"); ln++;
|
mvprintw(ln, 0, "User Registers"); ln++;
|
dispreg(ln, 0, "uR0 ", m_state.m_uR[0], (m_cursor==28));
|
dispreg(ln, 0, "uR0 ", m_state.m_uR[0], (m_cursor==28));
|
dispreg(ln,20, "uR1 ", m_state.m_uR[1], (m_cursor==29));
|
dispreg(ln,20, "uR1 ", m_state.m_uR[1], (m_cursor==29));
|
dispreg(ln,40, "uR2 ", m_state.m_uR[2], (m_cursor==30));
|
dispreg(ln,40, "uR2 ", m_state.m_uR[2], (m_cursor==30));
|
dispreg(ln,60, "uR3 ", m_state.m_uR[3], (m_cursor==31)); ln++;
|
dispreg(ln,60, "uR3 ", m_state.m_uR[3], (m_cursor==31)); ln++;
|
|
|
dispreg(ln, 0, "uR4 ", m_state.m_uR[4], (m_cursor==32));
|
dispreg(ln, 0, "uR4 ", m_state.m_uR[4], (m_cursor==32));
|
dispreg(ln,20, "uR5 ", m_state.m_uR[5], (m_cursor==33));
|
dispreg(ln,20, "uR5 ", m_state.m_uR[5], (m_cursor==33));
|
dispreg(ln,40, "uR6 ", m_state.m_uR[6], (m_cursor==34));
|
dispreg(ln,40, "uR6 ", m_state.m_uR[6], (m_cursor==34));
|
dispreg(ln,60, "uR7 ", m_state.m_uR[7], (m_cursor==35)); ln++;
|
dispreg(ln,60, "uR7 ", m_state.m_uR[7], (m_cursor==35)); ln++;
|
|
|
dispreg(ln, 0, "uR8 ", m_state.m_uR[8], (m_cursor==36));
|
dispreg(ln, 0, "uR8 ", m_state.m_uR[8], (m_cursor==36));
|
dispreg(ln,20, "uR9 ", m_state.m_uR[9], (m_cursor==37));
|
dispreg(ln,20, "uR9 ", m_state.m_uR[9], (m_cursor==37));
|
dispreg(ln,40, "uR10", m_state.m_uR[10], (m_cursor==38));
|
dispreg(ln,40, "uR10", m_state.m_uR[10], (m_cursor==38));
|
dispreg(ln,60, "uR11", m_state.m_uR[11], (m_cursor==39)); ln++;
|
dispreg(ln,60, "uR11", m_state.m_uR[11], (m_cursor==39)); ln++;
|
|
|
dispreg(ln, 0, "uR12", m_state.m_uR[12], (m_cursor==40));
|
dispreg(ln, 0, "uR12", m_state.m_uR[12], (m_cursor==40));
|
dispreg(ln,20, "uSP ", m_state.m_uR[13], (m_cursor==41));
|
dispreg(ln,20, "uSP ", m_state.m_uR[13], (m_cursor==41));
|
cc = m_state.m_uR[14];
|
cc = m_state.m_uR[14];
|
mvprintw(ln,40, "%suCC :%s%s%s%s%s%s%s",
|
mvprintw(ln,40, "%suCC :%s%s%s%s%s%s%s",
|
(m_cursor == 42)?">":" ",
|
(m_cursor == 42)?">":" ",
|
(cc&0x1000)?"FE":"",
|
(cc&0x1000)?"FE":"", // Floating point Exception
|
(cc&0x0800)?"DE":"",
|
(cc&0x0800)?"DV":"", // Division by zero
|
(cc&0x0400)?"BE":"",
|
(cc&0x0400)?"BE":"", // Bus Error
|
(cc&0x0200)?"TP":"",
|
(cc&0x0200)?"TP":"", // Trap
|
(cc&0x0100)?"IL":"",
|
(cc&0x0100)?"IL":"", // Illegal instruction
|
(cc&0x0040)?"ST":"",
|
(cc&0x0040)?"ST":"", // Single-step
|
((gie)&&(cc&0x0010))?"SL":"");
|
((gie)&&(cc&0x0010))?"SL":""); // Sleep
|
mvprintw(ln,54,"%s%s%s%s",
|
mvprintw(ln,54,"%s%s%s%s",
|
(cc&8)?"V":" ",
|
(cc&8)?"V":" ",
|
(cc&4)?"N":" ",
|
(cc&4)?"N":" ",
|
(cc&2)?"C":" ",
|
(cc&2)?"C":" ",
|
(cc&1)?"Z":" ");
|
(cc&1)?"Z":" ");
|
dispreg(ln,60, "uPC ", m_state.m_uR[15], (m_cursor==43));
|
dispreg(ln,60, "uPC ", m_state.m_uR[15], (m_cursor==43));
|
|
|
attroff(A_BOLD);
|
attroff(A_BOLD);
|
ln+=3;
|
ln+=3;
|
|
|
showins(ln+4, " ", 0);
|
showins(ln+4, " ", 0);
|
{
|
{
|
int lclln = ln+3;
|
int lclln = ln+3;
|
for(int i=1; i<5; i++)
|
for(int i=1; i<5; i++)
|
lclln = showins(lclln, (i==1)?">":" ", i);
|
lclln = showins(lclln, (i==1)?">":" ", i);
|
for(int i=0; i<5; i++)
|
for(int i=0; i<5; i++)
|
showstack(ln+i, (i==0)?">":" ", i);
|
showstack(ln+i, (i==0)?">":" ", i);
|
}
|
}
|
}
|
}
|
|
|
void cursor_up(void) {
|
void cursor_up(void) {
|
if (m_cursor > 3)
|
if (m_cursor > 3)
|
m_cursor -= 4;
|
m_cursor -= 4;
|
} void cursor_down(void) {
|
} void cursor_down(void) {
|
if (m_cursor < 40)
|
if (m_cursor < 40)
|
m_cursor += 4;
|
m_cursor += 4;
|
} void cursor_left(void) {
|
} void cursor_left(void) {
|
if (m_cursor > 0)
|
if (m_cursor > 0)
|
m_cursor--;
|
m_cursor--;
|
else m_cursor = 43;
|
else m_cursor = 43;
|
} void cursor_right(void) {
|
} void cursor_right(void) {
|
if (m_cursor < 43)
|
if (m_cursor < 43)
|
m_cursor++;
|
m_cursor++;
|
else m_cursor = 0;
|
else m_cursor = 0;
|
}
|
}
|
|
|
int cursor(void) { return m_cursor; }
|
int cursor(void) { return m_cursor; }
|
};
|
};
|
|
|
const int ZIPPY::MAXERR = 100000;
|
const int ZIPPY::MAXERR = 100000;
|
|
|
FPGA *m_fpga;
|
FPGA *m_fpga;
|
|
|
void get_value(ZIPPY *zip) {
|
void get_value(ZIPPY *zip) {
|
int wy, wx, ra;
|
int wy, wx, ra;
|
int c = zip->cursor();
|
int c = zip->cursor();
|
|
|
wx = (c & 0x03) * 20 + 9 + 1;
|
wx = (c & 0x03) * 20 + 9 + 1;
|
wy = (c >> 2);
|
wy = (c >> 2);
|
if (wy >= 3+4)
|
if (wy >= 3+4)
|
wy++;
|
wy++;
|
if (wy > 3)
|
if (wy > 3)
|
wy += 2;
|
wy += 2;
|
wy++;
|
wy++;
|
|
|
if (c >= 12)
|
if (c >= 12)
|
ra = c - 12;
|
ra = c - 12;
|
else
|
else
|
ra = c + 32;
|
ra = c + 32;
|
|
|
bool done = false;
|
bool done = false;
|
char str[16];
|
char str[16];
|
int pos = 0; str[pos] = '\0';
|
int pos = 0; str[pos] = '\0';
|
attron(A_NORMAL | A_UNDERLINE);
|
attron(A_NORMAL | A_UNDERLINE);
|
mvprintw(wy, wx, "%-8s", "");
|
mvprintw(wy, wx, "%-8s", "");
|
while(!done) {
|
while(!done) {
|
int chv = getch();
|
int chv = getch();
|
switch(chv) {
|
switch(chv) {
|
case KEY_ESCAPE:
|
case KEY_ESCAPE:
|
pos = 0; str[pos] = '\0'; done = true;
|
pos = 0; str[pos] = '\0'; done = true;
|
break;
|
break;
|
case KEY_RETURN: case KEY_ENTER: case KEY_UP: case KEY_DOWN:
|
case KEY_RETURN: case KEY_ENTER: case KEY_UP: case KEY_DOWN:
|
done = true;
|
done = true;
|
break;
|
break;
|
case KEY_LEFT: case KEY_BACKSPACE:
|
case KEY_LEFT: case KEY_BACKSPACE:
|
if (pos > 0) pos--;
|
if (pos > 0) pos--;
|
break;
|
break;
|
case KEY_CLEAR:
|
case KEY_CLEAR:
|
pos = 0;
|
pos = 0;
|
break;
|
break;
|
case '0': case ' ': str[pos++] = '0'; break;
|
case '0': case ' ': str[pos++] = '0'; break;
|
case '1': str[pos++] = '1'; break;
|
case '1': str[pos++] = '1'; break;
|
case '2': str[pos++] = '2'; break;
|
case '2': str[pos++] = '2'; break;
|
case '3': str[pos++] = '3'; break;
|
case '3': str[pos++] = '3'; break;
|
case '4': str[pos++] = '4'; break;
|
case '4': str[pos++] = '4'; break;
|
case '5': str[pos++] = '5'; break;
|
case '5': str[pos++] = '5'; break;
|
case '6': str[pos++] = '6'; break;
|
case '6': str[pos++] = '6'; break;
|
case '7': str[pos++] = '7'; break;
|
case '7': str[pos++] = '7'; break;
|
case '8': str[pos++] = '8'; break;
|
case '8': str[pos++] = '8'; break;
|
case '9': str[pos++] = '9'; break;
|
case '9': str[pos++] = '9'; break;
|
case 'A': case 'a': str[pos++] = 'A'; break;
|
case 'A': case 'a': str[pos++] = 'A'; break;
|
case 'B': case 'b': str[pos++] = 'B'; break;
|
case 'B': case 'b': str[pos++] = 'B'; break;
|
case 'C': case 'c': str[pos++] = 'C'; break;
|
case 'C': case 'c': str[pos++] = 'C'; break;
|
case 'D': case 'd': str[pos++] = 'D'; break;
|
case 'D': case 'd': str[pos++] = 'D'; break;
|
case 'E': case 'e': str[pos++] = 'E'; break;
|
case 'E': case 'e': str[pos++] = 'E'; break;
|
case 'F': case 'f': str[pos++] = 'F'; break;
|
case 'F': case 'f': str[pos++] = 'F'; break;
|
}
|
}
|
|
|
if (pos > 8)
|
if (pos > 8)
|
pos = 8;
|
pos = 8;
|
str[pos] = '\0';
|
str[pos] = '\0';
|
|
|
attron(A_NORMAL | A_UNDERLINE);
|
attron(A_NORMAL | A_UNDERLINE);
|
mvprintw(wy, wx, "%-8s", str);
|
mvprintw(wy, wx, "%-8s", str);
|
if (pos > 0) {
|
if (pos > 0) {
|
attron(A_NORMAL | A_UNDERLINE | A_BLINK);
|
attron(A_NORMAL | A_UNDERLINE | A_BLINK);
|
mvprintw(wy, wx+pos-1, "%c", str[pos-1]);
|
mvprintw(wy, wx+pos-1, "%c", str[pos-1]);
|
}
|
}
|
attrset(A_NORMAL);
|
attrset(A_NORMAL);
|
}
|
}
|
|
|
if (pos > 0) {
|
if (pos > 0) {
|
int v;
|
int v;
|
v = strtoul(str, NULL, 16);
|
v = strtoul(str, NULL, 16);
|
zip->cmd_write(ra, v);
|
zip->cmd_write(ra, v);
|
}
|
}
|
}
|
}
|
|
|
void on_sigint(int v) {
|
void on_sigint(int v) {
|
endwin();
|
endwin();
|
|
|
fprintf(stderr, "Interrupted!\n");
|
fprintf(stderr, "Interrupted!\n");
|
exit(-2);
|
exit(-2);
|
}
|
}
|
|
|
void stall_screen(void) {
|
void stall_screen(void) {
|
erase();
|
erase();
|
mvprintw(0,0, "CPU is stalled. (Q to quit)\n");
|
mvprintw(0,0, "CPU is stalled. (Q to quit)\n");
|
}
|
}
|
|
|
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
// FPGAOPEN(m_fpga);
|
// FPGAOPEN(m_fpga);
|
ZIPPY *zip; //
|
ZIPPY *zip; //
|
|
|
int skp=0, port = FPGAPORT;
|
int skp=0, port = FPGAPORT;
|
bool use_usb = true;
|
bool use_usb = true;
|
|
|
skp=1;
|
skp=1;
|
for(int argn=0; argn<argc-skp; argn++) {
|
for(int argn=0; argn<argc-skp; argn++) {
|
if (argv[argn+skp][0] == '-') {
|
if (argv[argn+skp][0] == '-') {
|
if (argv[argn+skp][1] == 'u')
|
if (argv[argn+skp][1] == 'u')
|
use_usb = true;
|
use_usb = true;
|
else if (argv[argn+skp][1] == 'p') {
|
else if (argv[argn+skp][1] == 'p') {
|
use_usb = false;
|
use_usb = false;
|
if (isdigit(argv[argn+skp][2]))
|
if (isdigit(argv[argn+skp][2]))
|
port = atoi(&argv[argn+skp][2]);
|
port = atoi(&argv[argn+skp][2]);
|
}
|
}
|
skp++; argn--;
|
skp++; argn--;
|
} else
|
} else
|
argv[argn] = argv[argn+skp];
|
argv[argn] = argv[argn+skp];
|
} argc -= skp;
|
} argc -= skp;
|
|
|
if (use_usb)
|
if (use_usb)
|
m_fpga = new FPGA(new USBI());
|
m_fpga = new FPGA(new USBI());
|
else
|
else
|
m_fpga = new FPGA(new NETCOMMS(FPGAHOST, port));
|
m_fpga = new FPGA(new NETCOMMS(FPGAHOST, port));
|
zip = new ZIPPY(m_fpga);
|
zip = new ZIPPY(m_fpga);
|
|
|
|
|
initscr();
|
initscr();
|
raw();
|
raw();
|
noecho();
|
noecho();
|
keypad(stdscr, true);
|
keypad(stdscr, true);
|
|
|
signal(SIGINT, on_sigint);
|
signal(SIGINT, on_sigint);
|
|
|
int chv;
|
int chv;
|
bool done = false;
|
bool done = false;
|
|
|
zip->halt();
|
zip->halt();
|
for(int i=0; (i<5)&&(zip->stalled()); i++)
|
for(int i=0; (i<5)&&(zip->stalled()); i++)
|
;
|
;
|
if (!zip->stalled())
|
if (!zip->stalled())
|
zip->read_state();
|
zip->read_state();
|
else
|
else
|
stall_screen();
|
stall_screen();
|
while((!done)&&(!gbl_err)) {
|
while((!done)&&(!gbl_err)) {
|
chv = getch();
|
chv = getch();
|
switch(chv) {
|
switch(chv) {
|
case 'g': case 'G':
|
case 'g': case 'G':
|
m_fpga->writeio(R_ZIPCTRL, CPU_GO);
|
m_fpga->writeio(R_ZIPCTRL, CPU_GO);
|
// We just released the CPU, so we're now done.
|
// We just released the CPU, so we're now done.
|
done = true;
|
done = true;
|
break;
|
break;
|
case 'l': case 'L': case CTRL('L'):
|
case 'l': case 'L': case CTRL('L'):
|
redrawwin(stdscr);
|
redrawwin(stdscr);
|
case 'm': case 'M':
|
case 'm': case 'M':
|
zip->show_user_timers(false);
|
zip->show_user_timers(false);
|
break;
|
break;
|
case 'q': case 'Q': case CTRL('C'):
|
case 'q': case 'Q': case CTRL('C'):
|
case KEY_CANCEL: case KEY_CLOSE: case KEY_EXIT:
|
case KEY_CANCEL: case KEY_CLOSE: case KEY_EXIT:
|
case KEY_ESCAPE:
|
case KEY_ESCAPE:
|
done = true;
|
done = true;
|
break;
|
break;
|
case 'r': case 'R':
|
case 'r': case 'R':
|
zip->reset();
|
zip->reset();
|
erase();
|
erase();
|
break;
|
break;
|
case 't': case 'T':
|
case 't': case 'T':
|
case 's': case 'S':
|
case 's': case 'S':
|
zip->step();
|
zip->step();
|
break;
|
break;
|
case 'u': case 'U':
|
case 'u': case 'U':
|
zip->show_user_timers(true);
|
zip->show_user_timers(true);
|
break;
|
break;
|
case '\r': case '\n':
|
case '\r': case '\n':
|
case KEY_IC: case KEY_ENTER:
|
case KEY_IC: case KEY_ENTER:
|
get_value(zip);
|
get_value(zip);
|
break;
|
break;
|
case KEY_UP:
|
case KEY_UP:
|
zip->cursor_up();
|
zip->cursor_up();
|
break;
|
break;
|
case KEY_DOWN:
|
case KEY_DOWN:
|
zip->cursor_down();
|
zip->cursor_down();
|
break;
|
break;
|
case KEY_LEFT:
|
case KEY_LEFT:
|
zip->cursor_left();
|
zip->cursor_left();
|
break;
|
break;
|
case KEY_RIGHT:
|
case KEY_RIGHT:
|
zip->cursor_right();
|
zip->cursor_right();
|
break;
|
break;
|
case ERR: case KEY_CLEAR:
|
case ERR: case KEY_CLEAR:
|
default:
|
default:
|
;
|
;
|
}
|
}
|
|
|
if ((done)||(gbl_err))
|
if ((done)||(gbl_err))
|
break;
|
break;
|
else if (zip->stalled())
|
else if (zip->stalled())
|
stall_screen();
|
stall_screen();
|
else
|
else
|
zip->read_state();
|
zip->read_state();
|
}
|
}
|
|
|
endwin();
|
endwin();
|
|
|
if (gbl_err) {
|
if (gbl_err) {
|
printf("Killed on error: could not access bus!\n");
|
printf("Killed on error: could not access bus!\n");
|
exit(-2);
|
exit(-2);
|
}
|
}
|
}
|
}
|
|
|
|
|