systemC 错误:没有构造函数"BlackBox<R、expR、C、expC、T、expT> ...等

systemC Error: No instance of constructor "BlackBox<R, expR, C, expC, T, expT> ... etc

本文关键字:expR expC gt expT lt 错误 构造函数 BlackBox systemC      更新时间:2023-10-16

我正试图在SystemC中创建一个模块,但不得不与此错误作斗争。

错误:

没有构造函数"BlackBox::BlackBox with[R=1, expR =3, C=5, expC=-6, T=1, expT=-1]"的实例匹配参数列表

我不知道问题在哪里。似乎是这行代码造成的:

dut0 = new BlackBox<1,3, 5,-6, 1,-4> ("DUT0");//ERROR

有人能帮我解决这个问题吗?我将非常感激。 我的代码是:
//(this is Core_osc.h)
    #include <systemc.h>
    #include <sc_float.h>
    #include <cmath>
    #ifndef _CORE_OSC_H_
    #define _CORE_OSC_H_
    ////CIRCUIT ELEMENTS DEFINITION 
    //#define R //definition of value of R - resistance
    //#define C //definition of value of C - kapacitance
    //#define T //definition of value of T - Time step

    template <int R, int expR, int C, int expC, int T, int expT>
    class BlackBox : public sc_module //MODULE DECLARATION
    {
      public:
    //PORTS
        //inputs
          sc_in_clk clk;
          sc_in<bool> rst;
          sc_in<bool> en;
        //outputs
          sc_out< sc_float<5,10> > outp;    // half precision output (1b_sign, 5b_exponent, 10b_mantisa)
        //handshaking
            sc_in<bool>     inp_vld;
            sc_out<bool>    inp_rdy;    
            sc_in<bool>     outp_rdy;
            sc_out<bool>    outp_vld;
    //COEFICIENTS AND PARAMETERS OF sc_exp_core
    const sc_float<5,10> coef0;
    const sc_float<5,10> coef1;
    const sc_float<5,10> coef2;
    #include "sc_exp.inc"
    //FUNCTION
        void oscilator();

    //CONSTRUCTOR
        SC_HAS_PROCESS( BlackBox );
        BlackBox(): coef0(coef_1_2()), coef1(coef_1_2()), coef2(coef_3()), 
        //(sc_module_name nm): sc_module(nm),
        //inputs
            clk         ("clk"),
            rst         ("rst"),
            en          ("en"),
        //outputs
            outp        ("outp"),
        //handshaking
            inp_vld     ("inp_vld"),
            inp_rdy     ("inp_rdy"),
            outp_rdy    ("outp_rdy"),
            outp_vld    ("outp_vld")
        {
            SC_CTHREAD( oscilator,  clk.pos());
                reset_signal_is( rst, true );
        }

    };//END MODULE DECLARATION
    #endif

  // (this is Core_osc.cpp)
    #include <systemc.h>
    #include <sc_float.h>
    #include "core_osc.h"
    #ifndef _CORE_OSC_CPP_
    #define _CORE_OSC_CPP_
    //                  FUNCTION OSCILATOR
    //      [calculation of next value of sequence]
    void BlackBox<1,3, 5,-6, 1,-4>::oscilator(void)
    {
    //
    //INTERNALS
        sc_float<5,10> func_value;
        sc_float<5,10> Uz;
        Uz = 100.0;
     //in
        bool en_var;
     //out
        sc_float<5,10> outp_var;
     //temporary for reset
        sc_float<5,10> tmp;
        tmp = 0.0;

    //RESET_EXECUTION
        outp_var = 0.0;                 //reseting internals
            inp_rdy.write(false);       //handshaking_reset
            outp_vld.write(false);
        outp.write(tmp);
        wait(); 
    //RESET_OVER

    while(true)
    {
    /// //handshaking input
            inp_rdy.write(true);
            do{
                wait();
            } while(!inp_vld.read());
                en_var = en.read();
            inp_rdy.write(false);
    /// /////////////

        if( en )
        {
            sc_exp(coef0, coef1, coef2, &func_value, Uz, en_var);
            //func_value[1] = func_value[0];
        }

        //wait();
    /// //handshaking output
            outp_vld.write(true);
            do {
                wait();
            } while (!outp_rdy.read());
                outp.write(func_value);
            outp_vld.write(false);
    /// ////////
    }//end while
    }//end func
    #endif

      //(this is sc_exp.inc)
           // ------------------------------------------------------------------
           // ---------------------------- Exponent function -------------------
           // ------------------------------------------------------------------
                 ///////////////////////////////////////////////////////
                 ///////            CORE FUNCTION               ///////
                 /////// [calculation of next value of sequence]    ///////
                 ///////////////////////////////////////////////////////
        void sc_exp(sc_float<5,10> coef0,sc_float<5,10> coef1, sc_float<5,10> coef2, sc_float<5,10> *func_value, sc_float<5,10> Uz, bool en)
                        {
                            if(en)
                            {   //current                                                   //previous
                                *func_value = coef0*Uz + coef1*Uz + coef2*(*func_value);
                            }
                        }


