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

Subversion Repositories zipcpu

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /zipcpu
    from Rev 146 to Rev 147
    Reverse comparison

Rev 146 → Rev 147

/trunk/bench/cpp/div_tb.cpp
75,29 → 75,40
}
 
void tick(void) {
char outstr[2048], *s;
sprintf(outstr, "Tick %4ld %s%s%s%s%s%s %2d", m_tickcount,
(m_core->o_busy)?"B":" ",
(m_core->o_valid)?"V":" ",
(m_core->i_wr)?"W":" ",
(m_core->v__DOT__pre_sign)?"+":" ",
(m_core->v__DOT__r_sign)?"-":" ",
(m_core->v__DOT__r_z)?"Z":" ",
m_core->v__DOT__r_bit); s = &outstr[strlen(outstr)];
sprintf(s, "%s\n%10s %40s",s, "Div",""); s = &s[strlen(s)];
bprint( s, 32, m_core->v__DOT__r_dividend); s=&s[strlen(s)];
sprintf(s, "%s\n%10s ",s, "Div"); s = &s[strlen(s)];
bprint( s, 64, m_core->v__DOT__r_divisor); s=&s[strlen(s)];
sprintf(s, "%s\n%10s %40s",s, "Q",""); s=&s[strlen(s)];
bprint( s, 32, m_core->o_quotient); s = &s[strlen(s)];
sprintf(s, "%s\n%10s %38s",s, "Diff",""); s=&s[strlen(s)];
bprint( s, 33, m_core->v__DOT__diff); s = &s[strlen(s)];
strcat(s, "\n");
puts(outstr);
bool debug = false;
 
if (debug) {
char outstr[2048], *s;
sprintf(outstr, "Tick %4ld %s%s%s%s%s%s %2d",
m_tickcount,
(m_core->o_busy)?"B":" ",
(m_core->o_valid)?"V":" ",
(m_core->i_wr)?"W":" ",
(m_core->v__DOT__pre_sign)?"+":" ",
(m_core->v__DOT__r_sign)?"-":" ",
(m_core->v__DOT__r_z)?"Z":" ",
m_core->v__DOT__r_bit);
s = &outstr[strlen(outstr)];
sprintf(s, "%s\n%10s %40s",s, "Div","");
s = &s[strlen(s)];
bprint( s, 32, m_core->v__DOT__r_dividend);
s=&s[strlen(s)];
sprintf(s, "%s\n%10s ",s, "Div"); s = &s[strlen(s)];
bprint( s, 64, m_core->v__DOT__r_divisor);
s=&s[strlen(s)];
sprintf(s, "%s\n%10s %40s",s, "Q",""); s=&s[strlen(s)];
bprint( s, 32, m_core->o_quotient); s = &s[strlen(s)];
sprintf(s, "%s\n%10s %38s",s, "Diff","");
s=&s[strlen(s)];
bprint( s, 33, m_core->v__DOT__diff); s = &s[strlen(s)];
strcat(s, "\n");
puts(outstr);
}
TESTB<Vdiv>::tick();
}
 
void divs(int n, int d) {
bool dbg = false;
int ans;
ans = (d==0)?0: (n / d);
assert(m_core->o_busy == 0);
122,10 → 133,12
while(!m_core->o_valid)
tick();
 
printf("%s%s: %d / %d =? %d\n",
(m_core->o_valid)?"V":" ",
(m_core->o_err)?"E":" ",
n, d, m_core->o_quotient);
if (dbg) {
printf("%s%s: %d / %d =? %d\n",
(m_core->o_valid)?"V":" ",
(m_core->o_err)?"E":" ",
n, d, m_core->o_quotient);
}
if ((m_core->o_err)||(d==0)) {
if (d==0)
assert(m_core->o_err);
135,6 → 148,7
}
 
void divu(unsigned n, unsigned d) {
bool dbg = false;
unsigned ans;
ans = (d==0)?0: (n / d);
assert(m_core->o_busy == 0);
158,10 → 172,12
while(!m_core->o_valid)
tick();
 
printf("%s%s: %u / %u =? %d (Expecting %u)\n",
(m_core->o_valid)?"V":" ",
(m_core->o_err)?"E":" ",
n, d, m_core->o_quotient, ans);
if (dbg) {
printf("%s%s: %u / %u =? %d (Expecting %u)\n",
(m_core->o_valid)?"V":" ",
(m_core->o_err)?"E":" ",
n, d, m_core->o_quotient, ans);
}
if ((m_core->o_err)||(d==0)) {
if (d==0)
assert(m_core->o_err);
184,7 → 200,7
int main(int argc, char **argv) {
Verilated::commandArgs(argc, argv);
DIV_TB *tb = new DIV_TB();
int rcode = 0;
int rcode = EXIT_SUCCESS;
 
tb->reset();
tb->divide(125,7);
224,6 → 240,7
tb->divide(rand(),rand()/2);
*/
 
printf("SUCCESS!\n");
exit(rcode);
}
 

powered by: WebSVN 2.1.0

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