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

Subversion Repositories openarty

[/] [openarty/] [trunk/] [sw/] [host/] [eqspiscope.cpp] - Blame information for rev 30

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

Line No. Rev Author Line
1 4 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    eqspiscope.cpp
4
//
5
// Project:     XuLA2-LX25 SoC based upon the ZipCPU
6
//
7 16 dgisselq
// Purpose:     This program decodes the bits in the debugging wires output
8
//              from the eqspiflash module, and stored in the Wishbone Scope
9
//      device.  The result is placed on the screen output, so you can see what
10
//      is going on internal to the device.
11
//              
12 4 dgisselq
//
13
// Creator:     Dan Gisselquist, Ph.D.
14
//              Gisselquist Technology, LLC
15
//
16
////////////////////////////////////////////////////////////////////////////////
17
//
18
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
19
//
20
// This program is free software (firmware): you can redistribute it and/or
21
// modify it under the terms of  the GNU General Public License as published
22
// by the Free Software Foundation, either version 3 of the License, or (at
23
// your option) any later version.
24
//
25
// This program is distributed in the hope that it will be useful, but WITHOUT
26
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
27
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
28
// for more details.
29
//
30
// You should have received a copy of the GNU General Public License along
31
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
32
// target there if the PDF file isn't present.)  If not, see
33
// <http://www.gnu.org/licenses/> for a copy.
34
//
35
// License:     GPL, v3, as defined and found on www.gnu.org,
36
//              http://www.gnu.org/licenses/gpl.html
37
//
38
//
39
////////////////////////////////////////////////////////////////////////////////
40
//
41
//
42
#include <stdio.h>
43
#include <stdlib.h>
44
#include <unistd.h>
45
#include <strings.h>
46
#include <ctype.h>
47
#include <string.h>
48
#include <signal.h>
49
#include <assert.h>
50
 
51
#include "port.h"
52
#include "regdefs.h"
53
#include "scopecls.h"
54
 
55
#define WBSCOPE         R_QSCOPE
56
#define WBSCOPEDATA     R_QSCOPED
57
 
58
FPGA    *m_fpga;
59
void    closeup(int v) {
60
        m_fpga->kill();
61
        exit(0);
62
}
63
 
64
class   EQSPISCOPE : public SCOPE {
65 16 dgisselq
        // While I put these in at one time, they really mess up other scopes,
66
        // since setting parameters based upon the debug word forces the decoder
67
        // to be non-constant, calling methods change, etc., etc., etc.
68
        //
69
        // int  m_oword[2], m_iword[2], m_p;
70 4 dgisselq
public:
71
        EQSPISCOPE(FPGA *fpga, unsigned addr, bool vecread)
72 30 dgisselq
                : SCOPE(fpga, addr, false, vecread) {};
73 4 dgisselq
        ~EQSPISCOPE(void) {}
74 16 dgisselq
        virtual void    decode(DEVBUS::BUSW val) const {
75 4 dgisselq
                int     cyc, cstb, dstb, ack, back, accepted, valid, word,
76
                        out, cs, sck, mod, odat, idat;
77
 
78
                cyc      = (val>>31)&1;
79
                cstb     = (val>>30)&1;
80
                dstb     = (val>>29)&1;
81
                ack      = (val>>28)&1;
82
                back     = (val>>27)&1;
83
                accepted = (val>>26)&1;
84
                valid    = (val>>25)&1;
85
                word     = (val>>18)&0x07f;
86
                out      = (val>>12)&0x03f;
87
                cs       = (val>>11)&1;
88
                sck      = (val>>10)&1;
89
                mod      = (val>> 8)&3;
90
                odat     = (val>> 4)&15;
91
                idat     = (val    )&15;
92
 
93 16 dgisselq
                /*
94 14 dgisselq
                m_p = (m_p^1)&1;
95
                if (mod&2) {
96
                        m_oword[m_p] = (m_oword[m_p]<<4)|odat;
97
                        m_iword[m_p] = (m_iword[m_p]<<4)|idat;
98
                } else {
99
                        m_oword[m_p] = (m_oword[m_p]<<1)|(odat&1);
100
                        m_iword[m_p] = (m_iword[m_p]<<1)|((idat&2)?1:0);
101
                }
102 16 dgisselq
                */
103 14 dgisselq
 
104
                printf("%s%s%s%s%s%s%s %02x %02x %s%s %d %x.%d->  ->%x.%d",
105
                        (cyc)?"CYC ":"    ",
106
                        (cstb)?"CSTB":"    ",
107
                        (dstb)?"DSTB":"    ",
108 4 dgisselq
                        (ack)?"AK":"  ",
109
                        (back)?"+":" ",
110
                        (accepted)?"ACC":"   ",
111
                        (valid)?"V":" ",
112
                        word<<1, out<<2,
113
                        (cs)?"  ":"CS",
114
                        (sck)?"CK":"  ",
115 14 dgisselq
                        (mod), odat, (odat&1)?1:0, idat, (idat&2)?1:0);
116
 
117 16 dgisselq
                // printf("  / %08x -> %08x", m_oword[m_p], m_iword[m_p]);
118 4 dgisselq
 
119
        }
120
};
121
 
122
int main(int argc, char **argv) {
123
        int     skp=0, port = FPGAPORT;
124
        bool    use_usb = false;
125
 
126
        skp=1;
127
        for(int argn=0; argn<argc-skp; argn++) {
128
                if (argv[argn+skp][0] == '-') {
129
                        if (argv[argn+skp][1] == 'u')
130
                                use_usb = true;
131
                        else if (argv[argn+skp][1] == 'p') {
132
                                use_usb = false;
133
                                if (isdigit(argv[argn+skp][2]))
134
                                        port = atoi(&argv[argn+skp][2]);
135
                        }
136
                        skp++; argn--;
137
                } else
138
                        argv[argn] = argv[argn+skp];
139
        } argc -= skp;
140
 
141
        FPGAOPEN(m_fpga);
142
 
143
        signal(SIGSTOP, closeup);
144
        signal(SIGHUP, closeup);
145
 
146
        EQSPISCOPE *scope = new EQSPISCOPE(m_fpga, WBSCOPE, false);
147
        if (!scope->ready()) {
148
                printf("Scope is not yet ready:\n");
149
                scope->decode_control();
150
        } else
151
                scope->read();
152
        delete  m_fpga;
153
}
154
 

powered by: WebSVN 2.1.0

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