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

Subversion Repositories xulalx25soc

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

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

Line No. Rev Author Line
1 105 dgisselq
////////////////////////////////////////////////////////////////////////////////
2 5 dgisselq
//
3
// Filename:    cpuscope.cpp
4
//
5 105 dgisselq
// Project:     XuLA2-LX25 SoC based upon the ZipCPU
6 5 dgisselq
//
7
// Purpose:     To read out, and decompose, the results of the wishbone scope
8
//              as applied to the ICAPE2 interaction.
9
//
10 105 dgisselq
// Creator:     Dan Gisselquist, Ph.D.
11
//              Gisselquist Technology, LLC
12 5 dgisselq
//
13 105 dgisselq
////////////////////////////////////////////////////////////////////////////////
14 5 dgisselq
//
15 105 dgisselq
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
16 5 dgisselq
//
17 105 dgisselq
// This program is free software (firmware): you can redistribute it and/or
18
// modify it under the terms of  the GNU General Public License as published
19
// by the Free Software Foundation, either version 3 of the License, or (at
20
// your option) any later version.
21
//
22
// This program is distributed in the hope that it will be useful, but WITHOUT
23
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
24
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
25
// for more details.
26
//
27
// You should have received a copy of the GNU General Public License along
28
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
29
// target there if the PDF file isn't present.)  If not, see
30
// <http://www.gnu.org/licenses/> for a copy.
31
//
32
// License:     GPL, v3, as defined and found on www.gnu.org,
33
//              http://www.gnu.org/licenses/gpl.html
34
//
35
//
36
////////////////////////////////////////////////////////////////////////////////
37
//
38
//
39 5 dgisselq
#include <stdio.h>
40
#include <stdlib.h>
41
#include <unistd.h>
42
#include <strings.h>
43
#include <ctype.h>
44
#include <string.h>
45
#include <signal.h>
46
#include <assert.h>
47
 
48
#include "usbi.h"
49
#include "port.h"
50
#include "llcomms.h"
51
#include "regdefs.h"
52
 
53
#define WBSCOPE         R_CPUSCOPE
54
#define WBSCOPEDATA     R_CPUSCOPED
55
 
56
#include "zopcodes.h"
57
 
58
FPGA    *m_fpga;
59
void    closeup(int v) {
60
        m_fpga->kill();
61
        exit(0);
62
}
63
 
64
unsigned brev(const unsigned v) {
65
        unsigned int r, a;
66
        a = v;
67
        r = 0;
68
        for(int i=0; i<8; i++) {
69
                r <<= 1;
70
                r |= (a&1);
71
                a >>= 1;
72
        } return r;
73
}
74
 
75
unsigned wrev(const unsigned v) {
76
        unsigned r = brev(v&0x0ff);
77
        r |= brev((v>>8)&0x0ff)<<8;
78
        return r;
79
}
80
 
81 105 dgisselq
void    decode(DEVBUS::BUSW val) {
82
 
83
}
84 5 dgisselq
int main(int argc, char **argv) {
85 105 dgisselq
        int     skp=0, port = FPGAPORT;
86
        bool    use_usb = true;
87 5 dgisselq
 
88 105 dgisselq
        skp=1;
89
        for(int argn=0; argn<argc-skp; argn++) {
90
                if (argv[argn+skp][0] == '-') {
91
                        if (argv[argn+skp][1] == 'u')
92
                                use_usb = true;
93
                        else if (argv[argn+skp][1] == 'p') {
94
                                use_usb = false;
95
                                if (isdigit(argv[argn+skp][2]))
96
                                        port = atoi(&argv[argn+skp][2]);
97
                        }
98
                        skp++; argn--;
99
                } else
100
                        argv[argn] = argv[argn+skp];
101
        } argc -= skp;
102
 
103
        if (use_usb)
104
                m_fpga = new FPGA(new USBI());
105
        else
106
                m_fpga = new FPGA(new NETCOMMS(FPGAHOST, port));
107
 
108 5 dgisselq
        signal(SIGSTOP, closeup);
109
        signal(SIGHUP, closeup);
110
 
111
        unsigned        v, lgln, scoplen;
112
        v = m_fpga->readio(WBSCOPE);
113
        if (0x60000000 != (v & 0x60000000)) {
114
                printf("Scope is not yet ready:\n");
115
                printf("\tRESET:\t\t%s\n", (v&0x80000000)?"Ongoing":"Complete");
116
                printf("\tSTOPPED:\t%s\n", (v&0x40000000)?"Yes":"No");
117
                printf("\tTRIGGERED:\t%s\n", (v&0x20000000)?"Yes":"No");
118
                printf("\tPRIMED:\t\t%s\n", (v&0x10000000)?"Yes":"No");
119
                printf("\tMANUAL:\t\t%s\n", (v&0x08000000)?"Yes":"No");
120
                printf("\tDISABLED:\t%s\n", (v&0x04000000)?"Yes":"No");
121
                printf("\tZERO:\t\t%s\n", (v&0x02000000)?"Yes":"No");
122
                exit(0);
123
        } else printf("SCOPD = %08x\n", v);
124
 
125
        lgln = (v>>20) & 0x1f;
126
        scoplen = (1<<lgln);
127
 
128
        DEVBUS::BUSW    *buf;
129
        buf = new DEVBUS::BUSW[scoplen];
130
 
131 105 dgisselq
        bool    compressed = false, vector_read = true;
132
        DEVBUS::BUSW    addrv = 0;
133
 
134
        if (vector_read) {
135 5 dgisselq
                m_fpga->readz(WBSCOPEDATA, scoplen, buf);
136
        } else {
137
                for(unsigned int i=0; i<scoplen; i++)
138
                        buf[i] = m_fpga->readio(WBSCOPEDATA);
139
        }
140
 
141 105 dgisselq
        if(compressed) {
142
                for(int i=0; i<(int)scoplen; i++) {
143
                        if ((buf[i]>>31)&1) {
144
                                addrv += (buf[i]&0x7fffffff);
145
                                printf(" ** \n");
146
                                continue;
147 5 dgisselq
                        }
148 105 dgisselq
                        printf("%10d %08x: ", addrv++, buf[i]);
149
                        decode(buf[i]);
150
                        printf("\n");
151
                }
152
        } else {
153
                for(int i=0; i<(int)scoplen; i++) {
154
                        if ((i>0)&&(buf[i] == buf[i-1])&&(i<(int)(scoplen-1))) {
155
                                if ((i>2)&&(buf[i] != buf[i-2]))
156
                                        printf(" **** ****\n");
157
                                continue;
158
                        } printf("%9d %08x: ", i, buf[i]);
159
                        decode(buf[i]);
160
                        printf("\n");
161
                }
162 5 dgisselq
        }
163
 
164
        if (m_fpga->poll()) {
165
                printf("FPGA was interrupted\n");
166
                m_fpga->clear();
167
                m_fpga->writeio(R_ICONTROL, SCOPEN);
168
        }
169 105 dgisselq
 
170
        delete[] buf;
171 5 dgisselq
        delete  m_fpga;
172
}
173
 

powered by: WebSVN 2.1.0

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