Jump to content

Hrishikesh

Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by Hrishikesh

  1. Thank you for taking time to go through the code and pointing out the problem, also thank you for your valuable suggestions. I also had to explicitly convert the read value to bool before writing it to output. // Multiplexer Logic void mux(){ // Convert bit vector to int int select_value = s_i.read().to_uint(); sc_bv<4> in = i_i.read(); switch(select_value){ case 0 : y_o.write(in[0].to_bool()); break; case 1 : y_o.write(in[1].to_bool()); break; case 2 : y_o.write(in[2].to_bool()); break; case 3 : y_o.write(in[3].to_bool()); break; default : y_o.write(false); } } I have limited knowledge in filed of system level design, but how modules will be designed if SC_MODULE macro is discontinued.
  2. Hi, I am new to system c and in the process of exploring I am facing below Issue please help me out in finding out the root cause. Error: (E112) get interface failed: index out of range: port 'mux.port_0' (sc_in) In file: ../../../src/sysc/communication/sc_port.cpp:235 //---------------------------------------------------------------------- // 4 TO 1 Multiplexer //---------------------------------------------------------------------- #include "systemc.h" SC_MODULE(mux_4_to_1){ // Port Decleration sc_in<sc_bv<4>> i_i; // 4-Bit Input sc_in<sc_bv<2>> s_i; // 2-Bit Select Line sc_out<bool> y_o; // Output // Multiplexer Logic void mux(){ // Convert bit vector to int int select_value = s_i.read().to_uint(); switch(select_value){ case 0 : y_o.write(i_i[0]); break; case 1 : y_o.write(i_i[1]); break; case 2 : y_o.write(i_i[2]); break; case 3 : y_o.write(i_i[3]); break; default : y_o.write(false); } } // Constructor SC_CTOR(mux_4_to_1){ SC_METHOD(mux); sensitive <<i_i <<s_i; } }; //---------------------------------------------------------------------- // 4 TO 1 Multiplexer Driver //---------------------------------------------------------------------- #include "systemc.h" SC_MODULE(driver){ // Signals to be driven sc_out<sc_bv<4>> i_i; sc_out<sc_bv<2>> s_i; // Function to apply inputs void inputs(){ i_i.write("0010"); s_i.write("00"); wait(5,SC_NS); s_i.write("01"); wait(5,SC_NS); s_i.write("10"); wait(5,SC_NS); s_i.write("11"); wait(5,SC_NS); } // Constructor SC_CTOR(driver){ SC_THREAD(inputs); sensitive <<i_i <<s_i; } }; //---------------------------------------------------------------------- // 4 TO 1 Multiplexer Driver //---------------------------------------------------------------------- #include "systemc.h" SC_MODULE(monitor){ // Signals to be monitored sc_in<sc_bv<4>> i_i; sc_in<sc_bv<2>> s_i; sc_in<bool> y_o; // Function to monitor signals void mon(){ cout << "Input: "<<i_i.read() << "Select:" <<s_i.read() << " Output: "<<y_o.read() <<endl; } // Constructor SC_CTOR(monitor){ SC_METHOD(mon); sensitive <<i_i <<s_i <<y_o; } }; //---------------------------------------------------------------------- // 4 TO 1 Multiplexer Main //---------------------------------------------------------------------- #include "systemc.h" #include "mux_4_to_1.h" #include "driver.h" #include "monitor.h" // Main Function int sc_main( int argc, char* argv[]){ sc_signal <sc_bv<4>> i_i; sc_signal <sc_bv<2>> s_i; sc_signal <bool> y_o; mux_4_to_1 mux("mux"); driver drive("driver"); monitor mon("monitor"); mux.i_i(i_i); mux.s_i(s_i); mux.y_o(y_o); drive.i_i(i_i); drive.s_i(s_i); mon.i_i(i_i); mon.s_i(s_i); mon.y_o(y_o); //Waveform sc_trace_file *Tf; Tf = sc_create_vcd_trace_file("traces"); sc_trace(Tf, i_i, "i_i"); sc_trace(Tf, s_i, "s_i"); sc_trace(Tf, y_o, "y_o"); sc_start(30,SC_NS); sc_close_vcd_trace_file(Tf); return 0; } Thank you in advance, I want some suggestions and guidance from the community to ramp up my learning journey.
×
×
  • Create New...