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

Subversion Repositories xulalx25soc

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

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

Line No. Rev Author Line
1 5 dgisselq
//
2
//
3
// Filename:    cfgscope.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 "port.h"
26
#include "llcomms.h"
27
#include "regdefs.h"
28
 
29
#define WBSCOPE         R_CFGSCOPE
30
#define WBSCOPEDATA     R_CFGSCOPED
31
 
32
FPGA    *m_fpga;
33
void    closeup(int v) {
34
        m_fpga->kill();
35
        exit(0);
36
}
37
 
38
unsigned brev(const unsigned v) {
39
        unsigned int r, a;
40
        a = v;
41
        r = 0;
42
        for(int i=0; i<8; i++) {
43
                r <<= 1;
44
                r |= (a&1);
45
                a >>= 1;
46
        } return r;
47
}
48
 
49
unsigned wrev(const unsigned v) {
50
        unsigned r = brev(v&0x0ff);
51
        r |= brev((v>>8)&0x0ff)<<8;
52
        return r;
53
}
54
 
55
int main(int argc, char **argv) {
56
        FPGAOPEN(m_fpga);
57
 
58
        signal(SIGSTOP, closeup);
59
        signal(SIGHUP, closeup);
60
 
61
        unsigned        v, lgln, scoplen;
62
        printf("Attempting to read address %08x\n", WBSCOPE);
63
        v = m_fpga->readio(WBSCOPE);
64
        if (0x60000000 != (v & 0x60000000)) {
65
                printf("Scope is not yet ready:\n");
66
                printf("\tRESET:\t\t%s\n", (v&0x80000000)?"Ongoing":"Complete");
67
                printf("\tSTOPPED:\t%s\n", (v&0x40000000)?"Yes":"No");
68
                printf("\tTRIGGERED:\t%s\n", (v&0x20000000)?"Yes":"No");
69
                printf("\tPRIMED:\t\t%s\n", (v&0x10000000)?"Yes":"No");
70
                printf("\tMANUAL:\t\t%s\n", (v&0x08000000)?"Yes":"No");
71
                printf("\tDISABLED:\t%s\n", (v&0x04000000)?"Yes":"No");
72
                printf("\tZERO:\t\t%s\n", (v&0x02000000)?"Yes":"No");
73
                exit(0);
74
        } else printf("SCOPD = %08x\n", v);
75
 
76
        lgln = (v>>20) & 0x1f;
77
        scoplen = (1<<lgln);
78
 
79
        DEVBUS::BUSW    *buf;
80
        buf = new DEVBUS::BUSW[scoplen];
81
 
82
        if (false) {
83
                printf("Attempting vector read\n");
84
                m_fpga->readz(WBSCOPEDATA, scoplen, buf);
85
 
86
                printf("Vector read complete\n");
87
        } else {
88
                for(unsigned int i=0; i<scoplen; i++)
89
                        buf[i] = m_fpga->readio(WBSCOPEDATA);
90
        }
91
 
92
        for(unsigned int i=0; i<scoplen; i++) {
93
                if ((i>0)&&(buf[i] == buf[i-1])&&
94
                                (i<scoplen-1)&&(buf[i] == buf[i+1]))
95
                        continue;
96
                printf("%6d %08x:", i, buf[i]);
97
                printf("S(%x) ", (buf[i]>>27)&0x0f);
98
                if (buf[i] & 0x40000000)
99
                        printf("W "); else printf("R ");
100
                printf("WB(%s%s%s%s%s)-%s%s%s%s%s",
101
                        (buf[i]&0x2000000)?"CYC":"   ",
102
                        (buf[i]&0x1000000)?"STB":"   ",
103
                        (buf[i]&0x0800000)?"WE":"  ",
104
                        (buf[i]&0x0400000)?"ACK":"   ",
105
                        (buf[i]&0x0200000)?"STL":"   ",
106
                        (buf[i]&0x0100000)?"EDG":"   ",
107
                        (buf[i]&0x0080000)?"CLK":"   ",
108
                        (buf[i]&0x0040000)?"   ":"CEn",
109
                        (buf[i]&0x0020000)?"BSY":"   ",
110
                        (buf[i]&0x0010000)?"  ":"WE");
111
                if (buf[i]&0x10000)
112
                        printf("->"); // Read
113
                else    printf("<-");
114
                printf(" %04x\n", wrev(buf[i] & 0x0ffff));
115
        }
116
 
117
        if (m_fpga->poll()) {
118
                printf("FPGA was interrupted\n");
119
                m_fpga->clear();
120
                m_fpga->writeio(R_ICONTROL, SCOPEN);
121
        }
122
        delete  m_fpga;
123
}
124
 

powered by: WebSVN 2.1.0

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