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

Subversion Repositories xulalx25soc

[/] [xulalx25soc/] [trunk/] [sw/] [cfgscope.cpp] - Blame information for rev 98

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

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

powered by: WebSVN 2.1.0

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