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

Subversion Repositories dblclockfft

[/] [dblclockfft/] [trunk/] [bench/] [cpp/] [butterfly_tb.cpp] - Diff between revs 36 and 41

Show entire file | Details | Blame | View Log

Rev 36 Rev 41
Line 1... Line 1...
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
//
// Filename:    butterfly_tb.cpp
// Filename:    butterfly_tb.cpp
//
//
// Project:     A Doubletime Pipelined FFT
// Project:     A General Purpose Pipelined FFT Implementation
//
//
// Purpose:     A test-bench for the butterfly.v subfile of the generic
// Purpose:     A test-bench for the butterfly.v subfile of the generic
//              pipelined FFT.  This file may be run autonomously.  If so,
//              pipelined FFT.  This file may be run autonomously.  If so,
//      the last line output will either read "SUCCESS" on success, or some
//      the last line output will either read "SUCCESS" on success, or some
//      other failure message otherwise.
//      other failure message otherwise.
Line 13... Line 13...
//      test butterfly.v
//      test butterfly.v
//
//
// Creator:     Dan Gisselquist, Ph.D.
// Creator:     Dan Gisselquist, Ph.D.
//              Gisselquist Technology, LLC
//              Gisselquist Technology, LLC
//
//
///////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
//
// Copyright (C) 2015,2018 Gisselquist Technology, LLC
// Copyright (C) 2015,2018 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
Line 28... Line 28...
// 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.
//
//
// You should have received a copy of the GNU General Public License along
// You should have received a copy of the GNU General Public License along
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
// with this program.  (It's in the $(ROOT)/doc directory.  Run make with no
// target there if the PDF file isn't present.)  If not, see
// target there if the PDF file isn't present.)  If not, see
// <http://www.gnu.org/licenses/> for a copy.
// <http://www.gnu.org/licenses/> for a copy.
//
//
// 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 <stdint.h>
#include <stdint.h>
 
 
#include "verilated.h"
#include "verilated.h"
#include "verilated_vcd_c.h"
#include "verilated_vcd_c.h"
Line 57... Line 57...
#define IWIDTH  TST_BUTTERFLY_IWIDTH
#define IWIDTH  TST_BUTTERFLY_IWIDTH
#define CWIDTH  TST_BUTTERFLY_CWIDTH
#define CWIDTH  TST_BUTTERFLY_CWIDTH
#define OWIDTH  TST_BUTTERFLY_OWIDTH
#define OWIDTH  TST_BUTTERFLY_OWIDTH
#define BFLYDELAY       TST_BUTTERFLY_MPYDELAY
#define BFLYDELAY       TST_BUTTERFLY_MPYDELAY
 
 
 
bool    gbl_debug = false;
 
 
class   BFLY_TB {
class   BFLY_TB {
public:
public:
        Vbutterfly      *m_bfly;
        Vbutterfly      *m_bfly;
        VerilatedVcdC   *m_trace;
        VerilatedVcdC   *m_trace;
        unsigned long   m_left[64], m_right[64];
        unsigned long   m_left[64], m_right[64];
Line 99... Line 101...
                m_tickcount++;
                m_tickcount++;
 
 
                m_lastaux = m_bfly->o_aux;
                m_lastaux = m_bfly->o_aux;
                m_bfly->i_clk = 0;
                m_bfly->i_clk = 0;
                m_bfly->eval();
                m_bfly->eval();
                if (m_trace) m_trace->dump((uint64_t)(10ul*m_tickcount-2));
                if (m_trace) m_trace->dump((vluint64_t)(10ul*m_tickcount-2));
                m_bfly->i_clk = 1;
                m_bfly->i_clk = 1;
                m_bfly->eval();
                m_bfly->eval();
                if (m_trace) m_trace->dump((uint64_t)(10ul*m_tickcount));
                if (m_trace) m_trace->dump((vluint64_t)(10ul*m_tickcount));
                m_bfly->i_clk = 0;
                m_bfly->i_clk = 0;
                m_bfly->eval();
                m_bfly->eval();
                if (m_trace) {
                if (m_trace) {
                        m_trace->dump((uint64_t)(10ul*m_tickcount+5));
                        m_trace->dump((vluint64_t)(10ul*m_tickcount+5));
                        m_trace->flush();
                        m_trace->flush();
                }
                }
 
 
                if ((!m_syncd)&&(m_bfly->o_aux))
                if ((!m_syncd)&&(m_bfly->o_aux))
                        m_offset = m_addr;
                        m_offset = m_addr;
Line 180... Line 182...
                }
                }
 
 
                m_bfly->i_ce = 1;
                m_bfly->i_ce = 1;
                cetick();
                cetick();
 
 
 
                if (gbl_debug) {
                if ((m_bfly->o_aux)&&(!m_lastaux))
                if ((m_bfly->o_aux)&&(!m_lastaux))
                        printf("\n");
                        printf("\n");
                printf("n,k=%d,%3d: COEF=%0*lx, LFT=%0*x, RHT=%0*x, A=%d, OLFT =%0*lx, ORHT=%0*lx, AUX=%d\n",
                printf("n,k=%d,%3d: COEF=%0*lx, LFT=%0*x, RHT=%0*x, A=%d, OLFT =%0*lx, ORHT=%0*lx, AUX=%d\n",
                        n,k,
                        n,k,
                        (2*CWIDTH+3)/4, ubits(m_bfly->i_coef, 2*CWIDTH),
                        (2*CWIDTH+3)/4, ubits(m_bfly->i_coef, 2*CWIDTH),
Line 191... Line 194...
                        (2*IWIDTH+3)/4, m_bfly->i_right,
                        (2*IWIDTH+3)/4, m_bfly->i_right,
                        m_bfly->i_aux,
                        m_bfly->i_aux,
                        (2*OWIDTH+3)/4, (long)m_bfly->o_left,
                        (2*OWIDTH+3)/4, (long)m_bfly->o_left,
                        (2*OWIDTH+3)/4, (long)m_bfly->o_right,
                        (2*OWIDTH+3)/4, (long)m_bfly->o_right,
                        m_bfly->o_aux);
                        m_bfly->o_aux);
 
                }
 
 
                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)) {
                        printf("WRONG O_LEFT! (%lx(exp) != %lx(sut)\n",
                        printf("WRONG O_LEFT! (%lx(exp) != %lx(sut)\n",
                                m_left[(m_addr-m_offset)&(64-1)],
                                m_left[(m_addr-m_offset)&(64-1)],
                                (long)m_bfly->o_left);
                                (long)m_bfly->o_left);
Line 318... Line 322...
        int32_t         smr, smi, dfr, dfi;
        int32_t         smr, smi, dfr, dfi;
        int             rnd = 0;
        int             rnd = 0;
 
 
        const int       TESTSZ = 256;
        const int       TESTSZ = 256;
 
 
        bfly->opentrace("butterfly.vcd");
        // bfly->opentrace("butterfly.vcd");
 
 
        bfly->reset();
        bfly->reset();
 
 
// #define      ZEROTEST
// #define      ZEROTEST
#define ZEROTEST bfly->test(9,0,0x0000000000l,0x00000000,0x00000000, 0)
#define ZEROTEST bfly->test(9,0,0x0000000000l,0x00000000,0x00000000, 0)

powered by: WebSVN 2.1.0

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