OpenCores
URL https://opencores.org/ocsvn/openarty/openarty/trunk

Subversion Repositories openarty

[/] [openarty/] [trunk/] [sw/] [host/] [zipdbg.cpp] - Diff between revs 31 and 51

Show entire file | Details | Blame | View Log

Rev 31 Rev 51
Line 1... Line 1...
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
//
// Filename:    
// Filename:    zipdbg.cpp
//
//
// Project:     OpenArty, an entirely open SoC based upon the Arty platform
// Project:     OpenArty, an entirely open SoC based upon the Arty platform
//
//
// Project:     XuLA2-LX25 SoC based upon the ZipCPU
 
//
 
// Purpose:     Provide a debugger to step through the ZipCPU assembler,
// Purpose:     Provide a debugger to step through the ZipCPU assembler,
//              evaluate the ZipCPU's current state, modify registers as(if)
//              evaluate the ZipCPU's current state, modify registers as(if)
//      needed, etc.  All of this through the UART port of the Arty board.
//      needed, etc.  All of this through the UART port of the Arty board.
//
//
//
//
// Creator:     Dan Gisselquist, Ph.D.
// Creator:     Dan Gisselquist, Ph.D.
//              Gisselquist Technology, LLC
//              Gisselquist Technology, LLC
//
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
//
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
// Copyright (C) 2015-2017, 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.
Line 27... Line 25...
// 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.
//
//
// You should have received a copy of the GNU General Public License along
// You should have received a copy of the GNU General Public License along
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
// with this program.  (It's in the $(ROOT)/doc directory.  Run make with no
// target there if the PDF file isn't present.)  If not, see
// target there if the PDF file isn't present.)  If not, see
// <http://www.gnu.org/licenses/> for a copy.
// <http://www.gnu.org/licenses/> for a copy.
//
//
// 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:
 
//      - No ability to verify CPU functionality (3rd party simulator)
 
//      - 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 "devbus.h"
#include "devbus.h"
#include "regdefs.h"
#include "regdefs.h"
 
 
#include "port.h"
#include "port.h"
 
 
Line 117... Line 119...
                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 - 4;
                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;
Line 135... Line 137...
                }
                }
 
 
                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+4;
                                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);
Line 151... Line 153...
                        }
                        }
                }
                }
 
 
                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+4;
                for(int i=0; i<5; i++) {
                for(int i=0; i<5; i++) {
                        m_state.m_smem[i].m_valid = true;
                        m_state.m_smem[i].m_valid = true;
                        if (m_state.m_smem[i].m_valid)
                        if (m_state.m_smem[i].m_valid)
                        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);
Line 213... Line 215...
                        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, bool ignore_a) {
                char    la[80], lb[80];
                char    la[80], lb[80];
                int     r = y-1;
                int     r = y-1, bln = r;
 
 
                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_double_string(m_state.m_imem[pcidx].m_a,
 
                                m_state.m_imem[pcidx].m_d, la, lb);
 
                        if ((lb[0]=='\0')||(!ignore_a)) {
                        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(bln, 0, "%11s", "");
                                mvprintw(y-1, strlen(lbl)+10+3+8+2, "%-25s", lb);
                                mvprintw(bln, strlen(lbl)+10+3+8+2, "%-25s", lb);
                                r--;
                                r--;
 
                        } else {
 
                                mvprintw(y-1, 0, "%46s", "");
                        }
                        }
                } else {
                } else {
                        printw(" 0x--------  %-25s", "(Bus Error)");
                        printw(" 0x--------  %-25s", "(Bus Error)");
                }
                }
                attroff(A_BOLD);
                attroff(A_BOLD);
Line 469... Line 475...
                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, true);
                {
                {
                        int     lclln = ln+3;
                        int     lclln = ln+3;
                        for(int i=1; i<5; i++)
                        for(int i=1; ((i<5)&&(lclln > ln)); i++)
                                lclln = showins(lclln, (i==1)?">":" ", i);
                                lclln = showins(lclln, (i==1)?">":" ", i, false);
                        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);
                }
                }
        }
        }
 
 
Line 593... Line 599...
 
 
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;
 
 
 
        FPGAOPEN(m_fpga);
        FPGAOPEN(m_fpga);
        zip = new ZIPPY(m_fpga);
        zip = new ZIPPY(m_fpga);
 
 
 
        try {
 
 
        initscr();
        initscr();
        raw();
        raw();
        noecho();
        noecho();
        keypad(stdscr, true);
        keypad(stdscr, true);
Line 676... Line 681...
                else if (zip->stalled())
                else if (zip->stalled())
                        stall_screen();
                        stall_screen();
                else
                else
                        zip->read_state();
                        zip->read_state();
        }
        }
 
        } catch(const char *err) {
 
                fprintf(stderr, "ERR: Caught exception -- %s", err);
 
        } catch(...) {
 
                fprintf(stderr, "ERR: Caught anonymous exception!!\n");
 
        }
 
 
        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");

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.