Jump to content

Error:<E109> complete binding failed: port not bound:


ehsanullah

Recommended Posts

Hi everybody..

Well i am new with systemC and working for the first time on it...

I have tried to implement a basic D Flip Flop circuit. The aim is to connect two D-Flip Flop in series to form a Johnson counter. (But right now i am trying to test only 1 flip flop)

The code is as follows:

SC_MODULE(dff){

sc_in_clk clk;

sc_in<bool>d;

sc_out<bool> q;

void dff::pro_dff()

{q=d;}

SC_CTOR(dff){

SC_METHOD(pro_dff);

sensitive<<clk.pos();}

};

SC_MODULE(my_mod){

sc_in_clk clk;

sc_in<bool>a;

sc_out<bool>b;

dff *d1;

void do_pro()

{

while (true)

{

d1->d(a);

d1->q(B);

wait();

}

}

SC_CTOR(my_mod){

d1 = new dff("My_dff");

d1->clk(clk);

SC_THREAD(do_pro);

sensitive<<clk.pos();

}

};

But when i run this program in sc_main it gives port binding error. what is wrong with the port binding?... and also please tell me that is the correct port binding method in systemC. I am using systemc v 2.1.

The error message is as follows..

Error:<E109> complete binding failed: port not bound: port 'TEST_UNIT.My_dff.port_2' <sc_out>

In file: ....\systemc-2.1.v1\src\sysc\communication\sc_port.cpp196

Please help me to resolve this problem..

thanks in Advance.

Link to comment
Share on other sites

Hi,

your code's confusing.

You seem to be mixing up port binding and assigning to channels. You don't need the module "my_mod" at all, as far as I can see.

Also I can't see how you're generating any stimulus.

Finally, you haven't shown sc_main.

But the error message is saying

