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

Subversion Repositories openarty

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

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

powered by: WebSVN 2.1.0

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