////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
//
|
//
|
// Filename: ramscope.cpp
|
// Filename: ramscope.cpp
|
//
|
//
|
// Project: XuLA2 board
|
// Project: XuLA2 board
|
//
|
//
|
// Purpose: To read out, and decompose, the results of the wishbone scope
|
// Purpose: To read out, and decompose, the results of the wishbone scope
|
// as applied to the ICAPE2 interaction.
|
// as applied to the SDRAM interaction.
|
//
|
//
|
//
|
//
|
// Creator: Dan Gisselquist, Ph.D.
|
// Creator: Dan Gisselquist, Ph.D.
|
// Gisselquist Technology, LLC
|
// Gisselquist Technology, LLC
|
//
|
//
|
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
//
|
//
|
// Copyright (C) 2015, Gisselquist Technology, LLC
|
// Copyright (C) 2015, Gisselquist Technology, LLC
|
//
|
//
|
// This program is free software (firmware): you can redistribute it and/or
|
// This program is free software (firmware): you can redistribute it and/or
|
// modify it under the terms of the GNU General Public License as published
|
// modify it under the terms of the GNU General Public License as published
|
// by the Free Software Foundation, either version 3 of the License, or (at
|
// by the Free Software Foundation, either version 3 of the License, or (at
|
// your option) any later version.
|
// your option) any later version.
|
//
|
//
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
|
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
// for more details.
|
// for more details.
|
//
|
//
|
// License: GPL, v3, as defined and found on www.gnu.org,
|
// License: GPL, v3, as defined and found on www.gnu.org,
|
// http://www.gnu.org/licenses/gpl.html
|
// http://www.gnu.org/licenses/gpl.html
|
//
|
//
|
//
|
//
|
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
//
|
//
|
//
|
//
|
#include <stdio.h>
|
#include <stdio.h>
|
#include <stdlib.h>
|
#include <stdlib.h>
|
#include <unistd.h>
|
#include <unistd.h>
|
#include <strings.h>
|
#include <strings.h>
|
#include <ctype.h>
|
#include <ctype.h>
|
#include <string.h>
|
#include <string.h>
|
#include <signal.h>
|
#include <signal.h>
|
#include <assert.h>
|
#include <assert.h>
|
|
|
#include "usbi.h"
|
#include "usbi.h"
|
#include "port.h"
|
#include "port.h"
|
#include "llcomms.h"
|
#include "llcomms.h"
|
#include "regdefs.h"
|
#include "regdefs.h"
|
|
|
#define WBSCOPE R_RAMSCOPE
|
#define WBSCOPE R_RAMSCOPE
|
#define WBSCOPEDATA R_RAMSCOPED
|
#define WBSCOPEDATA R_RAMSCOPED
|
|
|
FPGA *m_fpga;
|
FPGA *m_fpga;
|
void closeup(int v) {
|
void closeup(int v) {
|
m_fpga->kill();
|
m_fpga->kill();
|
exit(0);
|
exit(0);
|
}
|
}
|
|
|
unsigned brev(const unsigned v) {
|
unsigned brev(const unsigned v) {
|
unsigned int r, a;
|
unsigned int r, a;
|
a = v;
|
a = v;
|
r = 0;
|
r = 0;
|
for(int i=0; i<8; i++) {
|
for(int i=0; i<8; i++) {
|
r <<= 1;
|
r <<= 1;
|
r |= (a&1);
|
r |= (a&1);
|
a >>= 1;
|
a >>= 1;
|
} return r;
|
} return r;
|
}
|
}
|
|
|
unsigned wrev(const unsigned v) {
|
unsigned wrev(const unsigned v) {
|
unsigned r = brev(v&0x0ff);
|
unsigned r = brev(v&0x0ff);
|
r |= brev((v>>8)&0x0ff)<<8;
|
r |= brev((v>>8)&0x0ff)<<8;
|
return r;
|
return r;
|
}
|
}
|
|
|
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
bool skipping = false;
|
bool skipping = false;
|
unsigned v, lgln, scoplen;
|
unsigned v, lgln, scoplen;
|
DEVBUS::BUSW *buf;
|
DEVBUS::BUSW *buf;
|
|
|
FPGAOPEN(m_fpga);
|
FPGAOPEN(m_fpga);
|
|
|
signal(SIGSTOP, closeup);
|
signal(SIGSTOP, closeup);
|
signal(SIGHUP, closeup);
|
signal(SIGHUP, closeup);
|
|
|
printf("Attempting to read address %08x\n", WBSCOPE);
|
printf("Attempting to read address %08x\n", WBSCOPE);
|
v = m_fpga->readio(WBSCOPE);
|
v = m_fpga->readio(WBSCOPE);
|
if (0x60000000 != (v & 0x60000000)) {
|
if (0x60000000 != (v & 0x60000000)) {
|
printf("Scope is not yet ready:\n");
|
printf("Scope is not yet ready:\n");
|
printf("\tRESET:\t\t%s\n", (v&0x80000000)?"Ongoing":"Complete");
|
printf("\tRESET:\t\t%s\n", (v&0x80000000)?"Ongoing":"Complete");
|
printf("\tSTOPPED:\t%s\n", (v&0x40000000)?"Yes":"No");
|
printf("\tSTOPPED:\t%s\n", (v&0x40000000)?"Yes":"No");
|
printf("\tTRIGGERED:\t%s\n", (v&0x20000000)?"Yes":"No");
|
printf("\tTRIGGERED:\t%s\n", (v&0x20000000)?"Yes":"No");
|
printf("\tPRIMED:\t\t%s\n", (v&0x10000000)?"Yes":"No");
|
printf("\tPRIMED:\t\t%s\n", (v&0x10000000)?"Yes":"No");
|
printf("\tMANUAL:\t\t%s\n", (v&0x08000000)?"Yes":"No");
|
printf("\tMANUAL:\t\t%s\n", (v&0x08000000)?"Yes":"No");
|
printf("\tDISABLED:\t%s\n", (v&0x04000000)?"Yes":"No");
|
printf("\tDISABLED:\t%s\n", (v&0x04000000)?"Yes":"No");
|
printf("\tZERO:\t\t%s\n", (v&0x02000000)?"Yes":"No");
|
printf("\tZERO:\t\t%s\n", (v&0x02000000)?"Yes":"No");
|
exit(0);
|
exit(0);
|
} else printf("SCOPD = %08x\n", v);
|
} else printf("SCOPD = %08x\n", v);
|
|
|
lgln = (v>>20) & 0x1f;
|
lgln = (v>>20) & 0x1f;
|
scoplen = (1<<lgln);
|
scoplen = (1<<lgln);
|
|
|
buf = new DEVBUS::BUSW[scoplen];
|
buf = new DEVBUS::BUSW[scoplen];
|
|
|
if (false) {
|
if (false) {
|
printf("Attempting vector read\n");
|
printf("Attempting vector read\n");
|
m_fpga->readz(WBSCOPEDATA, scoplen, buf);
|
m_fpga->readz(WBSCOPEDATA, scoplen, buf);
|
|
|
printf("Vector read complete\n");
|
printf("Vector read complete\n");
|
} else {
|
} else {
|
for(unsigned int i=0; i<scoplen; i++)
|
for(unsigned int i=0; i<scoplen; i++)
|
buf[i] = m_fpga->readio(WBSCOPEDATA);
|
buf[i] = m_fpga->readio(WBSCOPEDATA);
|
}
|
}
|
|
|
for(unsigned int i=0; i<scoplen; i++) {
|
for(unsigned int i=0; i<scoplen; i++) {
|
int cmd;
|
int cmd;
|
|
|
if ((i>0)&&(buf[i] == buf[i-1])&&
|
if ((i>0)&&(buf[i] == buf[i-1])&&
|
(i<scoplen-1)&&(buf[i] == buf[i+1])) {
|
(i<scoplen-1)&&(buf[i] == buf[i+1])) {
|
if (!skipping)
|
if (!skipping)
|
printf(" ****\n");
|
printf(" ****\n");
|
skipping = true;
|
skipping = true;
|
continue;
|
continue;
|
} skipping = false;
|
} skipping = false;
|
printf("%6d %08x:", i, buf[i]);
|
printf("%6d %08x:", i, buf[i]);
|
printf("S(%x) ", (buf[i]>>27)&0x0f);
|
printf("S(%x) ", (buf[i]>>27)&0x0f);
|
if (buf[i] & 0x40000000)
|
if (buf[i] & 0x20000000)
|
printf("W "); else printf("R ");
|
printf("W "); else printf("R ");
|
printf("WB(%s%s%s%s%s",
|
printf("WB(%s%s%s%s%s",
|
(buf[i]&0x80000000)?"CYC":" ",
|
(buf[i]&0x80000000)?"CYC":" ",
|
(buf[i]&0x40000000)?"STB":" ",
|
(buf[i]&0x40000000)?"STB":" ",
|
(buf[i]&0x20000000)?"WE":" ",
|
(buf[i]&0x20000000)?"WE":" ",
|
(buf[i]&0x10000000)?"ACK":" ",
|
(buf[i]&0x10000000)?"ACK":" ",
|
(buf[i]&0x08000000)?"STL":" ");
|
(buf[i]&0x08000000)?"STL":" ");
|
//
|
//
|
if ((buf[i]&0xc8000000)==0xc0000000)
|
if ((buf[i]&0xc8000000)==0xc0000000)
|
printf("*");
|
printf("*");
|
else
|
else
|
printf(" ");
|
printf(" ");
|
printf(")-SD[%d%d%d%d,%d]",
|
printf(")-SD[%d%d%d%d,%d]",
|
(buf[i]&0x04000000)?1:0,
|
(buf[i]&0x04000000)?1:0,
|
(buf[i]&0x02000000)?1:0,
|
(buf[i]&0x02000000)?1:0,
|
(buf[i]&0x01000000)?1:0,
|
(buf[i]&0x01000000)?1:0,
|
(buf[i]&0x00800000)?1:0,
|
(buf[i]&0x00800000)?1:0,
|
(buf[i]&0x00600000)>>21);
|
(buf[i]&0x00600000)>>21);
|
cmd = (buf[i] >> 23)&0x0f;
|
cmd = (buf[i] >> 23)&0x0f;
|
if (buf[i]&0x00100000)
|
if (buf[i]&0x00100000)
|
printf("<- ");
|
printf("<- ");
|
else
|
else
|
printf("-> ");
|
printf("-> ");
|
printf("%s", (buf[i]&0x00080000)?"P":" "); // Pending
|
printf("%s", (buf[i]&0x00080000)?"P":" "); // Pending
|
printf("@%3x,", (buf[i]>>8)&0x07ff);
|
printf("@%3x,", (buf[i]>>8)&0x07ff);
|
/*
|
/*
|
printf(",%s%s%s%s%s",
|
printf(",%s%s%s%s%s",
|
(buf[i]&0x080)?"R":"-",
|
(buf[i]&0x080)?"R":"-",
|
(buf[i]&0x040)?"P":".",
|
(buf[i]&0x040)?"P":".",
|
(buf[i]&0x020)?"P":".",
|
(buf[i]&0x020)?"P":".",
|
(buf[i]&0x010)?"P":".",
|
(buf[i]&0x010)?"P":".",
|
(buf[i]&0x008)?"P":".");
|
(buf[i]&0x008)?"P":".");
|
printf("/%x%x%x",
|
printf("/%x%x%x",
|
(buf[i]>>2)&0x01,
|
(buf[i]>>2)&0x01,
|
(buf[i]>>1)&0x01,
|
(buf[i]>>1)&0x01,
|
(buf[i]&0x01));
|
(buf[i]&0x01));
|
*/
|
*/
|
printf("/%02x ", buf[i] & 0x0ff);
|
printf("/%02x ", buf[i] & 0x0ff);
|
|
|
if (cmd & 0x8)
|
if (cmd & 0x8)
|
printf("(inactive)");
|
printf("(inactive)");
|
switch(cmd) {
|
switch(cmd) {
|
case 0x01: printf("Refresh"); break;
|
case 0x01: printf("Refresh"); break;
|
case 0x02: printf("Precharge"); break;
|
case 0x02: printf("Precharge"); break;
|
case 0x03: printf("Activate"); break;
|
case 0x03: printf("Activate"); break;
|
case 0x04: printf("Write"); break;
|
case 0x04: printf("Write"); break;
|
case 0x05: printf("Read"); break;
|
case 0x05: printf("Read"); break;
|
case 0x07: printf("NoOp"); break;
|
case 0x07: printf("NoOp"); break;
|
default: break;
|
default: break;
|
}
|
}
|
|
|
printf("\n");
|
printf("\n");
|
}
|
}
|
|
|
if (m_fpga->poll()) {
|
if (m_fpga->poll()) {
|
printf("FPGA was interrupted\n");
|
printf("FPGA was interrupted\n");
|
m_fpga->clear();
|
m_fpga->clear();
|
m_fpga->writeio(R_ICONTROL, SCOPEN);
|
m_fpga->writeio(R_ICONTROL, SCOPEN);
|
}
|
}
|
delete m_fpga;
|
delete m_fpga;
|
}
|
}
|
|
|
|
|