首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误:(E109)完成绑定失败:未绑定端口- SystemC

错误:(E109)完成绑定失败:未绑定端口- SystemC
EN

Stack Overflow用户
提问于 2017-04-22 05:20:22
回答 3查看 4.7K关注 0票数 0

我正在尝试在SystemC中设计一个LFSR计数器,它应该看起来像这样:(click to see picture)

我已经写了我的代码,但我认为lfsr.h文件中的模块shiftreg.hlfsr-feedback.h之间的连接有问题,但我找不出问题所在。

我在终端上运行时收到以下错误消息:

代码语言:javascript
复制
Error: (E109) complete binding failed: port not bound: port 'top_p.LFSR_p.shiftReg_p.port_3' (sc_in)
In file: ../../../../src/sysc/communication/sc_port.cpp:231

main.cpp文件如下所示:

代码语言:javascript
复制
#include <iostream>
#include "systemc.h"
#include "lfsr.h"
#include "stim_shiftReg.h"

SC_MODULE(TOP)
{
    LFSR          *LFSR_p;
    stim_shiftReg *stim_shiftReg_p;

    sc_clock               sig_clk;  //define clock pin

    sc_signal< bool >      sig_rst;
    sc_signal< bool >      sig_lshift;
    sc_signal< sc_bv<8> >  sig_out;

    SC_CTOR(TOP) : sig_clk ("ClockSignal", 20, SC_NS)
    {
        stim_shiftReg_p = new stim_shiftReg("stim_shiftReg_p");
        stim_shiftReg_p -> clk(sig_clk);          //input bool
        stim_shiftReg_p -> rst(sig_rst);          //input bool
        stim_shiftReg_p -> stim_lshift(sig_lshift);    //input bool
        stim_shiftReg_p -> stim_out(sig_out);          //output sc_bv

        LFSR_p = new LFSR("LFSR_p");
        LFSR_p -> clk(sig_clk);           //input bool
        LFSR_p -> rst(sig_rst);           //input bool
        LFSR_p -> lshift(sig_lshift);
        LFSR_p -> out(sig_out);           //output sc_bv

    }
    ~TOP(){
        //free up memory
        delete LFSR_p;
        delete stim_shiftReg_p;
    }
};

TOP *top_p = NULL;

int sc_main(int argc, char* argv[])
{
    sc_set_time_resolution(1, SC_NS);
    top_p = new TOP("top_p");
    sc_start();
    return 0;
}

这是lfsr.h文件的外观:

代码语言:javascript
复制
#include"systemc.h"
#include"shiftReg.h"
#include"lfsr_feedback.h"

SC_MODULE(LFSR)
{
    shiftReg      *shiftReg_p;
    lfsr_feedback *lfsr_feedback_p;

       //define input
       sc_in<bool> clk;
       sc_in<bool> rst;
       sc_in<bool> lshift;

       //define output
       sc_out<sc_bv<8> > out;

       sc_signal<bool> rightin;

    SC_CTOR(LFSR)
    {
        shiftReg_p = new shiftReg("shiftReg_p");
        shiftReg_p -> clk(clk);                //input bool
        shiftReg_p -> rst(rst);                //input bool
        shiftReg_p -> lshift(lshift);     //enable shift signal connection
        shiftReg_p -> out(out);        //output sc_bv

        lfsr_feedback_p = new lfsr_feedback("lfsr_feedback_p");
        lfsr_feedback_p -> clk(clk);                  //input bool
        lfsr_feedback_p -> rst(rst);                  //input bool
        lfsr_feedback_p -> rightin(rightin);          //feedback signal
        lfsr_feedback_p -> out(out);                  //output sc_bv
    }
    ~LFSR()
    {
        //free up memory
        delete shiftReg_p;
        delete lfsr_feedback_p;
    }
};

这是shiftReg.h

