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

Subversion Repositories dblclockfft

[/] [dblclockfft/] [trunk/] [bench/] [cpp/] [butterfly_tb.cpp] - Diff between revs 15 and 23

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

Rev 15 Rev 23
Line 42... Line 42...
#include <stdio.h>
#include <stdio.h>
#include <stdint.h>
#include <stdint.h>
 
 
#include "Vbutterfly.h"
#include "Vbutterfly.h"
#include "verilated.h"
#include "verilated.h"
 
#include "twoc.h"
long    sbits(const long val, const int bits) {
 
        long    r;
 
 
 
        r = val & ((1l<<bits)-1);
 
        if (r & (1l << (bits-1)))
 
                r |= (-1l << bits);
 
        return r;
 
}
 
 
 
unsigned long   ubits(const long val, const int bits) {
 
        long    r;
 
 
 
        r = val & ((1l<<bits)-1);
 
        return r;
 
}
 
 
 
 
 
class   BFLY_TB {
class   BFLY_TB {
public:
public:
        Vbutterfly      *m_bfly;
        Vbutterfly      *m_bfly;
        unsigned long   m_left[64], m_right[64];
        unsigned long   m_left[64], m_right[64];
        bool            m_aux[64];
        bool            m_aux[64];
        int             m_addr, m_lastaux, m_offset;
        int             m_addr, m_lastaux, m_offset;
        bool            m_syncd;
        bool            m_syncd, m_waiting_for_sync_input;
 
 
        BFLY_TB(void) {
        BFLY_TB(void) {
                m_bfly = new Vbutterfly;
                m_bfly = new Vbutterfly;
                m_addr = 0;
                m_addr = 0;
                m_syncd = 0;
                m_syncd = 0;
 
                m_waiting_for_sync_input = true;
        }
        }
 
 
        void    tick(void) {
        void    tick(void) {
                m_lastaux = m_bfly->o_aux;
                m_lastaux = m_bfly->o_aux;
                m_bfly->i_clk = 0;
                m_bfly->i_clk = 0;
Line 113... Line 99...
                m_bfly->i_ce  = 1;
                m_bfly->i_ce  = 1;
                m_bfly->i_aux = 1;
                m_bfly->i_aux = 1;
                tick();
                tick();
                m_bfly->i_rst = 0;
                m_bfly->i_rst = 0;
                m_syncd = 0;
                m_syncd = 0;
 
 
 
                m_waiting_for_sync_input = true;
        }
        }
 
 
        void    test(const int n, const int k, const unsigned long cof,
        void    test(const int n, const int k, const unsigned long cof,
                        const unsigned lft, const unsigned rht, const int aux) {
                        const unsigned lft, const unsigned rht, const int aux) {
 
 
                m_bfly->i_coef  = cof & (~(-1l << 40));
                m_bfly->i_coef  = cof & (~(-1l << 40));
                m_bfly->i_left  = lft;
                m_bfly->i_left  = lft;
                m_bfly->i_right = rht;
                m_bfly->i_right = rht;
                m_bfly->i_aux   = aux & 1;
                m_bfly->i_aux   = aux & 1;
 
                if ((m_waiting_for_sync_input)&&(aux&1)) {
 
                        m_waiting_for_sync_input = false;
 
                        m_addr = 0;
 
                }
 
 
                tick();
                tick();
 
 
                if ((m_bfly->o_aux)&&(!m_lastaux))
                if ((m_bfly->o_aux)&&(!m_lastaux))
                        printf("\n");
                        printf("\n");
Line 161... Line 153...
                        m_bfly->v__DOT__mpy_i & (~(-1l<<40)));
                        m_bfly->v__DOT__mpy_i & (~(-1l<<40)));
                printf("\n");
                printf("\n");
                */
                */
 
 
                if ((m_syncd)&&(m_left[(m_addr-m_offset)&(64-1)] != m_bfly->o_left)) {
                if ((m_syncd)&&(m_left[(m_addr-m_offset)&(64-1)] != m_bfly->o_left)) {
                        fprintf(stderr, "WRONG O_LEFT! (%lx(exp) != %lx(sut)\n",
                        fprintf(stderr, "WRONG O_LEFT! (%lx(exp) != %lx(sut))\n",
                                m_left[(m_addr-m_offset)&(64-1)],
                                m_left[(m_addr-m_offset)&(64-1)],
                                m_bfly->o_left);
                                m_bfly->o_left);
                        exit(-1);
                        exit(-1);
                }
                }
 
 
                if ((m_syncd)&&(m_right[(m_addr-m_offset)&(64-1)] != m_bfly->o_right)) {
                if ((m_syncd)&&(m_right[(m_addr-m_offset)&(64-1)] != m_bfly->o_right)) {
                        fprintf(stderr, "WRONG O_RIGHT!\n");
                        fprintf(stderr, "WRONG O_RIGHT (%lx(exp) != (%lx(sut))!\n",
 
                                m_right[(m_addr-m_offset)&(64-1)], m_bfly->o_right);
                        exit(-1);
                        exit(-1);
                }
                }
 
 
                if ((m_syncd)&&(m_aux[(m_addr-m_offset)&(64-1)] != m_bfly->o_aux)) {
                if ((m_syncd)&&(m_aux[(m_addr-m_offset)&(64-1)] != m_bfly->o_aux)) {
                        fprintf(stderr, "FAILED AUX CHANNEL TEST (i.e. the SYNC)\n");
                        fprintf(stderr, "FAILED AUX CHANNEL TEST (i.e. the SYNC)\n");
                        exit(-1);
                        exit(-1);
                }
                }
 
 
                if ((m_addr > 22)&&(!m_syncd)) {
                if ((m_addr > 28)&&(!m_syncd)) {
                        fprintf(stderr, "NO SYNC PULSE!\n");
                        fprintf(stderr, "NO SYNC PULSE!\n");
                        exit(-1);
                        exit(-1);
                }
                }
 
 
                // Now, let's calculate an "expected" result ...
                // Now, let's calculate an "expected" result ...
Line 268... Line 261...
 
 
        const int       TESTSZ = 256;
        const int       TESTSZ = 256;
 
 
        bfly->reset();
        bfly->reset();
 
 
 
        // Test whether or not the aux channel starts clear, like its supposed to
 
        bfly->test(9,0,0x4000000000l,0x000f0000,0x000f0000, 0);
 
        bfly->test(9,1,0x4000000000l,0x000f0000,0xfff10000, 0);
 
        bfly->test(9,2,0x4000000000l,0x0000000f,0x0000fff1, 0);
 
        bfly->test(9,3,0x4000000000l,0x0000000f,0x0000000f, 0);
 
 
        bfly->test(9,0,0x4000000000l,0x7fff0000,0x7fff0000, 1);
        bfly->test(9,0,0x4000000000l,0x7fff0000,0x7fff0000, 1);
        bfly->test(9,1,0x4000000000l,0x7fff0000,0x80010000, 0);
        bfly->test(9,1,0x4000000000l,0x7fff0000,0x80010000, 0);
        bfly->test(9,2,0x4000000000l,0x00007fff,0x00008001, 0);
        bfly->test(9,2,0x4000000000l,0x00007fff,0x00008001, 0);
        bfly->test(9,3,0x4000000000l,0x00007fff,0x00007fff, 0);
        bfly->test(9,3,0x4000000000l,0x00007fff,0x00007fff, 0);
 
 

powered by: WebSVN 2.1.0

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