///////////////////////////////////////////////////////////////////
    ////CALCULATION COEFICIENTS OF SEQUENE
    ////[sequence is obtained from bilinear transform of RC(RL) circuit]
    //////////////////////////////////////////////////////////////////////
                        sc_float<5,10> coef_1_2()
                        {
                            double tmp_R = R*pow(10.0,expR);
                            double tmp_C = C*pow(10.0,expC);
                            double tmp_T = T*pow(10.0,expC);
                        return((tmp_T)/(2*tmp_R*tmp_C+tmp_T));}
                        sc_float<5,10> coef_3()
                        {
                            double tmp_R = R*pow(10.0,expR);
                            double tmp_C = C*pow(10.0,expC);
                            double tmp_T = T*pow(10.0,expC);
                            return((2*tmp_R*tmp_C-tmp_T)/(2*tmp_R*tmp_C+tmp_T));
                        }
                        /////////////////////////////////////////////////////////////////////////

   //(this is Main function) - there is also test bench header and cpp
    #include <systemc.h>
    #include <sc_float.h>
    #include "core_osc.h"
    #include "Core_tb.h"
    #ifndef _MAIN_CORE_CPP_
    #define _MAIN_CORE_CPP_
    class Main_Core : public sc_module
     {
      public:
    //INTERNAL SIGNALS  
           sc_clock clk_sig;
        sc_signal<bool> rst_sig;
        sc_signal<bool> en_sig;
        sc_signal< sc_float<5,10> > outp_sig;
    //handshaking
          sc_signal<bool> inp_vld_sig;
          sc_signal<bool> inp_rdy_sig;
          sc_signal<bool> outp_vld_sig;
          sc_signal<bool> outp_rdy_sig;
    //INSTANCES
    BlackBox<1,3, 5,-6, 1,-4> *dut0;
    BlackBox_TB *tb0;
    //CONSTRUCTOR
       SC_HAS_PROCESS(Main_Core);
       Main_Core (sc_module_name nm): sc_module(nm),
            clk_sig             ("clk_sig", 10, SC_NS),
        //inp signals to DUT
            rst_sig             ("rst_sig"),
            en_sig              ("en_sig"),
        //outp signals from DUT
            outp_sig            ("outp_sig")
       {
           dut0 = new BlackBox<1,3, 5,-6, 1,-4> ("DUT0"); //ERROR
           tb0 =  new BlackBox_TB ("TB0");
            dut0->clk       (clk_sig);
            dut0->rst       (rst_sig);
            dut0->en        (en_sig);
            dut0->outp      (outp_sig);
        //handshaking
            dut0->inp_vld   (inp_vld_sig);
            dut0->inp_rdy   (inp_rdy_sig);
            dut0->outp_vld  (outp_vld_sig);
            dut0->outp_rdy  (outp_rdy_sig);
            tb0->clk        (clk_sig);
            tb0->rst        (rst_sig);
            tb0->en         (en_sig);
            tb0->outp       (outp_sig);
        //handshaking
            tb0->inp_vld    (inp_vld_sig);
            tb0->inp_rdy    (inp_rdy_sig);
            tb0->outp_vld   (outp_vld_sig);
            tb0->outp_rdy   (outp_rdy_sig);
       }

    //DESTRUCTOR
      ~Main_Core() 
      {
          delete dut0;
          delete tb0;
      }
    };
    #endif
    int sc_main(int argc, char* argv[]) 
    {
        Main_Core *SYSTEM0 = new Main_Core ("SYSTEM0");
        sc_start();
    return 0;}

从查看您的代码和给出的错误,您似乎错过了BlackBox构造函数,该构造函数接受字符串(或指向char的指针)参数:

BlackBox::BlackBox(const char *);  // or similar

BlackBox::BlackBox(const std::string& s);  // or similar

您需要定义一个类似于上述构造函数的构造函数