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

Subversion Repositories xulalx25soc

[/] [xulalx25soc/] [trunk/] [sw/] [cpuscope.cpp] - Blame information for rev 45

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 dgisselq
//
2
//
3
// Filename:    cpuscope.cpp
4
//
5
// Project:     FPGA library development (Basys-3 development board)
6
//
7
// Purpose:     To read out, and decompose, the results of the wishbone scope
8
//              as applied to the ICAPE2 interaction.
9
//
10
// Creator:     Dan Gisselquist
11
//              Gisselquist Tecnology, LLC
12
//
13
// Copyright:   2015
14
//
15
//
16
#include <stdio.h>
17
#include <stdlib.h>
18
#include <unistd.h>
19
#include <strings.h>
20
#include <ctype.h>
21
#include <string.h>
22
#include <signal.h>
23
#include <assert.h>
24
 
25
#include "usbi.h"
26
#include "port.h"
27
#include "llcomms.h"
28
#include "regdefs.h"
29
 
30
#define WBSCOPE         R_CPUSCOPE
31
#define WBSCOPEDATA     R_CPUSCOPED
32
 
33
#include "zopcodes.h"
34
 
35
FPGA    *m_fpga;
36
void    closeup(int v) {
37
        m_fpga->kill();
38
        exit(0);
39
}
40
 
41
unsigned brev(const unsigned v) {
42
        unsigned int r, a;
43
        a = v;
44
        r = 0;
45
        for(int i=0; i<8; i++) {
46
                r <<= 1;
47
                r |= (a&1);
48
                a >>= 1;
49
        } return r;
50
}
51
 
52
unsigned wrev(const unsigned v) {
53
        unsigned r = brev(v&0x0ff);
54
        r |= brev((v>>8)&0x0ff)<<8;
55
        return r;
56
}
57
 
58
int main(int argc, char **argv) {
59
        FPGAOPEN(m_fpga);
60
 
61
        signal(SIGSTOP, closeup);
62
        signal(SIGHUP, closeup);
63
 
64
        unsigned        v, lgln, scoplen;
65
        v = m_fpga->readio(WBSCOPE);
66
        if (0x60000000 != (v & 0x60000000)) {
67
                printf("Scope is not yet ready:\n");
68
                printf("\tRESET:\t\t%s\n", (v&0x80000000)?"Ongoing":"Complete");
69
                printf("\tSTOPPED:\t%s\n", (v&0x40000000)?"Yes":"No");
70
                printf("\tTRIGGERED:\t%s\n", (v&0x20000000)?"Yes":"No");
71
                printf("\tPRIMED:\t\t%s\n", (v&0x10000000)?"Yes":"No");
72
                printf("\tMANUAL:\t\t%s\n", (v&0x08000000)?"Yes":"No");
73
                printf("\tDISABLED:\t%s\n", (v&0x04000000)?"Yes":"No");
74
                printf("\tZERO:\t\t%s\n", (v&0x02000000)?"Yes":"No");
75
                exit(0);
76
        } else printf("SCOPD = %08x\n", v);
77
 
78
        lgln = (v>>20) & 0x1f;
79
        scoplen = (1<<lgln);
80
 
81
        DEVBUS::BUSW    *buf;
82
        buf = new DEVBUS::BUSW[scoplen];
83
 
84
        if (false) {
85
                m_fpga->readz(WBSCOPEDATA, scoplen, buf);
86
        } else {
87
                for(unsigned int i=0; i<scoplen; i++)
88
                        buf[i] = m_fpga->readio(WBSCOPEDATA);
89
        }
90
 
91
        for(unsigned int i=0; i<scoplen; i++) {
92
                char    sbuf[64];
93
 
94
                if ((i>0)&&(buf[i] == buf[i-1])&&
95
                                (i<scoplen-1)&&(buf[i] == buf[i+1]))
96
                        continue;
97
                printf("%6d %08x:", i, buf[i]);
98
 
99
                unsigned addr = (buf[i]>>24)&0x0ff;
100
                zipi_to_string(m_fpga->readio(0x02000+addr),sbuf);
101
                printf(" %2x %-24s", (buf[i]>>24)&0x0ff, sbuf);
102
                printf(" %s%s%s%s%s %s%s%s",
103
                        ((buf[i]>>23)&1)?"P":" ",
104
                        ((buf[i]>>22)&1)?"D":" ",
105
                        ((buf[i]>>21)&1)?"O":" ",
106
                        ((buf[i]>>20)&1)?"A":" ",
107
                        ((buf[i]>>19)&1)?"M":" ",
108
                        ((buf[i]>>18)&1)?"o":" ",
109
                        ((buf[i]>>17)&1)?"a":" ",
110
                        ((buf[i]>>16)&1)?"m":" ");
111
                printf(" A=%02x ", (buf[i]>>8)&0x0ff);
112
                printf(" %s%02x ",
113
                        (((buf[i]>>16)&3)!=0)?"W->":"(w)",
114
                        (buf[i]&0x0ff));
115
                /*
116
                printf("%s", ((buf[i]>>31)&1)?"OpV":"   ");
117
                printf("%s", ((buf[i]>>30)&1)?"opA":"   ");
118
                printf("%s", ((buf[i]>>29)&1)?"AlV":"   ");
119
                printf("%s", ((buf[i]>>28)&1)?"AlW":"   ");
120
                printf("%s", ((buf[i]>>27)&1)?"opM":"   ");
121
                printf("%s", ((buf[i]>>26)&1)?"MmV":"   ");
122
                if (true) {
123
                        int     op = (buf[i]>>22)&0x0f;
124
                        switch(op) {
125
                        case  0: printf("CMP "); break;
126
                        case  1: printf("TST "); break;
127
                        case  2: printf("MOV "); break;
128
                        case  3: printf("LDI "); break;
129
                        case  4: printf("AUX "); break;
130
                        case  5: printf("ROL "); break;
131
                        case  6: printf("LOD "); break;
132
                        case  7: printf("STO "); break;
133
                        case  8: printf("SUB "); break;
134
                        case  9: printf("AND "); break;
135
                        case 10: printf("ADD "); break;
136
                        case 11: printf(" OR "); break;
137
                        case 12: printf("XOR "); break;
138
                        case 13: printf("LSL "); break;
139
                        case 14: printf("ASR "); break;
140
                        case 15: printf("LSR "); break;
141
                        default: printf("ILL "); break;
142
                        }
143
                } else
144
                        printf("%x", (buf[i]>>22)&0x0f);
145
                printf(" %s", ((buf[i]>>21)&1)?"W":" ");
146
                if ((buf[i]>>21)&1)
147
                        printf("[%X]", ((buf[i]>>17)&0x0f));
148
                else
149
                        printf("(%x)", ((buf[i]>>17)&0x0f));
150
                printf("D[%X]", ((buf[i]>>13)&0x0f));
151
                printf(" r_opA=..%02x", (buf[i]>>7)&0x3f);
152
                printf(" opA=..%02x", (buf[i]>>1)&0x3f);
153
                printf(" ALU=..%d", buf[i]&1);
154
                */
155
 
156
                printf("\n");
157
        }
158
 
159
        if (m_fpga->poll()) {
160
                printf("FPGA was interrupted\n");
161
                m_fpga->clear();
162
                m_fpga->writeio(R_ICONTROL, SCOPEN);
163
        }
164
        delete  m_fpga;
165
}
166
 

powered by: WebSVN 2.1.0

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