TRAVIS Posted December 10, 2021 Report Share Posted December 10, 2021 Hi I have a problem about using systemc. I designed a simple and module, and it compiled well. But if I execute the file, it shows me the below error. ////////////////////////////////////////////////////////////////////////////////////// SystemC 2.3.3-Accellera --- Dec 7 2021 18:09:54 Copyright (c) 1996-2018 by all Contributors, ALL RIGHTS RESERVED 0 sa : Error: (E112) get interface failed: port is not bound: port 'and_inst.port_0' (sc_in) In file: ../../../src/sysc/communication/sc_port.cpp:235 ////////////////////////////////////////////////////////////////////////////////////// The full source code is below. How can I fix the code? ////////////////////////////////////////////////////////////////////////////////////// #include <systemc.h> SC_MODULE(and2){ sc_in< bool > a; sc_in< bool > b; sc_out< bool > f; void func(){ f.write(a.read() & b.read() ); } SC_CTOR(and2){ SC_METHOD(func); sensitive << a << b; std::cout << sc_time_stamp() << "a : " << a.read() << "b : " << b.read() << "f : " << f.read() << endl; } }; int sc_main( int argc, char *argv[]){ sc_signal< bool > a; sc_signal< bool > b; sc_signal< bool > f; and2 and_inst("and_inst"); and_inst.a(a); and_inst.b(b); and_inst.f(f); a = 1; b = 0; sc_clock clk("clk",10,SC_NS,0.5,0.0,SC_NS,true); sc_start(50,SC_NS); b = 1; sc_start(50,SC_NS); return 0; } Quote Link to comment Share on other sites More sharing options...
Eyck Posted December 10, 2021 Report Share Posted December 10, 2021 You are readfing the port in the construcotr. At this time the port has no connection to a signal and you get the error message. You migth move this part to either end_of_elaboration() or start_of_simulation() or drop it at all. TRAVIS 1 Quote Link to comment Share on other sites More sharing options...
Sunny_Chaudhary Posted December 10, 2021 Report Share Posted December 10, 2021 REASON -> When the code run, the first thing run is constructor and at the point your port's is not bound. Move that piece of code to end_of_elaboration() or start_of_simulation(). Then, it will work fine. SUGGESTION => Use (->) operator instead of (.) operator like (a->read()) -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- #include "systemc.h" #include <bits/stdc++.h> using namespace sc_core; using namespace sc_dt; SC_MODULE(and2){ sc_in< bool > a; sc_in< bool > b; sc_out< bool > f; void func(){ f.write(a->read() & b->read() ); std::cout << sc_time_stamp() << "a : " << a->read() << "b : " << b.read() << "f : " << f->read() << endl; } SC_CTOR(and2){ SC_METHOD(func); sensitive << a << b; dont_initialize(); } }; int sc_main( int argc, char *argv[]){ sc_signal< bool > a; sc_signal< bool > b; sc_signal< bool > f; and2 and_inst("and_inst"); and_inst.a(a); and_inst.b(b); and_inst.f(f); a = 1; b = 0; sc_clock clk("clk",10,SC_NS,0.5,0,SC_NS,true); sc_start(50,SC_NS); b = 1; sc_start(50,SC_NS); b = 0; sc_start(50,SC_NS); return 0; } TRAVIS, Sunny Chaudhary and karthickg 2 1 Quote Link to comment Share on other sites More sharing options...
TRAVIS Posted December 10, 2021 Author Report Share Posted December 10, 2021 Thank you for helping me! I understand what you say. It runs well. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.