Line 120... |
Line 120... |
(m_core->o_ddr_ba),
|
(m_core->o_ddr_ba),
|
(m_core->o_ddr_addr),
|
(m_core->o_ddr_addr),
|
(m_core->i_ddr_data),
|
(m_core->i_ddr_data),
|
(m_core->o_ddr_data));
|
(m_core->o_ddr_data));
|
|
|
printf(" FIFO[%x,%x](%d,%d,%08x-%08x-%08x)",
|
printf(" FIFO[%x,%x](%s,%d,%08x)",
|
m_core->v__DOT__bus_fifo_head,
|
m_core->v__DOT__bus_fifo_head,
|
m_core->v__DOT__bus_fifo_tail,
|
m_core->v__DOT__bus_fifo_tail,
|
m_core->v__DOT__bus_fifo_new[m_core->v__DOT__bus_fifo_tail],
|
(m_core->v__DOT__bus_fifo_new[m_core->v__DOT__bus_fifo_tail])?"N":"o",
|
m_core->v__DOT__bus_fifo_sub[m_core->v__DOT__bus_fifo_tail],
|
m_core->v__DOT__bus_fifo_sub[m_core->v__DOT__bus_fifo_tail],
|
m_core->v__DOT__r_data,
|
|
m_core->v__DOT__bus_fifo_data[(m_core->v__DOT__bus_fifo_head-1)&15],
|
|
m_core->v__DOT__bus_fifo_data[m_core->v__DOT__bus_fifo_tail]);
|
m_core->v__DOT__bus_fifo_data[m_core->v__DOT__bus_fifo_tail]);
|
|
|
printf(" BUS[%03x/%03x/%03x/%d]",
|
printf(" BUS[%03x/%03x/%03x/%d]",
|
(m_core->v__DOT__bus_active),
|
(m_core->v__DOT__bus_active),
|
(m_core->v__DOT__bus_read),
|
(m_core->v__DOT__bus_read),
|
Line 145... |
Line 143... |
(m_core->v__DOT__reset_address),
|
(m_core->v__DOT__reset_address),
|
(m_core->v__DOT__reset_instruction),
|
(m_core->v__DOT__reset_instruction),
|
(m_core->v__DOT__reset_cmd));
|
(m_core->v__DOT__reset_cmd));
|
*/
|
*/
|
|
|
printf(" %s%03x[%d]%04x:%d",
|
printf(" R_%s%03x[%d]%04x:%d/%08x",
|
(m_core->v__DOT__r_pending)?"R":" ",
|
(!m_core->v__DOT__r_pending)?"_"
|
|
:(m_core->v__DOT__r_we)?"W":"R",
|
(m_core->v__DOT__r_row),
|
(m_core->v__DOT__r_row),
|
(m_core->v__DOT__r_bank),
|
(m_core->v__DOT__r_bank),
|
(m_core->v__DOT__r_col),0);
|
(m_core->v__DOT__r_col),
|
// (m_core->v__DOT__r_sub));
|
(m_core->v__DOT__r_sub),
|
|
(m_core->v__DOT__r_data));
|
|
|
|
printf(" S_%s%03x[%d]%04x:%d/%08x%s%s%s",
|
|
(!m_core->v__DOT__s_pending)?"_"
|
|
:(m_core->v__DOT__s_we)?"W":"R",
|
|
(m_core->v__DOT__s_row),
|
|
(m_core->v__DOT__s_bank),
|
|
(m_core->v__DOT__s_col),
|
|
(m_core->v__DOT__s_sub),
|
|
(m_core->v__DOT__s_data),
|
|
(m_core->v__DOT__s_match)?"M":" ",
|
|
(m_core->v__DOT__pipe_stall)?"P":" ",
|
|
"-"
|
|
//(m_core->v__DOT__s_stall)?"S":" "
|
|
);
|
|
|
|
|
printf(" %s%s%s",
|
printf(" %s%s%s",
|
"B",
|
"B",
|
// (m_core->v__DOT__all_banks_closed)?"b":"B",
|
// (m_core->v__DOT__all_banks_closed)?"b":"B",
|
(m_core->v__DOT__need_close_bank)?"C":"N",
|
(m_core->v__DOT__need_close_bank)?"C":"N",
|
//:(m_core->v__DOT__maybe_close_next_bank)?"c":"N",
|
//:(m_core->v__DOT__maybe_close_next_bank)?"c":"N",
|
Line 170... |
Line 186... |
|
|
|
|
extern int gbl_state, gbl_counts;
|
extern int gbl_state, gbl_counts;
|
printf(" %2d:%08x ", gbl_state, gbl_counts);
|
printf(" %2d:%08x ", gbl_state, gbl_counts);
|
|
|
printf(" %s%s%s%s%s%s%s:%08x:%08x",
|
printf(" %s%s%s%s%s%s:%08x:%08x",
|
(m_core->v__DOT__reset_override)?"R":" ",
|
(m_core->v__DOT__reset_override)?"R":" ",
|
(m_core->v__DOT__need_refresh)?"N":" ",
|
(m_core->v__DOT__need_refresh)?"N":" ",
|
(m_core->v__DOT__need_close_bank)?"C":" ",
|
(m_core->v__DOT__need_close_bank)?"C":" ",
|
(m_core->v__DOT__need_open_bank)?"O":" ",
|
(m_core->v__DOT__need_open_bank)?"O":" ",
|
(m_core->v__DOT__valid_bank)?"V":" ",
|
(m_core->v__DOT__valid_bank)?"V":" ",
|
(m_core->v__DOT__r_move)?"R":" ",
|
(m_core->v__DOT__r_move)?"R":" ",
|
(m_core->v__DOT__m_move)?"M":" ",
|
|
m_core->v__DOT__activate_bank_cmd,
|
m_core->v__DOT__activate_bank_cmd,
|
m_core->v__DOT__cmd);
|
m_core->v__DOT__cmd);
|
|
|
printf(" F%s%05x:%x/%s",
|
printf(" F%s%05x:%x/%s",
|
(m_core->v__DOT__refresh_ztimer)?"Z":" ",
|
(m_core->v__DOT__refresh_ztimer)?"Z":" ",
|
Line 249... |
Line 264... |
m_core->i_wb_addr= a & SDRAMMASK;
|
m_core->i_wb_addr= a & SDRAMMASK;
|
|
|
if (m_core->o_wb_stall) {
|
if (m_core->o_wb_stall) {
|
while((errcount++ < BOMBCOUNT)&&(m_core->o_wb_stall))
|
while((errcount++ < BOMBCOUNT)&&(m_core->o_wb_stall))
|
tick();
|
tick();
|
} else
|
} tick();
|
tick();
|
|
|
|
m_core->i_wb_stb = 0;
|
m_core->i_wb_stb = 0;
|
|
|
while((errcount++ < BOMBCOUNT)&&(!m_core->o_wb_ack))
|
while((errcount++ < BOMBCOUNT)&&(!m_core->o_wb_ack))
|
tick();
|
tick();
|
Line 421... |
Line 435... |
|
|
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
Verilated::commandArgs(argc, argv);
|
Verilated::commandArgs(argc, argv);
|
DDRSDRAM_TB *tb = new DDRSDRAM_TB;
|
DDRSDRAM_TB *tb = new DDRSDRAM_TB;
|
unsigned *rdbuf, *mbuf;
|
unsigned *rdbuf, *mbuf;
|
int nw = 3, nr = 13;
|
|
unsigned mlen = (1<<(LGMEMSIZE-2));
|
unsigned mlen = (1<<(LGMEMSIZE-2));
|
|
|
printf("Giving the core 140k cycles to start up\n");
|
printf("Giving the core 140k cycles to start up\n");
|
// Before testing, let's give the unit time enough to warm up
|
// Before testing, let's give the unit time enough to warm up
|
tb->reset();
|
tb->reset();
|
Line 441... |
Line 454... |
rdbuf = new unsigned[mlen];
|
rdbuf = new unsigned[mlen];
|
mbuf = new unsigned[mlen]; // Match buffer
|
mbuf = new unsigned[mlen]; // Match buffer
|
printf("Charging my memory with random values\n");
|
printf("Charging my memory with random values\n");
|
uload(mlen, rdbuf);
|
uload(mlen, rdbuf);
|
|
|
|
#define SINGULAR_WRITE
|
|
#define SINGULAR_READ
|
|
#define BIGPIPELINE_WRITE
|
|
#define BIGPIPELINE_READ
|
|
#define PRIMEVEC_WRITE
|
|
#define PRIMEVEC_READ
|
|
#define SKIP_WRITE
|
|
#define SKIP_READ
|
|
|
|
#ifdef SINGULAR_WRITE
|
// First test: singular reads through the memory, followed by
|
// First test: singular reads through the memory, followed by
|
// singular writes
|
// singular writes
|
printf("Starting the single-read test\n");
|
printf("Starting the single-read test\n");
|
for(int i=0; i<(int)mlen; i++) {
|
for(int i=0; i<(int)mlen; i++) {
|
tb->wb_write(i, rdbuf[i]);
|
tb->wb_write(i, rdbuf[i]);
|
Line 454... |
Line 477... |
i, (*tb)[i], rdbuf[i]);
|
i, (*tb)[i], rdbuf[i]);
|
goto test_failure;
|
goto test_failure;
|
} if (tb->bombed())
|
} if (tb->bombed())
|
goto test_failure;
|
goto test_failure;
|
|
|
} for(int i=0; i<(int)mlen; i++) {
|
}
|
|
#else
|
|
#ifdef SINGULAR_READ
|
|
// If we aren't doing the write test, we still need to charge
|
|
// the memory for the read test. Here we do it manually.
|
|
for(int i=0; i<(int)mlen; i++)
|
|
(*tb)[i] = rdbuf[i];
|
|
#endif // !SINGULAR_WRITE && SINGULAR_READ
|
|
#endif // SINGULAR_WRITE
|
|
#ifdef SINGULAR_READ
|
|
for(int i=0; i<(int)mlen; i++) {
|
unsigned v;
|
unsigned v;
|
if (rdbuf[i] != (v=tb->wb_read(i))) {
|
if (rdbuf[i] != (v=tb->wb_read(i))) {
|
printf("READ[%06x] = %08x (Expecting %08x)\n",
|
printf("READ[%06x] = %08x (Expecting %08x)\n",
|
i, v, rdbuf[i]);
|
i, v, rdbuf[i]);
|
goto test_failure;
|
goto test_failure;
|
} if (tb->bombed())
|
} if (tb->bombed())
|
goto test_failure;
|
goto test_failure;
|
tb->wb_tick();
|
tb->wb_tick();
|
}
|
}
|
|
#endif
|
|
|
|
#ifdef BIGPIPELINE_WRITE
|
// Second test: Vector writes going through all memory, followed a
|
// Second test: Vector writes going through all memory, followed a
|
// massive vector read
|
// massive vector read
|
uload(mlen, rdbuf); // Get some new values
|
uload(mlen, rdbuf); // Get some new values
|
tb->wb_write(0, mlen, rdbuf);
|
tb->wb_write(0, mlen, rdbuf);
|
if (tb->bombed())
|
if (tb->bombed())
|
Line 479... |
Line 514... |
printf("V-WRITE[%06x] = %08x (Expecting %08x)\n",
|
printf("V-WRITE[%06x] = %08x (Expecting %08x)\n",
|
i, v, rdbuf[i]);
|
i, v, rdbuf[i]);
|
goto test_failure;
|
goto test_failure;
|
}
|
}
|
}
|
}
|
|
#else
|
|
#ifdef BIGPIPELINE_READ
|
|
uload(mlen, rdbuf); // Get some new values
|
|
// If we aren't doing the write test, we still need to charge
|
|
// the memory for the read test. Here we do it manually.
|
|
for(int i=0; i<(int)mlen; i++)
|
|
(*tb)[i] = rdbuf[i];
|
|
#endif // BIGPIPELINE_WRITE && BIGPIPELINE_READ
|
|
#endif
|
|
#ifdef BIGPIPELINE_READ
|
tb->wb_read( 0, mlen, mbuf);
|
tb->wb_read( 0, mlen, mbuf);
|
if (tb->bombed())
|
if (tb->bombed())
|
goto test_failure;
|
goto test_failure;
|
for(int i=0; i<(int)mlen; i++) {
|
for(int i=0; i<(int)mlen; i++) {
|
if (rdbuf[i] != mbuf[i]) {
|
if (rdbuf[i] != mbuf[i]) {
|
printf("V-READ[%06x] = %08x (Expecting %08x)\n",
|
printf("V-READ[%06x] = %08x (Expecting %08x)\n",
|
i, mbuf[i], rdbuf[i]);
|
i, mbuf[i], rdbuf[i]);
|
goto test_failure;
|
goto test_failure;
|
}
|
}
|
}
|
}
|
|
#endif
|
|
|
|
#ifdef PRIMEVEC_WRITE
|
// Third test: Vector writes going through all memory, in prime numbers
|
// Third test: Vector writes going through all memory, in prime numbers
|
// of values at a time, followed by reads via a different prime number
|
// of values at a time, followed by reads via a different prime number
|
uload(mlen, rdbuf); // Get some new values
|
uload(mlen, rdbuf); // Get some new values
|
|
{
|
|
int nw = 3;
|
for(int i=0; i<(int)mlen; i+=nw) {
|
for(int i=0; i<(int)mlen; i+=nw) {
|
int ln = ((int)mlen-i>nw)?nw:mlen-i;
|
int ln = ((int)mlen-i>nw)?nw:mlen-i;
|
tb->wb_write(i, nw, &rdbuf[i]);
|
tb->wb_write(i, nw, &rdbuf[i]);
|
for(int j=0; j<ln; j++) {
|
for(int j=0; j<ln; j++) {
|
if ((*tb)[i+j] != rdbuf[i+j]) {
|
if ((*tb)[i+j] != rdbuf[i+j]) {
|
Line 505... |
Line 553... |
i, (*tb)[i], rdbuf[i]);
|
i, (*tb)[i], rdbuf[i]);
|
goto test_failure;
|
goto test_failure;
|
}
|
}
|
} if (tb->bombed())
|
} if (tb->bombed())
|
goto test_failure;
|
goto test_failure;
|
} for(int i=0; i<(int)mlen; i+=nr) {
|
}
|
|
}
|
|
#else
|
|
#ifdef PRIMEVEC_READ
|
|
uload(mlen, rdbuf); // Get some new values
|
|
// If we aren't doing the write test, we still need to charge
|
|
// the memory for the read test. Here we do it manually.
|
|
for(int i=0; i<(int)mlen; i++)
|
|
(*tb)[i] = rdbuf[i];
|
|
#endif
|
|
#endif
|
|
#ifdef PRIMEVEC_READ
|
|
{
|
|
int nr = 13;
|
|
for(int i=0; i<(int)mlen; i+=nr) {
|
int ln = ((int)mlen-i>nr)?nr:mlen-i;
|
int ln = ((int)mlen-i>nr)?nr:mlen-i;
|
tb->wb_read(i, nr, &mbuf[i]);
|
tb->wb_read(i, nr, &mbuf[i]);
|
for(int j=0; j<ln; j++) {
|
for(int j=0; j<ln; j++) {
|
if (mbuf[i+j] != rdbuf[i+j]) {
|
if (mbuf[i+j] != rdbuf[i+j]) {
|
printf("P-READ[%06x] = %08x (Expecting %08x) FAILED\n",
|
printf("P-READ[%06x] = %08x (Expecting %08x) FAILED\n",
|
Line 517... |
Line 579... |
goto test_failure;
|
goto test_failure;
|
}
|
}
|
} if (tb->bombed())
|
} if (tb->bombed())
|
goto test_failure;
|
goto test_failure;
|
}
|
}
|
|
}
|
|
#endif
|
|
|
|
#ifdef SKIP_WRITE
|
// Fourth test: Singular writes though all of memory, skipping by some
|
// Fourth test: Singular writes though all of memory, skipping by some
|
// prime address increment each time, followed by reads via a different
|
// prime address increment each time, followed by reads via a different
|
// prime numbered increment.
|
// prime numbered increment.
|
uload(mlen, rdbuf); // Get some new values
|
uload(mlen, rdbuf); // Get some new values
|
for(int i=0; i<(int)mlen; i++) {
|
for(int i=0; i<(int)mlen; i++) {
|
int loc = (i*13)&0x3ffffff;
|
int loc = (i*3889)&(mlen-1);
|
tb->wb_write(loc, rdbuf[loc]);
|
tb->wb_write(loc, rdbuf[loc]);
|
if ((*tb)[loc] != rdbuf[loc]) {
|
if ((*tb)[loc] != rdbuf[loc]) {
|
printf("R-WRITE[%06x] = %08x (Expecting %08x) FAILED\n",
|
printf("R-WRITE[%06x] = %08x (Expecting %08x) FAILED\n",
|
i, (*tb)[loc], rdbuf[loc]);
|
i, (*tb)[loc], rdbuf[loc]);
|
goto test_failure;
|
goto test_failure;
|
} if (tb->bombed())
|
} if (tb->bombed())
|
goto test_failure;
|
goto test_failure;
|
} for(int i=0; i<(int)mlen; i++) {
|
}
|
int loc = (i*19)&0x3ffffff;
|
#else
|
|
#ifdef SKIP_READ
|
|
uload(mlen, rdbuf); // Get some new values
|
|
for(int i=0; i<(int)mlen; i++)
|
|
(*tb)[i] = rdbuf[i];
|
|
#endif // !SKIP_WRITE && SKIP_READ
|
|
#endif
|
|
#ifdef SKIP_READ
|
|
for(int i=0; i<(int)mlen; i++) {
|
|
int loc = (i*7477)&(mlen-1);
|
mbuf[loc] = tb->wb_read(loc);
|
mbuf[loc] = tb->wb_read(loc);
|
if (mbuf[loc] != rdbuf[loc]) {
|
if (mbuf[loc] != rdbuf[loc]) {
|
printf("R-READ[%06x] = %08x (Expecting %08x) FAILED\n",
|
printf("R-READ[%06x] = %08x (Expecting %08x) FAILED\n",
|
loc, mbuf[loc], rdbuf[loc]);
|
loc, mbuf[loc], rdbuf[loc]);
|
goto test_failure;
|
goto test_failure;
|
} if (tb->bombed())
|
} if (tb->bombed())
|
goto test_failure;
|
goto test_failure;
|
}
|
}
|
|
#endif
|
|
|
|
|
printf("SUCCESS!!\n");
|
printf("SUCCESS!!\n");
|
exit(0);
|
exit(0);
|
test_failure:
|
test_failure:
|