SC_MODULE(my_mod){
sc_in_clk clk;
sc_in<bool>d;
[color=#ee82ee]sc_out<bool> q;[/color]

port q is not bound.

You might want to look at our website tutorial, http://www.doulos.com/knowhow/systemc/tutorial/, for a basic introduction.

Also I would recommend using SystemC 2.3.0 if you've got a choice,

regards

Alan

Link to comment
Share on other sites

  • 2 years later...

Hi , I am also getting the same error. Can Any one tell where I am going wrong and how to fix it.

This program is doing convolution.

convo.h

#pragma once
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include "systemc.h"
SC_MODULE(convo)
{
    sc_in<sc_uint<4> > x[4],h[4];
    sc_out<sc_uint<4> > y[8];

    int i, j, k;
    void prc_convo()
    {

        for (i = 0;i<7;i++)
        {
            y = 0;
            for (j = 0;j <= i;j++)
            {
                y.write(y.read() + (x[j].read() * h[i - j].read()));
            }
        }

        for (i = 0;i<7 - 1;i++)
            cout<<"\n The Value of output y["<<i<<"] "<< y;
    }

    SC_CTOR(convo)
    {    
        SC_METHOD(prc_convo);
        for (k= 0;k < 4;k++)
        {
            sensitive << x[k] << h[k];
        }            
    }

};

 

------------------------------------------------------------------------------------------------------------------

convo_driver.h

SC_MODULE(driver)
{
    sc_out<sc_uint<4>> d_x[4],d_h[4];

    sc_uint<4> pattern =0;

    int i,j;

    void prc_driver()
    {
        for (j = 0;j < 4;j++)
        {
            d_x[j].write(pattern);
            d_h[j].write(pattern);
            pattern++;
            wait(10, SC_MS);
        }
    }

    SC_CTOR(driver)
    {
        SC_THREAD(prc_driver);
        for (i = 0;i < 4;i++)
        {
            sensitive << d_x << d_h;
        }
    }
};
---------------------------------------------------------------------------------------------------------

convo_monitor.h

SC_MODULE(monitor)
{
    sc_in<sc_uint<4>> m_x[4], m_h[4], m_y[4];
    int i,j;

    void prc_monitor()
    {
        cout << "At time " << sc_time_stamp() << " :: \n";
        for (j = 0;j < 4;j++)
        {
            cout << "x[" << j << "] =" << m_x[j];
            cout << "h[" << j << "] =" << m_h[j];
            cout << "y[" << j << "] =" << m_y[j];
        }
    }

    SC_CTOR(monitor)
    {    
        SC_METHOD(prc_monitor);
        for (i = 0;i < 4;i++)
        {
            sensitive << m_x << m_h;
        }
    }
};
----------------------------------------------------------------------------------------

convo.cpp

int sc_main(int argc, char* argv[])
{
    sc_signal<sc_uint<4>> t_x[4], t_h[4], t_y[4];
    int i;
    convo cv("Convolution");
    for (i = 0;i < 4;i++)
    {
        cv.x(t_x);
        cv.h(t_h);
        cv.y(t_y);
    }
    
    driver dv("Driver");
    for (i = 0;i < 4;i++)
    {
        dv.d_x(t_x);
        dv.d_h(t_h);
    }

    monitor mt("Monitor");
    for (i = 0;i < 4;i++)
    {
        mt.m_x(t_x);
        mt.m_h(t_h);
        mt.m_y(t_y);
    }

    sc_start(400, SC_MS);
    _getch();
    return (0);

}

 

 

Link to comment
Share on other sites

  • 6 months later...
  • 1 year later...
  • 3 weeks later...

Hi,

the reason for the error is that you're not binding all your ports. You bind the ports in this loop:

 

       for(int i=0;i<n;i++)
        {
            for (int j=0;j<=i;j++)
            {
                    std::cout << i << " " << j << " " << std::endl;
                test_CHOL0->chol_in_data[i][j](chol_in_data[i][j]);
                test_CHOL0->chol_out_data[i][j](chol_out_data[i][j]);
            }
        }

but in the second loop you have j <= i. I've added printing and you can see that you only bind 6 of the 9 ports

 

        SystemC 2.3.1-Accellera --- Sep  3 2016 13:00:03
        Copyright (c) 1996-2014 by all Contributors,
        ALL RIGHTS RESERVED
0 0 
1 0 
1 1 
2 0 
2 1 
2 2 

I think you need j < n

 

regards

Alan

Link to comment
Share on other sites

  • 3 years later...

Hi,

I am getting similar error. But I don't understand how to bind the ports for this. Can someone please help?

Here is the error:

        SystemC 2.3.3-Accellera --- Aug 13 2020 01:41:43
        Copyright (c) 1996-2018 by all Contributors,
        ALL RIGHTS RESERVED

Error: (E109) complete binding failed: port not bound: port 'top.port_2' (sc_inout_rv)
In file: ../../../src/sysc/communication/sc_port.cpp:235

 

Here is the SystemC code:

#include <systemc.h>

SC_MODULE(module_A) {
  sc_in_rv<1>  in;
  sc_out_rv<1> out;
  sc_inout_rv<4> inout;

  void body () {
    out.write(0);
    if (in.read() == 1) {
      out.write(1);
      inout.write(rand());
    } else {
      out.write('z');
      inout.write("zzzz");
    }
  }

  SC_CTOR(module_A) {
    SC_METHOD(body);
      sensitive << in;
  }
};

module_A *top = NULL;

int sc_main (int argc, char* argv[]) {
        top = new module_A("top");
        sc_start();
        return(0);
}

 

 

 

Link to comment
Share on other sites

Each port of a module needs to be bound to some channel -- in your case of type sc_signal_rv<W> (see IEEE Std 1666-2011, clause 6.17). In you example, you would do this binding in sc_main(). However, you model lacks also stimuli generation.

You seem to be just starting with C++ and SystemC: I suggest to read first a good book on C++ and SystemC before trying to write your own models. E.g., check out isocpp.org/get-starteDoulos, and "SystemC: From the Ground Up, Second Edition".

Link to comment
Share on other sites

  • 2 months later...

hello everyone,

i have the same error , i dont know how i resolve it , i want do summation of 4 pixels in each line and display the sum , 

Error: (E109) complete binding failed: port not bound: port 'i_adder_10.port_2' (sc_in)

 

adder.h 

 


#include <iostream> 
#include <fstream>
#include <stdlib.h>
#include "systemc-ams.h"
#include "systemc.h"

SC_MODULE(adder) 
{
sc_in<double> in[4];
sc_out<double> out;


void somme (){

 double sum=0;
    while(true) {
for (int j=0; j<4 ; j++){
 sum +=in[j].read();
 
     out.write(sum);
 sum_finished.notify(SC_ZERO_TIME);
 cout<< "sum =  " << sum<< endl;
 
 }}}
 
 
SC_CTOR(adder){

 SC_THREAD(somme);
for ( int i=0; i<4;i++){
sensitive<<in[i];}

}
 };
 
main.cpp

 

 int sc_main(int argc, char *argv[])
 {

 sc_set_time_resolution(1, SC_FS); 

 int NB_elements_trans = 4;

int N =3;

sc_signal<double>sig_data[N][NB_elements_trans];  

sc_signal<double>sig_add;

  donnee <3,4> *i_donnee = new donnee <3,4>( "i_donnee" );
        
     for ( int i=0; i<N ; i++){

     for ( int j=0; j<NB_elements_trans ; j++){

                  i_donnee-> out[i][j] (sig_data[i][j]);
                  i_donnee -> initialize(sim_rate*fs) ;}}

 

adder *i_adder;

  for ( int i=0; i<N ; i++){

     for ( int j=0; j<NB_elements_trans ; j++){   

 i_adder = new adder("i_adder");
 
  i_adder->in[j](sig_data[i][j]);}
  i_adder->out(sig_add);  }


 

  

Link to comment
Share on other sites

  • 2 weeks later...

This part is wrong:

for ( int i=0; i<N ; i++){
    for ( int j=0; j<NB_elements_trans ; j++){   

        i_adder = new adder("i_adder");
        i_adder->in[j](sig_data[i][j]);
    }
    i_adder->out(sig_add);
}

You create N x NB_elements_trans i_adder elements and on each of them you only connect 1 of 4 in ports. I guess you mean:

for ( int i=0; i<N ; i++){
    i_adder = new adder("i_adder");
    for ( int j=0; j<NB_elements_trans ; j++){   
        i_adder->in[j](sig_data[i][j]);
    }
    i_adder->out(sig_add);
}

A few remarks:

  • you create a memory leak by assigning objects created with new to the same variable
  • you should not use raw pointer. Use C++11 unique_ptr instead
  • Name you SystemC objects, this helps debugging. C++11 makes it easy witn in-class constructors, e.g.:
    sc_signal<double> sig_add{"sig_add"}; 
  • don't use plain C-style arrays, uses either std::array or std::vector. These provide range checking capabilities and help finding out-of-bounds problems
  • don't use C  or C++arrays for SystemC objects. Use sc_core::sc_vector instead
  • use proper formatting, this eases reading (an IDe or clang-format is your friend). Keep in mind: code is a hundret times more often read than written!
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...