| 1 |
16 |
dgisselq |
////////////////////////////////////////////////////////////////////////////////
|
| 2 |
|
|
//
|
| 3 |
|
|
// Filename: sdramscope.cpp
|
| 4 |
|
|
//
|
| 5 |
|
|
// Project: XuLA2-LX25 SoC based upon the ZipCPU
|
| 6 |
|
|
//
|
| 7 |
|
|
// Purpose: This file decodes the debug bits produced by the wbicapetwo.v
|
| 8 |
|
|
// Verilog module, and stored in a Wishbone Scope. It is useful
|
| 9 |
|
|
// for determining if the scope works at all or not. (The scope does work
|
| 10 |
|
|
// ... now ... and it turned out the most recent bugs were found in the
|
| 11 |
|
|
// bus interconnect rather than the wbicapetwo module itself. Still ...
|
| 12 |
|
|
// the wbicapetwo module was updated with an adjustable clock, so
|
| 13 |
|
|
// things always get better ... right?)
|
| 14 |
|
|
//
|
| 15 |
|
|
// Creator: Dan Gisselquist, Ph.D.
|
| 16 |
|
|
// Gisselquist Technology, LLC
|
| 17 |
|
|
//
|
| 18 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
| 19 |
|
|
//
|
| 20 |
|
|
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
|
| 21 |
|
|
//
|
| 22 |
|
|
// This program is free software (firmware): you can redistribute it and/or
|
| 23 |
|
|
// modify it under the terms of the GNU General Public License as published
|
| 24 |
|
|
// by the Free Software Foundation, either version 3 of the License, or (at
|
| 25 |
|
|
// your option) any later version.
|
| 26 |
|
|
//
|
| 27 |
|
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
| 28 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
|
| 29 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
| 30 |
|
|
// for more details.
|
| 31 |
|
|
//
|
| 32 |
|
|
// You should have received a copy of the GNU General Public License along
|
| 33 |
|
|
// with this program. (It's in the $(ROOT)/doc directory, run make with no
|
| 34 |
|
|
// target there if the PDF file isn't present.) If not, see
|
| 35 |
|
|
// <http://www.gnu.org/licenses/> for a copy.
|
| 36 |
|
|
//
|
| 37 |
|
|
// License: GPL, v3, as defined and found on www.gnu.org,
|
| 38 |
|
|
// http://www.gnu.org/licenses/gpl.html
|
| 39 |
|
|
//
|
| 40 |
|
|
//
|
| 41 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
| 42 |
|
|
//
|
| 43 |
|
|
//
|
| 44 |
|
|
#include <stdio.h>
|
| 45 |
|
|
#include <stdlib.h>
|
| 46 |
|
|
#include <unistd.h>
|
| 47 |
|
|
#include <strings.h>
|
| 48 |
|
|
#include <ctype.h>
|
| 49 |
|
|
#include <string.h>
|
| 50 |
|
|
#include <signal.h>
|
| 51 |
|
|
#include <assert.h>
|
| 52 |
|
|
|
| 53 |
|
|
#include "port.h"
|
| 54 |
|
|
#include "regdefs.h"
|
| 55 |
|
|
#include "scopecls.h"
|
| 56 |
|
|
|
| 57 |
|
|
#define WBSCOPE R_CFGSCOPE
|
| 58 |
|
|
#define WBSCOPEDATA R_CFGSCOPED
|
| 59 |
|
|
|
| 60 |
|
|
FPGA *m_fpga;
|
| 61 |
|
|
void closeup(int v) {
|
| 62 |
|
|
m_fpga->kill();
|
| 63 |
|
|
exit(0);
|
| 64 |
|
|
}
|
| 65 |
|
|
|
| 66 |
|
|
class CFGSCOPE : public SCOPE {
|
| 67 |
|
|
public:
|
| 68 |
|
|
CFGSCOPE(FPGA *fpga, unsigned addr, bool vecread)
|
| 69 |
|
|
: SCOPE(fpga, addr, false, false) {};
|
| 70 |
|
|
~CFGSCOPE(void) {}
|
| 71 |
|
|
virtual void decode(DEVBUS::BUSW val) const {
|
| 72 |
|
|
int clk, ckstb, ckstl,
|
| 73 |
|
|
wbstb, wbstl, wback,
|
| 74 |
|
|
csn, rdwrn, state,
|
| 75 |
|
|
cfgin, cfgout;
|
| 76 |
|
|
|
| 77 |
|
|
clk = (val>>30)&1;
|
| 78 |
|
|
ckstb = (val>>29)&1;
|
| 79 |
|
|
ckstl = (val>>28)&1;
|
| 80 |
|
|
wbstb = (val>>27)&1;
|
| 81 |
|
|
wback = (val>>26)&1;
|
| 82 |
|
|
csn = (val>>25)&1;
|
| 83 |
|
|
rdwrn = (val>>24)&1;
|
| 84 |
|
|
wbstl = (val>>23)&1;
|
| 85 |
|
|
state = (val>>18)&0x1f;
|
| 86 |
|
|
cfgin = (val>> 8)&0x0ff;
|
| 87 |
|
|
cfgout = (val )&0x0ff;
|
| 88 |
|
|
|
| 89 |
|
|
printf("%s %s/%s [%d%d%d] %2x [%02x - %02x]",
|
| 90 |
|
|
(wbstb)?"STB":" ",
|
| 91 |
|
|
(wbstl)?"STL":" ",
|
| 92 |
|
|
(wback)?"ACK":" ",
|
| 93 |
|
|
clk, ckstb, ckstl,
|
| 94 |
|
|
state, cfgin, cfgout);
|
| 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 |
|
|
CFGSCOPE *scope = new CFGSCOPE(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 |
|
|
|