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

Subversion Repositories openarty

[/] [openarty/] [trunk/] [sw/] [host/] [mdioscope.cpp] - Blame information for rev 48

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

Line No. Rev Author Line
1 30 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    mdioscope.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_NETSCOPE
52
#define WBSCOPEDATA     R_NETSCOPED
53
 
54
FPGA    *m_fpga;
55
void    closeup(int v) {
56
        m_fpga->kill();
57
        exit(0);
58
}
59
 
60
class   MDIOSCOPE : public SCOPE {
61
public:
62
        MDIOSCOPE(FPGA *fpga, unsigned addr, bool vecread)
63
                : SCOPE(fpga, addr, false, false) {};
64
        ~MDIOSCOPE(void) {}
65
        virtual void    decode(DEVBUS::BUSW val) const {
66
                int     wbstall, wbstb, wbwe, wbaddr,
67
                        wback, rclk, zclk, zreg, wbdata, regpos, ctstate, rpend,
68
                        mdclk, mdwe, omdio, imdio;
69
 
70
                wbstall = (val>>31)&1;
71
                wbstb   = (val>>30)&1;
72
                wbwe    = (val>>29)&1;
73
                wbaddr  = (val>>24)&0x01f;
74
                wback   = (val>>23)&1;
75
                wbdata  = (val>>16)&0x03f;
76
 
77
                rclk    = (val>>22)&1;
78
                zreg    = (val>>10)&1;
79
                zclk    = (val>>9)&1;
80
                regpos  = (val>>8)&0x3f;
81
                rpend   = (val>>7)&1;
82
                ctstate = (val>>4)&7;
83
 
84
                mdclk = (val&8)?1:0;
85
                mdwe  = (val&4)?1:0;
86
                omdio = (val&2)?1:0;
87
                imdio = (val&1)?1:0;
88
 
89
                printf("WB[%s%s@%2x -> %s%s/%04x] (%d%d%d,%2d,%2x%s) MDIO[%s%s %d-%d]",
90
                        (wbstb)?"STB":"   ", (wbwe)?"WE":"  ", (wbaddr),
91
                        (wback)?"ACK":"   ",(wbstall)?"STALL":"     ", (wbdata),
92
                        zclk, rclk, zreg, regpos, ctstate,
93
                        (rpend)?"R":" ",
94
                        (mdclk)?"CLK":"   ", (mdwe)?"WE":"  ",(omdio),(imdio));
95
        }
96
};
97
 
98
int main(int argc, char **argv) {
99
        FPGAOPEN(m_fpga);
100
 
101
        signal(SIGSTOP, closeup);
102
        signal(SIGHUP, closeup);
103
 
104
        MDIOSCOPE *scope = new MDIOSCOPE(m_fpga, WBSCOPE, false);
105
        if (!scope->ready()) {
106
                printf("Scope is not yet ready:\n");
107
                scope->decode_control();
108
        } else
109
                scope->read();
110
        delete  m_fpga;
111
}
112
 

powered by: WebSVN 2.1.0

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