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

Subversion Repositories zipcpu

[/] [zipcpu/] [trunk/] [bench/] [cpp/] [div_tb.cpp] - Diff between revs 147 and 154

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 147 Rev 154
Line 72... Line 72...
                        if (((nbits-1-i)&3)==0)
                        if (((nbits-1-i)&3)==0)
                                *str++ = ' ';
                                *str++ = ' ';
                } *str = '\0';
                } *str = '\0';
        }
        }
 
 
        void    tick(void) {
        void    dbgdump(void) {
                bool    debug = false;
 
 
 
                if (debug) {
 
                        char    outstr[2048], *s;
                        char    outstr[2048], *s;
                        sprintf(outstr, "Tick %4ld %s%s%s%s%s%s %2d",
                sprintf(outstr, "Tick %4ld %s%s%s%s%s%s%s %2d(%s= 0)",
                                m_tickcount,
                                m_tickcount,
                                (m_core->o_busy)?"B":" ",
                                (m_core->o_busy)?"B":" ",
 
                        (m_core->v__DOT__r_busy)?"R":" ",
                                (m_core->o_valid)?"V":" ",
                                (m_core->o_valid)?"V":" ",
                                (m_core->i_wr)?"W":" ",
                                (m_core->i_wr)?"W":" ",
                                (m_core->v__DOT__pre_sign)?"+":" ",
                                (m_core->v__DOT__pre_sign)?"+":" ",
                                (m_core->v__DOT__r_sign)?"-":" ",
                                (m_core->v__DOT__r_sign)?"-":" ",
                                (m_core->v__DOT__r_z)?"Z":" ",
                                (m_core->v__DOT__r_z)?"Z":" ",
                                m_core->v__DOT__r_bit);
                        m_core->v__DOT__r_bit,
 
                        (m_core->v__DOT__last_bit)?"=":"!");
                        s = &outstr[strlen(outstr)];
                        s = &outstr[strlen(outstr)];
                        sprintf(s, "%s\n%10s %40s",s, "Div","");
                        sprintf(s, "%s\n%10s %40s",s, "Div","");
                                s = &s[strlen(s)];
                                s = &s[strlen(s)];
                        bprint( s, 32, m_core->v__DOT__r_dividend);
                        bprint( s, 32, m_core->v__DOT__r_dividend);
                                s=&s[strlen(s)];
                                s=&s[strlen(s)];
Line 102... Line 101...
                                s=&s[strlen(s)];
                                s=&s[strlen(s)];
                        bprint( s, 33, m_core->v__DOT__diff); s = &s[strlen(s)];
                        bprint( s, 33, m_core->v__DOT__diff); s = &s[strlen(s)];
                        strcat(s, "\n");
                        strcat(s, "\n");
                        puts(outstr);
                        puts(outstr);
                }
                }
 
 
 
        void    tick(void) {
 
                bool    debug = false;
 
 
 
                if (debug)
 
                        dbgdump();
                TESTB<Vdiv>::tick();
                TESTB<Vdiv>::tick();
        }
        }
 
 
        void    divs(int n, int d) {
        void    divs(int n, int d) {
                bool    dbg = false;
                bool    dbg = false;
Line 124... Line 129...
                m_core->i_wr = 0;
                m_core->i_wr = 0;
                m_core->i_signed = 0;
                m_core->i_signed = 0;
                m_core->i_numerator = 0;
                m_core->i_numerator = 0;
                m_core->i_denominator = 0;
                m_core->i_denominator = 0;
 
 
 
                // Make certain busy is immediately true upon the first clock
 
                // after we issue the divide.
                assert(m_core->o_busy);
                assert(m_core->o_busy);
                assert(m_core->o_valid == 0);
                assert(m_core->o_valid == 0);
 
 
                // while((!m_core->o_valid)&&(!m_core->o_err))
                // while((!m_core->o_valid)&&(!m_core->o_err))
                while(!m_core->o_valid)
                while(!m_core->o_valid) {
 
                        if (!m_core->o_busy) {
 
                                // Make certain busy is asserted whenever
 
                                // valid is false and we're ... well, busy
 
                                dbgdump();
 
                                assert(m_core->o_busy);
 
                        }
                        tick();
                        tick();
 
                } if (dbg) dbgdump();
 
                assert(!m_core->o_busy);
 
 
                if (dbg) {
                if (dbg) {
                        printf("%s%s: %d / %d =? %d\n",
                        printf("%s%s: %d / %d =? %d\n",
                                (m_core->o_valid)?"V":" ",
                                (m_core->o_valid)?"V":" ",
                                (m_core->o_err)?"E":" ",
                                (m_core->o_err)?"E":" ",
Line 167... Line 182...
                m_core->i_denominator = 0;
                m_core->i_denominator = 0;
 
 
                assert(m_core->o_busy);
                assert(m_core->o_busy);
                assert(m_core->o_valid == 0);
                assert(m_core->o_valid == 0);
 
 
                while(!m_core->o_valid)
                while(!m_core->o_valid) {
 
                        assert(m_core->o_busy);
                        tick();
                        tick();
 
                } assert(!m_core->o_busy);
 
 
                if (dbg) {
                if (dbg) {
                        printf("%s%s: %u / %u =? %d (Expecting %u)\n",
                        printf("%s%s: %u / %u =? %d (Expecting %u)\n",
                                (m_core->o_valid)?"V":" ",
                                (m_core->o_valid)?"V":" ",
                                (m_core->o_err)?"E":" ",
                                (m_core->o_err)?"E":" ",

powered by: WebSVN 2.1.0

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