代码语言:javascript
复制
#include<iostream>
#include<systemc.h>
SC_MODULE(shiftReg) //'shiftReg' - Module name
{

   //define input
   sc_in<bool> clk;
   sc_in<bool> rst;
   sc_in<bool> lshift;
   sc_in<bool> rightin;

   //define output
   sc_out<sc_bv<8> > out;

   sc_bv<8> RegValue;

   SC_CTOR(shiftReg) //'shiftReg' - Module name
   {
     SC_CTHREAD(ShiftReg, clk.pos());
     async_reset_signal_is(rst, true);
   }

   private:
   void ShiftReg()
   {
       //Reset actions
       RegValue = (11111111); //Use RegValue to store the register value
       wait();
       std::cout << "Reset done! RegisterValue = " << RegValue << endl;
       wait();

       while(true)
       {
           if(lshift.read() == true)
           {
               RegValue = RegValue << 1; //shift to the left
               RegValue[0] = rightin.read();
               std::cout << "Left shift done! RegisterValue = " << RegValue << endl;
           }
           else //if both are set to FALSE, no action should happen
           {
               std::cout << "'lshift' is set to FALSE status. No shift is done!" << endl;
           }
           out.write(RegValue); //Write output value to the out port
           wait();
       }
   };
};

这是lfsr_feedback.h

代码语言:javascript
复制
#include<iostream>
#include<systemc.h>
SC_MODULE(lfsr_feedback) //'lfsr_feedback' - Module name
{
   sc_in< bool > clk;
   sc_in< bool > rst;
   sc_out< bool > rightin;
   sc_in< sc_bv<8> > out;

   sc_signal<bool> fb_xor, a, b, c, d;

   SC_CTOR(lfsr_feedback)    //'lfsr_feedback' - Module name
   {
     SC_CTHREAD(Feedaback_Gen, clk.pos());
     async_reset_signal_is(rst, true);
   }

   private: void Feedaback_Gen()
   {
       wait();
       while(true)
       {
           a = out[7]; b = out[5]; c = out[4]; d = out[3];
           std::cout << "Load random bits" << endl;

           fb_xor =  (a ^ b) ^ (c ^ d);
           std::cout << "Calculate xor value!" << rightin << endl;

           rightin.write(fb_xor);
           wait();
       }
   };
};

这是stim_shiftReg.h

代码语言:javascript
复制
#include "systemc.h"

SC_MODULE(stim_shiftReg) 
{
    //define stimuli input for shift register
    sc_in<bool> clk;
    sc_out<bool> rst;
    sc_out<bool> stim_lshift;

    //define stimuli output for shift register
    sc_in<sc_bv<8> > stim_out;

    SC_CTOR(stim_shiftReg) {   //'stim_shiftReg' module name
      SC_CTHREAD(Stim_Shift, clk.pos());
    }

    private:
    void Stim_Shift() {
        //Simulate reset signal
        wait();
        rst.write(true);
        wait();
        rst.write(false);

        //Write input value for 'in'
        stim_lshift.write(true);  //enable shifting
        wait(40000);

        sc_stop();
    };
};

注意:我不确定lfsr.h中的out端口。它是来自shiftReg.hsc_out<T>,也是LFSR.h的输出。但是相同的端口应该是lfsr_feedback.h的输入。

非常感谢!

EN

回答 3

Stack Overflow用户

发布于 2017-04-22 13:17:36

1)很可能是您忘记了绑定LFSR模块实例的"out“端口

2)你应该总是用名字初始化所有的sc_objects,这样你就可以得到可读的错误。例如,在C++11中,您可以就地初始化成员

代码语言:javascript
复制
//define input
sc_in<bool> clk{"clk"};
sc_in<bool> rst{"rst"};
sc_in<bool> lshift{"lshift"};
//define output
sc_out<sc_bv<8> > out{"out"};
票数 0
EN

Stack Overflow用户

发布于 2017-04-22 13:45:32

顶级模块中未绑定端口"lshift“。查看我的内联评论:

代码语言:javascript
复制
#include <iostream>
#include "systemc.h"
#include "lfsr.h"
#include "stim_shiftReg.h"

