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

Subversion Repositories xulalx25soc

[/] [xulalx25soc/] [trunk/] [sw/] [cpuscope.cpp] - Diff between revs 105 and 113

Show entire file | Details | Blame | View Log

Rev 105 Rev 113
Line 47... Line 47...
 
 
#include "usbi.h"
#include "usbi.h"
#include "port.h"
#include "port.h"
#include "llcomms.h"
#include "llcomms.h"
#include "regdefs.h"
#include "regdefs.h"
 
#include "scopecls.h"
 
 
#define WBSCOPE         R_CPUSCOPE
#define WBSCOPE         R_CPUSCOPE
#define WBSCOPEDATA     R_CPUSCOPED
#define WBSCOPEDATA     R_CPUSCOPED
 
 
#include "zopcodes.h"
#include "zopcodes.h"
Line 76... Line 77...
        unsigned r = brev(v&0x0ff);
        unsigned r = brev(v&0x0ff);
        r |= brev((v>>8)&0x0ff)<<8;
        r |= brev((v>>8)&0x0ff)<<8;
        return r;
        return r;
}
}
 
 
void    decode(DEVBUS::BUSW val) {
const char *opcodestr[] = {
 
        "SUB","AND","ADD","OR","XOR","LSR","LSL","ASR",
 
        "MPY","LDILO","MPYUHI","MPYSHI","BREV","POPC","ROL","MOV",
 
        "CMP","TEST","LOD","STO","DIVU","DIVS","LDI","LDI",
 
        "NOOP","BREAK","LOCK","(rsrvd)","(rsrvd)","(rsrvd)","(rsrvd)","(rsrvd)"
 
};
 
const char *regstr[] = {
 
        "R0","R1","R2","R3","R4","R5","R6","R7","R8","R9","RA","RB","RC",
 
        "SP","CC","PC"
 
};
 
 
 
class   CPUSCOPE : public SCOPE {
 
public:
 
        CPUSCOPE(FPGA *fpga, unsigned addr, bool vecread)
 
                : SCOPE(fpga, addr, false, false) {};
 
        ~CPUSCOPE(void) {}
 
        virtual void    decode(DEVBUS::BUSW val) const {
 
                int     i_wb_err, gie, alu_illegal, newpc, mem_busy, stb, we,
 
                        maddr, ins, pfval, alu_pc;
 
                int     pfcyc, pfstb, pfaddr;
 
 
 
                i_wb_err    = (val>>31)&1;
 
                gie         = (val>>30)&1;
 
                alu_illegal = (val>>29)&1;
 
                newpc       = (val>>28)&1;
 
                mem_busy    = (val>>27)&1;
 
                stb         = (val>>26)&1;
 
                we          = (val>>25)&1;
 
                maddr       = (val>>16)&0x01ff;
 
                ins         = (val>>16)&0x07ff;
 
                pfval       = (val>>15)&1;
 
                pfcyc       = (val>>14)&1;
 
                pfstb       = (val>>13)&1;
 
                pfaddr      = (val & 0x1fff);
 
                alu_pc      = (val & 0x7fff);
 
 
 
                printf("%s%s%s%s%s ",
 
                        (i_wb_err)?"E ":"  ",
 
                        (gie)?"GIE":"   ",
 
                        (alu_illegal)?"ILL":"   ",
 
                        (newpc)?"NPC":"   ",
 
                        (mem_busy)?"MBSY":"    ");
 
                if (mem_busy)
 
                        printf("M:%s%s@..%4x", (stb)?"STB":"   ",(we)?"W":"R",
 
                                maddr);
 
                else {
 
                        int     inreg = (ins>>6)&0x0f;
 
                        int     opcode = ((ins>>1)&0x1f);
 
                        const char *incode = opcodestr[opcode];
 
                        printf("I:%03x %5s,%s", (ins<<1), incode, regstr[inreg]);
 
                }
 
 
 
                if (pfval)
 
                        printf(" V: %04x%4s", alu_pc, "");
 
                else
 
                        printf(" %s%s@%04x",
 
                                (pfcyc)?"CYC":"   ",
 
                                (pfstb)?"STB":"   ",
 
                                pfaddr);
}
}
 
};
 
 
int main(int argc, char **argv) {
int main(int argc, char **argv) {
        int     skp=0, port = FPGAPORT;
        int     skp=0, port = FPGAPORT;
        bool    use_usb = true;
        bool    use_usb = true;
 
 
        skp=1;
        skp=1;
Line 106... Line 166...
                m_fpga = new FPGA(new NETCOMMS(FPGAHOST, port));
                m_fpga = new FPGA(new NETCOMMS(FPGAHOST, port));
 
 
        signal(SIGSTOP, closeup);
        signal(SIGSTOP, closeup);
        signal(SIGHUP, closeup);
        signal(SIGHUP, closeup);
 
 
        unsigned        v, lgln, scoplen;
        CPUSCOPE *scope = new CPUSCOPE(m_fpga, WBSCOPE, false);
        v = m_fpga->readio(WBSCOPE);
        if (!scope->ready()) {
        if (0x60000000 != (v & 0x60000000)) {
 
                printf("Scope is not yet ready:\n");
                printf("Scope is not yet ready:\n");
                printf("\tRESET:\t\t%s\n", (v&0x80000000)?"Ongoing":"Complete");
                scope->decode_control();
                printf("\tSTOPPED:\t%s\n", (v&0x40000000)?"Yes":"No");
        } else
                printf("\tTRIGGERED:\t%s\n", (v&0x20000000)?"Yes":"No");
                scope->read();
                printf("\tPRIMED:\t\t%s\n", (v&0x10000000)?"Yes":"No");
 
                printf("\tMANUAL:\t\t%s\n", (v&0x08000000)?"Yes":"No");
 
                printf("\tDISABLED:\t%s\n", (v&0x04000000)?"Yes":"No");
 
                printf("\tZERO:\t\t%s\n", (v&0x02000000)?"Yes":"No");
 
                exit(0);
 
        } else printf("SCOPD = %08x\n", v);
 
 
 
        lgln = (v>>20) & 0x1f;
 
        scoplen = (1<<lgln);
 
 
 
        DEVBUS::BUSW    *buf;
 
        buf = new DEVBUS::BUSW[scoplen];
 
 
 
        bool    compressed = false, vector_read = true;
 
        DEVBUS::BUSW    addrv = 0;
 
 
 
        if (vector_read) {
 
                m_fpga->readz(WBSCOPEDATA, scoplen, buf);
 
        } else {
 
                for(unsigned int i=0; i<scoplen; i++)
 
                        buf[i] = m_fpga->readio(WBSCOPEDATA);
 
        }
 
 
 
        if(compressed) {
 
                for(int i=0; i<(int)scoplen; i++) {
 
                        if ((buf[i]>>31)&1) {
 
                                addrv += (buf[i]&0x7fffffff);
 
                                printf(" ** \n");
 
                                continue;
 
                        }
 
                        printf("%10d %08x: ", addrv++, buf[i]);
 
                        decode(buf[i]);
 
                        printf("\n");
 
                }
 
        } else {
 
                for(int i=0; i<(int)scoplen; i++) {
 
                        if ((i>0)&&(buf[i] == buf[i-1])&&(i<(int)(scoplen-1))) {
 
                                if ((i>2)&&(buf[i] != buf[i-2]))
 
                                        printf(" **** ****\n");
 
                                continue;
 
                        } printf("%9d %08x: ", i, buf[i]);
 
                        decode(buf[i]);
 
                        printf("\n");
 
                }
 
        }
 
 
 
        if (m_fpga->poll()) {
 
                printf("FPGA was interrupted\n");
 
                m_fpga->clear();
 
                m_fpga->writeio(R_ICONTROL, SCOPEN);
 
        }
 
 
 
        delete[] buf;
 
        delete  m_fpga;
        delete  m_fpga;
}
}
 
 
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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