2017-04-21 366 views
0

我試圖設計中的SystemC至極一個LFSR計數器的值應該是這個樣子:(click to see picture)錯誤:(E109)完全綁定失敗:端口未綁定 - SystemC的

我寫我的代碼,但我覺得療法是什麼worng與模塊shiftreg.hlfsr-feedback.h之間的連接lfsr.h文件,但我無法弄清楚是什麼問題。

我在終端運行時收到此錯誤信息:

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文件的樣子:

#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文件看起來的樣子:

#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

#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

#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

#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(); 
    }; 
}; 

注:我不知道有關端口out這是lfsr.h。它是來自shiftReg.hsc_out<T>以及作爲輸出形式LFSR.h。但同一個端口應該是lfsr_feedback.h的輸入。

非常感謝!

回答

0

1)最有可能你忘了綁定端口「走出去」 LFSR模塊實例

2)你應該總是初始化所有sc_objects用的名字,這樣你就可以得到讀取錯誤。例如在C++ 11中,您可以初始化成員

//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

我不知道如何在Eclipse中使用開普勒C++ 11 ... – Limko

+0

你可以設置在編譯器設置頁面中的-std = C++ 11的項目下不可用。但是你使用的是哪個版本的編譯器? – AmeyaVS

0

端口「lshift」未綁定到TOP模塊中。 見我的評論在線:

#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; 
} 

更新:你仍然可以使用初始化列表方法來調用構造函數SystemC的對象。

從你的代碼示例:

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

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

噢,謝謝..我只是固定的,但我還是老樣子得到類似的錯誤: 錯誤:(E109)完全結合失敗:端口沒有綁定:端口「top_p.LFSR_p.shiftReg_p.port_3」(sc_in) 在文件:../../../../src/sysc/communication/sc_port.cpp:231 – Limko

+0

沒有shiftReg模塊的偏差,它會在黑暗中拍攝。 – AmeyaVS

+0

我試圖從你的更新後添加代碼,但我STIL拿到'port_3' :(。因此,這裏有用於該項目的所有我的文件。(我希望沒有太多的內容).. 。 – Limko