SC_MODULE(TOP)
{
  LFSR          *LFSR_p;
  stim_shiftReg *stim_shiftReg_p;

  sc_clock               sig_clk;  //define clock pin

  sc_signal< bool >      sig_rst;
  sc_signal< bool >      sig_lshift;
  sc_signal< sc_bv<8> >  sig_out;

  SC_CTOR(TOP) : sig_clk ("ClockSignal", 20, SC_NS)
  {
    stim_shiftReg_p = new stim_shiftReg("stim_shiftReg_p");
    stim_shiftReg_p -> clk(sig_clk);          //input bool
    stim_shiftReg_p -> rst(sig_rst);          //input bool
    stim_shiftReg_p -> stim_lshift(sig_lshift);    //input bool
    stim_shiftReg_p -> stim_out(sig_out);          //output sc_bv

    LFSR_p = new LFSR("LFSR_p");
    LFSR_p -> clk(sig_clk);           //input bool
    LFSR_p -> rst(sig_rst);           //input bool
    LFSR_p -> out(sig_out);           //output sc_bv
    LFSR_p -> lshift(sig_lshift);     //< The missing lshift port bind.
  }
  ~TOP(){
    //free up memory
    delete LFSR_p;
    delete stim_shiftReg_p;
  }
};

TOP *top_p = NULL;

int sc_main(int argc, char* argv[])
{
  sc_set_time_resolution(1, SC_NS);
  top_p = new TOP("top_p");
  sc_start();
  return 0;
}

更新:您仍然可以使用初始值设定项list方法来调用SystemC对象的构造函数。

从您的代码示例中:

代码语言:javascript
复制
SC_MODULE(LFSR)
{
  shiftReg      *shiftReg_p;
  lfsr_feedback *lfsr_feedback_p;

  //define input
  sc_in<bool> clk;
  sc_in<bool> rst;
  sc_in<bool> lshift;

  //define output
  sc_out<sc_bv<8> > out;

  sc_signal<bool> rightin;

  SC_CTOR(LFSR):
    clk("clk")    //<< Added these lines
    , rst("rst")  //<< Added these lines
    , lshift("lshift")  //<< Added these lines
    , out("out")  //<< Added these lines
    , rightin("rightin")  //<< Added these lines
  {

这些更改将使错误消息更有意义,而不仅仅是打印未绑定的port_3。

更新2:

模块中rightin中的端口在模块中未绑定: LFSR (在lfsr.h中)

代码语言:javascript
复制
SC_CTOR(LFSR)
{
    shiftReg_p = new shiftReg("shiftReg_p");
    shiftReg_p -> clk(clk);                //input bool
    shiftReg_p -> rst(rst);                //input bool
    shiftReg_p -> lshift(lshift);     //enable shift signal connection
    shiftReg_p -> out(out);        //output sc_bv
    shiftReg_p -> rightin(rightin); //< Missing statement.

    lfsr_feedback_p = new lfsr_feedback("lfsr_feedback_p");
    lfsr_feedback_p -> clk(clk);                  //input bool
    lfsr_feedback_p -> rst(rst);                  //input bool
    lfsr_feedback_p -> rightin(rightin);          //feedback signal
    lfsr_feedback_p -> out(out);                  //output sc_bv
}

注意:请遵循上一次更新中提到的更改,以便获得比未绑定"port_3“更有意义的错误消息。

票数 0
EN

Stack Overflow用户

发布于 2020-12-19 06:49:04

处理不太有用的消息的一种方法:

代码语言:javascript
复制
Error: (E109) complete binding failed: port not bound: port 'top_p.LFSR_p.shiftReg_p.port_3' (sc_in)

是在定义模块端口的头文件上使用egrep (此处猜测):

代码语言:javascript
复制
egrep "sc_in|sc_out" shiftReg_p.h

然后,您将看到按数字顺序排列的sc_in和sc_out的列表,然后就可以知道哪个是port_3

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43552195

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档