| 1 |
31 |
dgisselq |
////////////////////////////////////////////////////////////////////////////////
|
| 2 |
|
|
//
|
| 3 |
|
|
// Filename: erxscope.cpp
|
| 4 |
|
|
//
|
| 5 |
|
|
// Project: XuLA2-LX25 SoC based upon the ZipCPU
|
| 6 |
|
|
//
|
| 7 |
|
|
// Purpose: This file decodes the debug bits produced by the enetpackets.v
|
| 8 |
|
|
// Verilog module, and stored in a Wishbone Scope. It is useful
|
| 9 |
|
|
// for determining if the packet transmitter works at all or not.
|
| 10 |
|
|
//
|
| 11 |
|
|
// Creator: Dan Gisselquist, Ph.D.
|
| 12 |
|
|
// Gisselquist Technology, LLC
|
| 13 |
|
|
//
|
| 14 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
| 15 |
|
|
//
|
| 16 |
|
|
// Copyright (C) 2015-2016, 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 |
|
|
// You should have received a copy of the GNU General Public License along
|
| 29 |
|
|
// with this program. (It's in the $(ROOT)/doc directory, run make with no
|
| 30 |
|
|
// target there if the PDF file isn't present.) If not, see
|
| 31 |
|
|
// <http://www.gnu.org/licenses/> for a copy.
|
| 32 |
|
|
//
|
| 33 |
|
|
// License: GPL, v3, as defined and found on www.gnu.org,
|
| 34 |
|
|
// http://www.gnu.org/licenses/gpl.html
|
| 35 |
|
|
//
|
| 36 |
|
|
//
|
| 37 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
| 38 |
|
|
//
|
| 39 |
|
|
//
|
| 40 |
|
|
#include <stdio.h>
|
| 41 |
|
|
#include <stdlib.h>
|
| 42 |
|
|
#include <unistd.h>
|
| 43 |
|
|
#include <strings.h>
|
| 44 |
|
|
#include <ctype.h>
|
| 45 |
|
|
#include <string.h>
|
| 46 |
|
|
#include <signal.h>
|
| 47 |
|
|
#include <assert.h>
|
| 48 |
|
|
|
| 49 |
|
|
#include "port.h"
|
| 50 |
|
|
#include "regdefs.h"
|
| 51 |
|
|
#include "scopecls.h"
|
| 52 |
|
|
|
| 53 |
|
|
#define WBSCOPE R_NETSCOPE
|
| 54 |
|
|
#define WBSCOPEDATA R_NETSCOPED
|
| 55 |
|
|
|
| 56 |
|
|
FPGA *m_fpga;
|
| 57 |
|
|
void closeup(int v) {
|
| 58 |
|
|
m_fpga->kill();
|
| 59 |
|
|
exit(0);
|
| 60 |
|
|
}
|
| 61 |
|
|
|
| 62 |
|
|
class ERXSCOPE : public SCOPE {
|
| 63 |
|
|
public:
|
| 64 |
|
|
ERXSCOPE(FPGA *fpga, unsigned addr, bool vecread = true)
|
| 65 |
|
|
: SCOPE(fpga, addr, false, vecread) {};
|
| 66 |
|
|
~ERXSCOPE(void) {}
|
| 67 |
|
|
virtual void decode(DEVBUS::BUSW val) const {
|
| 68 |
|
|
int trigger, nerr, wr, nprev, crcv, mace, bcast, clear,
|
| 69 |
|
|
rxerr, miss, rxvalid, rxbusy, crs, dv, rxd, macv,
|
| 70 |
|
|
pred, crcd, macd, neop;
|
| 71 |
|
|
|
| 72 |
|
|
trigger= (val>>31)&1;
|
| 73 |
|
|
neop = (val>>30)&1;
|
| 74 |
|
|
wr = (val>>29)&1;
|
| 75 |
|
|
nprev = (val>>28)&1;
|
| 76 |
|
|
pred = (val>>24)&15;
|
| 77 |
|
|
crcv = (val>>23)&1;
|
| 78 |
|
|
crcd = (val>>19)&15;
|
| 79 |
|
|
mace = (val>>18)&1;
|
| 80 |
|
|
bcast = (val>>17)&1;
|
| 81 |
|
|
macv = (val>>16)&1;
|
| 82 |
|
|
macd = (val>>12)&15;
|
| 83 |
|
|
clear = (val>>11)&1;
|
| 84 |
|
|
rxerr = (val>>10)&1;
|
| 85 |
|
|
miss = (val>> 9)&1;
|
| 86 |
|
|
nerr = (val>> 8)&1;
|
| 87 |
|
|
rxvalid= (val>> 7)&1;
|
| 88 |
|
|
rxbusy = (val>> 6)&1;
|
| 89 |
|
|
crs = (val>> 5)&1;
|
| 90 |
|
|
dv = (val>> 4)&1;
|
| 91 |
|
|
rxd = (val )&15;
|
| 92 |
|
|
|
| 93 |
|
|
printf("%s [%s%s%s%x] p[%s%x] c[%s%x] m[%s%s%s%x] ![%s-] %s%s%s%s%s%s",
|
| 94 |
|
|
(trigger)?"TR":" ",
|
| 95 |
|
|
(rxerr)?"RXER":" ",
|
| 96 |
|
|
(crs)?"CRS":" ",
|
| 97 |
|
|
(dv)?"DV":" ", rxd,
|
| 98 |
|
|
(nprev)?"P":" ", pred,
|
| 99 |
|
|
(crcv)?"C":" ", crcd,
|
| 100 |
|
|
(bcast)?"B":" ", (mace)?"E":" ", (macv)?"M":" ", macd,
|
| 101 |
|
|
(wr)?"WR":" ", (nerr)?"ER":" ", (rxbusy)?"BSY":" ",
|
| 102 |
|
|
(neop)?"EOP":" ",
|
| 103 |
|
|
(miss)?"MISS":" ", (clear)?"CLEAR":" ",
|
| 104 |
|
|
(rxvalid)?"VALID":" ");
|
| 105 |
|
|
}
|
| 106 |
|
|
};
|
| 107 |
|
|
|
| 108 |
|
|
int main(int argc, char **argv) {
|
| 109 |
|
|
FPGAOPEN(m_fpga);
|
| 110 |
|
|
|
| 111 |
|
|
signal(SIGSTOP, closeup);
|
| 112 |
|
|
signal(SIGHUP, closeup);
|
| 113 |
|
|
|
| 114 |
|
|
ERXSCOPE *scope = new ERXSCOPE(m_fpga, WBSCOPE);
|
| 115 |
|
|
if (!scope->ready()) {
|
| 116 |
|
|
printf("Scope is not yet ready:\n");
|
| 117 |
|
|
scope->decode_control();
|
| 118 |
|
|
} else
|
| 119 |
|
|
scope->read();
|
| 120 |
|
|
delete m_fpga;
|
| 121 |
|
|
}
|
| 122 |
|
|
|