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

Subversion Repositories xulalx25soc

[/] [xulalx25soc/] [trunk/] [sw/] [ramscope.cpp] - Blame information for rev 116

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

Line No. Rev Author Line
1 5 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    ramscope.cpp
4
//
5
// Project:     XuLA2 board
6
//
7
// Purpose:     To read out, and decompose, the results of the wishbone scope
8 42 dgisselq
//              as applied to the SDRAM interaction.
9 5 dgisselq
//
10
//
11
// Creator:     Dan Gisselquist, Ph.D.
12
//              Gisselquist Technology, LLC
13
//
14
////////////////////////////////////////////////////////////////////////////////
15
//
16
// 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
#include <stdio.h>
36
#include <stdlib.h>
37
#include <unistd.h>
38
#include <strings.h>
39
#include <ctype.h>
40
#include <string.h>
41
#include <signal.h>
42
#include <assert.h>
43
 
44
#include "usbi.h"
45
#include "port.h"
46
#include "llcomms.h"
47
#include "regdefs.h"
48
 
49
#define WBSCOPE         R_RAMSCOPE
50
#define WBSCOPEDATA     R_RAMSCOPED
51
 
52
FPGA    *m_fpga;
53
void    closeup(int v) {
54
        m_fpga->kill();
55
        exit(0);
56
}
57
 
58
unsigned brev(const unsigned v) {
59
        unsigned int r, a;
60
        a = v;
61
        r = 0;
62
        for(int i=0; i<8; i++) {
63
                r <<= 1;
64
                r |= (a&1);
65
                a >>= 1;
66
        } return r;
67
}
68
 
69
unsigned wrev(const unsigned v) {
70
        unsigned r = brev(v&0x0ff);
71
        r |= brev((v>>8)&0x0ff)<<8;
72
        return r;
73
}
74
 
75
int main(int argc, char **argv) {
76
        bool            skipping = false;
77
        unsigned        v, lgln, scoplen;
78
        DEVBUS::BUSW    *buf;
79
 
80
        FPGAOPEN(m_fpga);
81
 
82
        signal(SIGSTOP, closeup);
83
        signal(SIGHUP, closeup);
84
 
85
        printf("Attempting to read address %08x\n", WBSCOPE);
86
        v = m_fpga->readio(WBSCOPE);
87
        if (0x60000000 != (v & 0x60000000)) {
88
                printf("Scope is not yet ready:\n");
89
                printf("\tRESET:\t\t%s\n", (v&0x80000000)?"Ongoing":"Complete");
90
                printf("\tSTOPPED:\t%s\n", (v&0x40000000)?"Yes":"No");
91
                printf("\tTRIGGERED:\t%s\n", (v&0x20000000)?"Yes":"No");
92
                printf("\tPRIMED:\t\t%s\n", (v&0x10000000)?"Yes":"No");
93
                printf("\tMANUAL:\t\t%s\n", (v&0x08000000)?"Yes":"No");
94
                printf("\tDISABLED:\t%s\n", (v&0x04000000)?"Yes":"No");
95
                printf("\tZERO:\t\t%s\n", (v&0x02000000)?"Yes":"No");
96
                exit(0);
97
        } else printf("SCOPD = %08x\n", v);
98
 
99
        lgln = (v>>20) & 0x1f;
100
        scoplen = (1<<lgln);
101
 
102
        buf = new DEVBUS::BUSW[scoplen];
103
 
104
        if (false) {
105
                printf("Attempting vector read\n");
106
                m_fpga->readz(WBSCOPEDATA, scoplen, buf);
107
 
108
                printf("Vector read complete\n");
109
        } else {
110
                for(unsigned int i=0; i<scoplen; i++)
111
                        buf[i] = m_fpga->readio(WBSCOPEDATA);
112
        }
113
 
114
        for(unsigned int i=0; i<scoplen; i++) {
115
                int     cmd;
116
 
117
                if ((i>0)&&(buf[i] == buf[i-1])&&
118
                                (i<scoplen-1)&&(buf[i] == buf[i+1])) {
119
                        if (!skipping)
120
                                printf("         ****\n");
121
                        skipping = true;
122
                        continue;
123
                } skipping = false;
124
                printf("%6d %08x:", i, buf[i]);
125
                printf("S(%x) ", (buf[i]>>27)&0x0f);
126 42 dgisselq
                if (buf[i] & 0x20000000)
127 5 dgisselq
                        printf("W "); else printf("R ");
128
                printf("WB(%s%s%s%s%s",
129
                        (buf[i]&0x80000000)?"CYC":"   ",
130
                        (buf[i]&0x40000000)?"STB":"   ",
131
                        (buf[i]&0x20000000)?"WE":"  ",
132
                        (buf[i]&0x10000000)?"ACK":"   ",
133
                        (buf[i]&0x08000000)?"STL":"   ");
134
                        //
135
                if ((buf[i]&0xc8000000)==0xc0000000)
136
                        printf("*");
137
                else
138
                        printf(" ");
139
                printf(")-SD[%d%d%d%d,%d]",
140
                        (buf[i]&0x04000000)?1:0,
141
                        (buf[i]&0x02000000)?1:0,
142
                        (buf[i]&0x01000000)?1:0,
143
                        (buf[i]&0x00800000)?1:0,
144
                        (buf[i]&0x00600000)>>21);
145
                cmd = (buf[i] >> 23)&0x0f;
146
                if (buf[i]&0x00100000)
147
                        printf("<- ");
148
                else
149
                        printf("-> ");
150
                printf("%s", (buf[i]&0x00080000)?"P":" "); // Pending
151
                printf("@%3x,", (buf[i]>>8)&0x07ff);
152
                /*
153
                printf(",%s%s%s%s%s",
154
                        (buf[i]&0x080)?"R":"-",
155
                        (buf[i]&0x040)?"P":".",
156
                        (buf[i]&0x020)?"P":".",
157
                        (buf[i]&0x010)?"P":".",
158
                        (buf[i]&0x008)?"P":".");
159
                printf("/%x%x%x",
160
                        (buf[i]>>2)&0x01,
161
                        (buf[i]>>1)&0x01,
162
                        (buf[i]&0x01));
163
                */
164
                printf("/%02x ", buf[i] & 0x0ff);
165
 
166
                if (cmd & 0x8)
167
                        printf("(inactive)");
168
                switch(cmd) {
169
                        case 0x01: printf("Refresh"); break;
170
                        case 0x02: printf("Precharge"); break;
171
                        case 0x03: printf("Activate"); break;
172
                        case 0x04: printf("Write"); break;
173
                        case 0x05: printf("Read"); break;
174
                        case 0x07: printf("NoOp"); break;
175
                        default: break;
176
                }
177
 
178
                printf("\n");
179
        }
180
 
181
        if (m_fpga->poll()) {
182
                printf("FPGA was interrupted\n");
183
                m_fpga->clear();
184
                m_fpga->writeio(R_ICONTROL, SCOPEN);
185
        }
186
        delete  m_fpga;
187
}
188
 

powered by: WebSVN 2.1.0

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